# install eslint dependencies
npm i -D eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin
# prettier dependencies
yarn add -D prettier eslint-config-prettier eslint-plugin-prettier
# Optional - add script for linting all files
{
"scripts": {
...
"lint": "tsc --noEmit && eslint '*/**/*.{js,ts}' --quiet --fix"
...
}
}
# vscode workspace config
{
"eslint.format.enable": true,
"editor.formatOnSave": true,
"[typescriptreact]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[typescript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
}
}
Last active
November 14, 2020 04:17
-
-
Save robertoandres24/fd29689486bc07023abafa175035095c to your computer and use it in GitHub Desktop.
Nodejs typescript Eslint + Prettier
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
parser: '@typescript-eslint/parser', // Specifies the ESLint parser | |
extends: [ | |
'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin | |
'prettier/@typescript-eslint', // agrega las reglas de prettier a eslint | |
'plugin:prettier/recommended' // agregar el plugin que integra eslint con prettier | |
], | |
parserOptions: { | |
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features | |
sourceType: 'module' // Allows for the use of imports | |
}, | |
rules: { | |
'no-shadow': 'warn', | |
'@typescript-eslint/explicit-member-accessibility': 'off', | |
'@typescript-eslint/explicit-function-return-type': 'off', | |
'@typescript-eslint/indent': 'off', | |
'@typescript-eslint/no-explicit-any': 'off', | |
'@typescript-eslint/no-non-null-assertion': 'off', | |
'@typescript-eslint/camelcase': 'off', | |
'@typescript-eslint/array-type': 'off', | |
'@typescript-eslint/no-object-literal-type-assertion': 'off' | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"semi": true, | |
"tabWidth": 2, | |
"printWidth": 80, | |
"singleQuote": true, | |
"trailingComma": "none" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment