question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Proposal: support custom message for all no-restricted-* rules and possibly others

See original GitHub issue

The 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 a name, variable or identifier 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:closed
  • Created 6 years ago
  • Reactions:15
  • Comments:16 (16 by maintainers)

github_iconTop GitHub Comments

3reactions
not-an-aardvarkcommented, Apr 4, 2017

Thanks for the proposal. This seems like a good idea to me. 👍

2reactions
platinumazurecommented, Jan 15, 2018

I’m going to close this and create a new issue for whether we need to support custom messages for patterns in no-restricted-modules and no-restricted-imports. If users don’t seem to need them, then we can regard this as solved (until users start needing them).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Customize message and file retention - Slack
By default, Slack will retain all messages and files (including audio and video clips) ... On the free plan, your options for data...
Read more >
Chapter 3-Security Policy: Development and Implementation ...
Other chapters in this document also address ways to customize policy to your organization's specific needs--a concept that should not be ignored if...
Read more >
Language Guide | Protocol Buffers - Google Developers
If you have a message with many optional fields and where at most one field will be set at the same time, you...
Read more >
Rules • Asana Product Guide
Enterprise and Business customers can create a custom rule in the rules dialogue and find Due date is approaching in the list of...
Read more >
About FCM messages | Firebase Cloud Messaging - Google
Set the appropriate key with your custom key-value pairs to send a data payload to the client app. Make sure that you do...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found