Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add textlint rules and plugins #54443

Merged
merged 1 commit into from May 10, 2019
Merged

Conversation

matthew-piziak
Copy link
Contributor

Motivation for this change

This is a continuation of #53981. That pull request installed textlint; this one installs rules and plugins.

Question: these are separate npm packages, but should I be grouping these under a common label in nix somehow? I'm assuming not, but let me know if there's a way to keep things more organized. Thanks!

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@matthew-piziak
Copy link
Contributor Author

Is this sufficient? This is all I did in the previous PR. However I'm also happy to go through the checklist—is there documentation on how to "test using sandboxing"?

@Mic92
Copy link
Member

Mic92 commented Jan 26, 2019

@matthew-piziak How would I use texlint with your added rules?

@matthew-piziak
Copy link
Contributor Author

@Mic92 Hi! Like this:

textlint \
--rule write-good \
--rule no-start-duplicated-conjunction \
--rule max-comma \
--rule terminology \
--rule period-in-list-item \
--rule period-in-list-item \
--rule unexpanded-acronym \
--rule abbr-within-parentheses \
--rule alex \
--rule common-misspellings \
--rule en-max-word-count \
--rule diacritics \
--rule stop-words \
file_to_check

@matthew-piziak
Copy link
Contributor Author

@Mic92 Does that make sense?

@matthew-piziak
Copy link
Contributor Author

Is this sufficient? This is all I did in the previous PR. However I'm also happy to go through the checklist—is there documentation on how to "test using sandboxing"?

Bump. Looking for some beginner device here. I've only make one other nixpkgs PR before, and that one was just merged without further ceremony.

@matthew-piziak matthew-piziak force-pushed the textlint-rules branch 2 times, most recently from cafa963 to dd0d90b Compare February 22, 2019 22:21
@matthew-piziak
Copy link
Contributor Author

@adisbladis @6AA4FD Does this look okay to you?

@matthew-piziak
Copy link
Contributor Author

Looks like I can't get any attention here. I will try to contribute to NUR instead.

@veprbl
Copy link
Member

veprbl commented Mar 27, 2019

@matthew-piziak
This is very unfortunate. I think there is a problem with contributing Node.js packages to nixpkgs. The changes to the generated node-packages-v10.nix will quickly run into merge conflicts and PRs will get stalled and buried. I also suspect that we might not have enough people with node knowledge and time to review those PR's in the first place.

I think the pull requests should only update the .json file so that .nix file is updated by nodejs maintainers in a more synchronized fashion. Perhaps we could try doing this for your contribution.

@matthew-piziak
Copy link
Contributor Author

@veprbl That sounds great! Thank you so much for helping me out. My thinking is that the .nix generation step happening as a hook or a CI step makes sense. That way there will be no merge conflicts and reviewers only have to review a dozen lines instead of thousands.

I will remove the generate .nix file for now since I think that's what you're suggesting. Let me know if I can do anything else to help!

@matthew-piziak matthew-piziak force-pushed the textlint-rules branch 2 times, most recently from 8d043b7 to 631c802 Compare March 27, 2019 18:45
nodePackages_10_x.textlint-plugin-latex: init at 1.0.4
nodePackages_10_x.textlint-rule-abbr-within-parentheses: init at 1.0.2
nodePackages_10_x.textlint-rule-alex: init at 1.3.1
nodePackages_10_x.textlint-rule-common-misspellings: init at 1.0.1
nodePackages_10_x.textlint-rule-diacritics: init at 0.0.2
nodePackages_10_x.textlint-rule-en-max-word-count: init at 1.0.1
nodePackages_10_x.textlint-rule-max-comma: init at 1.0.4
nodePackages_10_x.textlint-rule-no-start-duplicated-conjunction: init at 2.0.2
nodePackages_10_x.textlint-rule-period-in-list-item: init at 0.2.0
nodePackages_10_x.textlint-rule-stop-words: init at 1.0.8
nodePackages_10_x.textlint-rule-terminology: init at 1.1.30
nodePackages_10_x.textlint-rule-unexpanded-acronym: init at 1.2.3
nodePackages_10_x.textlint-rule-write-good: init at 1.6.2
@matthew-piziak
Copy link
Contributor Author

@veprbl Okay, now the diff is restricted to node-packages-v10.json.

@Mic92
Copy link
Member

Mic92 commented Mar 27, 2019

Sorry, your pr got burden under the other ones.
You said you would use, one would use it like this:

$ textlint \
  --rule write-good \
  --rule no-start-duplicated-conjunction \
  --rule max-comma \
  --rule terminology \
  --rule period-in-list-item \
  --rule period-in-list-item \
  --rule unexpanded-acronym \
  --rule abbr-within-parentheses \
  --rule alex \
  --rule common-misspellings \
  --rule en-max-word-count \
  --rule diacritics \
  --rule stop-words \
  file_to_check

How can I bring the other packages get into scope? Do they just provide a binary each, that is picked up by texlint or do they need to be loaded as a library?

@matthew-piziak
Copy link
Contributor Author

All these packages are so-called "plugins" of textlint, each one is an npm module, and I believe they are loaded dynamically at runtime. There is more documentation here: https://textlint.github.io/docs/plugin.html

I'm not exactly sure how plugin discovery works...I've never used npm before. Hopefully it doesn't actually require npm to exist in order to wire in the plugins. I believe this is where rules are loaded in textlint: https://github.com/textlint/textlint/blob/master/packages/textlint/src/engine/textlint-module-loader.ts

@matthew-piziak
Copy link
Contributor Author

If I were doing this myself and guessing, I'd probably just make all the rules dependencies of textlint and hope that that'd be enough to get them loaded. That does make it less granular, where rule installation becomes all or nothing. Maybe there's a better way.

@endgame
Copy link
Contributor

endgame commented Mar 29, 2019

I wonder if the correct thing is to relax checks on the node stuff in nixpkgs so that we get more users and npm-aware nixpkgs contributors?

I don't have a dog in this race, because I don't do any JS, but it's a thought.

@matthew-piziak
Copy link
Contributor Author

@endgame I think you're right.

@Mic92
Copy link
Member

Mic92 commented Mar 29, 2019

@astro do you know if there was a way to extend the npm modules search path via environment variables?

@astro
Copy link
Contributor

astro commented Mar 30, 2019

@Mic92 Not npm itself, but node evaluates NODE_PATH from the environment. As per its man page:

NODE_PATH=path[:...]
       ':'-separated list of directories prefixed to the module search path.

@matthew-piziak
Copy link
Contributor Author

matthew-piziak commented Mar 30, 2019

@astro I'm looking at node2nix now. It includes this:

# Provide the dependencies in a development shell through the NODE_PATH environment variable
inherit nodeDependencies;
shellHook = stdenv.lib.optionalString (dependencies != []) ''
  export NODE_PATH=$nodeDependencies/lib/node_modules
'';

Does that mean we should be including all these packages as dependencies of textlint so that textlint can pick them up?

@astro
Copy link
Contributor

astro commented Apr 4, 2019

@matthew-piziak Yes.

If that doesn't do the trick, makeWrapper/wrapProgram may be used to add the env to the textlint entrypoint.

@matthew-piziak
Copy link
Contributor Author

Hmm, I don't know how to do either of those things. That is, I do not know how to add a dependency to the node-packages-v10.json so that the generation script will pick it up (there appear to be no analogous examples); and I do not know how to use makeWrapper or makeProgram. @astro can you show me how to do either one?

One thing I did try is, I cloned textlint, added the rules to its dependencies, and ran node2nix on it directly. However when I run nix-build -A package, this always happens on the last dependency:

npm ERR! code ENOTFOUND
npm ERR! errno ENOTFOUND
npm ERR! network request to http://www.example.com/@textlint%2fast-node-types failed, reason: getaddrinfo ENOTFOUND www.example.com www.example.com:80
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly.  See: 'npm help config'

npm ERR! A complete log of this run can be found in:
npm ERR!     /nix/store/iw009dc4rpla6i6gx98fdz22k8kjah28-node-dependencies-textlint-11.2.3/textlint/.npm/_logs/2019-04-05T01_31_17_744Z-debug.log
builder for '/nix/store/nraxcsn2d3lgmnpwzqv6njhilfkmiak3-node-dependencies-textlint-11.2.3.drv' failed with exit code 1
error: build of '/nix/store/nraxcsn2d3lgmnpwzqv6njhilfkmiak3-node-dependencies-textlint-11.2.3.drv' failed

@matthew-piziak
Copy link
Contributor Author

You can see my experimentation here: textlint/textlint@6aa579a...matthew-piziak:master

@matthew-piziak
Copy link
Contributor Author

Can a maintainer help me get this merged? Textlint without the rules is basically useless, and I've been trying to get this merged for three months now.

@nixos-discourse
Copy link

This pull request has been mentioned on Nix community. There might be relevant details there:

https://discourse.nixos.org/t/prs-ready-for-review-january/2002/5

@ryantm
Copy link
Member

ryantm commented May 10, 2019

@GrahamcOfBorg build nodePackages.textlint-plugin-latex

@ryantm ryantm merged commit 95738ec into NixOS:master May 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants