# @compiled/eslint-plugin 中文文档

规范地址：https://npmcn.com/package/%40compiled/eslint-plugin/

版本：0\.20\.2
npm 元数据更新时间：2026-09-16T05:11:33.607Z
中文译文更新时间：2026-11-14T16:21:29.605Z
软件包许可：Apache-2\.0

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40compiled/eslint-plugin
原文对照：https://npmcn.com/package/%40compiled/eslint-plugin/?lang=original
项目主页：https://compiledcssinjs.com/docs/pkg-eslint-plugin
源码仓库：https://github.com/atlassian-labs/compiled

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：544 kB，172 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- Node.js 要求：^16\.0\.0 \|\| \>=18\.0\.0
- 运行依赖：2 个
- 首次发布：2021-11-04T06:38:31.364Z
- 最新版本发布：2026-09-16T05:11:33.402Z
- 近 30 天下载量：1981（2026-10-11 至 2026-11-09，npm 官方下载统计）
- 已发布版本数：52（近 12 个月 4 个）

## 中文简介

一个熟悉且能表演的编译时间 CSS-in-JS 库用于React.

## 安装

```sh
npm install @compiled/eslint-plugin
```

也可以使用：`pnpm add @compiled/eslint-plugin`、`yarn add @compiled/eslint-plugin`、`bun add @compiled/eslint-plugin`

## README

# @ compriled/eslint- plugin (英语)

此插件包含规则, 用于工作时 `@compiled/react`。 。 。 .

## 安装

```sh
npm install @compiled/eslint-plugin --save-dev
```

## 使用量

### 平面配置

导入 `@compiled/eslint-plugin` 并添加到您这样的插件中,然后在“支持规则”栏下配置您想要使用的规则.

```ts
import compiled from '@compiled/eslint-plugin';

export default [
  {
    plugins: {
      '@compiled': compiled,
    },
    rules: {
      '@compiled/no-js-xcss': 'error',
    },
  },
];
```

通过扩展 `flat/recommended` 这样配置 :

```ts
import compiled from '@compiled/eslint-plugin';

export default [compiled.configs['flat/recommended']];
```

### 遗产配置( E)`.eslintrc`(中文(简体) )

添加 `@compiled` 到您的插件区 `.eslintrc` 配置文件,然后在规则节下配置您想要使用的规则.

```json
{
  "plugins": ["@compiled"],
  "rules": {
    "@compiled/no-js-xcss": "error"
  }
}
```

您也可以通过添加来启用推荐的规则进行编译 `plugin:@compiled/recommended` 扩展中:

```diff
{
+  "extends": ["plugin:@compiled/recommended"],
-  "plugins": ["@compiled"]
}
```

## 支持的规则

\* 包括在建议的配置中.  
自动修复 [`--fix` CLI 选项](https://eslint.org/docs/user-guide/command-line-interface#--fix)。

| 名称 | 说明 | 建议 | 可修复 |
| --- | --- | :-: | :-: |
| [@ 编译/jsx-pragma](https://npmcn.com/package/%40compiled/eslint-plugin/src/rules/jsx-pragma) | 使用时执行 jsx pragma `css` 道具 |  | 🔧 |
| [@ 编译/ local- cx- xss](https://npmcn.com/package/%40compiled/eslint-plugin/src/rules/local-cx-xcss) | 确保 `cx()` 函数仅在 `xcss` 道具 | ✅ |  |
| [@ compiled/ no- css- prof- unite- cs- 函数](https://npmcn.com/package/%40compiled/eslint-plugin/src/rules/no-css-prop-without-css-function) | 否定 `css` 道具用途,如果它不是包裹在 `css` 从 `@compiled/react` 或在何处 `@compiled` 无法确定是否 `css` 导入包含在构建时间. | ✅ | 🔧 |
| [@ compiled/ no- css- tagn- template- expression (没有标记) @ info: whatsthis](https://npmcn.com/package/%40compiled/eslint-plugin/src/rules/no-css-tagged-template-expression) | 放弃 `css` 标记模板表达式 | ✅ | 🔧 |
| [@ 编译/ 否情感- css](https://npmcn.com/package/%40compiled/eslint-plugin/src/rules/no-emotion-css) | 否定 `@emotion` 用途 |  | 🔧 |
| [@ compiled/ no- 空- speating- speating](https://npmcn.com/package/%40compiled/eslint-plugin/src/rules/no-empty-styled-expression) | 拒绝任何 `styled` 表达式,用于通过空参数时 `@compiled/react` | ✅ |  |
| [@ 编译/ 不出口- css](https://npmcn.com/package/%40compiled/eslint-plugin/src/rules/no-exported-css) | 否定 `css` 从导出用途 | ✅ |  |
| [@ 编译/ 不导出键框](https://npmcn.com/package/%40compiled/eslint-plugin/src/rules/no-exported-keyframes) | 否定 `keyframes` 从导出用途 | ✅ |  |
| [@ 编译/ 无效- css- map](https://npmcn.com/package/%40compiled/eslint-plugin/src/rules/no-invalid-css-map) | 检查通过 assMap 创建的 CSS 映射的有效性。 此功能意在与 TypeScript 的类型检查同时使用 . | ✅ |  |
| [@ 编译/ no-js- xcs](https://npmcn.com/package/%40compiled/eslint-plugin/src/rules/no-js-xcss) | Xcss道具的前提是遵守类型合同。 在不使用TypeScript的情况下使用它会打破这个合同,因此是不允许的. | ✅ |  |
| [@ compiled/ no- keyframes- tagn- template- expression 翻译/ 无键框- template- 表达式](https://npmcn.com/package/%40compiled/eslint-plugin/src/rules/no-keyframes-tagged-template-expression) | 放弃 `keyframes` 标记模板表达式 | ✅ | 🔧 |
| [@ 编译/ 无类标记- template- expression](https://npmcn.com/package/%40compiled/eslint-plugin/src/rules/no-styled-tagged-template-expression) | 放弃 `styled` 标记模板表达式 | ✅ | 🔧 |
| [@ compriled/ no- suppress- xcss (英语)](https://npmcn.com/package/%40compiled/eslint-plugin/src/rules/no-suppress-xcss) | Xcss道具的前提是遵守类型合同。 扣压它违反合同,因此不允许. | ✅ |  |
| [@ 编译/ 短手财产类型](https://npmcn.com/package/%40compiled/eslint-plugin/src/rules/shorthand-property-sorting) | 通过确保短手属性在相应的长手属性之前总是被定义来防止不必要的副作用. | ✅ |  |

## 常见问题

### @compiled/eslint-plugin 是什么？

一个熟悉且能表演的编译时间 CSS-in-JS 库用于React\.

### 如何安装 @compiled/eslint-plugin？

在项目目录运行 npm install @compiled/eslint-plugin，或使用 pnpm add / yarn add / bun add。

### @compiled/eslint-plugin 支持 TypeScript 吗？

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

### @compiled/eslint-plugin 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @compiled/eslint-plugin 需要什么版本的 Node\.js？

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

### @compiled/eslint-plugin 可以商用吗？

@compiled/eslint-plugin 使用 Apache-2\.0 许可。宽松许可：允许商业使用、修改和再分发，并附带明确的专利授权；分发时需保留许可与 NOTICE 文件，修改过的文件要注明改动。以上为概括，不构成法律意见，请以许可原文为准。

### @compiled/eslint-plugin 的下载量有多少？

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

### @compiled/eslint-plugin 还在维护吗？

最新版本 0\.20\.2 发布于 2026/09/16（1 个月前）；至今共发布 52 个版本，其中过去 12 个月发布了 4 个；首次发布于 2021/11/04。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

