-
-
Notifications
You must be signed in to change notification settings - Fork 490
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
fix(linter): add option "allowTypeImports" for rule "no-restricted-imports" #7894
base: main
Are you sure you want to change the base?
fix(linter): add option "allowTypeImports" for rule "no-restricted-imports" #7894
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. |
CodSpeed Performance ReportMerging #7894 will not alter performanceComparing Summary
|
… option inside `patterns`
…ld regex in `from_configuration`
…-linter-no-restricted-imports-improve-diagnostics
…nto bugfix-linter-add-option-allow-type-imports-for-no-restricted-imports
@@ -1832,6 +2600,270 @@ fn test() { | |||
// ), | |||
]; | |||
|
|||
let fail_typescript = vec![ | |||
("import foo from 'import1';", Some(serde_json::json!(["import1", "import2"]))), | |||
// ("import foo = require('import1');", Some(serde_json::json!(["import1", "import2"]))), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@camc314 should we support this?
Notice the import
at the start. There is no entry in ModuleRecord
for it.
I searched a bit on the internet and it looks like this is a old syntax.
There is 2 options how to solve this:
- fix
ModuleRecord
to implement this use case - loops to the AST nodes and find the require
I am not that good in typescript to understand what the best solution is for the absurd syntax
) > The regex property is used to specify the regex patterns for restricting modules. > Note: regex cannot be used in combination with group. _https://eslint.org/docs/latest/rules/no-restricted-imports#regex_ > This option allows you to use regex patterns to restrict import names: _https://eslint.org/docs/latest/rules/no-restricted-imports#importnamepattern_ > This is a string option. Inverse of importNamePattern, this option allows imports that matches the specified regex pattern. So it restricts all imports from a module, except specified allowed patterns. > Note: allowImportNamePattern cannot be used in combination with importNames, importNamePattern or allowImportNames. _https://eslint.org/docs/latest/rules/no-restricted-imports#allowimportnamepattern_ Needed to install `regress` to support JS Sntax like Lookaheads and Lookbehinds Next Goals: - #7894 - Improve spans - Error for wrong configurations - update documentation - Output messages like [eslint](https://github.com/eslint/eslint/blob/main/lib/rules/no-restricted-imports.js#L140-L184)
waiting for #8113