1.0.6 • Published 2 months ago

@gx-web/eslint-config v1.0.6

Weekly downloads
-
License
-
Repository
-
Last release
2 months ago

ESLint Config of Project

安装

# pnpm
pnpm add @gx-web/eslint-config -D
# npm
npm i @gx-web/eslint-config -D
# yarn
yarn add @gx-web/eslint-config -D

使用

// .eslintrc.js
import BaseEslintConfig from '@gx-web/eslint-config'

export default BaseEslintConfig()

忽略文件

# .eslintignore
dist
node_modules

*.js
!.eslintrc.js
!.stylelintrc.js

格式化配置

// .vscode/settings.json
{
  // Enable the ESlint flat config support
  "eslint.experimental.useFlatConfig": true,
  // Disable the default formatter, use eslint instead
  "prettier.enable": false,
  "editor.formatOnSave": false,
  // Auto fix
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": "explicit",
    "source.organizeImports": "never"
  },
  // Silent the stylistic rules in you IDE, but still auto fix them
  "eslint.rules.customizations": [
    {
      "rule": "style/*",
      "severity": "off"
    },
    {
      "rule": "format/*",
      "severity": "off"
    },
    {
      "rule": "*-indent",
      "severity": "off"
    },
    {
      "rule": "*-spacing",
      "severity": "off"
    },
    {
      "rule": "*-spaces",
      "severity": "off"
    },
    {
      "rule": "*-order",
      "severity": "off"
    },
    {
      "rule": "*-dangle",
      "severity": "off"
    },
    {
      "rule": "*-newline",
      "severity": "off"
    },
    {
      "rule": "*quotes",
      "severity": "off"
    },
    {
      "rule": "*semi",
      "severity": "off"
    }
  ],
  // Enable eslint for all supported languages
  "eslint.validate": [
    "javascript",
    "javascriptreact",
    "typescript",
    "typescriptreact",
    "vue",
    "html",
    "markdown",
    "json",
    "jsonc"
  ],
}

格式化命令

// package.json
{
  "scripts": {
    "lint:eslint": "eslint --fix ./src"
  }
}

命令参数说明

  • --fix
    • 此项指示 ESLint 尝试修复尽可能多的问题。这些修复是对实际文件本身进行的,只有剩余的未修复的问题才会被输出
  • --ext .js,.ts,tsx,.vue
    • 此选项用于指定 ESLint 在目录中匹配目标文件所用扩展
  • ./src
    • 格式化目录, 支持目录, 文件名

其余命令可参考官方

1.0.6

2 months ago

1.0.5

2 months ago

1.0.4

2 months ago

1.0.3

2 months ago

1.0.2

5 months ago

1.0.1

7 months ago