1.0.1 • Published 7 months ago

@mao-fu/eslint-config v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
7 months ago

介绍

常用的eslint共享配置,包含vue2、vue3、vue3-ts、react、typescript、javascript、node

你可以查看源代码来了解具体的配置,它都是使用了一些推荐的配置。

安装依赖

安装本包:

pnpm i -D @mao-fu/eslint-config

如果你在接下来的配置中使用了

  1. @mao-fu/eslint-config

    • 你需要安装pnpm i -D eslint-plugin-jsdoc
  2. @mao-fu/eslint-config/typescript

    • 你需要安装 pnpm i -D @typescript-eslint/eslint-plugin
  3. @mao-fu/eslint-config/vue2,@mao-fu/eslint-config/vue3,@mao-fu/eslint-config/vue3-ts

    • 你需要安装 pnpm i -D eslint-plugin-vue
  4. @mao-fu/eslint-config/react

    • 你需要安装pnpm i -D eslint-plugin-react
  5. @mao-fu/eslint-config/node

    • 你需要安装pnpm i -D eslint-plugin-node
  6. @mao-fu/eslint-config/import

    • 你需要安装pnpm i - D eslint-plugin-import

使用

在项目根目录下创建 eslint 配置文件.eslintrc.cjs,根据你的需要选择配置:

module.exports = {
  /** 通常是一个很好的 ESLint 实践,用于指示此文件是项目使用的根级文件,ESLint 不应该在这个目录之外搜索配置文件。 */
  root: true,
  extends: [
    '@mao-fu/eslint-config',
    '@mao-fu/eslint-config/import',
    '@mao-fu/eslint-config/typescript',
    '@mao-fu/eslint-config/vue3-ts',
    // '@mao-fu/eslint-config/vue3',
    // '@mao-fu/eslint-config/vue2',
    // '@mao-fu/eslint-config/react',
    // '@mao-fu/eslint-config/node',
  ],
};

注意,同时使用 ts 和 vue 的 eslint 检查配置时,必须把 vue 的配置放在后边

module.exports = {
    /** 通常是一个很好的 ESLint 实践,用于指示此文件是项目使用的根级文件,ESLint 不应该在这个目录之外搜索配置文件。 */
    root: true,
    extends: [
        '@mao-fu/eslint-config',
        '@mao-fu/eslint-config/import',
        '@mao-fu/eslint-config/typescript',
        '@mao-fu/eslint-config/vue3-ts', // 放在后边
    ],
};