Description
I would like to propose a rule which forbids all Node.js core modules, though which makes allowances for them under certain conditions. The purpose would be to ensure that one restricts such modules to use within Node entry files but otherwise allows one's code to work universally as polyglot code.
As far as the conditions under which to allow Node.js modules:
- The file is pointed to by a
node
conditional export inpackage.json
- The file has
{env: {node: true}}
applied to it
These conditions are more likely to suggest that the file or the entire package is Node only.
Such an option ought to help discourage packages which could be polyglot friendly from restricting their files or packages unnecessarily to Node only.
If you are open to the idea, I would think this could be its own rule, or it could be added as an option within the likes of node/no-restricted-import
/node/no-restricted-require
.
(Note that I originally submitted this rule proposal to import-js/eslint-plugin-import#2369 as that project already has a rule to restrict Node modules, but as they did not wish to support this, I thought I would ask here, especially since you already have some other very convenient rules which check package.json
or other config.)