eslint-config-phoenix v1.2.6
eslint-config-phoenix
ESLint config for React TypeScript projects.
This config extends eslint-config-airbnb-typescript and eslint-config-prettier. It provides some useful plugins which will improve your code quality.
Installation
npm install -D eslint-config-phoenix
# or with yarn
yarn add -D eslint-config-phoenix
š” Make sure ESLint is also installed.
Setup
1) Configure ESLint
Extend your .eslintrc
, with phoenix
.
{
"extends": ["phoenix"]
}
Or if you have another config, you can set it like this,
{
"extends": ["phoenix", "next/core-web-vitals"]
}
The order of the array items depends on your needs.
Read more about ESLint configuration file.
2) Configure the ESLint TypeScript parser
- Set parser to
@typescript-eslint/parser
. - Set parserOptions.project to the path of your
tsconfig.json
ortsconfig.eslint.json
(see FAQ below).
For example:
{
extends: ['phoenix'],
+ parser: '@typescript-eslint/parser',
+ parserOptions: {
+ project: './tsconfig.json'
+ }
}
This means you are attempting to lint a file that tsconfig.json
doesn't include.
A common fix is to create a tsconfig.eslint.json
file, which extends your tsconfig.json
file and includes all files you are linting.
{
"extends": "./tsconfig.json",
"include": ["src/**/*.ts", "src/**/*.js", "test/**/*.ts"]
}
Update your ESLint config file:
parserOptions: {
- project: './tsconfig.json',
+ project: './tsconfig.eslint.json',
}
Note
eslint-config-phoenix will include these packages:
- TypeScript ESLint
- ESLint Plugins
- ESLint Configs
š Therefore, you don't have to install them.