项目作者: websublime

项目描述 :
Eslint config rules
高级语言: JavaScript
项目地址: git://github.com/websublime/eslint-config.git
创建时间: 2020-04-16T11:25:39Z
项目社区:https://github.com/websublime/eslint-config

开源协议:

下载


eslint-config

These are my personal configurations for ESLint. They are based on Airbnb’s ESLint configurations.

Overview

This repository contains ESLint configurations for the following setups:

  • JavaScript
  • JavaScript with React
  • TypeScript
  • TypeScript with React
  • Angular
  • Vue

They are designed to be used together with Prettier.

Usage

  1. Install the required packages:

    • JavaScript:

      1. yarn add --dev @websublime/eslint-config \
      2. eslint-config-prettier \
      3. eslint-plugin-simple-import-sort \
      4. && npx install-peerdeps --dev eslint-config-airbnb-base
    • JavaScript with React:

      1. yarn add --dev @websublime/eslint-config \
      2. eslint-config-prettier \
      3. eslint-plugin-simple-import-sort \
      4. && npx install-peerdeps --dev eslint-config-airbnb
    • TypeScript:

      1. yarn add --dev @websublime/eslint-config \
      2. eslint-config-prettier \
      3. @typescript-eslint/eslint-plugin \
      4. @typescript-eslint/parser \
      5. eslint-plugin-simple-import-sort \
      6. && npx install-peerdeps --dev eslint-config-airbnb-base
    • TypeScript with React:

      1. yarn add --dev @websublime/eslint-config \
      2. eslint-config-prettier \
      3. @typescript-eslint/eslint-plugin \
      4. @typescript-eslint/parser \
      5. eslint-plugin-simple-import-sort \
      6. && npx install-peerdeps --dev eslint-config-airbnb
    • Angular:

      1. yarn add --dev @websublime/eslint-config \
      2. eslint-config-prettier \
      3. @typescript-eslint/eslint-plugin \
      4. @typescript-eslint/parser \
      5. eslint-plugin-simple-import-sort \
      6. && npx install-peerdeps --dev eslint-config-airbnb
    • Vuejs:

      1. yarn add --dev @websublime/eslint-config \
      2. eslint-config-prettier \
      3. eslint-plugin-vue \
      4. @typescript-eslint/eslint-plugin \
      5. @typescript-eslint/parser \
      6. vue-eslint-parser \
      7. eslint-plugin-simple-import-sort \
      8. && npx install-peerdeps --dev eslint-config-airbnb
  2. Create the following entry in your package.json file:

    • JavaScript:

      1. {
      2. "eslintConfig": {
      3. "root": true,
      4. "extends": ["@websublime/eslint-config"]
      5. }
      6. }
    • JavaScript with React:

      1. {
      2. "eslintConfig": {
      3. "root": true,
      4. "extends": ["@websublime/eslint-config/react"]
      5. }
      6. }
    • TypeScript:

      1. {
      2. "eslintConfig": {
      3. "root": true,
      4. "extends": ["@websublime/eslint-config/typescript"]
      5. }
      6. }
    • TypeScript with React:

      1. {
      2. "eslintConfig": {
      3. "root": true,
      4. "extends": ["@websublime/eslint-config/typescript-react"]
      5. }
      6. }
    • Angular:

      1. {
      2. "eslintConfig": {
      3. "root": true,
      4. "extends": ["@websublime/eslint-config/angular"]
      5. }
      6. }
    • Vuejs:

      1. {
      2. "eslintConfig": {
      3. "root": true,
      4. "extends": ["@websublime/eslint-config/vue"]
      5. }
      6. }
  3. Add a linting script to your package.json file:

    • JavaScript:

      1. {
      2. "scripts": {
      3. "lint": "eslint --fix --max-warnings 0 ."
      4. }
      5. }
    • JavaScript with React:

      1. {
      2. "scripts": {
      3. "lint": "eslint --ext .js,.jsx --fix --max-warnings 0 ."
      4. }
      5. }
    • TypeScript:

      1. {
      2. "scripts": {
      3. "lint": "eslint --ext .ts --fix --max-warnings 0 ."
      4. }
      5. }
    • TypeScript with React:

      1. {
      2. "scripts": {
      3. "lint": "eslint --ext .ts,.tsx --fix --max-warnings 0 ."
      4. }
      5. }