We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
The input to require should be a static string literal.
This is beneficial to various Bundles and Analyzer. And less difficult to migrate to es module.
The dynamic require should be prohibited.
require(pathToTargetModule) require('./icons/' + iconType + '.svg')
require('./path/to/module') require('./icons/pass.svg')
no-dynamic-require
Of course, in our project, there will indeed be such a situation.
require(pathToTargetModule)
This is a typical scenario that needs to be ignored.
exports[`no-dynamic-require 1`] = ` ## invalid(1): require(foo) > Input 1 | require(foo) > Error 1/1: Unexpected dynamic require. > 1 | require(foo) | ^^^^^^^^^^^^ ## invalid(2): require("foo" + "bar") > Input 1 | require("foo" + "bar") > Error 1/1: Unexpected dynamic require. > 1 | require("foo" + "bar") | ^^^^^^^^^^^^^^^^^^^^^^ ## invalid(3): require(\`\${foo}/bar\`) > Input 1 | require(\`\${foo}/bar\`) > Error 1/1: Unexpected dynamic require. > 1 | require(\`\${foo}/bar\`) | ^^^^^^^^^^^^^^^^^^^^^ `;
The text was updated successfully, but these errors were encountered:
We are not adding any new CommonJS-related rules here.
And it seems more appropriate for https://github.com/un-ts/eslint-plugin-import-x anyway
Sorry, something went wrong.
No branches or pull requests
Description
The input to require should be a static string literal.
This is beneficial to various Bundles and Analyzer. And less difficult to migrate to es module.
The dynamic require should be prohibited.
Fail
Pass
Proposed rule name
no-dynamic-require
Additional Info
Of course, in our project, there will indeed be such a situation.
This is a typical scenario that needs to be ignored.
The text was updated successfully, but these errors were encountered: