@itaober/eslint-config
v1.0.5
Published
Taober's Eslint preset
Readme
@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 -DUsage
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