Skip to content

Instantly share code, notes, and snippets.

@robertoandres24
Last active November 14, 2020 04:17
Show Gist options
  • Save robertoandres24/fd29689486bc07023abafa175035095c to your computer and use it in GitHub Desktop.
Save robertoandres24/fd29689486bc07023abafa175035095c to your computer and use it in GitHub Desktop.
Nodejs typescript Eslint + Prettier
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'
}
};
{
"semi": true,
"tabWidth": 2,
"printWidth": 80,
"singleQuote": true,
"trailingComma": "none"
}
# 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"
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment