ESLint Config
English | 简体中文
🔧 This package provides community-recommended ESLint rules configuration as an extensible shared configuration. (Use with Prettier)
Support ESLint V8, Node.js requires version >=16.
Usage
npm install --save-dev @wang1212/eslint-config
-
Install peerDependencies
:
npm install --save-dev eslint
npm install --save-dev --save-exact prettier
-
Create a .prettierrc.yml file in the project root directory and configure the following:
printWidth: 80
tabWidth: 2
useTabs: false
singleQuote: true
semi: true
endOfLine: 'auto'
This is just a recommended configuration and can be adjusted to your liking.
-
Then you need to add @wang1212/eslint-config
in your .eslintrc.json:
{
+ "extends": ["@wang1212/eslint-config"]
}
The rule configuration of ESLint can be configured and covered according to your own requirements, please refer to the official documentation.
Configuration Details
@wang1212/eslint-config
This configuration is for basic JavaScript, based on the Airbnb JavaScript Style Guide, SonarJS, JSDoc, and check API compatibility with Browserslist. (See Source)
@wang1212/eslint-config/typescript
This configuration is for basic TypeScript, based on the Airbnb JavaScript Style Guide, SonarJS, TSDoc, and check API compatibility with Browserslist. (See Source)
This config also has an alias @wang1212/eslint-config/ts
.
Using this configuration also requires some extra work.
-
Install additional peerDependencies
:
npm install --save-dev @typescript-eslint/parser @typescript-eslint/eslint-plugin
Note: according to the official maintenance policy, the above dependencies should always be installed with the same version number.
-
Then you need to add @wang1212/eslint-config/typescript
in your .eslintrc.json:
{
- "extends": ["@wang1212/eslint-config"],
+ "extends": ["@wang1212/eslint-config/typescript"],
+ "parser": "@typescript-eslint/parser",
+ "parserOptions": {
+ "project": './tsconfig.json'
+ },
}
@wang1212/eslint-config/react
This configuration is for react.js applications written in JavaScript, based on the Airbnb JavaScript Style Guide, Hooks, SonarJS, JSDoc, and check API compatibility with Browserslist. (See Source)
Using this configuration also requires some extra work.
-
You need to add @wang1212/eslint-config/react
in your .eslintrc.json:
{
- "extends": ["@wang1212/eslint-config"],
+ "extends": ["@wang1212/eslint-config/react"],
}
@wang1212/eslint-config/react-typescript
This configuration is for react.js applications written in TypeScript, based on the Airbnb JavaScript Style Guide, Hooks, SonarJS, TSDoc, and check API compatibility with Browserslist. (See Source)
This config also has an alias @wang1212/eslint-config/react-ts
.
Using this configuration also requires some extra work.
-
Install additional peerDependencies
:
npm install --save-dev @typescript-eslint/parser @typescript-eslint/eslint-plugin
Note: according to the official maintenance policy, the above dependencies should always be installed with the same version number.
-
Then you need to add @wang1212/eslint-config/react-typescript
in your .eslintrc.json:
{
- "extends": ["@wang1212/eslint-config"],
+ "extends": ["@wang1212/eslint-config/react-typescript"],
+ "parser": "@typescript-eslint/parser",
+ "parserOptions": {
+ "project": './tsconfig.json'
+ },
}
@wang1212/eslint-config/node
This configuration is for Node.js programs written in JavaScript, based on the Airbnb JavaScript Style Guide, SonarJS, JSDoc. (See Source)
Using this configuration also requires some extra work.
-
You need to add @wang1212/eslint-config/node
in your .eslintrc.json:
{
- "extends": ["@wang1212/eslint-config"],
+ "extends": ["@wang1212/eslint-config/node"],
}
Development Guidelines
Git Commit Message Format
Adopt community commit format best practices:
git commit
npm run commit
This constraint relies on tools commitizen and commitlint provided by the community.
npm publish
The version management of this module adopts the specifications recommended by the community Semantic Versioning. Follow version changes and maintain a CHANGELOG.md(Learn why).
npm run release
npm run release -- --dry-run
npm publish
These jobs are done with the help of release-it tool provided by the community.
License
MIT.