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
no-restricted-modules and TemplateLiteral #12926
Comments
Thanks for quick response! I don't want to add more work for you folks as I see there are already deprecation pull requests and migration of rules into |
Thanks for being willing! I think it would be great to get this in before we deprecate it, since at that point we won't be making bug fixes (though the rule will live on in |
I opened pull request ( #12927 ) and only questions I have are
But I included them in the PR description so maybe those could be answered there |
) (eslint#12927) * Update: no-restricted-modules handle TemplateLiteral (fixes eslint#12926) * add fixture using backslashes * finally understood, I think
Tell us about your environment
5.16.0
(in production), but issue exist also in6.8.0
10.16.3
6.13.4
What parser (default, Babel-ESLint, etc.) are you using?
babel-eslint
Please show your full configuration:
Configuration
Pasted full config below - but relevant part is in overrides configuration for
packages/gatsby-cli/src/**/*.js
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
What did you expect to happen?
For
no-restricted-modules
to raise linting errorWhat actually happened? Please include the actual, raw output from ESLint.
No linting error
Are you willing to submit a pull request to fix this bug?
Yes!
Extra information / motivation:
The
no-restricted-modules
works well when using regular single or double quoted strings as argument forrequire
calls - it results in expected linting error then.However
gatsbyjs/gatsby
repository usesquotes
rule withbackticks
( https://github.com/gatsbyjs/gatsby/blob/e720d8efe58eba0f6fae9f26ec8879128967d0b5/.eslintrc.js#L53 ) which automatically will turn allrequire
call arguments to use backticks, which makes it so theno-restricted-modules
rule is ineffective.Code in rule:
eslint/lib/rules/no-restricted-modules.js
Lines 159 to 175 in 41de9df
only handle cases of using
Literal
as argument, but it doesn't have handling forTemplateLiteral
- see AST for:require("react")
(Literal
case):require(`react`)
(TemplateLiteral
case):As mentioned in one of questions - I'm happy to provide pull request to adjust rule and tests to handle
TemplateLiteral
case (if it is desirable for the rule to handle it as well).The text was updated successfully, but these errors were encountered: