@brandlab-digital/eslint-plugin

中文文档
4.2.2发布于 2026/11/06UNLICENSEDTypeScriptES Module零依赖近 30 天下载 7760

Proprietary software © Brandlab Digital Marketing. All rights reserved. Published for Brandlab client sites.

原始使用文档
文档目录5 节
  1. Client preset
  2. Recommended flat config
  3. Site System config
  4. Stable rule IDs
  5. Deliberate boundaries

@brandlab-digital/eslint-plugin

Proprietary software © Brandlab Digital Marketing. All rights reserved. Published for Brandlab client sites.

Fast, syntax-level safeguards for Brandlab Next.js consumers. The plugin gives immediate editor and CI feedback for violations that can be established from a single source file.

It deliberately does not implement release support, migration policy, project health, rendered-output validation or portfolio scoring. Those decisions belong to @brandlab-digital/conformance.

Client preset

Every Brandlab Next.js client uses the complete preset as its whole eslint.config.mjs:

import brandlab from '@brandlab-digital/eslint-plugin'

export default brandlab.configs.next

configs.next is Next's core-web-vitals and typescript configs, then configs.recommended, then react/no-unescaped-entities off (apostrophes are ordinary copy) and the standard ignores (.next/, out/, build/, coverage/, playwright-report/, test-results/, .vercel/, public/, next-env.d.ts). It loads eslint-config-next when first used, so install eslint-config-next at the exact version of next.

For a non-Next consumer, or to compose a custom array:

import brandlab from '@brandlab-digital/eslint-plugin'

export default [brandlab.configs.recommended]

The recommended config enables every rule in the table below as an error except the two marked "site-system config", which the next section covers.

Site System config

configs['site-system'] is configs.recommended plus the two Site System rules (no-preferred-region, no-long-class-in-list), all errors. A site adds it when it declares a siteSystem tier in brandlab.config.ts, so fleet bumps and security patches stay green until a site adopts the shared shell:

import brandlab from '@brandlab-digital/eslint-plugin'

export default [...brandlab.configs.next, brandlab.configs['site-system']]

The conformance engineering check accepts exactly two eslint.config.mjs default exports: export default brandlab.configs.next, and the form above (brandlab.configs["site-system"] with double quotes is also accepted, and so is a trailing comma or the array split over lines). Any other array fails the tool-preset check.

For a non-Next consumer, [brandlab.configs['site-system']] alone enables all nine rules. SITE_SYSTEM_RULE_IDS lists the two IDs.

Stable rule IDs

RulePurposePreferred implementation
brandlab/no-retired-analytics-eventsRejects retired event names such as contact_form_submission and phone_call.Use contact_form for accepted forms and phone_link_click for telephone-link diagnostics.
brandlab/no-raw-json-ldRejects raw JSON-LD <script> and createElement output in consumers.Render typed graphs through @brandlab-digital/site-next/schema.
brandlab/no-unsafe-rich-text-sinksRejects every project-owned raw HTML sink (dangerouslySetInnerHTML in JSX, props objects or assignments), whatever sanitiser it names. The conformance checker applies the same policy.Render JSON-LD with SchemaScript and rich text with SafeRichText from @brandlab-digital/site-next.
brandlab/no-protected-platform-reimplementationRejects local declarations and direct calls that bypass protected contact, SEO or analytics surfaces.Import the shared site-core or site-next API.
brandlab/no-analytics-piiRejects statically provable lead PII, message and attachment data in known analytics sinks.Send only shared allowlisted event parameters.
brandlab/no-unsafe-external-linksRejects script-bearing link schemes and external new-context links with opener access when the URL is static.Use safe schemes and rel="noopener"; keep runtime URL validation at the trust boundary.
brandlab/no-raw-image-elementsRejects raw website <img> and createElement('img') output.Use next/image; the documented getImageProps art-direction pattern and email renderer files remain exempt.
brandlab/no-preferred-region (site-system config, 3.13.0)Rejects an exported preferredRegion (a variable, function or export { x as preferredRegion }). It is deprecated, and on Vercel accepts only auto, global or home.Leave the region to vercel.json regions, recorded in brandlab.config.ts hosting.originRegion (rule origin-region-v1).
brandlab/no-long-class-in-list (site-system config, 3.14.0)Rejects a className (or class) string over 80 characters inside a .map() or .flatMap() callback: a literal, template text, or a string inside cx(), a ternary, && or an array. Every item repeats it in the HTML and the RSC payload. Tests and installed packages are exempt.Style the repeated item once with a named class in the site stylesheet, or keep the class at 80 characters or fewer.

RULE_IDS (all twelve) is exported for tools that need the canonical IDs without duplicating strings. The 3.0 release removed brandlab/no-allow-indexing-true together with the ALLOW_INDEXING path it guarded; indexing is decided by the deployment environment.

Deliberate boundaries

  • The protected-surface rule checks declarations with reserved platform API names and direct transport or analytics calls. It does not compare implementation behaviour or package versions.
  • The analytics rule inspects known event sinks and source-visible payloads. It does not guess the contents of opaque dynamic objects; runtime allowlisting and conformance remain mandatory.
  • The link rule acts only on statically resolvable URLs. Dynamic destinations require runtime validation and behavioural verification.
  • The image rule applies to website UI. Raw image markup remains available to non-Next renderers when the file is clearly located or named as an email renderer.
  • Shared implementations in site-core, site-next and installed @brandlab-digital packages are not treated as consumer reimplementations.
  • The telephone-link rule reads the href attribute where it is written. A link built elsewhere (a telHref variable, a config object, createElement) is out of reach; conformance reads the rendered links.
  • The hover-timer rule follows handlers declared in the same file: inline, named, wrapped in a call such as useCallback, or reached through local helper functions. A timer in an imported hook, or in an effect driven by hover state, is not found. It ignores files outside src/ and files whose path and exports do not name a header, nav, menu or drawer.
  • The deep-import rule covers @brandlab-digital/site-next only.

These constraints keep linting deterministic and editor-fast while the conformance engine owns deeper AST, behavioural and rendered-output evidence.

版本与发布记录

@brandlab-digital/eslint-plugin 共发布 118 个版本,首次发布于 2026/05/26;过去 12 个月发布了 118 个版本。

版本发布日期距今
4.2.2latest2026/11/062 天前
4.2.12026/11/062 天前
4.2.02026/11/062 天前
4.1.02026/11/053 天前
4.0.02026/11/053 天前
3.20.02026/11/044 天前

其他发布通道:next → 1.0.0,maintenance-1-0 → 1.0.15,maintenance-3-4 → 3.4.1,maintenance-3-5 → 3.5.2,maintenance-3-3 → 3.3.6。

关于 @brandlab-digital/eslint-plugin 的常见问题

@brandlab-digital/eslint-plugin 是什么?

Proprietary software © Brandlab Digital Marketing. All rights reserved. Published for Brandlab client sites.

如何安装 @brandlab-digital/eslint-plugin?

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

@brandlab-digital/eslint-plugin 支持 TypeScript 吗?

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

@brandlab-digital/eslint-plugin 支持 ESM 还是 CommonJS?

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

@brandlab-digital/eslint-plugin 可以商用吗?

@brandlab-digital/eslint-plugin 使用 UNLICENSED 许可。作者声明为 UNLICENSED,即不授予公开使用许可(与公共领域的 Unlicense 不同)。使用前需获得作者授权。以上为概括,不构成法律意见,请以许可原文为准。

@brandlab-digital/eslint-plugin 的下载量有多少?

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

@brandlab-digital/eslint-plugin 还在维护吗?

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