ESLint
ESLint existed to lint JavaScript, but now it is also becoming the defacto linter for TypeScript, thanks to the collaboration between the two teams.
Install
To setup ESLint for TypeScript you need the following packages:
TIP: eslint calls packages that contain lint rules as "plugin"
eslint : Core eslint
eslint-plugin-react : For react rules provided by eslint. Supported rules list
@typescript-eslint/parse : To allow eslint to understand ts / tsx files
@typescript-eslint/eslint-plugin : For TypeScript rules. Supported rules list
As you can see there are two eslint packages (for use with js or ts) and two @typescript-eslint packages (for use with ts). So the overhead for TypeScript is not that much.
Configure
Create .eslintrc.js
:
Run
In your package.json
add to scripts
:
Now you can npm run lint
to validate.
Configure VSCode
Add to
settings.json
:
Last updated