Testing Library Preset for ESLint
This package provides a predefined, opinionated ESLint configuration suitable for any TypeScript-based web project with Testing Library tests.
This preset configures a subset of rules from the following plugin, which is installed along with the preset package:
-
eslint-plugin-testing-library (with rule names prefixed by
testing-library/
)
Installation
Install the @rainstormy/presets-eslint-testing-library
package and its peer dependencies:
npm install --save-dev @rainstormy/presets-eslint-testing-library @rainstormy/presets-eslint eslint typescript
pnpm install --save-dev @rainstormy/presets-eslint-testing-library @rainstormy/presets-eslint eslint typescript
yarn add --dev @rainstormy/presets-eslint-testing-library @rainstormy/presets-eslint eslint typescript
Usage
Create or extend a flat ESLint configuration file (eslint.config.js
) and apply the eslintPresetTestData
and eslintPresetTestingLibrary
presets.
For example (with the default options in comments):
import {
eslintPresetTestData,
eslintPresets,
} from "@rainstormy/presets-eslint"
import { eslintPresetTestingLibrary } from "@rainstormy/presets-eslint-testing-library"
export default eslintPresets({
additionalPresets: [
// ...other presets...
eslintPresetTestData({
// targetFilePatterns: [
// "**/*.@(spec|specs|stories|test|testdata|tests).@(js|jsx|ts|tsx)",
// ],
}),
eslintPresetTestingLibrary({
// targetFilePatterns: ["**/*.@(spec|specs|test|tests).@(jsx|tsx)"],
}),
],
})