@wang1212/eslint-config

0.4.0 • Public • Published

ESLint Config

LICENSE NPM VERSION DOWNLOAD LAST COMMIT GITHUB PACKAGE CI Commitizen friendly Codacy Badge

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
  1. Install peerDependencies:

    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:

    # 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:

    {
    + "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.

  1. 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.

  2. 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.

  1. 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.

  2. 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:

# Before
git commit

# Now
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).

# 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 tool provided by the community.

License

MIT.

Package Sidebar

Install

npm i @wang1212/eslint-config

Weekly Downloads

1

Version

0.4.0

License

MIT

Unpacked Size

22.4 kB

Total Files

9

Last publish

Collaborators

  • wang1212