tools: force common be required before any other modules#27650
tools: force common be required before any other modules#27650ZYSzys wants to merge 2 commits intonodejs:masterfrom zys-contrib:eslint-require-common
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
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.
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
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.
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.
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.
Yup 👍, that sounds great, will try to implement this in the next PR.
|
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-firstto enforcecommonbe loaded in tests before any other modules.Refs: #27455 (comment)
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes