This package contains shareable ESLint configuration used by the applications created with @shaizei/cli.
Using Yarn:
yarn add @shaizei/eslint-config --dev
Using npm:
npm install @shaizei/eslint-config --save-dev
- Create a new file and name it as
.eslintrc.js
- Import relevant config file from
@shaizei/eslint-config
and just export it as follows.
For JavaScript projects:
module.exports = {
extends: '@shaizei/eslint-config/javascriptReact',
};
For TypeScript projects:
module.exports = {
extends: '@shaizei/eslint-config/typescriptReact',
};
- In order to have a
.eslintignore
file as well, just run the following command from terminal:
cat ./node_modules/@shaizei/eslint-config/.eslintignore >> .eslintignore
If you want to override the default configuration, then add the following code in .eslintrc.js
file:
For JavaScript projects:
module.exports = {
extends: '@shaizei/eslint-config/javascriptReact',
// your config options goes here, e.g. plugins: [...]
};
For TypeScript projects:
module.exports = {
extends: '@shaizei/eslint-config/typescriptReact',
// your config options goes here, e.g. plugins: [...]
};
As we're not installing ESLint locally per project, but leveraging ESLint and associated packages installed in @shaizei/eslint-config
project. Thus, we need to inform VSCode ESLint extension that how to resolve ESLint.
-
Go to
settings.json
in VSCode. -
Add following settings:
"eslint.nodePath": "./node_modules/@shaizei/eslint-config/node_modules"
Above mentioned settings will let the extension read ESLint from @shaizei/eslint-config
.
Also, for TypeScript, we need to tell ESLint extension to lint .ts
and .tsx
files as well. We recommend to add following setting as well in settings.json
:
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact"
],