@claylevering/eslint-config

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

A set of ESLint configurations supporting flat config format with Vue (and with TypeScript), Node, and TypeScript rules

原始使用文档
文档目录23 节
  1. TOC
  2. Features
  3. Installation
  4. Base Installation
  5. Framework-Specific Dependencies
  6. Usage
  7. Node.js/JavaScript Projects
  8. TypeScript Projects
  9. Vue 3 Projects
  10. Framework configurations
  11. Nuxt projects
  12. Using Custom Rules
  13. Prettier note
  14. Custom Rule Definitions
  15. pinia-store-top-level
  16. no-switch-statements
  17. no-vue-global-imports
  18. pinia-store-pattern
  19. Built-in Rule Configurations
  20. padding-line-between-statements (warn, auto-fixable)
  21. Requirements
  22. License
  23. Repository

@claylevering/claxxon-lint

Publish Package to npm

A comprehensive ESLint plugin providing shareable configurations in ESLint flat config format (ESLint 9+) with support for Vue, Node.js, and TypeScript projects. Includes custom rules for Vue/Pinia development patterns.

TOC

Features

  • ESLint 9+ Flat Config Format - Modern array-based configuration
  • Multiple Presets - Choose configurations for your stack:
    • Node.js/JavaScript
    • TypeScript
    • Vue 3
    • Vue 3 + TypeScript
    • Nuxt 4
    • Nuxt 4 + TypeScript
  • Custom Rules - Specialized rules for Vue and Pinia development
  • Opinionated Defaults - Battle-tested rules for production applications

Installation

Base Installation

All projects require the base package and ESLint:

pnpm add -D @claylevering/eslint-config eslint

Framework-Specific Dependencies

Depending on which configuration you're using, install the appropriate peer dependencies:

For Node.js/JavaScript Only

No additional dependencies needed! The base installation is sufficient.

For TypeScript Projects

pnpm add -D typescript-eslint

For Vue 3 Projects

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

Note: typescript-eslint is required even for pure JavaScript Vue projects to support the hybrid parser that allows mixing JS and TS components.

For Nuxt Projects

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

Usage

All examples use the defineConfig() helper from the ESLint package to create flat config arrays.

Node.js/JavaScript Projects

Create eslint.config.js in your project root:

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

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

    {
        // Your custom configurations here
    }
]);

TypeScript Projects

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 Projects

The vue config supports hybrid JavaScript and TypeScript Vue components in the same project:

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
    }
]);

Framework configurations

When you're dealing with specific frameworks (e.g. Nuxt) simply spreading the configurations may not always work.

Nuxt projects

The eslint Nuxt plugin loads the eslint-plugin-vue plugin during their withNuxt() method and eslint likes to barf if differing / conflicting plugins exist from within the same configuration. I suppose you could leverage the FlatConfigComposer / etc. from the Nuxt plugin itself but the whole intention of this particular library is to make this as dead-ass simple as possible for config. So here you go:

Nuxt Configuration

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
]);

Using Custom Rules

All configurations include custom rules automatically. To use individual custom rules:

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'
        }
    }
];

Prettier note

While these rules are already opinionated-AF, I recognize that some folks don't love Prettier and just want some established rules for safety (which is totally fine). That being said - if you wanted to add the eslint-config-prettier to your config so that those two place nicely with each other, just have it be the last thing in your config. Here's how:

Vue w/Prettier

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
    ]);

Custom Rule Definitions

pinia-store-top-level

Enforces Pinia store definitions only at top-level scope to prevent stores being created in loops or conditionals.

Valid:

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

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

Invalid:

// 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 switch statements to prevent fallthrough bugs and improve readability.

Invalid:

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

Valid:

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

no-vue-global-imports

Prevents importing Vue 3 compiler macros (defineProps, defineEmits, defineExpose, defineOptions, defineSlots, defineModel, withDefaults) that are automatically available in <script setup>. This is a complementary rule to vue/no-import-compiler-macros.

Note: defineComponent and defineAsyncComponent are not flagged as they are runtime functions that must be imported.

Invalid:

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

Valid:

// 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

Enforces defining stores as variables before accessing properties.

Invalid:

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

Valid:

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

Built-in Rule Configurations

padding-line-between-statements (warn, auto-fixable)

Requires blank lines around block statements (if, for, while, switch, try) for improved readability. This prevents code from being too compressed and makes control flow easier to scan.

Before (triggers warning):

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

After (auto-fixed):

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

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

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

Requirements

  • ESLint 9.0.0 or higher (peer dependency, always required)
  • Node.js 18 or higher (recommended)
  • Framework-specific packages (optional peer dependencies):
    • typescript-eslint >= 8.0.0 for TypeScript support
    • eslint-plugin-vue >= 10.0.0 for Vue support
    • vue-eslint-parser >= 10.0.0 for Vue support
    • @nuxt/eslint >= 1.0.0 for Nuxt support

Install only the packages you need for your project type (see Installation section above).

License

MIT © Clay Levering

Repository

https://github.com/claylevering/claxxon-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 是什么?

A set of ESLint configurations supporting flat config format with Vue (and with TypeScript), Node, and TypeScript rules

如何安装 @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 和提交记录判断。