ESlint
ESlint let's you find and fix problems in your JavaScript code.
If you used the CLI method to install Minze you can extend your environment with linting quite quickly.
The following guide is based on a fresh Minze CLI installation.
JavaScript
- Install dependencies.
bash
$ npm add -D eslint
bash
$ yarn add -D eslint
bash
$ pnpm add -D eslint
bash
$ bun add -D eslint
- Add lint script to
package.json
.
json
{
"scripts": {
// ...
"lint": "eslint --fix --cache {src,.storybook}/**/*.js"
}
}
- Create and populate
.eslintignore
and.eslintrc.json
files.
txt
├─ src/
├─ ...
├─ .eslintignore
└─ .eslintrc.json
dist
storybook
!.storybook
json
{
"$schema": "https://json.schemastore.org/eslintrc",
"extends": ["eslint:recommended"],
"env": {
"node": true,
"browser": true
},
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 2022
}
}
- Lint your code.
bash
$ npm run lint
bash
$ yarn run lint
bash
$ pnpm run lint
bash
$ bun run lint
TIP
For more details about ESLint refer to the ESLint docs.
TypeScript
- Install dependencies.
bash
$ npm add -D eslint @typescript-eslint/eslint-plugin @typescript-eslint/parser
bash
$ yarn add -D eslint @typescript-eslint/eslint-plugin @typescript-eslint/parser
bash
$ pnpm add -D eslint @typescript-eslint/eslint-plugin @typescript-eslint/parser
bash
$ bun add -D eslint @typescript-eslint/eslint-plugin @typescript-eslint/parser
- Add lint script to
package.json
.
json
{
"scripts": {
// ...
"lint": "eslint --fix --cache {src,.storybook}/**/*.{ts,js}"
}
}
- Create and populate
.eslintignore
and.eslintrc.json
files.
txt
├─ src/
├─ ...
├─ .eslintignore
└─ .eslintrc.json
dist
storybook
!.storybook
json
{
"$schema": "https://json.schemastore.org/eslintrc",
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"rules": {
"@typescript-eslint/no-unsafe-declaration-merging": "off"
}
}
- Lint your code.
bash
$ npm run lint
bash
$ yarn run lint
bash
$ pnpm run lint
bash
$ bun run lint
TIP
For more details about ESLint refer to the ESLint docs.