@alint-js/plugin-js

中文文档
0.7.3发布于 2026/09/29MITTypeScriptES Module零依赖近 30 天下载 6962

Model-backed JavaScript and TypeScript review rules for alint

原始使用文档
文档目录7 节
  1. Rules
  2. Repository-aware review requirements
  3. How to use
  4. Recommended preset
  5. Opt in to repository-aware rules
  6. When to use
  7. When not to use

@alint-js/plugin-js

Model-backed JavaScript and TypeScript review rules for alint.

The package default export is the plugin definition. Individual rule definitions are also available as named exports.

Rules

The bundled recommended config enables these rules under the js plugin name:

  • js/inline-miniature-normalizer reports clusters of local helpers that form a private reader or narrowing toolkit.
  • js/no-config-file-tests reports standalone tests that restate repository configuration instead of verifying behavior. It skips non-test files before calling the model, but the files: glob must include tests and ignored files remain excluded.
  • js/no-mixed-layers-without-abstraction reports consuming features that own independently reusable external-integration responsibilities without a stable interface.
  • js/no-private-schema-toolkit reports clusters of local helpers that form an ad hoc schema or payload-normalization toolkit.
  • js/no-redundant-binding reports local bindings that only rename an unchanged value or reference without adding a useful boundary.
  • js/no-redundant-jsdoc reports JSDoc that mostly restates the documented declaration, signature, or implementation.
  • js/no-trivial-wrapper-stack reports chains of shallow wrappers that add no meaningful policy or runtime boundary.
  • js/no-vacuous-function reports functions whose shallow implementation does not earn a separate runtime boundary.

js/no-vacuous-function remains a local, cacheable model review. Repository-wide test usage is handled by a separate opt-in rule so enabling an agent does not change the recommended rule's behavior or cacheability.

Five repository-aware rules are registered but intentionally not enabled by recommended:

  • js/no-duplicated-knowledge finds policy or mechanism knowledge duplicated across files when both locations encode one decision that must change together. A small, whole-helper clone is usually a better fit for simplicity/no-duplicated-helper.
  • js/no-redundant-catch finds an outer error-normalization catch that is made redundant by a callee's proven domain-error postcondition.
  • js/no-single-use-materialization finds a collection produced once and consumed once immediately when the producer and consumer can be fused safely. It is broader than the local js/no-redundant-binding check for unchanged aliases.
  • js/no-test-only-production-wrapper finds a shallow wrapper declared in production but referenced only by tests and unreachable through package exports.
  • js/no-overlapping-entrypoints finds competing package public entrypoints that expose materially the same symbol surface and have unclear canonical ownership. It is not a replacement for js/no-trivial-wrapper-stack, which reviews shallow local call chains.

Repository-aware review requirements

The five opt-in rules require both a configured model and an agent adapter capable of tool calls. They reuse the standard @alint-js/tools-fs list, search, and read tools, and ask the agent to include repository evidence with each finding.

js/no-config-file-tests is not repository-aware and needs no agent adapter: it judges the test file it is handed, so a configured model is enough.

How to use

Use the default export with the js plugin name because the bundled preset refers to js/* rule IDs.

import jsPlugin from '@alint-js/plugin-js'

import { defineConfig } from '@alint-js/cli'

export default defineConfig([
  {
    extends: ['js/recommended'],
    files: ['**/*.{js,jsx,ts,tsx,mjs,cjs,mts,cts}'],
    plugins: {
      js: jsPlugin,
    },
  },
])

Opt in to repository-aware rules

Configure an agent and tool-call-capable model in your alint runtime, then enable the repository-aware rules explicitly:

import jsPlugin from '@alint-js/plugin-js'

import { defineConfig } from '@alint-js/cli'

export default defineConfig([
  {
    files: ['**/*.{js,jsx,ts,tsx,mjs,cjs,mts,cts}'],
    plugins: {
      js: jsPlugin,
    },
    rules: {
      'js/no-duplicated-knowledge': 'warn',
      'js/no-overlapping-entrypoints': 'warn',
      'js/no-redundant-catch': 'warn',
      'js/no-single-use-materialization': 'warn',
      'js/no-test-only-production-wrapper': 'warn',
    },
  },
])

When to use

  • Use the recommended preset for model-assisted JavaScript and TypeScript design review.
  • Opt in to repository-aware rules when cross-file ownership, package surfaces, or control/data-flow contracts need investigation.
  • Use the named rule exports when composing another plugin definition programmatically.

When not to use

  • Do not use model-backed rules as a deterministic replacement for syntax-aware lint.
  • Do not enable repository-aware rules with a generation-only model or without an agent adapter.
  • Do not use js/no-config-file-tests when the configuration module owns logic the repository must verify, such as a custom lint rule, a custom bundler plugin, or a merge or normalization helper. Move that logic into its own module and test the module instead.
  • Do not use js/no-duplicated-knowledge for coincidental literals or clones that do not encode one shared decision.
  • Do not use js/no-overlapping-entrypoints for documented compatibility aliases or conditional/type-only exports.
  • Do not use js/no-redundant-catch when the outer catch changes cleanup, observability, error metadata, cause, identity, or cancellation behavior.
  • Do not use js/no-single-use-materialization when fusion would change validation ordering, evaluation, identity, side effects, concurrency, or another observable behavior.

版本与发布记录

@alint-js/plugin-js 共发布 28 个版本,首次发布于 2026/07/16;过去 12 个月发布了 28 个版本。

版本发布日期距今
0.7.3latest2026/09/291 个月前
0.7.22026/09/281 个月前
0.7.12026/08/292 个月前
0.7.02026/08/292 个月前
0.6.02026/08/192 个月前
0.5.02026/08/162 个月前

关于 @alint-js/plugin-js 的常见问题

@alint-js/plugin-js 是什么?

Model-backed JavaScript and TypeScript review rules for alint

如何安装 @alint-js/plugin-js?

在项目目录运行 npm install @alint-js/plugin-js,或使用 pnpm add / yarn add / bun add。

@alint-js/plugin-js 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@alint-js/plugin-js 支持 ESM 还是 CommonJS?

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

@alint-js/plugin-js 可以商用吗?

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

@alint-js/plugin-js 的下载量有多少?

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

@alint-js/plugin-js 还在维护吗?

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