$ show Factory-AI/eslint-plugin
This repository is an ESLint plugin (`@factory/eslint-plugin`) developed by Factory AI. It provides a suite of custom lint rules and shared configurations designed to enforce strict code organization, testing, and logging conventions. The codebase is fully AI-generated and explicitly unmaintained, intended for inspiration rather than direct import. It demonstrates high craftsmanship in AST manipulation (e.g., `jest-mock-require-actual`, `structured-logging` rules with auto-fix) and complex configuration curation (e.g., `frontend.js` config with extensive `no-restricted-syntax` selectors banning specific React/Next.js patterns). The rules enforce a highly opinionated architecture, including specific file naming conventions (`.page.tsx`, `.module.tsx`), mandatory middleware in route handlers, and structured logging over template literals. While the code quality and test coverage are strong, the plugin is technically drifted (ESLint 8.x API, TypeScript 5.x) and relies on outdated dependencies, limiting its direct applicability without significant modernization.
The LLM identified 4 files worth highlighting for reuse:
Enforces that `jest.mock()` calls include `jest.requireActual()` to prevent auto-mocking all exports. Demonstrates advanced AST traversal to recursively search for `jest.requireActual` calls within complex nested structures (arrow functions, blocks, spreads). Includes an auto-fix feature that generates the correct mock factory or removes pointless mocks. This is a highly reusable pattern for any Jest-based project struggling with brittle mocks.
Enforces structured logging by detecting template literals and string concatenation in calls to `logError`, `logException`, etc. It parses the template to extract static message parts and dynamic expressions, then provides an auto-fix that converts the call to a structured format (e.g., `logError('Failed to process request', { requestId })`). This solves a common observability anti-pattern and is easily adaptable to any logging framework.
Enforces that filenames match their exported React component or function name. Handles complex edge cases like special file suffixes (`.page.tsx`, `.module.tsx`, `.layout.tsx`, `.view.tsx`, `.provider.tsx`) and intelligently suggests the correct filename (e.g., `SessionsPage` in `SessionsPage.tsx` suggests `Sessions.page.tsx`). This is a robust, self-contained rule for enforcing strict file-to-export naming conventions.
A highly opinionated ESLint configuration for React/Next.js projects. It is not a simple list of rules but a carefully curated set of constraints using `no-restricted-syntax` to ban specific patterns like `useEffect`, `Promise.then()`, `window.location` manipulation, and direct `<a>` tags without `target="_blank"`. It also integrates `@eslint-react` and `react-compiler` rules. This config represents a specific, aggressive architectural stance and is a valuable reference for teams looking to enforce strict frontend conventions.