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

RuleTester prints \u000a instead of newline #12027

Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly core Relates to ESLint's core APIs and features

Comments

@golopot
Copy link
Contributor

golopot commented Jul 27, 2019

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
@golopot golopot added bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon labels Jul 27, 2019
@zamboney
Copy link
Contributor

I would like it to be my first issue

zamboney pushed a commit to zamboney/eslint that referenced this issue Jul 27, 2019
@platinumazure platinumazure added core Relates to ESLint's core APIs and features evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Jul 27, 2019
@platinumazure
Copy link
Member

Hi @golopot, thanks for the issue.

Based on your description, this does sound like a bug. Hopefully a team member can reproduce this bug soon so we can mark the issue as accepted. (I'm on vacation without access to my PC, so I can't test this myself right now.)

zamboney pushed a commit to zamboney/eslint that referenced this issue Jul 28, 2019
@ulrichb
Copy link

ulrichb commented Jul 31, 2019

Same here:

image

(BTW: Running on Windows.)

@golopot
Copy link
Contributor Author

golopot commented Aug 19, 2019

@platinumazure
Copy link
Member

I'll mark as accepted based on the CI example. Thanks!

@platinumazure platinumazure added accepted There is consensus among the team that this change meets the criteria for inclusion and removed evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Aug 19, 2019
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Mar 29, 2020
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Mar 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.