Closed EvHaus closed 8 years ago
I thought we fixed this one @mdevils?
I have the same issue in react-starter-kit after upgrading to 3.0.2
3.0.3
doesn't fix it, take a look https://travis-ci.org/kriasoft/react-starter-kit/builds/123586977
@hzoo I though so
Will take a look soon
This has been happening for me for any version in the 3.0.x
series.
I went through my codebase and ran jscs
on each file until I discovered which file was causing the error to occur, and then through each function inside that file until I narrowed down the root cause. It seems that this object destructuring assignment inside of a function parameter causes the error: https://github.com/tangrams/tangram-play/blob/master/src/js/map/map.js#L80
This is valid ES6 and has been addressed before.
I created a very minimal test case so you can duplicate the error:
export function myFunction ({ foo = false, bar = null } = {}) {
console.log(foo, bar);
}
See here: https://gist.github.com/louh/0b2e74228c141afc4a34b70d3e944254
still happening in 3.0.3
I have same problem use with react
Same error for static property definition (in jscs 3.0.3)
class Bar {
static test = {
foo: 'bar'
};
}
That seems to be valid code.
TypeError: Cannot read property 'replace' of undefined
at renderLine (/var/www/test/node_modules/jscs/lib/errors.js:266:16)
at Object.Errors.explainError (/var/www/test/node_modules/jscs/lib/errors.js:197:13)
at /var/www/test/node_modules/jscs/lib/reporters/console.js:16:36
at Array.forEach (native)
at /var/www/test/node_modules/jscs/lib/reporters/console.js:14:35
at Array.forEach (native)
at Object.module.exports [as writer] (/var/www/test/node_modules/jscs/lib/reporters/console.js:9:22)
at /var/www/test/node_modules/jscs/lib/cli.js:149:18
at Array.<anonymous> (/var/www/test/node_modules/vow/lib/vow.js:712:56)
at Immediate.callFns [as _onImmediate] (/var/www/test/node_modules/vow/lib/vow.js:23:35)
I got the same error when using esnext bind expression, which doesn't seem to be supported in cst used by jscs 3.0. Whenever there is a parse error (error.rule === "parseError"), the error has no line number.
The fixed I applied temporarily to my jscs install was this, which a least prints the underlying reason for the parse error. I'm not sure if that's the best place for the fix or if it should be as soon as the parse error is detected.
explainError: function(error, colorize) {
if (typeof error.line === 'undefined') {
//probably a parseError, so include the rule name
return formatErrorMessage(error.rule + ': ' + error.message, this.getFilename(), colorize);
}
//... the rest
}
There is lot of different errors here and they about different things, like
export function myFunction ({ foo = false, bar = null } = {}) {
console.log(foo, bar);
}
Is https://github.com/cst/cst/issues/118
static properties is about - https://github.com/cst/cst/issues/112
And so on.
After https://github.com/cst/cst/pull/116 and with https://github.com/jscs-dev/node-jscs/commit/729db94f86902496f3962a4a97bdd91a75ab5514, errors will be outputted in a friendly manner
pulling in the latest changes from master fixed this issue for me:
"devDependencies": {
...
"jscs": "git:github.com/jscs-dev/node-jscs.git",
...
}
This is enough:
"devDependencies": {
...
"jscs": "jscs-dev/node-jscs",
...
}
@zxqfox cool, thanks!
For me problem still occurs. Even on the jscs-dev/node-jscs version. It's hard for me to paste example code because project is too large.
Reporting in the same. Version 3.0.3. May move to ESLint as suggested though on the blog. For now I'm using the fix people have suggested.
We gonna publish 3.0.4 in a few days with a fix (we hope). Can you please try master branch?
I will try it on Monday (just finished work;) On 20 May 2016 4:06 pm, "Alexej Yaroshevich" notifications@github.com wrote:
We gonna publish 3.0.4 in a few days with a fix (we hope). Can you please try master branch?
— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/jscs-dev/node-jscs/issues/2219#issuecomment-220615013
Unfortunatly, I still get 'replace' of undefined error. :(
On Fri, May 20, 2016 at 4:17 PM Sebastian mergol@gmail.com wrote:
I will try it on Monday (just finished work;) On 20 May 2016 4:06 pm, "Alexej Yaroshevich" notifications@github.com wrote:
We gonna publish 3.0.4 in a few days with a fix (we hope). Can you please try master branch?
— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/jscs-dev/node-jscs/issues/2219#issuecomment-220615013
Most basic example to get the error:
var m = require('mori');
function getTrNid(trNid, saveRes) {
return trNid < 0
? m.getIn(saveRes, [parseInt(trNid), 'nid'])
: trNid;
};
module.exports = getTrNid;
Results in:
~/delme/node-jscs/bin/jscs -x --preset airbnb src/js/model/FlightListLeg/getTrNid.js
validateIndentation: Invalid indentation character: at src/js/model/FlightListLeg/getTrNid.js :
3 |function getTrNid(trNid, saveRes) {
4 | return trNid < 0
5 | ? m.getIn(saveRes, [parseInt(trNid), 'nid'])
--------^
6 | : trNid;
7 |};
validateIndentation: Invalid indentation character: at src/js/model/FlightListLeg/getTrNid.js :
4 | return trNid < 0
5 | ? m.getIn(saveRes, [parseInt(trNid), 'nid'])
6 | : trNid;
--------^
7 |};
8 |
TypeError: Cannot read property 'replace' of undefined
at renderLine (/home/x/delme/node-jscs/lib/errors.js:267:16)
at Object.Errors.explainError (/home/x/delme/node-jscs/lib/errors.js:198:13)
at /home/x/delme/node-jscs/lib/reporters/console.js:16:36
at Array.forEach (native)
at /home/x/delme/node-jscs/lib/reporters/console.js:14:35
at Array.forEach (native)
at Object.module.exports [as writer] (/home/x/delme/node-jscs/lib/reporters/console.js:9:22)
at /home/x/delme/node-jscs/lib/cli.js:149:18
at Array.<anonymous> (/home/x/delme/node-jscs/node_modules/vow/lib/vow.js:712:56)
at Immediate.callFns [as _onImmediate] (/home/x/delme/node-jscs/node_modules/vow/lib/vow.js:23:35)
After upgrading to 3.0.2, I can't seem to be able to get JSCS to work. Running the
jscs
CLI returns this error:My .jscsrc is: