-
-
Notifications
You must be signed in to change notification settings - Fork 208
[rule: spaced-comment] shebang errors if followed by import #163
Comments
Ok looks like the issue is because although eslint tries to remove all shebang comments in https://github.com/eslint/eslint/blob/c694db4740d3f8e3d9f908a4e7321c398e924225/lib/eslint.js#L804-L810, babel-eslint has another leadingComments on not sure why it's different since it's the same comment attachment? it("shebang comment with spaceed-comment", function () {
verifyAndAssertMessages(
[
"#!/usr/bin/env node",
"",
"import { BlockWorker } from '../Workers';",
"import config from '../config';"
].join("\n"),
{ "spaced-comment": 1 },
[ ]
)
}); |
As a workaround for now, I start my cli files with this instead: #!/usr/bin/env node
var _eslint_workaround = true // eslint-disable-line no-unused-vars Third line can be anything it seems. Works with the latest standard code style. This works too: #!/usr/bin/env node
// see https://github.com/babel/babel-eslint/issues/163
var _eslint_workaround = true // eslint-disable-line no-unused-vars |
There is a PR with the fix for babylon now. Problem was that babylon is cloning the key-Identifier to the value-Identifier if destructuring with shorthands is used in objects. Espree/Acorn is not doing any cloning and therefore also not cloning the comment. |
Thanks for working on the fix @danez! Looking forward to remove my personal workaround from the code: #!/usr/bin/env node
// @flow
2 + 2 === 5 // https://git.io/vwmJK
import fs from 'fs' |
Well this is strange. I'm using "devDependencies": {
"ava": "^0.14.0",
"babel-eslint": "^6.0.4",
"coveralls": "^2.11.9",
"nyc": "^6.4.3",
"standard": "^7.0.1"
} And it worked for a day or so without the workaround. After another install, something (not sure what) upgraded babel-types from 6.8.0 to 6.8.1 and it's failing again. |
Sorry that it took so long to fix this. As of babylon 6.8.2 this is now fixed. |
Thanks @danez! |
This works as of babylon 6.8.2
So I found out that:
gives a spaced-comment error, while this does not:
See eslint/eslint#3296
The text was updated successfully, but these errors were encountered: