Search code examples
eslintrules

Is it possible to modify the error messages given by ESLint?


In my day job we use ESLint to make sure everyone rows in the right direction. I'm wondering if we can leverage the linting error/warning messages to direct users to our internal policy/how to guides on addressing the linting issues presented?

Is there a way to modify ESLint error/warning messages to do this?

I took a quick look into using custom rules, but most of what I'm looking for is for existing rules like "no implicit any".


Solution

  • Unfortunately no. There appears to be no support for customizing the error message of any rule. See Issue 15821.

    The response from nzakas was:

    Thanks for the suggestion. Unfortunately, this is just not practical. There is no way to centrally implement this, so it would mean modifying nearly 300 rules, and that is not only more work than our small team can commit to, but not worth the opportunity cost to attempt.

    Remember, you can always create custom rules that do exactly what you want.

    So it's up to individual rules to implement message customization, which some have. (See this Answer about eslint-plugin-mocha).