-
Notifications
You must be signed in to change notification settings - Fork 30k
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
lint: move eslint to new plugin system #18566
Conversation
4425ec3
to
0ab97f4
Compare
Should the |
0ab97f4
to
eee34c8
Compare
.eslintrc.js
Outdated
if (!r && hacks.includes(request)) | ||
return require.resolve(`./tools/node_modules/${request}`); | ||
return r; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As an alternative to monkeypatching the module resolution code, you could also use something like eslint-plugin-rulesdir
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i actually started by looking at things like that. eslint-plugin-rulesdir solves a different problem. the eslint-plugin-node plugin actually does mostly the same thing as eslint-plugin-rulesdir. the reason i monkeypatch is because eslint doesn't know (rightfully so) to look in tools/node_modules
for babel-eslint and eslint-plugin-node. eslint accepting relative paths to plugins/parsers would allow me to get rid of the module patch, but the issues/prs surrounding that for eslint seem to have stalled so i just did this instead.
Sorry for the conflict after #18569, this needs rebasing) |
0e1d2b3
to
78d105c
Compare
@vsemozhetbyt this should be gtg, and probably fast-track-able? |
Yay, editor integration working again. I noticed these errors when running on the CLI, can anyone reproduce?
|
@silverwind i can't reproduce it, perhaps you can do a little digging? |
78d105c
to
b1ba338
Compare
Hmm, not sure where to start looking. BTW, is it intentional that |
.eslintrc.js
Outdated
@@ -0,0 +1,222 @@ | |||
const NodePlugin = require('./tools/node_modules/eslint-plugin-node'); | |||
NodePlugin.RULES_DIR = 'tools/eslint-rules'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this path be path.join(__dirname, 'tools', 'eslint-rules')
, so that eslint can be called from subdirectories too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@silverwind i wasn't able to figure out what markdown was doing, it wasn't in tools/node_modules and i don't have it installed globally so i assumed it was builtin to eslint and didn't think about it any further, but i will make that change for the rules dir, good catch 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's in tools/node_modules/eslint/node_modules
. I got the error about it missing when running my global eslint
without the plugin installed globally but if you don't see these errors, I think something might be wrong in my setup. I use yarn for global modules, if that matters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interesting, i have modified the script to fix this thanks 😄
ebdce6f
to
4d2995b
Compare
.eslintrc.js
Outdated
NodePlugin.RULES_DIR = path.resolve(__dirname, 'tools', 'eslint-rules'); | ||
|
||
const ModuleFindPath = Module._findPath; | ||
const hacks = ['eslint-plugin-node', 'eslint-plugin-markdown', 'babel-eslint']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use eslint-plugin-node-core
as the namespace since eslint-plugin-node
is already taken and seems quite popular? I have put a placeholder in eslint-plugin-node-core
to export these rules out (currently empty, the prototypes are in @joyeecheung
scope until we figure out how how it's going to be adopted)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that sounds ok, once they move to nodejs's namespace on github i can integrate them into this pr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I am not an expert on eslint but I think if we publish eslint-plugin-node-core
to npm and install them globally, the editors are going to work as well? (The error documentation rules would be a bit tricky since they need to read doc/api/errors.md
though)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if installed globally and run with global eslint install then yes it would work 👍
Ping @devsnek |
@BridgeAR this is kinda sitting while i wait to see what happens with nodejs/admin#55 |
@devsnek Since this is already in working shape, maybe we can just use the node-core namespace now (since it's taken we don't need to worry about potential conflicts) and land this. When they do get published npm the users can then use them without the hack |
4d2995b
to
43d50df
Compare
@joyeecheung pr uses node-core namespace now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with one suggestion
return r; | ||
}; | ||
|
||
module.exports = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it makes sense to put these into a separate file (either a JSON or a .js), and re-export that from here. That way we can separate the hack from the actual rules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'd rather not just for simplicity's sake
landed in 6934792 |
PR-URL: #18566 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io>
Should this be backported to |
This adds the eslint rules back in that were falsely removed while landing nodejs#18566. Refs: nodejs#18566
Seems like this removed a couple of rules that landed since the PR was originally opened. I opened a PR to fix those: #18933 So if this is backported, please include that fix as well. |
This adds the eslint rules back in that were falsely removed while landing nodejs#18566. PR-URL: nodejs#18933 Refs: nodejs#18566 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Hey all... this is blocking updating the eslint rules for all previous release lines. Can we please get this backported to v9.x -> v6.x |
If anybody looks into this deeply, please consider finding a fix for the #19250 (concise investigation in #19250 (comment)) |
PR-URL: nodejs#18566 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io>
This adds the eslint rules back in that were falsely removed while landing nodejs#18566. PR-URL: nodejs#18933 Refs: nodejs#18566 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
PR-URL: nodejs#18566 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io>
This adds the eslint rules back in that were falsely removed while landing nodejs#18566. PR-URL: nodejs#18933 Refs: nodejs#18566 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Refs: nodejs#18566 PR-URL: nodejs#21449 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Ping re 8.x backport needs to come with #18933 |
another ping for 8.x update for the eslint stuff /cc @Trott |
@MylesBorins I believe this will be easier to backport if #17820 lands on 8.x-staging first. |
this allows any global eslint install to run the eslint, letting editor's eslint addons lint node source as you edit it. i realize this is quite hacky but it seems fairly worth it for the ease of editing. this also moves all our custom eslint rules to a
node
namespace as a side-effect which seems to me like a bonus.Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
lint