-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Bug: no-restricted-imports
doesn't distinguish between package names that have a substring as a name
#18126
Comments
This works as intended because pattern Note that this also disallows |
Thanks. This is something I wanted to avoid:
Is there any way to achieve what I want? Seems like a missing use-case for this rule. Perhaps an |
Currently not, |
Environment
Node version: 20.1.0
npm version: N/A
Local ESLint version: 8.56.0
Global ESLint version: 8.56.0
Operating System: macOS 14.3.1
What parser are you using?
@typescript-eslint/parser
What did you do?
What did you expect to happen?
should error:
shouldn't error:
What actually happened?
Both
import
s error.Link to Minimal Reproducible Example
https://eslint.org/play/#eyJ0ZXh0IjoiLyplc2xpbnQgbm8tcmVzdHJpY3RlZC1pbXBvcnRzOiBbXCJlcnJvclwiLCB7XG4gICAgICAgIFwicGF0dGVybnNcIjogW1xuICAgICAgICAgIHtcbiAgICAgICAgICAgIFwiZ3JvdXBcIjogW1xuICAgICAgICAgICAgICBcInJlYWN0XCJcbiAgICAgICAgICAgIF0sXG4gICAgICAgICAgICBcImltcG9ydE5hbWVzXCI6IFtcbiAgICAgICAgICAgICAgXCJmb3J3YXJkUmVmXCJcbiAgICAgICAgICAgIF0sXG4gICAgICAgICAgICBcIm1lc3NhZ2VcIjogXCJVc2Ugb3VyIHR5cGUtc2FmZSB3cmFwcGVyIGZyb20gXFxcImZvb1xcXCIgaW5zdGVhZC5cIlxuICAgICAgICAgIH1cbiAgICAgICAgXVxuICAgICAgfV0qL1xuXG5pbXBvcnQgeyBmb3J3YXJkUmVmIGFzIG9yaWdpbmFsRm9yd2FyZFJlZiB9IGZyb20gJ3JlYWN0J1xuaW1wb3J0IHsgZm9yd2FyZFJlZiBhcyBtb2RpZmllZEZvcndhcmRSZWYgfSBmcm9tICdAbXktb3JnL3V0aWxzL3JlYWN0J1xuIiwib3B0aW9ucyI6eyJlbnYiOnt9LCJydWxlcyI6e30sInBhcnNlck9wdGlvbnMiOnsiZWNtYUZlYXR1cmVzIjp7fSwiZWNtYVZlcnNpb24iOiJsYXRlc3QiLCJzb3VyY2VUeXBlIjoibW9kdWxlIn19fQ==
Additional comments
I tried changing the rule configuration slightly, but to no avail.
Note that using this:
Is not good enough since it now errors on all of these lines:
Which, while technically correct (since you can then use
React.forwardRef
) is too much of an overhead, and not what I want to fix here. I'll prevent usage ofReact.forwardRef
using another rule (no-restricted-syntax maybe
).The text was updated successfully, but these errors were encountered: