1.0.4 • Published 5 months ago
@itaober/eslint-config v1.0.4
@itaober/eslint-config
English | 简体中文
Introduction
@itaober/eslint-config
provides a set of ESLint configuration presets based on personal preferences:
- Requires ESLint v9 or above
- Default support for ESLint Flat config
- Reasonable presets, one-line setup, out-of-the-box usage
- Support for TypeScript, React, and more
- Compatible with Prettier
Installation
pnpm add eslint @itaober/eslint-config -D
Usage
Configuration File
For more configuration options, refer to ESLint Flat config
Create eslint.config.js
in your project root directory and add the following code:
import getESLintConfig from '@itaober/eslint-config';
export default getESLintConfig();
Add Scripts to package.json
{
"scripts": {
"lint": "eslint .",
"lint:fix": "eslint . --fix"
}
}
IDE Support
VSCode
- Install the ESLint extension
- Add the following configuration to your
settings.json
:
{
"eslint.enable": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
"source.organizeImports": "never",
},
"eslint.runtime": "node",
"eslint.run": "onSave",
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"vue",
"html",
],
"eslint.workingDirectories": [
{
"mode": "auto",
},
],
}
Optional Configs
Lint staged
If you want ESLint to check and automatically fix your code before each commit, you can use simple-git-hooks
and lint-staged
:
- Install the required dependencies:
pnpm add simple-git-hooks lint-staged -D
- Add the following configuration to your
package.json
:
{
"scripts": {
"prepare": "simple-git-hooks"
},
"simple-git-hooks": {
"pre-commit": "pnpm lint-staged"
},
"lint-staged": {
"*": "pnpm lint:fix"
}
}
- Activate
simple-git-hooks
:
npx simple-git-hooks
License
1.0.2
5 months ago
1.0.1
7 months ago
1.0.0
8 months ago
1.0.4
5 months ago
0.1.0-alpha.3
1 year ago
0.1.0-alpha.2
1 year ago
0.1.0-alpha.1
1 year ago