-
Notifications
You must be signed in to change notification settings - Fork 5
Trailing space in comment breaks brackets-jscs #15
Comments
And here is by the way the .jscs.json-config that was used if that helps {
"excludeFiles": ["frontend/app/bower_components", "frontend/node_modules", "frontend/instrument",
"frontend/dist", "frontend/.tmp", "frontend/coverage",
"backend/node_modules", "backend/coverage"],
"disallowKeywords": ["with"],
"disallowKeywordsInComments": ["TODO"],
"disallowKeywordsOnNewLine": ["else"],
"disallowMixedSpacesAndTabs": true,
"disallowMultipleLineStrings": true,
"disallowNewlineBeforeBlockStatements": true,
"disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"],
"disallowSpaceBeforePostfixUnaryOperators": ["++", "--"],
"disallowSpacesInCallExpression": true,
"disallowSpacesInsideParentheses": true,
"maximumLineLength": 120,
"requireBlocksOnNewline": true,
"requireCapitalizedConstructors": true,
"requireCommaBeforeLineBreak": true,
"requireDotNotation": "except_snake_case",
"requireLineBreakAfterVariableAssignment": true,
"requireOperatorBeforeLineBreak": true,
"requireParenthesesAroundIIFE": true,
"requireSpaceBeforeBlockStatements": true,
"requireSpaceBeforeKeywords": ["else", "while", "catch"],
"requireSpaceBeforeObjectValues": true,
"requireSpaceBetweenArguments": true,
"requireSpacesInConditionalExpression": true,
"requireSpacesInForStatement": true,
"validateLineBreaks": "LF",
"validateParameterSeparator": ", ",
"validateQuoteMarks": "'"
} |
I have now found that the error is in handleJSXJSCS (Probably in JSXTransformer.transform(text, {harmony: true}).code;) I added some console output to confirm this console.log('text', text);
console.log('JSXCode', JSXCode);
return handleJSCS(JSXCode, fullPath, config); Which gives the output: text // This line has a trailing space
function a() {
return;
}
JSXCode // This line has a trailing spacefunction a() {
return;
} My workaround until it is fixed is to change line 189 in main.js to (since I do not use harmony I hope guess that JSXTransformer.transform is not necessary for me): return handleJSCS(text, fullPath, config); |
Looks like an issue with the JSXTransformer. I have opened a new bug with the Facebook team: facebook/react#3378 |
I think it is not JSXTransformer, but this line in handleJSXJSCS: // Trim trailing whitespace
JSXCode = JSXCode.replace(/( +)\n/g, ''); If I remove it it works better. Also Node-shebangs ( #!/usr/bin/env node\n ) are not handled correctly. It should be ignored if it is in the beginning of a file. I suggest the following in the beginning of the handleJSXJSCS-function: text = text.replace(/^#!.+\n/m, ''); |
A fix has been pushed for this. Please try v0.2.2 of the extension. |
The first problem is fixed now. But the other one is still a problem, I will create separate issue for that and a pull request. |
Now you have a new problem. The rule: {"disallowTrailingWhitespace": true} does not work anymore. I will create a new issue for that. |
If there is a trailing space in a comment an "Unexpected token"-error is created in brackets-jscs.
This is not a problem when running JSCS in commandline.
The text was updated successfully, but these errors were encountered: