jscs-dev / node-jscs

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

Error in new linter feature validateQuoteMarks with ignoreJSX #1993

Closed justin808 closed 8 years ago

justin808 commented 8 years ago
internalError: Error running rule validateQuoteMarks: This is an issue with JSCS and not your codebase.
Please file an issue (with the stack trace below) at: https://github.com/jscs-dev/node-jscs/issues/new
TypeError: Cannot read property 'type' of null
    at /Users/my-project/client/node_modules/jscs/lib/rules/validate-quote-marks.js:118:63
    at /Users/my-project/client/node_modules/jscs/lib/js-file.js:614:17
    at Object.JsFile._forEachToken (/Users/my-project/client/node_modules/jscs/lib/js-file.js:651:13)
    at Object.JsFile.iterateTokensByType (/Users/my-project/client/node_modules/jscs/lib/js-file.js:612:14)
    at Object.module.exports.check (/Users/my-project/client/node_modules/jscs/lib/rules/validate-quote-marks.js:115:14)
    at null.<anonymous> (/Users/my-project/client/node_modules/jscs/lib/string-checker.js:165:22)
    at Array.forEach (native)
    at StringChecker._checkJsFile (/Users/my-project/client/node_modules/jscs/lib/string-checker.js:161:31)
    at StringChecker.checkString (/Users/my-project/client/node_modules/jscs/lib/string-checker.js:106:14)
    at null.<anonymous> (/Users/my-project/client/node_modules/jscs/lib/checker.js:56:21) at ./app/bundles/properties/components/common/PhotoTile.jsx :
     1 |/* eslint new-cap: [2, {"capIsNewExceptions": ["DropTarget","DragSource"]}] */

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

markelog commented 8 years ago

Would you mind providing the code example?

justin808 commented 8 years ago

/* eslint new-cap: [2, {"capIsNewExceptions": ["DropTarget","DragSource"]}] */

justin808 commented 8 years ago

it's those quotes

markelog commented 8 years ago

Could you clarify? I'm not sure what do you mean by that.

justin808 commented 8 years ago

File with a header of that line produces the error.

markelog commented 8 years ago

Can't repro with this example -

/* eslint new-cap: [2, {"capIsNewExceptions": ["DropTarget","DragSource"]}] */
<div className="flex-card__header">{this.props.children}</div>;

and .jscsrc like that -

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

Would you mind posting full content on https://gist.github.com?

justin808 commented 8 years ago

I don't remember offhand what project it is, but I do remember that this file is a JSX file with some react.

The comment was on the very first line of the file, before imports.

markelog commented 8 years ago

Can't repro

mlesk commented 8 years ago

I am experiencing this error as well, also on the first line of a file containing JSX. The error is reported on the first line of the file which is:

import React, {Component, PropTypes} from 'react';

I know it has nothing to do with this line because that exact line is present in many files that are not triggering the error. Something in the files is causing validateQuoteMarks to fail. Stack is the same as originally reported. Here is a gist containing the full contents of the file triggering the error:

https://gist.github.com/mlesk/ae6e9cef4c39afe92e42

My .jscsrc file:

{
  "preset": "airbnb",
  "disallowYodaConditions": true,
  "disallowMultipleVarDecl": true,
   "requireCurlyBraces": [
       "do"
   ],
   "requirePaddingNewLinesBeforeLineComments": {
       "allExcept": "firstAfterCurly"
   },
   "requirePaddingNewLinesBeforeLineComments": null,
   "requireObjectKeysOnNewLine": "true",
   "requireObjectKeysOnNewLine": {
     "allExcept": ["sameLine"]
   },
   "maxErrors": -1,
   "maxErrors": null,
   "fix": true,
   "maximumLineLength": null,
   "verbose": true
 }
farrrr commented 8 years ago

I also meet this problem, same with @mlesk .