Я добавил пару строк для проверки ошибок в моем REST API (метод POST). Строки 39-60
app.post('/collections/:collectionName', (req, res, next) => {
pino(req,res);
req.log.info('pino output');
try {
req.collection.insert(req.body, {}, (e, results) => {
if (e) return next(e)
res.send(results.ops)
} catch (err) {
if (err instanceof CustomError) {
return res.status(err.status).send({
error: err.code,
description: err.message,
}) else {
console.error(err);
return res.status(500).send({
error: 'GENERIC',
description: 'Something went wrong!!!',
})
}
}
}
})
Когда я запускаю
eslint --fix index.js
/home/miki/restwitherrors/index.js
46:7 error Parsing error: Unexpected token catch
✖ 1 problem (1 error, 0 warnings)
Если я пытаюсь в VSCode ,Shift+ALt+.
и выбираю Fix all detected spelling errors
, вывод равен
<semantic> TypeScript Server Error (3.8.3)
Cannot read property 'groups' of null
TypeError: Cannot read property 'groups' of null
at DiagnosticIDDecorator.UndecorateFix (/home/miki/.vscode/extensions/manuth.eslint-language-service-1.0.1/node_modules/typescript-eslint-plugin/lib/Diagnostics/DiagnosticIDDecorator.js:65:92)
at DiagnosticIDDecorator.UndecorateCombinedFix (/home/miki/.vscode
/extensions/manuth.eslint-language-service-1.0.1/node_modules/typescript-eslint-plugin/lib/Diagnostics/DiagnosticIDDecorator.js:75:109)
at /home/miki/.vscode/extensions/manuth.eslint-language-service-1.0.1/node_modules/typescript-eslint-plugin/lib/Plugin.js:397:45
at Proxy.<anonymous> (/home/miki/.vscode/extensions/manuth.eslint-language-service-1.0.1/node_modules/typescript-eslint-plugin/lib/Interception/Interceptor.js:100:34)
at IOSession.Session.getCombinedCodeFix (tsserver.js:145760:56)
at Session.handlers.ts.createMapFromTemplate._a.<computed> (tsserver.js:144516:61)
at tsserver.js:146003:88
at IOSession.Session.executeWithRequestId (tsserver.js:145994:28)
at IOSession.Session.executeCommand (tsserver.js:146003:33)
at IOSession.Session.onMessage (tsserver.js:146027:35)
at Interface.<anonymous> (tsserver.js:147342:27)
at Interface.emit (events.js:203:13)
at Interface._onLine (readline.js:316:10)
at Interface._normalWrite (readline.js:461:12)
at Socket.ondata (readline.js:172:10)
at Socket.emit (events.js:203:13)
at addChunk (_stream_readable.js:295:12)
at readableAddChunk (_stream_readable.js:276:11)
at Socket.Readable.push (_stream_readable.js:210:10)
at Pipe.onStreamRead (internal/stream_base_commons.js:166:17)
Как получить больше информации? Как исправить синтаксис автоматически? Я добавляю свой .eslinter. json
{
"env": {
"browser": true,
"es6": true
},
"extends": [
"plugin:react/recommended",
"standard"
],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 2018,
"sourceType": "module"
},
"plugins": [
"react"
],
"rules": {
}
}