This is a sharable eslint config for TypeScript React projects. One config to rule all them projects.
To install the package run
foo@bar:~$ npm install @fastone/eslint-config
Create .eslintrc.cjs
in the root of your project with the following content:
/** @type {import('eslint').Linter.Config} */
export default {
extends: ['@fastone/eslint-config'],
parserOptions: {
tsconfigRootDir: __dirname
}
};
After you've added the following to your package.json
:
"scripts": {
"lint": "eslint --ext .ts,.tsx .",
"lint:fix": "eslint --ext .ts,.tsx . --fix"
}
You'll be able to run the linting commands with:
foo@bar:~$ npm run lint
foo@bar:~$ npm run lint:fix
You can also add the following to your .vscode/settings.json
to lint on save:
( You need to install the Prettier - Code formatter
[esbenp.prettier-vscode] extension)
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
To hide the following error from vscode:
Parsing error: ESLint was configured to run on `<tsconfigRootDir>/.eslintrc.cjs` using `parserOptions.project`
add the following to your .eslintrc.cjs
:
ignorePatterns: ['**/*.config.js', '**/*.config.cjs', '**/*.config.ts', '**/*.config.tsx', '.eslintrc.cjs'],
- Double check and update the rules while using it in a real project