@claylevering/eslint-config

中文文档
2.0.23发布于 2026/03/05MITES Module近 30 天下载 3452

一套支持平面配置格式的ESLint配置,有Vue(以及TypeScript)、Node和TypeScript规则

中文使用文档
文档目录23 节
  1. 技选
  2. 特征
  3. 安装
  4. 基地安装
  5. 特定框架的依赖性
  6. 使用量
  7. 节点.js/JavaScript项目
  8. 类型脚本项目
  9. Vue 3 项目
  10. 框架配置
  11. 努克特项目
  12. 使用自定义规则
  13. 高级注释
  14. 自定义
  15. pinia-store-top-level
  16. no-switch-statements
  17. no-vue-global-imports
  18. pinia-store-pattern
  19. 内建规则配置
  20. padding-line-between-statements (警报,自动固定)
  21. 所需资源
  22. 许可证
  23. 仓库

@claylevering/claxon-lint (英语)

Publish Package to npm

一个全面的ESLint插件,以ESLint平面配置格式(ESLint 9+)提供可共享配置,支持Vue,Node.js和TypeScript等项目. 包括Vue/Pinia开发模式的自定义规则.

技选

特征

  • ESLint 9+平面配置格式 - 现代数组配置
  • 多个预设 - 为您的堆栈选择配置 :
    • 节点.js/贾瓦脚本
    • 类型脚本
    • 第3组
    • Vue 3 + 类型脚本
    • 数值 4
    • Nuxt 4 + 类型脚本
  • 自定义规则 - 关于Vue和Pinia发展的专门规则
  • 默认 - 试验生产应用规则

安装

基地安装

所有项目都需要基包和ESLint:

pnpm add -D @claylevering/eslint-config eslint

特定框架的依赖性

根据您使用的配置, 安装相应的对等依赖 :

只针对节点.js/Java脚本

不需要额外的依赖! 基地安装已经足够.

用于类型脚本项目

pnpm add -D typescript-eslint

Vue 3 项目

pnpm add -D eslint-plugin-vue vue-eslint-parser typescript-eslint

说明: typescript-eslint 即使是纯JavaScript Vue项目也需要支持混合解析器,允许混合JS和TS组件.

用于 Nuxt 项目

pnpm add -D @nuxt/eslint eslint-plugin-vue vue-eslint-parser typescript-eslint

使用量

所有实例都使用 defineConfig() 来自 ESLint 软件包 创建平面配置阵列.

节点.js/JavaScript项目

创建 eslint.config.js 在您的工程根中 :

import { defineConfig } from 'eslint/config';
import claxxonLint from '@claylevering/eslint-config';

export default defineConfig([
    ...claxxonLint.configs['node'],

    {
        // Your custom configurations here
    }
]);

类型脚本项目

import { defineConfig } from 'eslint/config';
import claxxonLint from '@claylevering/eslint-config';

export default defineConfig([
    ...claxxonLint.configs['typescript'], // Includes Node config + TypeScript rules

    {
        // Your custom configurations here
    }
]);

Vue 3 项目

这个 vue 配置支持混合 JavaScript 和 TypeScript Vue 组件在同一项目中:

import { defineConfig } from 'eslint/config';
import claxxonLint from '@claylevering/eslint-config';

export default defineConfig([
    ...claxxonLint.configs['vue'], // Supports both JS and TS Vue components + standalone .ts files

    {
        // Your custom configurations here
    }
]);

框架配置

处理特定框架时(如:. Nuxt) 仅仅传播配置可能并不总是可行的.

努克特项目

这个 eslint Nuxt 插件 装入 斯林特- 插图- vue 它们的插件 withNuxt() 如果存在不同的/相冲突的插件,则方法和 eslint 喜欢吐槽 在同一配置内。 我想你可以利用 FlatConfigComposer / 从 Nuxt 插件本身 但整个意图是 这个特殊的库 是为了让这个死屁股 尽可能简单的配置。 所以给你:

Nuxt 配置

import claxxonLint from '@claylevering/eslint-config';
import withNuxt from './.nuxt/eslint.config.mjs';

const claxxonNuxtConfig = claxxonLint.configs['nuxt'];

export default withNuxt({
    // Your custom config options / objects
}).prepend([
    /**
     * Prepend the custom Claxxon configurations. This includes Node and Vue
     * configurations but WITHOUT the Vue plugin itself so Nuxt/ESLint don't conflict.
     * Supports both JavaScript and TypeScript Vue components.
     */
    ...claxxonNuxtConfig
]);

使用自定义规则

所有配置自动包括自定义规则. 使用个别习惯规则:

import claxxonLint from '@claylevering/eslint-config';

export default [
    {
        plugins: {
            claxxon: claxxonLint
        },

        rules: {
            'claxxon/pinia-store-top-level': 'error',
            'claxxon/no-switch-statements': 'warn',
            'claxxon/no-vue-global-imports': 'error',
            'claxxon/pinia-store-pattern': 'error'
        }
    }
];

高级注释

虽然这些规矩已经被评为AF 但我承认有些人不喜欢 高级 而只是想要一些既定的安全规则(这完全可以). 这么说吧 如果你想加一句的话 页:1 埃斯林特- 配置- prettier {\fn黑体\fs22\bord1\shad0\3ahbe\4ah00\fscx67\fscy66\2chffffff\3ch808080}那两个 彼此和睦相处, 把它作为最后的东西 在你的配置。 这就是:

Vue w/更纯洁

import claxxonLint from '@claylevering/eslint-config';
import eslintConfigPrettier from 'eslint-config-prettier/flat';

export default defineConfig([
    ...claxxonLint.configs['vue'], // For Vue SFC files

    {
        // Your custom configurations here
    },

    eslintConfigPrettier // Prettier goes last to disable conflicting rules
]);

Nuxt + Prettier 键

import claxxonLint from '@claylevering/eslint-config';
import withNuxt from './.nuxt/eslint.config.mjs';
import eslintConfigPrettier from 'eslint-config-prettier/flat';

const claxxonNuxtConfig = claxxonLint.configs['nuxt'];

export default withNuxt({
    // Your custom config options / objects
})
    .prepend([
        /**
         * Prepend the custom Claxxon configurations. This includes Node and Vue
         * configurations but WITHOUT the Vue plugin itself so Nuxt/ESLint don't conflict.
         * Supports both JavaScript and TypeScript Vue components.
         */
        ...claxxonNuxtConfig
    ])
    .append([
        // Prettier goes last to disable conflicting rules
        eslintConfigPrettier
    ]);

自定义

pinia-store-top-level

执行 Pinia 只在顶级范围存储定义,以防止在循环或条件中创建商店.

有效性 :

// Top-level in script setup
const myPiniaStore = useMyPiniaStore();

// In setup function
export default {
    setup() {
        const myPiniaStore = useMyPiniaStore();
    }
};

无效 :

// Inside conditional
if (condition) {
    const myPiniaStore = useMyPiniaStore(); // ❌ Error
}

// Inside loop
for (let i = 0; i < 10; i += 1) {
    const store = useMyStore(); // ❌ Error
}

no-switch-statements

Disallows切换语句以防止掉入bug并改进可读性.

无效 :

switch (
    value // ❌ Error
) {
    case 1:
        return 'one';
    default:
        return 'other';
}

有效性 :

if (value === 1) {
    return 'one';
} else {
    return 'other';
}

no-vue-global-imports

防止导入 Vue 3 编译器宏( S)defineProps, (中文(简体) ), defineEmits, (中文(简体) ), defineExpose, (中文(简体) ), defineOptions, (中文(简体) ), defineSlots, (中文(简体) ), defineModel, (中文(简体) ), withDefaults自动在 <script setup>这是一条补充规则 vue/no-import-compiler-macros。 。 。 .

说明: defineComponent 财务报告和审定财务报表 defineAsyncComponent 为: 没有 标记为必须导入的运行时函数 .

无效 :

import { defineProps, defineEmits } from 'vue'; // ❌ Error

有效性 :

// Compiler macros: just use them directly in <script setup>
const props = defineProps({...});
const emit = defineEmits(['update']);

// Runtime functions: these must be imported
import { defineComponent, defineAsyncComponent } from 'vue'; // ✅ OK

pinia-store-pattern

在访问属性前强制将存储定义为变量 .

无效 :

const userId = useMyPiniaStore().id; // ❌ Error

有效性 :

const myPiniaStore = useMyPiniaStore();
const userId = userStore.id;

内建规则配置

padding-line-between-statements (警报,自动固定)

为改进可读性,需要将空行绕入块语句(如果,同时切换,尝试). 这样可以防止代码被过度压缩,使控制流更容易被扫描.

前 (触发警告) :

const onClickEvent = () => {
    if (!myMovieRef.value) {
        return;
    }
    if (myMovieRef.value?.title_id) {
        const title = myMovieRef.value?.title;
        if (title) {
            modalStore.openModal({ ... });
        }
    }
};

在(自动固定)之后:

const onClickEvent = () => {
    if (!myMovieRef.value) {
        return;
    }

    if (myMovieRef.value?.title_id) {
        const title = myMovieRef.value?.title;

        if (title) {
            modalStore.openModal({ ... });
        }
    }
};

所需资源

  • ESLint 语录 9.0.0或以上(依赖性较强,始终需要)
  • 节点.js 18或以上(建议)
  • 具体框架的一揽子措施 (可选对等者依赖性) :
    • typescript-eslint 用于类型脚本支持的 QQ 8. 0. 0
    • eslint-plugin-vue ^ 10.0.0 用于 Vue 支持
    • vue-eslint-parser ^ 10.0.0 用于 Vue 支持
    • @nuxt/eslint ++ 1.0.0 用于 Nuxt 支持

只安装您的工程类型所需的软件包(见上文安装部分).

许可证

麻省理工学院

仓库

https://github.com/claylevering/claxon-lint 页面存档备份,存于互联网档案馆

版本与发布记录

@claylevering/eslint-config 共发布 32 个版本,首次发布于 2025/11/14;过去 12 个月发布了 32 个版本。

版本发布日期距今
2.0.23latest2026/03/058 个月前
2.0.222026/01/0110 个月前
2.0.212025/12/1610 个月前
2.0.202025/12/1610 个月前
2.0.192025/12/1610 个月前
2.0.182025/12/1610 个月前

关于 @claylevering/eslint-config 的常见问题

@claylevering/eslint-config 是什么?

一套支持平面配置格式的ESLint配置,有Vue(以及TypeScript)、Node和TypeScript规则

如何安装 @claylevering/eslint-config?

在项目目录运行 npm install @claylevering/eslint-config,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:eslint(>=9.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@claylevering/eslint-config 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/claylevering__eslint-config 是否存在。

@claylevering/eslint-config 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@claylevering/eslint-config 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20.19.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@claylevering/eslint-config 可以商用吗?

@claylevering/eslint-config 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@claylevering/eslint-config 的下载量有多少?

根据 npm 官方下载统计,@claylevering/eslint-config 在 2026/10/10 – 2026/11/08 这 30 天内被下载 3,452 次,日均约 115 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@claylevering/eslint-config 还在维护吗?

最新版本 2.0.23 发布于 2026/03/05(8 个月前);至今共发布 32 个版本,其中过去 12 个月发布了 32 个;首次发布于 2025/11/14。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。