Answer the question
In order to leave comments, you need to log in
What is the correct way to set up ESLint for typescript?
I'm transferring back to ts.
I have a route handler for Koa
import { Context } from 'koa';
export class IndexController {
static manifest({ response: res }: Context) {
res.body = manifest;
}
}
{
"parser": "typescript-eslint-parser",
"extends": [
"airbnb-base"
],
"env": {
"node": true,
"es6": true
},
"plugins": [
"import",
"mongodb",
"typescript"
],
"rules": {
"func-names" : "error",
"no-await-in-loop": "off",
"strict": "off",
"import/prefer-default-export": "off",
"import/extensions": "off"
},
"settings": {
"import/resolver": {
"node": true,
"eslint-import-resolver-typescript": true
}
}
}
import { Context } from 'koa';
Says unused ver. Answer the question
In order to leave comments, you need to log in
eslint is now focused on working with typescript as well
. Personally, I came up with this eslint setup for typescript:
.eslintrc.json
{
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "prettier"],
"extends": [
"plugin:@typescript-eslint/recommended",
"prettier/@typescript-eslint",
"plugin:prettier/recommended"
],
"parserOptions": {
"sourceType": "module",
"useJSXTextNode": true,
"project": "./tsconfig.json"
}
}
{
"singleQuote": true,
"arrowParens": "always",
"tabWidth": 2,
"useTabs": false
}
{
"plugins": ["babel-plugin-rewire"],
"presets": [
"@babel/preset-typescript",
[
"@babel/preset-env",
{
"targets": {
"node": "current"
}
}
]
]
}
{
"compilerOptions": {
"diagnostics": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"lib": ["es7"],
"module": "commonjs",
"target": "esnext",
"moduleResolution": "node",
"noImplicitAny": false,
"noUnusedLocals": true,
"noUnusedParameters": true,
"outDir": "dist/",
"pretty": true,
"removeComments": true,
"strict": true,
"declaration": true
},
"exclude": [
"src/**/*.spec.*",
"node_modules",
"**/__tests__/*",
"**/__mocks__/*"
],
"include": ["src", "typings"]
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question