ESLint Error: Line number out of range

ESLint Error: Line number out of range

我在标准配置中使用 ESLint。

当 运行 eslint --fix */**:

时出现此错误
Line number out of range (line 318 requested, but only 317 lines present).
RangeError: Line number out of range (line 318 requested, but only 317 lines present).
    at SourceCode.getIndexFromLoc (/usr/local/lib/node_modules/eslint/lib/util/source-code.js:389:19)
    at Object.fix (/usr/local/lib/node_modules/eslint/lib/rules/no-multiple-empty-lines.js:116:52)
    at RuleContext.report (/usr/local/lib/node_modules/eslint/lib/rule-context.js:127:34)
    at Program:exit.allLines.reduce.concat.reduce (/usr/local/lib/node_modules/eslint/lib/rules/no-multiple-empty-lines.js:108:37)
    at Array.reduce (native)
    at EventEmitter.Program:exit (/usr/local/lib/node_modules/eslint/lib/rules/no-multiple-empty-lines.js:93:22)
    at emitOne (events.js:101:20)
    at EventEmitter.emit (events.js:191:7)
    at NodeEventGenerator.applySelector (/usr/local/lib/node_modules/eslint/lib/util/node-event-generator.js:265:26)
    at NodeEventGenerator.applySelectors (/usr/local/lib/node_modules/eslint/lib/util/node-event-generator.js:294:22)

有什么解决办法吗?

我先从Standard CLI试了standard --fix,同样的错误,然后直接从ESLint试了下,确认是后者抛出的错误,而不是前者抛出的错误。

想通了:https://github.com/eslint/eslint/issues/8401

It appears that this error is consistently thrown if the file ends in a new line with a space character. When I delete the space, the error goes away.