npm install --save-dev eslint @eslint/js @types/eslint__js typescript typescript-eslint
- We used the below configuration to configure eslint, and in our case, we are using the
eslint.config.mjs
file.
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
export default tseslint.config(
{
// config with just ignores is the replacement for `.eslintignore`
ignores: ['**/build/**', '**/dist/**', 'coverage', 'docker'],
},
// recommended eslint config
eslint.configs.recommended,
// strict: a superset of recommended that includes more opinionated rules which may also catch bugs.
...tseslint.configs.strict,
// stylistic: additional rules that enforce consistent styling without significantly catching bugs or changing logic.
...tseslint.configs.stylistic,
);
- Add below script in
package.json
"lint": "eslint .",
"lint-fix": "eslint --fix .",
npm run lint