-
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
tools: force common be required before any other modules #27650
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
return {}; | ||
} | ||
|
||
// Trim required module names | ||
const requiredModule = context.options[0]; |
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.
Doesn't this change the original rule? It could have been configured to enforce multiple modules before, now it only supports a single one.
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.
Theoretically yes, but the usage of this rule is only for the common
module under test directory, so it wouldn't break our linter and I think maybe it acceptable ?
Lines 23 to 24 in 56ab82e
## common module is mandatory in tests | |
node-core/required-modules: [error, common] |
I'm also not sure to limit this rule for a single one module configuration, or maybe should I write a new rule(maybe named require-top-level-common
) to force common be required before any other modules ?
Any advice ?
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 a new rule makes sense or also change this rule name as required-modules
is misleading.
cc: @Trott
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'm fine with the approach in this pull request + a name change to required-module
.
Alternatively, can we add a configuration object to the rule that allows you to specify that one of the modules must be loaded before all the others and only do this "load first" check for the module that has that option set?? It might look like this:
node-core/required-modules: [error, [common, assert, foo], { first: common}]
That might be over-engineering or it might be good flexibility to build in for the future. I'm fine with either approach.
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.
Yup 👍, that sounds great, will try to implement this in the next PR.
b97b353
to
0f9918b
Compare
Landed in dcc5e51 |
PR-URL: #27650 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
PR-URL: #27650 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Add a new eslint rule
require-common-first
to enforcecommon
be loaded in tests before any other modules.Refs: #27455 (comment)
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes