# @cordova/eslint-config 中文文档

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

版本：6\.0\.1
npm 元数据更新时间：2026-02-18T04:35:15.611Z
中文译文更新时间：2026-11-10T18:46:00.142Z
软件包许可：Apache-2\.0

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

原始 npm 页面：https://www.npmjs.com/package/%40cordova/eslint-config
原文对照：https://npmcn.com/package/%40cordova/eslint-config/?lang=original
项目主页：https://github.com/apache/cordova-eslint#readme
源码仓库：https://github.com/apache/cordova-eslint

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

- 包体积（解压后）：45.3 kB，17 个文件
- 模块格式：CommonJS
- TypeScript 类型：未声明
- Node.js 要求：\>=20\.9\.0
- 运行依赖：5 个
- 首次发布：2019-11-09T15:19:52.893Z
- 最新版本发布：2026-02-18T04:35:15.268Z
- 近 30 天下载量：81376（2026-10-11 至 2026-11-09，npm 官方下载统计）
- 已发布版本数：8（近 12 个月 1 个）

## 中文简介

Cordova ESLint 配置

## 安装

```sh
npm install @cordova/eslint-config
```

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

## README

# @cordova/eslint-config

[![NPM](https://nodei.co/npm/@cordova/eslint-config.svg?style=flat&data=n,v,u&color=blue)](https://www.npmjs.com/package/@cordova/eslint-config)

[![Node CI](https://github.com/apache/cordova-eslint/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/apache/cordova-eslint/actions/workflows/ci.yml?query=branch%3Amaster) [![Release Audit](https://github.com/apache/cordova-eslint/actions/workflows/release-audit.yml/badge.svg?branch=master)](https://github.com/apache/cordova-eslint/actions/workflows/release-audit.yml?query=branch%3Amaster) [![codecov.io](https://codecov.io/github/apache/cordova-eslint/coverage.svg?branch=master)](https://codecov.io/github/apache/cordova-eslint?branch=master)

这个寄存器集中了用于 Cordova 开发的 ESLint 配置, 具体地说, 以 `apache/cordova-`。 。 。 .

## 安装

`@cordova/eslint-config` 包含所有插件配置甚至 `eslint` 自己来 所以,你只需要做 开始是:

```shell
npm i -D @cordova/eslint-config
```

## 使用量

```yml
# In package.json
{
  "scripts": {
    "lint": "eslint"
  }
}
```

```javascript
// In eslint.config.js
const { defineConfig, globalIgnores } = require('eslint/config');
const nodeConfig = require('@cordova/eslint-config/node');
const nodeTestConfig = require('@cordova/eslint-config/node-tests');
const browserConfig = require('@cordova/eslint-config/browser');

module.exports = defineConfig([
    globalIgnores([
        // Add files or folders to ignore...
        // For example: exclude everything in the "coverage" directory.
        'coverage'
    ]),

    // Node Linting
    ...nodeConfig.map(config => ({
        files: [
            // Add files or folders to check...
            // For example: include everything in the "lib" directory.
            // By default, ESLint lints files with extensions .js, .mjs & .cjs.
            'lib'
        ],

        // Spread each shared config to preserve its settings while extending or overriding specific properties
        ...config
    })),

    // Node Test Linting
    ...nodeTestConfig.map(config => ({
        // Add files or folders to check...
        // For example: include everything in the "spec" directory.
        // By default, ESLint lints files with extensions .js, .mjs & .cjs.
        files: [
            'spec'
        ],

        // Spread each shared config to preserve its settings while extending or overriding specific properties
        ...config,

        // Overriding Rules
        rules: {
            // Make sure the original rules are applied
            ...(config.rules || {}),

            // Then append or update rules
            'prefer-promise-reject-errors': 'off'
        }
    })),

    // Browser Linting
    ...browserConfig.map(config => ({
        files: [
            // Add files or folders to check...
            // For Example: Platforms usuall has "cordova-js-src" that comiles down into a cordova.js file to runs in the app's WebView.
            'cordova-js-src'
        ],

        // Spread each shared config to preserve its settings while extending or overriding specific properties
        ...config,

        // Overriding Language Options
        languageOptions: {

            // Make sure the original languageOptions are applied if existing
            ...(config?.languageOptions || {}),

            // Overriding Global
            globals: {
                // Make sure the original languageOptions.globals are applied
                ...(config.languageOptions?.globals || {})

                // Then append or update globals
                require: 'readonly',
                module: 'readonly',
            }
        }
    }))
]);
```

## 参考文献

此套件会曝光以下可共享的 ESLint 配置 :

### `@cordova/eslint-config/node` (或简单 `@cordova`(中文(简体) )

对于想与Node.js一起运行的林廷脚本.

### `@cordova/eslint-config/node-tests`

用于对克多瓦节点的"茉莉花"作测试. js脚本.

### `@cordova/eslint-config/browser`

对于想在浏览器中运行的linting codova-style CommunityJS模块(在被捆绑之前).

### `@cordova/eslint-config/browser-tests`

用于Linting Jasmine测试 Cordova的浏览器代码.

## 常见问题

### @cordova/eslint-config 是什么？

Cordova ESLint 配置

### 如何安装 @cordova/eslint-config？

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

### @cordova/eslint-config 支持 TypeScript 吗？

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

### @cordova/eslint-config 支持 ESM 还是 CommonJS？

以 CommonJS 形式发布，可以直接 require\(\)；在 ES Module 项目中也可以用 import 引入（Node\.js 会把 module\.exports 作为默认导出）。

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

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

### @cordova/eslint-config 可以商用吗？

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

### @cordova/eslint-config 的下载量有多少？

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

### @cordova/eslint-config 还在维护吗？

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

