Cannot read property 'loc' of undefined crash in newline-after-import #592
Closed
Description
Seeing this when greenkeeper updated a project to version 2. It's using decorators, which I know might not be supported, but I don't think it should be crashing. Here's a reduced test case that I came up with (I put the whole thing in a gist too):
.eslintrc
{
"parser": "babel-eslint",
"plugins": ["import"],
"rules": {
"import/newline-after-import": 2
}
}
.babelrc
{
"presets": ["es2015"]
}
app.js
@SomeDecorator(require('./some-file'))
export default class App {}
output
> eslint-plugin-import-v2-test@1.0.0 lint /Users/lukekarrys/Desktop/403897c78dc5b0b7387c15851fe48b5a
> DEBUG=eslint-plugin-import:rules:newline-after-import eslint .
eslint-plugin-import:rules:newline-after-import exit processing for +0ms /Users/lukekarrys/Desktop/403897c78dc5b0b7387c15851fe48b5a/app.js
eslint-plugin-import:rules:newline-after-import got scope: +2ms [ Node {
type: 'ExportDefaultDeclaration',
start: 39,
end: 66,
loc: SourceLocation { start: [Object], end: [Object] },
declaration:
Node {
type: 'ClassDeclaration',
start: 54,
end: 66,
loc: [Object],
id: [Object],
superClass: null,
body: [Object],
decorators: [Object],
range: [Object],
_babelType: 'ClassDeclaration',
parent: [Circular] },
range: [ 39, 66 ],
_babelType: 'ExportDefaultDeclaration',
parent:
Node {
type: 'Program',
start: 0,
end: 67,
loc: [Object],
comments: [],
tokens: [Object],
range: [Object],
sourceType: 'module',
directives: undefined,
body: [Circular],
parent: null } } ]
eslint-plugin-import:rules:newline-after-import node position in scope: +13ms -1
Cannot read property 'loc' of undefined
TypeError: Cannot read property 'loc' of undefined
at getLineDifference (/Users/lukekarrys/Desktop/403897c78dc5b0b7387c15851fe48b5a/node_modules/eslint-plugin-import/lib/rules/newline-after-import.js:48:40)
at checkForNewLine (/Users/lukekarrys/Desktop/403897c78dc5b0b7387c15851fe48b5a/node_modules/eslint-plugin-import/lib/rules/newline-after-import.js:60:11)
at /Users/lukekarrys/Desktop/403897c78dc5b0b7387c15851fe48b5a/node_modules/eslint-plugin-import/lib/rules/newline-after-import.js:119:13
at Array.forEach (native)
at EventEmitter.Program:exit (/Users/lukekarrys/Desktop/403897c78dc5b0b7387c15851fe48b5a/node_modules/eslint-plugin-import/lib/rules/newline-after-import.js:105:22)
at emitOne (events.js:90:13)
at EventEmitter.emit (events.js:182:7)
at NodeEventGenerator.leaveNode (/Users/lukekarrys/Desktop/403897c78dc5b0b7387c15851fe48b5a/node_modules/eslint/lib/util/node-event-generator.js:49:22)
at CodePathAnalyzer.leaveNode (/Users/lukekarrys/Desktop/403897c78dc5b0b7387c15851fe48b5a/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:628:23)
at CommentEventGenerator.leaveNode (/Users/lukekarrys/Desktop/403897c78dc5b0b7387c15851fe48b5a/node_modules/eslint/lib/util/comment-event-generator.js:110:23)
Metadata
Assignees
Labels
No labels