no-restricted-imports with custom messages is throwing a validation error
See original GitHub issueNode 10.15.3 and latest ESLint version.
When configuring the rule with a custom message exactly how it is done in the example page https://eslint.org/docs/rules/no-restricted-imports
"no-restricted-imports": ["error", [{
"name": "import-foo",
"message": "Please use import-bar instead."
}]]
I get an ESLint rule validation error
Error: /Users/me/project/my-rules.js:
Configuration for rule "no-restricted-imports" is invalid:
Value [{"name":"import-foo","message":"Please use import-bar instead."}] should be string.
Value [{"name":"import-foo","message":"Please use import-bar instead."}] should be object.
Value [{"name":"import-foo","message":"Please use import-bar instead."}] should match some schema in anyOf.
Value [{"name":"import-foo","message":"Please use import-bar instead."}] should be object.
Value [[{"name":"import-foo","message":"Please use import-bar instead."}]] should match some schema in anyOf.
I don’t think the documentation is wrong because the rule should accept custom messages as stated here https://github.com/eslint/eslint/issues/8400
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Lint rule "no-restricted-imports" throw error when patterns ...
Configuration for rule "no-restricted-imports" is invalid: Value {"patterns":[{"group":["lodash/"],"message":"Message"}]} should be string.
Read more >no-restricted-imports - ESLint - Pluggable JavaScript Linter
This rule allows you to specify imports that you don't want to use in your application. It applies to static imports only, not...
Read more >Error 'bad value for restricted picklist field' appears when a ...
This error can occur when you deploy a picklist field from sandbox and the values are not selected on the record types. This...
Read more >Resolve validation errors - Azure DevOps Services
Fix errors reported upon importing a process to support customization of tracking work in Azure DevOps Services.
Read more >Import format quotas and validation - Amazon DynamoDB
There are three categories of import errors: API validation errors, ... does not exist, the import will fail and log the error message...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think the issue is that the severity and options should all be a flat array:
@yvele Could you please give that a try? And if it works, please advise (or submit a PR) where the documentation needs to be corrected… Thanks!
Example from the original post is indeed wrong in the documentation, it should be as in this comment
It seems that the other examples are correct.