@apify/eslint-config

中文文档
2.0.6发布于 2026/04/11ISCCommonJS构建来源已验证近 30 天下载 7.3万

ESLint configuration shared across projects in Apify.

原始使用文档

apify-eslint-config

This repository contains a shared eslint config used across Apify. It offers several configs:

  • JavaScript config @apify/eslint-config/js
  • TypeScript config that also includes JavaScript config @apify/eslint-config/ts
  • Jest config that only applies to test files and folders @apify/eslint-config/jest
  • Vitest config that only applies to test files and folders @apify/eslint-config/vitest
  • Opt-in stylistic rules @apify/eslint-config/style (see below)

How to add to your project

First install the packages as development dependencies:

npm install --save-dev @apify/eslint-config eslint

Optionally, you can install:

  • typescript-eslint if you intend to use TypeScript,
  • eslint-plugin-jest if you intend to use Jest for testing,
  • @vitest/eslint-plugin if you intend to use Vitest for testing.

Add eslint.config.js file, here's an example configuration for a TypeScript project using ESM and Jest for tests:

import apifyTypescriptConfig from '@apify/eslint-config/ts';
// Optional
import apifyJestConfig from '@apify/eslint-config/jest';

export default [
    ...apifyTypescriptConfig,
    ...apifyJestConfig,
    {
        languageOptions: {
            sourceType: 'module',
            parserOptions: {
                projectService: true,
                tsconfigRootDir: import.meta.dirname,
            },
        },
    },
];

An example configuration for a JavaScript project using CommonJS without Jest:

const apifyJsConfig = require('@apify/eslint-config/js');

module.exports = [
    ...apifyJsConfig,
];

An example configuration for a JavaScript project using ESM and Vitest for tests:

import apifyJsConfig from '@apify/eslint-config/js';
import apifyVitestConfig from '@apify/eslint-config/vitest';

export default [
    ...apifyJsConfig,
    ...apifyVitestConfig,
];

Stylistic rules (opt-in)

The base config does not enforce stylistic / formatting rules — Prettier (or any other formatter) is the recommended way to handle those. If you have a strong reason not to use a formatter and want to keep the airbnb-style stylistic ruleset, install @stylistic/eslint-plugin and add the opt-in @apify/eslint-config/style config:

npm install --save-dev @stylistic/eslint-plugin
import apifyTypescriptConfig from '@apify/eslint-config/ts';
import apifyStyleConfig from '@apify/eslint-config/style';

export default [
    ...apifyTypescriptConfig,
    ...apifyStyleConfig,
];

This adds 58 stylistic rules (indent, quotes, semi, comma-dangle, space-before-blocks, keyword-spacing, max-len, etc.) with the same options eslint-config-airbnb-base used to enforce, rewritten as @stylistic/* rules so they work with eslint v9 + flat config. If you're using Prettier, do not include this config — the rules will conflict with your formatter.

版本与发布记录

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

版本发布日期距今
2.0.6latest2026/04/116 个月前
2.0.52026/04/116 个月前
2.0.42026/04/106 个月前
2.0.32026/04/096 个月前
2.0.22026/04/096 个月前
2.0.12026/04/096 个月前

其他发布通道:beta → 1.1.1-beta.0。

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

@apify/eslint-config 是什么?

ESLint configuration shared across projects in Apify.

如何安装 @apify/eslint-config?

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

@apify/eslint-config 支持 TypeScript 吗?

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

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

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

@apify/eslint-config 可以商用吗?

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

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

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

@apify/eslint-config 还在维护吗?

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