@alleyinteractive/eslint-config

中文文档
0.2.0发布于 2025/07/22GPL-2.0-or-laterCommonJS近 30 天下载 1931

Alley's ESLint configuration

原始使用文档
文档目录14 节
  1. Background
  2. Releases
  3. Use
  4. TypeScript and Monorepo configuration
  5. From Source
  6. Changelog
  7. Development Process
  8. Contributing
  9. Project Structure
  10. Third-Party Dependencies
  11. Related Efforts
  12. Maintainers
  13. Contributors
  14. License

Alley's ESLint Configuration

standard README badge

Alley's standard ESLint configuration, which includes support for React, React Hooks, and TypeScript.

Background

This package leverages Airbnb's ESLint config and Airbnb Typescript along with Babel and Typescript ESLint parsers making it easy to configure JavaScript linting for projects that might also include React and TypeScript.

Releases

This package adheres to semantic versioning and is released on https://www.npmjs.com/.

Use

First, install the package from npm:

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

Next, choose a configuration from the available ESLint configurations.

This package exports four ESLint configurations for usage.

  1. @alleyinteractive/eslint-config - Default configuration that supports React.
  2. @alleyinteractive/eslint-config/base - Base configuration similar to Airbnb's base configuration without supporting React plugins.
  3. @alleyinteractive/eslint-config/typescript - Typescript support without React plugin support.
  4. @alleyinteractive/eslint-config/typescript-react - Typescript and React support.

Then create an .eslintrc.json file in your project that extends the configuration:

  {
    "extends": ["@alleyinteractive/eslint-config"]
  }

Finally, add lint commands to your package.json:

{
  "scripts": {
    "lint": "eslint --ext .ts,.tsx,.js,.jsx .",
    "lint:fix": "eslint --ext .ts,.tsx,.js,.jsx --fix ."
  }
}

If you are resolving your modules with the ESLint webpack import resolver, you will need to add the eslint-import-resolver-webpack package and settings configuration in your project:

npm install --save-dev eslint-import-resolver-webpack

You will also need to add the following to the projects .eslintrc.json file:

  "settings": {
    "import/resolver": "webpack"
  },

TypeScript and Monorepo configuration

TypeScript

For TypeScript projects, you will need to explicitly include files you would like to lint in your tsconfig.json file. One way of doing this is to extend the base `tsconfig.json`` file and provide specific configurations for ESLint.

  1. Create a tsconfig.eslint.json file in your project that extends the base tsconfig.json file.
  2. Add the allowImportingTsExtensions and noEmit compiler options to the compilerOptions object since this configuration is not for compiling TypeScript.
  3. Add the files you would like to lint to the include array.

Example of a tsconfig.eslint.json file:

{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "allowImportingTsExtensions": true,
    "noEmit": true,
  },
  "include": [
    "../jest.config.js",
    "../config/webpack.config.ts",
    "../utils",
    "../index.ts",
    "../.eslintrc.js",
    "../utils/index.test.ts",
    "../utils/webpack.test.ts"
  ]
}

Monorepo

If you're using a monorepo, there may be additional steps to setup typed linting.

This package uses the typescript-eslint parser and plugin to support TypeScript.

ESLint requires a tsconfig.json file to be present in the root of the project and typescript-eslint needs to find the tsconfig.json file that is used for linting.

If you have a specific tsconfig file for ESLint such as a tsconfig.eslint.json file you will need to specify the path to this file in the parserOptions.project setting in your .eslintrc.json file.

  "parserOptions": {
    "project": "./tsconfig.eslint.json"
  }

More details: https://typescript-eslint.io/linting/typed-linting/monorepos

In some cases where there is no tsconfig file in your project root you may need to convert your eslintrc file to JavaScript to pass in the node global of __dirname to the parserOptions.tsconfigRootDir setting.

// eslintrc.js
module.exports = {
  extends: ['@alleyinteractive/eslint-config/typescript'],
+  parserOptions: {
+    project: `./tsconfig.eslint.json`,
+    tsconfigRootDir: __dirname,
+  },
};

From Source

To work on this repository:

git clone [email protected]:alleyinteractive/alley-scripts.git
cd packages/eslint-config
npm ci

In order to test the config with another project, you will need to point to this package, e.g.:

{
  "devDependences": {
    "@alleyinteractive/eslint-config": "file:../path/to/alley-scripts/packages/eslint-config"
  }
}

Then simply run npm install and npm will symlink to this folder, and you can work on your changes.

Changelog

This project keeps a changelog.

Development Process

See instructions above on installing from source. Pull requests are welcome from the community and will be considered for inclusion. Releases follow semantic versioning and are shipped on an as-needed basis.

Contributing

See our contributor guidelines for instructions on how to contribute to this open source project.

Project Structure

This is an npm package that is published to https://www.npmjs.com/. Dependencies are defined in package.json and the ESLint configuration is found in index.js.

Third-Party Dependencies

Third party dependencies are managed by npm and are visible in package.json. This package intends to reduce the dependency load on projects that use it by managing the dependencies itself.

Maintainers

Alley logo

Contributors

Thanks to all of the contributors to this project.

License

This project is licensed under the GNU Public License (GPL) version 2 or later.

版本与发布记录

@alleyinteractive/eslint-config 共发布 10 个版本,首次发布于 2023/03/29;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.2.0latest2025/07/221.3 年前
0.1.62024/02/282 年前
0.1.52023/11/302 年前
0.1.42023/09/253 年前
0.1.32023/09/233 年前
0.1.22023/08/173 年前

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

@alleyinteractive/eslint-config 是什么?

Alley's ESLint configuration

如何安装 @alleyinteractive/eslint-config?

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

@alleyinteractive/eslint-config 支持 TypeScript 吗?

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

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

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

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

@alleyinteractive/eslint-config 使用 GPL-2.0-or-later 许可。强 Copyleft:分发包含该代码的软件时,整个作品需以兼容的 GPL 许可开源。仅在内部使用、不对外分发时不触发此义务。以上为概括,不构成法律意见,请以许可原文为准。

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

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

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

最新版本 0.2.0 发布于 2025/07/22(1.3 年前);至今共发布 10 个版本,其中过去 12 个月发布了 0 个;首次发布于 2023/03/29。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。