Proposal: support custom message for all no-restricted-* rules and possibly others
See original GitHub issueThe basic idea is to allow custom message for rules which may not be self-evident and may demand a description of why they exist.
Semi-duplicate of https://github.com/eslint/eslint/issues/8315, but I’m opening a new issue to suggest this for (IMO) all the rules that really need this, and to discuss what other rules we could implement this for.
I think all no-restricted*
rules need this. no-restricted-syntax
and no-restricted-properties
rules already have this, but these don’t:
no-restricted-modules
no-restricted-globals
no-restricted-imports
Syntax is comparative to the rules where it’s already implemented, but the naming of the keys is up for bikeshed. Proposals:
-
no-restricted-globals
- either aname
,variable
oridentifier
for the main key:/* * eslint no-restricted-globals: [ * "error", * { * "name": "self", * "message": "some explanation" * } * ] */
-
no-restricted-modules
&&no-restricted-imports
/* * eslint no-restricted-modules: [ * "error", * { * "name": "myModule", * "message": "some explanation" * } * ] */ // and /* * eslint no-restricted-modules: [ * "error", * { * "paths": [{ "path": "myModule", "message": "some message" }], * "patterns": [{ "pattern": "import2/*", "message": "some message" }] * } * ] */
It may be a good idea to implement custom messages for other rules, as well. Thoughts?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:15
- Comments:16 (16 by maintainers)
Thanks for the proposal. This seems like a good idea to me. 👍
I’m going to close this and create a new issue for whether we need to support custom messages for
patterns
inno-restricted-modules
andno-restricted-imports
. If users don’t seem to need them, then we can regard this as solved (until users start needing them).