@factory/eslint-plugin

中文文档
0.1.0发布于 2026/02/04MITCommonJS近 30 天下载 1.2万

ESLint plugin with configurations and custom rules for Factory projects

原始使用文档
文档目录17 节
  1. About This Project
  2. How to Use This Repository
  3. Available Configurations
  4. Configuration Hierarchy
  5. Factory Plugin Rules
  6. File Organization
  7. Naming & Exports
  8. Testing
  9. Logging
  10. API Routes (Next.js/Express)
  11. React
  12. Installation
  13. Quick Start
  14. For TypeScript packages/libraries
  15. For frontend applications (React/Vite)
  16. For backend applications
  17. License

@factory/eslint-plugin

An open-source ESLint plugin showcasing how agent-native organizations use custom lint rules to drive AI coding agents toward better results.

About This Project

This codebase is forked from what is used internally at Factory and has been altered to be more generic. We are sharing this as requested by the developer community and to showcase an example of what an agent-native organization does with custom lint rules to improve agent output quality.

All code in this repository is fully AI-generated.

To learn more about our approach:

How to Use This Repository

Our recommendation is NOT to simply import this package. Instead, take the ideas from these rules and build your own set of custom lint rules tailored to your codebase, tech stack, and conventions.

We have included comprehensive markdown documentation for each rule (in rules/<rule-name>/README.md) that makes it easy for any AI agent to parse and adapt to your custom tech stack or framework.

Note: This repository is not planned to be actively maintained or updated. It is designed for sharing and inspiration only.

Available Configurations

ConfigUse CaseDescription
plugin:@factory/baseBaseCore TypeScript/JavaScript rules
plugin:@factory/recommendedPackages/LibrariesBase + Factory plugin rules
plugin:@factory/frontendReact/Vite appsRecommended + React/JSX rules
plugin:@factory/backendBackend appsRecommended + backend constraints

Configuration Hierarchy

graph TD
    A[base] --> B[recommended]
    B --> C[frontend]
    B --> D[backend]

Factory Plugin Rules

This plugin includes custom rules that enforce code organization and best practices:

File Organization

  • @factory/enum-file-organization - Enums must live in enums.ts files
  • @factory/types-file-organization - Type definitions must live in types.ts files
  • @factory/constants-file-organization - Constants must live in constants.ts files
  • @factory/errors-file-organization - Error classes must live in errors.ts files
  • @factory/test-utils-organization - Test utilities must live under test-utils/
  • @factory/test-file-location - Test files must be colocated with source files

Naming & Exports

  • @factory/filename-match-export - Filenames must match exported components/functions
  • @factory/no-exported-function-expressions - Prefer function declarations for exports
  • @factory/no-exported-string-union-types - Prefer enums over string union types

Testing

  • @factory/require-test-files - TypeScript files must have corresponding test files
  • @factory/require-tsx-test-stories-files - TSX files need test and story files
  • @factory/jest-mock-absolute-paths - Jest mocks must use absolute paths
  • @factory/jest-mock-require-actual - Jest mocks must include jest.requireActual()
  • @factory/no-unstable-mock-module - Disallow unstable_mockModule

Logging

  • @factory/structured-logging - Enforce structured logging patterns
  • @factory/no-log-exception-with-throw - No logging exceptions before throwing

API Routes (Next.js/Express)

  • @factory/require-route-middleware - Route files must use middleware
  • @factory/require-v0-route-handle-middleware - v0 routes need specific middleware
  • @factory/require-v0-strict-schemas - v0 routes need strict schema validation

React

  • @factory/no-dynamic-styled-components - No dynamic styled-components
  • @factory/no-plain-html-text-elements - No plain text in HTML elements
  • @factory/no-use-effect-in-hooks - Restrict useEffect in custom hooks
  • @factory/restrict-tsx-components - Enforce component patterns

Installation

npm install @factory/eslint-plugin eslint --save-dev

Quick Start

Create an .eslintrc.js file in your project root:

For TypeScript packages/libraries

module.exports = {
  root: true,
  plugins: ['@factory'],
  extends: ['plugin:@factory/recommended'],
};

For frontend applications (React/Vite)

module.exports = {
  root: true,
  plugins: ['@factory'],
  extends: ['plugin:@factory/frontend'],
};

For backend applications

module.exports = {
  root: true,
  plugins: ['@factory'],
  extends: ['plugin:@factory/backend'],
};

License

MIT

版本与发布记录

@factory/eslint-plugin 共发布 1 个版本,首次发布于 2026/02/04;过去 12 个月发布了 1 个版本。

版本发布日期距今
0.1.0latest2026/02/049 个月前

关于 @factory/eslint-plugin 的常见问题

@factory/eslint-plugin 是什么?

ESLint plugin with configurations and custom rules for Factory projects

如何安装 @factory/eslint-plugin?

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

@factory/eslint-plugin 支持 TypeScript 吗?

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

@factory/eslint-plugin 支持 ESM 还是 CommonJS?

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

@factory/eslint-plugin 需要什么版本的 Node.js?

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

@factory/eslint-plugin 可以商用吗?

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

@factory/eslint-plugin 的下载量有多少?

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

@factory/eslint-plugin 还在维护吗?

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