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 eslintbash
$ yarn add -D eslintbash
$ pnpm add -D eslintbash
$ bun add -D eslint- Add lint script to
package.json.
json
{
"scripts": {
// ...
"lint": "eslint --fix --cache {src,.storybook}/**/*.js"
}
}- Create and populate
.eslintignoreand.eslintrc.jsonfiles.
txt
├─ src/
├─ ...
├─ .eslintignore // [!code ++]
└─ .eslintrc.json // [!code ++]dist
storybook
!.storybookjson
{
"$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 lintbash
$ yarn run lintbash
$ pnpm run lintbash
$ bun run lintTIP
For more details about ESLint refer to the ESLint docs.
TypeScript
- Install dependencies.
bash
$ npm add -D eslint @typescript-eslint/eslint-plugin @typescript-eslint/parserbash
$ yarn add -D eslint @typescript-eslint/eslint-plugin @typescript-eslint/parserbash
$ pnpm add -D eslint @typescript-eslint/eslint-plugin @typescript-eslint/parserbash
$ 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
.eslintignoreand.eslintrc.jsonfiles.
txt
├─ src/
├─ ...
├─ .eslintignore // [!code ++]
└─ .eslintrc.json // [!code ++]dist
storybook
!.storybookjson
{
"$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 lintbash
$ yarn run lintbash
$ pnpm run lintbash
$ bun run lintTIP
For more details about ESLint refer to the ESLint docs.