@codeyourfuture/eslint-config-standard

中文文档
8.1.1发布于 2026/02/19ISCTypeScriptES Module构建来源已验证近 30 天下载 5974

A standard ESLint configuration for all CYF examples/projects.

原始使用文档
文档目录5 节
  1. Versioning
  2. Usage
  3. Principles
  4. Rules
  5. Development

CYF ESLint Configuration

License Build Status NPM Version

A standard ESLint configuration for all CYF examples/projects.

Versioning

This configuration uses SemVer, interpreted as follows:

  • Patch release (x.y.z -> x.y.z+1): bugfixes and tooling updates mean that code that previously passed linting should continue to pass after the update.

  • Minor release (x.y.z -> x.y+1.0): a change to an existing rule means that code that previously failed linting may now pass, or a new configuration means that code that previously passed linting should continue to pass.

  • Major release (x.y.z -> x+1.0.0): a new rule, or a change to an existing rule, means that code that previously passed linting will not pass any more.

Please bear these definitions in mind when reporting any bugs.

Usage

Install this package along with ESLint itself:

npm install --save-dev eslint @codeyourfuture/eslint-config-standard

Then create an ESLint config file and add this config:

import cyf from "@codeyourfuture/eslint-config-standard";

export default [...cyf.configs.standard];

Alternatively, for a slightly more permissive set of rules, you can use cyf.configs.lax.

You can also call cyf.configure with some rules to add/override your own settings:

export default [...cyf.configure({
  // ...
})];

Principles

  1. Errors only - don't teach learners to ignore any output, all rules should either be "error" or "off"
  2. Maximise consistency - where there are options (e.g. braces for single-line statements, parentheses around arrow function parameters), be consistent with the non-optional cases
  3. Minimise change set size - keep commits small so learners can focus on the important changes

Rules

This config starts from the ESLint and Stylistic recommended rules then adds the following:

ConfigurationRuleSettingPrinciples/rationale
standard, lax@stylistic/arrow-parens2, 3
standard, lax@stylistic/brace-style"1tbs", { "allowSingleLine": false }
standard, lax@stylistic/comma-dangle"always-multiline"3
standard@stylistic/indent"tab", { "SwitchCase": 1 }Tabs are more accessible
standard@stylistic/linebreak-style"unix"
standard, lax@stylistic/no-trailing-spaces
standard, lax@stylistic/object-curly-spacing"always"
standard, lax@stylistic/operator-linebreak"before"
standard, lax@stylistic/quote-props"as-needed"3
standard, lax@stylistic/quotes"double", { "avoidEscape": true, "allowTemplateLiterals": false }More likely to need ' inside a string than "
standard, lax@stylistic/semiLearners shouldn't have to memorise the ASI rules
standard, laxcurly2
standard, laxno-unused-vars{ "ignoreRestSiblings": true }
standard, laxno-varStick with let and const for more predictable behaviour

Development

You can clone this repo and run npm install to install the development dependencies. Two scripts are provided:

  • lint: uses the version of ESLint installed as a dev dependency to lint index.js against its own rules.

  • test:examples: runs bin/examples.sh to test the configuration against the pass.js and fail.js examples in examples/. pass.js contains code that should pass linting according to the configuration, fail.js contains code that should fail linting.

  • test:install: runs bin/test.sh to create a package, installs ESLint (version defined by the required environment variable ESLINT_VERSION) and the current version of this configuration, then checks that there are no version conflicts and lints index.js. E.g. ESLINT_VERSION=9 npm run test:install will test that this configuration works with the latest version of ESLint 9.

版本与发布记录

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

版本发布日期距今
8.1.1latest2026/02/198 个月前
8.1.02026/02/198 个月前
8.0.02025/11/3011 个月前
7.0.22025/11/2911 个月前
7.0.02025/02/101.7 年前
6.0.12025/01/161.8 年前

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

@codeyourfuture/eslint-config-standard 是什么?

A standard ESLint configuration for all CYF examples/projects.

如何安装 @codeyourfuture/eslint-config-standard?

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

@codeyourfuture/eslint-config-standard 支持 TypeScript 吗?

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

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

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

@codeyourfuture/eslint-config-standard 需要什么版本的 Node.js?

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

@codeyourfuture/eslint-config-standard 可以商用吗?

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

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

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

@codeyourfuture/eslint-config-standard 还在维护吗?

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