Skip to content
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

messageId doc examples throw during testing. #9889

betaorbust opened this issue Jan 25, 2018 · 2 comments · May be fixed by ali8889/emerald-wallet#4, guru2088/tokeno#3, DmytroSkrypnyk/test_bootstrap#6 or ali8889/emerald-wallet#17


Copy link

@betaorbust betaorbust commented Jan 25, 2018

Tell us about your environment

  • ESLint Version: 4.15+
  • Node Version: 8.9.3
  • npm Version: 5.5.1

What parser (default, Babel-ESLint, etc.) are you using?

Please show your full configuration:

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
Ran the code provided in the messageId section of the Working with Rules page.
Recreated below:


'use strict';
module.exports = {
    meta: {
        messages: {
            avoidName: "Avoid using variables named '{{ name }}'"
    create(context) {
        return {
            Identifier(node) {
                if ( === "foo") {
                        messageId: "avoidName",
                        data: {
                            name: "foo",

Updated require path which was var rule = require('../../../lib/rules/no-insecure-random'); which seems unrelated to this example.

'use strict';
// In your tests:
var rule = require('../../../lib/rules/no-foo');
var RuleTester = require('eslint').RuleTester;

var ruleTester = new RuleTester();'my-rule', rule, {
  valid: ['bar', 'baz'],

  invalid: [
      code: 'foo',
      errors: [
          messageId: 'foo',

What did you expect to happen?
It should work out of the box more or less.

What actually happened? Please include the actual, raw output from ESLint.

 1 failing

  1) my-rule invalid foo:
     AssertionError [ERR_ASSERTION]: Invalid messageId 'foo'. Expected one of ['avoidName'].
      at testInvalidTemplate (node_modules\eslint\lib\testers\rule-tester.js:508:40)
      at (node_modules\eslint\lib\testers\rule-tester.js:581:25)
Copy link

@platinumazure platinumazure commented Jan 25, 2018

Hi @betaorbust, thanks for the issue! I agree 100%, those docs need tweaking. Would you like to submit a pull request?

Copy link
Contributor Author

@betaorbust betaorbust commented Jan 25, 2018

Unfortunately, while putting together my PR for this, I ran into a much bigger problem in how the messageId feature currently works.

See #9890 for more details.

j-f1 added a commit to j-f1/forked-eslint that referenced this issue Jan 25, 2018
platinumazure added a commit that referenced this issue Jan 25, 2018
kaicataldo added a commit that referenced this issue Jan 30, 2018
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Jul 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.