@drupal-canvas/eslint-config

中文文档
0.10.1发布于 2026/09/26MITES Module近 30 天下载 4673

ESLint config for validating Drupal Canvas Code Components

原始使用文档
文档目录4 节
  1. Config variants
  2. Usage
  3. Rules
  4. Development

Drupal Canvas ESLint Config

ESLint config for validating Drupal Canvas Code Components.

Config variants

ConfigDescription
requiredBase settings for parsing JavaScript and TypeScript files, YAML parsing for component metadata files, and custom rules for Drupal Canvas Code Component validation. Automatically used by @drupal-canvas/cli when validating, building, or pushing components.
recommendedrequired + recommended rules from @eslint/js, eslint-plugin-react, eslint-plugin-react-hooks, eslint-plugin-jsx-a11y, eslint-plugin-yml and typescript-eslint.
strictrecommended + strict rules from eslint-plugin-jsx-a11y and typescript-eslint.

Usage

npm install -D @drupal-canvas/eslint-config
// eslint.config.js
import { defineConfig } from 'eslint/config';
import { recommended as drupalCanvasRecommended } from '@drupal-canvas/eslint-config';

export default defineConfig([
  ...drupalCanvasRecommended,
  // ...
]);

Rules

The required config checks portable authoring rules and project conventions. Metadata structure and target acceptance are validated separately through the Canvas Code Component metadata schema and the target Drupal site.

RuleDescription
component-dir-nameValidates that machineName matches the directory name (index-style) or filename prefix (named-style).
component-exportsValidates that component has a default export.
component-importsValidates that component imports only from supported import sources and patterns.
component-no-hierarchyValidates that component directories are direct children of the configured componentDir.
component-prop-example-value-no-empty-stringValidates that string prop examples do not contain empty values.
component-prop-namesValidates that component prop IDs match the camelCase version of their titles.
component-required-propsValidates that required props are defined and provide a default example.

Development

The following scripts are available for developing this package:

CommandDescription
devCompile to the dist folder for development while watching for changes.
buildCompile to the dist folder for production use.
type-checkRun TypeScript type checking without emitting files.
testRun tests.

版本与发布记录

@drupal-canvas/eslint-config 共发布 18 个版本,首次发布于 2025/12/01;过去 12 个月发布了 18 个版本。

版本发布日期距今
0.10.1latest2026/09/261 个月前
0.10.02026/09/102 个月前
0.9.02026/08/192 个月前
0.8.02026/08/133 个月前
0.7.02026/07/223 个月前
0.6.12026/07/014 个月前

关于 @drupal-canvas/eslint-config 的常见问题

@drupal-canvas/eslint-config 是什么?

ESLint config for validating Drupal Canvas Code Components

如何安装 @drupal-canvas/eslint-config?

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

@drupal-canvas/eslint-config 支持 TypeScript 吗?

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

@drupal-canvas/eslint-config 支持 ESM 还是 CommonJS?

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

@drupal-canvas/eslint-config 需要什么版本的 Node.js?

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

@drupal-canvas/eslint-config 可以商用吗?

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

@drupal-canvas/eslint-config 的下载量有多少?

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

@drupal-canvas/eslint-config 还在维护吗?

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