@aleph-alpha/eslint-config-frontend

中文文档
0.7.1发布于 2026/08/10Apache-2.0ES Module近 30 天下载 1.5万

@aleph-alpha/eslint-config-frontend

原始使用文档
文档目录7 节
  1. ESLint Config
  2. Install
  3. Quick Start
  4. Composable Configs
  5. Usage Examples
  6. What's Included
  7. Customization

ESLint Config

@aleph-alpha/eslint-config-frontend

Shared, composable ESLint flat config for Aleph Alpha frontend projects. Requires ESLint 10+.

Install

pnpm add -D @aleph-alpha/eslint-config-frontend eslint

Quick Start

Create an eslint.config.mjs in your project:

import { base } from '@aleph-alpha/eslint-config-frontend';

export default [...base];

That's it. This replaces the entire create-vue boilerplate and gives you @eslint/js recommended + eslint-plugin-vue recommended + TypeScript parsing + org-standard Vue rules.

Composable Configs

The package exports four configs that can be composed together:

ExportWhat it adds
base@eslint/js recommended, eslint-plugin-vue recommended, TS parser, Vue style rules, globals
tsRecommended@typescript-eslint plugin + typescript-eslint recommended rules + org-standard severity tunings
stricteslint-plugin-sonarjs recommended rules
a11yeslint-plugin-vuejs-accessibility recommended, accessibility rules

Usage Examples

Vue + TS project (most common):

import { base } from '@aleph-alpha/eslint-config-frontend';
import skipFormatting from '@vue/eslint-config-prettier/skip-formatting';

export default [...base, skipFormatting];

With TypeScript rules:

import { base, tsRecommended } from '@aleph-alpha/eslint-config-frontend';
import skipFormatting from '@vue/eslint-config-prettier/skip-formatting';

export default [...base, ...tsRecommended, skipFormatting];

With code quality rules (sonarjs) on top:

import { base, tsRecommended, strict } from '@aleph-alpha/eslint-config-frontend';
import skipFormatting from '@vue/eslint-config-prettier/skip-formatting';

export default [...base, ...tsRecommended, ...strict, skipFormatting];

Full setup with accessibility:

import { base, tsRecommended, strict, a11y } from '@aleph-alpha/eslint-config-frontend';
import skipFormatting from '@vue/eslint-config-prettier/skip-formatting';

export default [...base, ...tsRecommended, ...strict, ...a11y, skipFormatting];

In an Nx workspace (drop nx.configs['flat/typescript'] and nx.configs['flat/javascript'] — tsRecommended owns the @typescript-eslint registration and rule set):

import nx from '@nx/eslint-plugin';
import { base, tsRecommended, strict, a11y } from '@aleph-alpha/eslint-config-frontend';

export default [
  ...nx.configs['flat/base'],
  ...tsRecommended,
  ...base,
  ...strict,
  ...a11y,
  // ...workspace-specific blocks
];

With project-specific overrides:

import { base, tsRecommended, strict } from '@aleph-alpha/eslint-config-frontend';
import skipFormatting from '@vue/eslint-config-prettier/skip-formatting';

export default [
  ...base,
  ...tsRecommended,
  ...strict,
  {
    rules: {
      'no-console': 'warn',
      'vue/block-order': ['error', { order: ['i18n', 'script', 'template', 'style'] }],
    },
  },
  skipFormatting,
];

With vitest and playwright (common pattern):

import { base } from '@aleph-alpha/eslint-config-frontend';
import pluginVitest from '@vitest/eslint-plugin';
import pluginPlaywright from 'eslint-plugin-playwright';
import skipFormatting from '@vue/eslint-config-prettier/skip-formatting';

export default [
  ...base,
  {
    ...pluginVitest.configs.recommended,
    files: ['src/**/__tests__/*'],
  },
  {
    ...pluginPlaywright.configs['flat/recommended'],
    files: ['e2e/**/*.{test,spec}.{js,ts,jsx,tsx}'],
  },
  skipFormatting,
];

What's Included

base

tsRecommended

  • Scoped to **/*.{ts,tsx,cts,mts,vue} (order-independent — safe to spread before or after base)
  • typescript-eslint recommended config
  • @typescript-eslint plugin registration
  • Org-standard severity tunings: no-require-imports off; no-empty-function, no-inferrable-types, no-empty-object-type, no-unused-expressions, no-non-null-asserted-optional-chain, prefer-const, no-non-null-assertion, no-explicit-any, no-unused-vars set to warn for graceful adoption
  • @typescript-eslint/prefer-as-const: error

strict

a11y

Customization

Each config is an array of ESLint flat config objects. Override any rule by adding config objects after the shared configs. For details on available rules, see:

版本与发布记录

@aleph-alpha/eslint-config-frontend 共发布 193 个版本,首次发布于 2025/03/10;过去 12 个月发布了 86 个版本。

版本发布日期距今
0.7.1latest2026/08/102 个月前
0.7.02026/06/184 个月前
0.6.02026/05/265 个月前
0.5.02026/03/167 个月前
0.4.02025/12/1810 个月前
0.3.1862025/12/1110 个月前

其他发布通道:canary → 0.3.42-canary.6a2fa49c.0。

关于 @aleph-alpha/eslint-config-frontend 的常见问题

@aleph-alpha/eslint-config-frontend 是什么?

@aleph-alpha/eslint-config-frontend

如何安装 @aleph-alpha/eslint-config-frontend?

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

@aleph-alpha/eslint-config-frontend 支持 TypeScript 吗?

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

@aleph-alpha/eslint-config-frontend 支持 ESM 还是 CommonJS?

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

@aleph-alpha/eslint-config-frontend 可以商用吗?

@aleph-alpha/eslint-config-frontend 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@aleph-alpha/eslint-config-frontend 的下载量有多少?

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

@aleph-alpha/eslint-config-frontend 还在维护吗?

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