Skip to content

Instantly share code, notes, and snippets.

@aspen-roller
Last active September 9, 2021 16:55
Show Gist options
  • Save aspen-roller/51e56fe831057f93fcecbfae7ab5c15d to your computer and use it in GitHub Desktop.
Save aspen-roller/51e56fe831057f93fcecbfae7ab5c15d to your computer and use it in GitHub Desktop.
setup eslint for typescript in vscode #vscode #typescript #eslint
coverage
dist
node_modules
root: true
parser: '@typescript-eslint/parser'
parserOptions:
project: tsconfig.json
plugins:
- '@typescript-eslint'
extends:
- airbnb-typescript/base
- plugin:@typescript-eslint/recommended
- plugin:@typescript-eslint/recommended-requiring-type-checking
rules:
import/prefer-default-export: 0
max-len: 0
no-new: 0
# .vscode/settings.json
{
"editor.formatOnSave": true,
"eslint.format.enable": true,
"eslint.validate": [
"typescript"
],
"eslint.workingDirectories": [
"./project_name",
{
"pattern": "./project/*/"
}
]
}

These notes are written using VSCode as the IDE.

VSCode Exensions

  • dbaeumer.vscode-eslint

Typescript Project Setup

# install required packages
# https://github.com/typescript-eslint/typescript-eslint
npm i -D eslint @typescript-eslint/{parser,eslint-plugin}

# for airbnb style (backend only, no react)
# https://www.npmjs.com/package/eslint-config-airbnb-typescript
npm i -D eslint-config-airbnb-typescript eslint-plugin-import

# maintain sync on aws dependencies
npm i -D npm-check-updates
# add this script to package.json to upgrade all packages
# "ncu": "ncu -u && npm update && npm install",

Restart ESLint Server

Restart the ESLint Server to allow for the project changes to take effect.

CMD + SHIFT + P => ESLint: Restart ESLint Server

NOTE: you might still have to restart VSCode. I noticed that a problem was being noted in tsconfig.json until I restarted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment