@exercism/eslint-config-typescript

中文文档
0.8.0发布于 2024/08/15MITES Module近 30 天下载 4346

ESLint configuration for the TypeScript track on Exercism

原始使用文档
文档目录5 节
  1. Usage
  2. Students configuration
  3. Maintainers configuration
  4. Tooling configuration
  5. Development

@exercism/eslint-config-typescript

This is the shared eslint configuration used by the TypeScript track (for students) and the files contributors and maintainers touch. Shareable configs are designed to work with the extends feature of ESLint configuration files. This means you can use the same configuration you're used to on Exercism in your on projects!

Usage

To use the configuration for students, open your eslint configuration file, and import the following file for the flat config. For example, for flat config configuration files:

import baseConfig from '@exercism/eslint-config-typescript';

// ...
export default [
  ...baseConfig,
  // ... your configuration
];

To use the configuration used by contributors and maintainers, add the following:

import baseConfig from '@exercism/eslint-config-typescript/maintainers';

// ...
export default [
  ...baseConfig,
  // ... your configuration
];

Students configuration

Find the student configuration here. Its goal is to help detect and prevent common problems, without making any decisions about code-style.

The rules are based on:

  • eslint:recommended
  • A few extra rules that catch common issues but are not enabled via the recommended plugin. See this PR for a bit of discussion and rationale.
  • Adding TypeScript specific rules.

Because the Exercism TypeScript track is primarily focussing on running the exercises on Node, only node globals are turned on in the environment, but when extending this configuration, you can add more (or turn those off).

Maintainers configuration

Similar to the students configuration, and found here, it also includes the prettier plugin because we use prettier to achieve consistent code formatting. This plugin turns off rules that conflict with formatting.

Additionally, it doesn't have warnings but errors for most/all of the rules in the students configuration.

Tooling configuration

Because the tooling (such as the TypeScript Analyzer, Representer, and Test Runner) are written in TypeScript, they don't use the same configuration files. If you're looking for those, or to build your own tools in TypeScript, go to @exercism/eslint-config-tooling.

Development

If you want to work on this repository, install the dependencies using corepack and yarn:

corepack enable yarn
corepack yarn install

# or similar, see yarn documentation
# https://yarnpkg.com/getting-started/editor-sdks
corepack yarn dlx @yarnpkg/sdks vscode

版本与发布记录

@exercism/eslint-config-typescript 共发布 13 个版本,首次发布于 2021/06/16;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.8.0latest2024/08/152 年前
0.7.12024/07/292 年前
0.7.02024/07/292 年前
0.6.02023/07/073 年前
0.5.02023/06/063 年前
0.4.12022/02/214 年前

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

@exercism/eslint-config-typescript 是什么?

ESLint configuration for the TypeScript track on Exercism

如何安装 @exercism/eslint-config-typescript?

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

@exercism/eslint-config-typescript 支持 TypeScript 吗?

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

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

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

@exercism/eslint-config-typescript 可以商用吗?

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

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

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

@exercism/eslint-config-typescript 还在维护吗?

最新版本 0.8.0 发布于 2024/08/15(2 年前);至今共发布 13 个版本,其中过去 12 个月发布了 0 个;首次发布于 2021/06/16。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。