jscs-dev / node-jscs

:arrow_heading_up: JavaScript Code Style checker (unmaintained)
https://jscs-dev.github.io
MIT License
4.96k stars 513 forks source link

--fix option breaks code by removing \\ in strings #2043

Closed justin808 closed 8 years ago

justin808 commented 8 years ago

See https://github.com/shakacode/react_on_rails/commit/eac2a29dc1c6352b34a1a0fa0957c78b3e428a3c#diff-f1982fe6b827afdc18aa0d36700f4cc2R80

When I run --fix on the below code, the \\ are removed! and that breaks the test.

(npm bin)/jscs --version    
title:8: parse error
2.7.0

code that breaks

test('buildConsoleReplay wraps console replay in a script tag', (assert) => {
  assert.plan(1);
  console.history = [
    { arguments: ['some message', { a: 1, b: 2 }], level: 'log' },
    { arguments: ['other message', { c: 3, d: 4 }], level: 'warn' },
  ];
  const actual = buildConsoleReplay();
  const expected = `
<script>
console.log.apply(console, ["some message","{\\"a\\":1,\\"b\\":2}"]);
console.warn.apply(console, ["other message","{\\"c\\":3,\\"d\\":4}"]);
</script>`;
  assert.equals(actual, expected, 'Unexpected value for console replay history');
});
markelog commented 8 years ago

Hm, didn't happen for me -

markelog in ~/Workspace/react_on_rails on (HEAD detached at eac2a29)*
$ git status
HEAD detached at eac2a29
nothing to commit, working directory clean
markelog in ~/Workspace/react_on_rails on (HEAD detached at eac2a29)*
$ jscs -x node_package/tests/buildConsoleReplay.test.js
markelog in ~/Workspace/react_on_rails on (HEAD detached at eac2a29)*
$ git status
HEAD detached at eac2a29
nothing to commit, working directory clean
markelog in ~/Workspace/react_on_rails on (HEAD detached at eac2a29)*
$ node -v
v5.1.0
justin808 commented 8 years ago

@markelog What do you recommend? Is my version of jscs wrong? or my .jsrc? or version of node?

markelog commented 8 years ago

It seems config is okay. Can you try to reinstall your modules? And post version of the node.

justin808 commented 8 years ago

Should I first update to node latest? Did you pull my project and run jscs -x?

markelog commented 8 years ago

Should I first update to node latest?

No, it should work from node .10, i'm asking about the node version, so i would repro it

Did you pull my project and run jscs -x?

Yeah, you can see my actions at the comment - https://github.com/jscs-dev/node-jscs/issues/2043#issuecomment-168161191

Happy new year btw!

justin808 commented 8 years ago

When I tried again, with no linting issues, so let's close this. I'll keep an eye out for this one. Thanks for the great work on this tool!

markelog commented 8 years ago

Okay, keep us posted if you see anything :)