eslint: [rule-tester.js] checking error mesasges

right now, if i want to test error messages returned by the linter i do this:

    {code: 'class A {}', errors: [{message: '111'}]}

If the test fails, it’ll result into the following error

AssertionError: Error message should be 111

that has no information about what message actually was there.

I assume this is the line that makes the assertion https://github.com/eslint/eslint/blob/master/lib/testers/rule-tester.js#L407

would it be reasonable to add a better description and possibly a regex matching?

I made a rule that checks for existence of test files corresponding to the file that’s being linted, what i want to do ideally is:

{
  code: 'class VeryImportantClass {}', 
  errors: [
    {
      message: /^because this file is important it should have a test file at .*\-test\.js$/
    }
  ]
}

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 1
  • Comments: 17 (17 by maintainers)

Commits related to this issue

Most upvoted comments

Huh, that’s interesting. Nice research! I can get behind that.

Other thoughts?

We need to get TSC approval. @eslint/eslint-tsc does anyone object to removing our custom assert message so the actual and expected values are shown automatically?