@1password/eslint-config

中文文档
9.2.0发布于 2026/06/11ISCES Module近 30 天下载 3666

1Password’s shared ESLint configuration.

原始使用文档
文档目录5 节
  1. Getting Started
  2. Customizing ESLint Rules
  3. Config Format
  4. Integrating ESLint with Your Editor
  5. Philosophy

@1password/eslint-config

1Password’s shared ESLint configs:

  • javascript: for vanilla JavaScript
  • typescript: for TypeScript
  • react: for React + TypeScript
  • disabled-formatting-rules: for disabling deprecated ESLint formatting rules

Getting Started

  1. Navigate to the root of your project. Note that the root is wherever your manifest (or package.json) file lives, and that can be a subdirectory or the root of your repo.

  2. Use your project’s package manager to install @1password/eslint-config and ESLint:

pnpm add --save-dev @1password/eslint-config eslint
npm install --save-dev @1password/eslint-config eslint
yarn add --dev @1password/eslint-config eslint
  1. Add an eslint.config.mjs file, if one does not yet exist:
touch eslint.config.mjs
  1. Extend the appropriate ESLint config you need in your eslint.config.mjs file. The typescript-eslint package includes a nice config function that helps apply file rules to extended configs.
// Base config
import opLintConfig from "@1password/eslint-config";
// Alternatively, import `opLintConfig` from one of the other shared
// configurations listed above, according to the needs of your web project.
//
// For example, if your repo is a React project:
// import opLintConfig from "@1password/eslint-config/react";
import tseslint from "typescript-eslint";

export default tseslint.config({
    extends: [opLintConfig],
    files: ["src/**/*.ts"],
    // other settings
});
  1. If needed, disable the formatting rules that have been deprecated in (but not yet removed from) ESLint, will be deprecated in typescript-eslint, and might be deprecated in eslint-plugin-react, by extending the config in which the formatting rules have been turned off:
import opLintConfig from "@1password/eslint-config";
import disabledFormattingRules from "@1password/eslint-config/disabled-formatting-rules";

// Base Config
export default tseslint.config({
    extends: [opLintConfig, disabledFormattingRules],
    // other settings
});

If the custom config can’t disable all of the formatting rules in your project, see if you’re using an ESLint plugin that isn’t included in @1password/eslint-config, but is included in this list:

  https://github.com/prettier/eslint-config-prettier#plugins

If you are, you’ll be able to turn off that plugin’s formatting rules through eslint-config-prettier instead of the custom config.

Customizing ESLint Rules

You can customize the ESLint configuration by adding or overriding specific rules in your eslint.config.mjs file. This is useful when your project has unique linting needs that differ from the defaults provided by @1password/eslint-config.

  1. If your project does not use React, extend @1password/eslint-config and add or override rules under rules. Example:
import opLintConfig from "@1password/eslint-config";
import tseslint from "typescript-eslint";

export default tseslint.config({
    extends: [opLintConfig],
    rules: {
        "@typescript-eslint/switch-exhaustiveness-check": "error",
        "no-console": ["error", { allow: ["warn", "error"] }],
        // ...more rules
    },
});
  1. If your project uses React, extend @1password/eslint-config/react and add or override React specific rules under rules. Example:
import opLintConfig from "@1password/eslint-config/react";
import tseslint from "typescript-eslint";

export default tseslint.config({
    extends: [opLintConfig],
    rules: {
        "react/react-in-jsx-scope": "off",
        "react/prop-types": "off",
        // ...more rules
    },
});
  1. If your project requires additional ESLint plugins not included in @1password/eslint-config, install them separately and declare them in the eslint.config.mjs. For example, adding eslint-plugin-vitest for Vitest testing rules:
pnpm add --save-dev eslint-plugin-vitest

Then update your eslint.config.mjs file:

import opLintConfig from "@1password/eslint-config/react";
import tseslint from "typescript-eslint";
import vitest from "eslint-plugin-vitest";

export default tseslint.config({
    extends: [opLintConfig],
    plugins: { vitest },
    rules: {
        "vitest/no-focused-tests": "error",
    },
});

Config Format

In ESLint v9, the default config format has changed to "flat config", which is what you see above. See the docs for more information about migrating to the new format.

Integrating ESLint with Your Editor

If you want to integrate ESLint with your IDE or text editor so that you can have your JavaScript and TypeScript code linted as you code, visit

  https://eslint.org/docs/latest/use/integrations#editors

to see which integrations are currently supported.

Philosophy

Discussions around this package have caused us to identify a sort of philosophy to guide how we manage rules. The current state of the package may not meet these ideals completely.

  1. Changes must consider that this package is intended to be used in every TypeScript project at 1Password. Thus, changes shouldn't focus on the needs of one particular project, and they should be kept as uncontroversial as possible, while considering that hundreds of people will rarely fully agree about anything.

  2. If a rules package has broad acceptance within the JS/TS community, its recommended ruleset should be extended (e.g. eslint.configs.recommended), with minimal overrides as needed. See ./internal/eslint.js for an example.

  3. If a rules package has a recommended set containing a good portion of controversial/preferential rules, that set should not be extended. Enable individual rules instead of enabling an entire set of rules and then disabling controversial rules. See ./internal/sonar.js for an example.

版本与发布记录

@1password/eslint-config 共发布 57 个版本,首次发布于 2023/04/22;过去 12 个月发布了 3 个版本。

版本发布日期距今
9.2.0latest2026/06/114 个月前
9.1.02026/05/235 个月前
9.0.0-test.3test2026/04/296 个月前
9.0.02025/10/101.1 年前
9.0.0-test.22025/10/091.1 年前
9.0.0-test.12025/10/081.1 年前

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

@1password/eslint-config 是什么?

1Password’s shared ESLint configuration.

如何安装 @1password/eslint-config?

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

@1password/eslint-config 支持 TypeScript 吗?

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

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

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

@1password/eslint-config 可以商用吗?

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

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

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

@1password/eslint-config 还在维护吗?

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