eslint-etc provides a collection of utility functions designed primarily to aid in the implementation and testing of custom ESLint rules, particularly those targeting TypeScript codebases. The current stable version is 5.2.1. While there isn't a stated release cadence, updates are typically made as needed for new features, bug fixes, or compatibility with newer ESLint and TypeScript versions. A key differentiator is the `fromFixture` utility, which enables a TSLint-like fixture testing approach for ESLint rules. This simplifies the creation of test cases by allowing developers to directly annotate expected error locations and messages within multiline code strings, abstracting away the need for explicit line and column numbers. This library is largely used by its author for their own suite of ESLint rules, indicating a practical, developer-focused design, though documentation can be light for external users.
npm install eslint-etcVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `fromFixture` with `@typescript-eslint/rule-tester` to simplify the testing of a custom ESLint rule that disallows `const` declarations. It shows how to define a rule and then write test cases using annotated code snippets instead of explicit line and column numbers.
Always consult the package's changelog or release notes for specific migration guides when upgrading between major versions.
For advanced usage or unclear scenarios, it's often necessary to review the package's source code or examine how the author uses these utilities in their own ESLint rule projects.
Ensure your ESLint configuration includes `parser: '@typescript-eslint/parser'` and, for type-aware rules, `parserOptions.project` is correctly set to point to your `tsconfig.json` file.
Add `import { fromFixture } from 'eslint-etc';` (or the relevant symbol) to the top of your test file to ensure the utility is available.