https://github.com/wang1212/eslint-config
đ§ (Config) My ESLint config. | æį ESLint é
įŊŽã
https://github.com/wang1212/eslint-config
eslint-config nodejs prettier react typescript
Last synced: about 1 year ago
JSON representation
đ§ (Config) My ESLint config. | æį ESLint é įŊŽã
- Host: GitHub
- URL: https://github.com/wang1212/eslint-config
- Owner: wang1212
- License: mit
- Created: 2022-04-16T06:04:14.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2025-04-07T21:53:08.000Z (about 1 year ago)
- Last Synced: 2025-04-07T22:33:39.720Z (about 1 year ago)
- Topics: eslint-config, nodejs, prettier, react, typescript
- Language: JavaScript
- Homepage:
- Size: 541 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 20
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# ESLint Config

[](https://www.npmjs.com/package/@wang1212/eslint-config)



[](http://commitizen.github.io/cz-cli/)
[](https://www.codacy.com/gh/wang1212/eslint-config/dashboard?utm_source=github.com&utm_medium=referral&utm_content=wang1212/eslint-config&utm_campaign=Badge_Grade)
English | [įŽäŊ䏿](./README.zh-CN.md)
đ§ This package provides community-recommended [ESLint](https://eslint.org/) rules configuration as an extensible shared configuration. (Use with [Prettier](https://prettier.io/))
_Support [ESLint V8](https://eslint.org/blog/2021/10/eslint-v8.0.0-released), Node.js requires version >=18._
## Usage
```bash
npm install --save-dev @wang1212/eslint-config
```
1. Install `peerDependencies`:
```bash
npm install --save-dev eslint
npm install --save-dev --save-exact prettier
```
2. Create a **.prettierrc.yml** file in the project root directory and configure the following:
```yaml
# see docs: https://prettier.io/docs/en/configuration.html
# prettier config
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._
3. Then you need to add `@wang1212/eslint-config` in your **.eslintrc.json**:
```diff
{
+ "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](https://eslint.org/docs/user-guide/configuring/rules)._
## Configuration Details
### `@wang1212/eslint-config`
This configuration is for basic JavaScript, based on the [Airbnb JavaScript Style Guide](https://github.com/airbnb/javascript), [SonarJS](https://github.com/SonarSource/eslint-plugin-sonarjs), [JSDoc](https://jsdoc.app/), and [check API compatibility](https://github.com/amilajack/eslint-plugin-compat) with [Browserslist](https://github.com/browserslist/browserslist). (See [Source](./src/javascript.cjs))
### `@wang1212/eslint-config/typescript`
This configuration is for basic [TypeScript](https://www.typescriptlang.org/), based on the [Airbnb JavaScript Style Guide](https://github.com/airbnb/javascript), [SonarJS](https://github.com/SonarSource/eslint-plugin-sonarjs), [TSDoc](https://tsdoc.org/), and [check API compatibility](https://github.com/amilajack/eslint-plugin-compat) with [Browserslist](https://github.com/browserslist/browserslist). (See [Source](./src/typescript.cjs))
_This config also has an alias `@wang1212/eslint-config/ts`._
Using this configuration also requires some extra work.
1. Install additional `peerDependencies`:
```bash
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._
2. Then you need to add `@wang1212/eslint-config/typescript` in your **.eslintrc.json**:
```diff
{
- "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](https://reactjs.org/) applications written in JavaScript, based on the [Airbnb JavaScript Style Guide](https://github.com/airbnb/javascript), [Hooks](https://reactjs.org/docs/hooks-intro.html), [SonarJS](https://github.com/SonarSource/eslint-plugin-sonarjs), [JSDoc](https://jsdoc.app/), and [check API compatibility](https://github.com/amilajack/eslint-plugin-compat) with [Browserslist](https://github.com/browserslist/browserslist). (See [Source](./src/react.cjs))
Using this configuration also requires some extra work.
- You need to add `@wang1212/eslint-config/react` in your **.eslintrc.json**:
```diff
{
- "extends": ["@wang1212/eslint-config"],
+ "extends": ["@wang1212/eslint-config/react"],
}
```
### `@wang1212/eslint-config/react-typescript`
This configuration is for [react.js](https://reactjs.org/) applications written in [TypeScript](https://www.typescriptlang.org/), based on the [Airbnb JavaScript Style Guide](https://github.com/airbnb/javascript), [Hooks](https://reactjs.org/docs/hooks-intro.html), [SonarJS](https://github.com/SonarSource/eslint-plugin-sonarjs), [TSDoc](https://tsdoc.org/), and [check API compatibility](https://github.com/amilajack/eslint-plugin-compat) with [Browserslist](https://github.com/browserslist/browserslist). (See [Source](./src/react-ts.cjs))
_This config also has an alias `@wang1212/eslint-config/react-ts`._
Using this configuration also requires some extra work.
1. Install additional `peerDependencies`:
```bash
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._
2. Then you need to add `@wang1212/eslint-config/react-typescript` in your **.eslintrc.json**:
```diff
{
- "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](https://nodejs.dev/) programs written in JavaScript, based on the [Airbnb JavaScript Style Guide](https://github.com/airbnb/javascript), [SonarJS](https://github.com/SonarSource/eslint-plugin-sonarjs), [JSDoc](https://jsdoc.app/). (See [Source](./src/node.cjs))
Using this configuration also requires some extra work.
- You need to add `@wang1212/eslint-config/node` in your **.eslintrc.json**:
```diff
{
- "extends": ["@wang1212/eslint-config"],
+ "extends": ["@wang1212/eslint-config/node"],
}
```
## Development Guidelines
### Git Commit Message Format
Adopt [community commit format best practices](https://www.conventionalcommits.org/):
```bash
# Before
git commit
# Now
npm run commit
```
_This constraint relies on tools [commitizen](http://commitizen.github.io/cz-cli/) and [commitlint](https://commitlint.js.org/) provided by the community._
### npm publish
The version management of this module adopts the specifications recommended by the community [Semantic Versioning](https://semver.org/). Follow version changes and maintain a **CHANGELOG.md**([Learn why](https://keepachangelog.com/)).
```bash
# Update version and generate changelog before publishing to npm repository
npm run release
# Or, preview
npm run release -- --dry-run
# Then publish to npm, if yes is not selected when auto-publishing to npm
npm publish # npm publish --access public
```
_These jobs are done with the help of [release-it](https://github.com/release-it/release-it) tool provided by the community._
## License
[MIT](./LICENSE).