Skip to content

RuleTester prints \u000a instead of newline #12027

@chiawendt

Description

@chiawendt

Since eslint 6, rule tester prints newline in codes as \u000a. It is hard to read for plugin developers.

Code to repoduce

npx mocha index.js
// index.js

const {RuleTester} = require('eslint');

const someRule = {
  create() {
    return {};
  },
};

const ruleTester = new RuleTester();

ruleTester.run('some-rule', someRule, {
  valid: [],
  invalid: [
    {
      code: `
        var a;
        var b;
      `,
      errors: [{message: 'foooooooooooo'}],
    },
  ],
});

Actual output

Note the lines with \u000a.

  0 passing (46ms)
  1 failing

  1) some-rule
       invalid
         \u000a        var a;\u000a        var b;\u000a      :

      AssertionError [ERR_ASSERTION]: Should have 1 error but had 0: []
      + expected - actual

      -0
      +1

Expected ouput

This is the behavior with npm i eslint@5.

  1) some-rule
       invalid
         
        var a;
        var b;
      :

      AssertionError [ERR_ASSERTION]: Should have 1 error but had 0: []
      + expected - actual

      -0
      +1

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedThere is consensus among the team that this change meets the criteria for inclusionarchived due to ageThis issue has been archived; please open a new issue for any further discussionbugESLint is working incorrectlycoreRelates to ESLint's core APIs and features

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions