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

Internal Error: Error running rule validateQuoteMarks when using ES7 @ decorator #2141

Closed epsitec closed 8 years ago

epsitec commented 8 years ago

Following snippet crashes JSCS:

'use strict';

function foo () {}

@foo (s => '1') // works if you replace '1' with 1
export default class Bar {
}

Here is the stack trace:

TypeError: Cannot read property 'type' of null
    at C:\Users\Epsitec\.atom\packages\linter-jscs\node_modules\jscs\lib\rules\validate-quote-marks.js:118:63
    at C:\Users\Epsitec\.atom\packages\linter-jscs\node_modules\jscs\lib\js-file.js:614:17
    at Object.JsFile._forEachToken (C:\Users\Epsitec\.atom\packages\linter-jscs\node_modules\jscs\lib\js-file.js:651:13)
    at Object.JsFile.iterateTokensByType (C:\Users\Epsitec\.atom\packages\linter-jscs\node_modules\jscs\lib\js-file.js:612:14)
    at Object.module.exports.check (C:\Users\Epsitec\.atom\packages\linter-jscs\node_modules\jscs\lib\rules\validate-quote-marks.js:115:14)
    at [object Object]. (C:\Users\Epsitec\.atom\packages\linter-jscs\node_modules\jscs\lib\string-checker.js:165:22)
    at Array.forEach (native)
    at [object Object].StringChecker._checkJsFile (C:\Users\Epsitec\.atom\packages\linter-jscs\node_modules\jscs\lib\string-checker.js:161:31)
    at [object Object].StringChecker.checkString (C:\Users\Epsitec\.atom\packages\linter-jscs\node_modules\jscs\lib\string-checker.js:106:14)
    at Object.lint (C:/Users/Epsitec/.atom/packages/linter-jscs/index.js:124:12)
    at promises.push.Promise.then._this.emitter.emit.linter (C:/Users/Epsitec/.atom/packages/linter/lib/linter-registry.js:63:26)
    at C:/Users/Epsitec/.atom/packages/linter/lib/linter-registry.js:62:23
    at Set.forEach (native)
    at LinterRegistry.lint (C:/Users/Epsitec/.atom/packages/linter/lib/linter-registry.js:60:18)
    at file:///C:/Users/Epsitec/.atom/packages/linter/lib/linter.coffee:98:16
    at Function.module.exports.Emitter.simpleDispatch (C:\Users\Epsitec\AppData\Local\atom\app-1.5.3\resources\app.asar\node_modules\event-kit\lib\emitter.js:25:14)
    at Emitter.module.exports.Emitter.emit (C:\Users\Epsitec\AppData\Local\atom\app-1.5.3\resources\app.asar\node_modules\event-kit\lib\emitter.js:125:28)
    at C:/Users/Epsitec/.atom/packages/linter/lib/editor-linter.js:80:22
    at C:\Users\Epsitec\.atom\packages\linter\lib\helpers.coffee:23:18at line 1 col 1
Skywalker13 commented 8 years ago

:+1:

The problem appears with the validateQuoteMarks rule when ignoreJSX is true. For example:

  "validateQuoteMarks":                       { "mark": "'", "escape": true, "ignoreJSX": true },

Change ignoreJSX to false, then it works for this case.

markelog commented 8 years ago

Fix for it will be released with 2.11 i.e. monday, working on it for 3.0, this is why this issue still needs to be open

hzoo commented 8 years ago

This is fixed right?