1.2.1 • Published 1 month ago

@vill-v/eslint-config v1.2.1

Weekly downloads
-
License
MIT
Repository
-
Last release
1 month ago

Villv Eslint Config

NPM Version NPM Downloads NPM License

  • prettier 为基础的 eslint 配置
  • 可以在 vue typescript markdown 工作
  • 会自动 对 import 进行排序
  • 自动切换对 vue@2 vue@3 的支持

从 1.0 版本开始 将使用 ESLint Flat config 进行重构

安装

pnpm add eslint prettier -D

pnpm add @vill-v/eslint-config -D

使用

eslint.config.js

ESM

import villv from '@vill-v/eslint-config'

export default villv()

CJS

const villv = require('@vill-v/eslint-config')

module.exports = villv()

Pipeline

1.1.0 版本起,使用 eslint-flat-config-utils#composer 替换了 villv() 工厂函数返回的结果,是您可以像 @antfu/eslint-config 使用 pipeline 语法更灵活的组合 eslint 配置

// eslint.config.js
import villv from '@vill-v/eslint-config'

export default villv()
  .prepend(
    // 在预制的配置前插入某些配置
  )
  // 通过插件名覆盖部分插件配置
  .override(
    'antfu/imports',
    {
      rules: {
        'import/order': ['error', { 'newlines-between': 'always' }],
      }
    }
  )
  // 重命名插件在规则定义时的前缀
  .renamePlugins({
    'old-prefix': 'new-prefix',
    // ...
  })
  /// ...

工作环境

  • node >=16.0.0
  • eslint >=8.56.0
  • prettier >=3.0.0
  • typescript >=5.0
  • vue >=2.0||>=3.0

配置项

使用 ESLint Flat config 之后,可以更加灵活的配置eslint 选项

你可以像这样覆盖各个插件的规则与配置

import villv from '@vill-v/eslint-config'

export default villv({
  vue: {
    overides: {
      'vue/no-v-html': 'error',
    },
  },
  // 可以定制根据特定 ignore 文件快捷让 eslint 忽略一些文件
  gitignore: {
    files: ['.gitignore', '.eslintignore', '.dockerignore'],
  },
})

详细的配置项请查看Options

您也可以在 villv 的基础上加上更多额外的自定义ESLint Flat config规则与插件

import villv from '@vill-v/eslint-config'
import react from 'eslint-plugin-react'

export default villv(
  {
    //。。。villv 内置插件的配置
  },
  {
    rules: {
      'no-undef': 'off',
    },
  },
  {
    plugin: {
      react,
    },
  }
)

其他代码规范

eslint config - eslint flat 风格的配置集合

prettier config - prettier 的默认配置

tsconfig - typescript tsconfig.json 基础配置

License

MIT License

1.2.0

1 month ago

1.2.1

1 month ago

1.1.1

1 month ago

1.1.0

1 month ago

1.0.0

1 month ago

1.0.0-beta.9

1 month ago

1.0.0-beta.8

3 months ago

1.0.0-beta.7

3 months ago

1.0.0-beta.6

4 months ago

1.0.0-beta.5

4 months ago

1.0.0-beta.2

4 months ago

1.0.0-beta.3

4 months ago

1.0.0-beta.4

4 months ago

1.0.0-beta.0

4 months ago

1.0.0-beta.1

4 months ago

0.0.18

10 months ago

0.1.0

10 months ago

0.2.1

10 months ago

0.1.2

10 months ago

0.2.0

10 months ago

0.1.1

10 months ago

0.1.4

10 months ago

0.2.2

9 months ago

0.1.3

10 months ago

0.1.5

10 months ago

0.0.17

11 months ago

0.0.15

12 months ago

0.0.16

11 months ago

0.0.12

1 year ago

0.0.13

1 year ago

0.0.14

1 year ago

0.0.11

1 year ago

0.0.10

1 year ago

0.0.9

1 year ago

0.0.8

2 years ago

0.0.5

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago