@commerce-klaus/eslint-config-sfcc

中文文档
2.1.0发布于 2026/11/06MITTypeScriptES Module构建来源已验证近 30 天下载 2613

A collection of shareable ESLint configurations for Salesforce Commerce Cloud (SFCC)

原始使用文档
文档目录4 节
  1. Highlights
  2. Install
  3. Documentation
  4. License

NPM version Downloads

@commerce-klaus/eslint-config-sfcc

Shareable ESLint flat config for Salesforce Commerce Cloud projects. It catches SFCC script runtime compatibility problems and platform-specific mistakes before code reaches a sandbox.

Highlights

  • Detects unsupported syntax and standard library APIs
  • Checks SFCC module paths, hooks, and Custom API exports
  • Handles Rhino-specific const and scoping behavior
  • Includes SFCC and SiteGenesis rules
  • Provides Storefront Next, PWA, SFRA, and SiteGenesis policy presets
  • Provides additive presets for older SFCC compatibility modes
  • Provides a reviewable, safe batch migration away from the SFCC empty() global
  • Includes an action-oriented formatter for empty() migration inventories
  • Uses Custom Attribute and Site Preference metadata for higher-confidence empty() migration guidance
  • Connects parsed Custom API request bodies to generated OAS operation types
  • Provides an opt-in preset for enforcing generated project types at metadata boundaries
  • Provides an opt-in sfcc-test preset for sequential runtime use, delayed cartridge imports, managed test globals, and safe mock setup
  • Supports ESLint and an Oxlint-compatible preset
  • Provides equivalent Oxlint override builders for recommended, compatibility, generated-types, empty-migration, storefront architecture, and SFCC test configurations

Prefer Oxlint for everyday linting. It provides the fast feedback loop for normal development and CI and runs the same recommended JavaScript rules over the same server-side cartridge files as ESLint. Use ESLint for complete migrations and audits where .ds files, E4X-like syntax, JavaScript type annotations, JSON metadata, or complex inferred types require its parser and TypeScript services. The full guide documents a focused ESLint fallback for the four rules Oxlint cannot run.

Install

pnpm add -D eslint @commerce-klaus/eslint-config-sfcc
npm install -D eslint @commerce-klaus/eslint-config-sfcc
yarn add -D eslint @commerce-klaus/eslint-config-sfcc
vp install -D eslint @commerce-klaus/eslint-config-sfcc
import sfcc from "@commerce-klaus/eslint-config-sfcc"
import { defineConfig } from "eslint/config"

export default defineConfig(sfcc.configs.recommended)

Projects that generate declarations with @commerce-klaus/typescript-sfcc can add the generated-types preset after recommended:

export default defineConfig(sfcc.configs.recommended, sfcc.configs["generated-types"])

The preset checks registered job step functions, SFCC system hook implementations, Custom API handlers, and local Custom API success response values against their generated types.

The recommended config checks server-side JavaScript below cartridges/ and excludes client-side and static asset folders. It also disables Node.js and browser globals inherited from earlier flat config entries while keeping CommonJS and SFCC runtime globals available.

It also disables selected incompatible rules from ESLint core/recommended, eslint-plugin-unicorn, typescript-eslint, and eslint-plugin-sonarjs. This keeps those presets usable alongside SFCC code without suggesting syntax, APIs, or module patterns unsupported by the SFCC script runtime. See the configuration guide for the documented compatibility overrides.

The recommended config follows the current SFCC Script API. Projects using an older compatibility mode can add the corresponding preset after recommended:

export default defineConfig(sfcc.configs.recommended, sfcc.configs["compatibility-21.2"])

Presets are available for compatibility modes 21.2 and 22.7. The 22.7 preset currently matches the recommended API baseline and establishes an explicit version contract for future Script API additions. The 21.2 preset also prevents Unicorn from suggesting BigInt, globalThis, or Object.fromEntries as replacements.

Documentation

See the complete configuration guide and rule reference.

License

MIT

版本与发布记录

@commerce-klaus/eslint-config-sfcc 共发布 47 个版本,首次发布于 2026/06/29;过去 12 个月发布了 47 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.1.0latest2026/11/064 天前
2.0.12026/10/3011 天前
2.0.02026/10/3011 天前
1.15.12026/10/2912 天前
1.15.02026/10/2417 天前
1.14.02026/10/051 个月前

关于 @commerce-klaus/eslint-config-sfcc 的常见问题

@commerce-klaus/eslint-config-sfcc 是什么?

A collection of shareable ESLint configurations for Salesforce Commerce Cloud (SFCC)

如何安装 @commerce-klaus/eslint-config-sfcc?

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

@commerce-klaus/eslint-config-sfcc 支持 TypeScript 吗?

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

@commerce-klaus/eslint-config-sfcc 支持 ESM 还是 CommonJS?

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

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

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

@commerce-klaus/eslint-config-sfcc 可以商用吗?

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

@commerce-klaus/eslint-config-sfcc 的下载量有多少?

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

@commerce-klaus/eslint-config-sfcc 还在维护吗?

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