@openreachtech/eslint-rules-default-jest
v2.0.1
Published
A showcasing package all the Jest plugin rules of ESLint.
Keywords
Readme
eslint-rules-default-jest
Language
Overview
This package provides ESLint Jest plugin rules with default options.
If this package is used as a base ruleset in another ESLint config repository, all rules are enabled by default. You must explicitly turn off each rule that you want to disable.
Rules deprecated in the plugin are kept out of the exported ruleset. Their default
options are documented in rules/deprecated.js and exported as deprecated instead.
The plugin carries no deprecated rule at present, so the exported ruleset holds every
rule of it. The two rulesets together always cover the whole plugin.
This package is only for Flat Config.
Usage
Installing
Install this package alongside ESLint v10 or greater:
npm install --save-dev \
eslint \
@openreachtech/eslint-rules-default-jestConfiguring
In your eslint.config.js file, import @openreachtech/eslint-rules-default-jest and include the all rules to use it:
// eslint.config.js
import jestPlugin from '@openreachtech/eslint-rules-default-jest'
export default [
{
...jestPlugin,
rules: {
...jestPlugin.rules,
'jest/consistent-test-it': [
'error',
{
fn: 'test',
withinDescribe: 'test', // 'it'
},
],
'jest/prefer-lowercase-title': [
'error',
{
ignore: [],
allowedPrefixes: [],
ignoreTopLevelDescribe: true, // false
ignoreTodos: false,
},
],
...
},
},
]Track of Changes with Line Comments
When overwriting default values in each ESLint Config package, we recommend leaving the default values as line comments.
// eslint.config.js
import jestPlugin from '@openreachtech/eslint-rules-default-jest'
export default [
{
...jestPlugin,
rules: {
...jestPlugin.rules,
'jest/consistent-test-it': [
'error',
{
fn: 'test',
withinDescribe: 'test', // 'it' <--- ✅
},
],
'jest/prefer-lowercase-title': [
'error',
{
ignore: [],
allowedPrefixes: [],
ignoreTopLevelDescribe: true, // false <--- ✅
ignoreTodos: false,
},
],
...
},
},
]License
This project is released under the Apache License 2.0.
See → LICENSE
Contributing
We welcome bug reports, feature requests, and ruleset contributions.
Please feel free to contact us through GitHub Issues or Pull Requests.
We strive to meet user expectations and your contributions are highly appreciated!
% git clone https://github.com/openreachtech/eslint-rules-default-jest.git
% cd eslint-rules-default-jest
% npm install
% npm run lint
% npm test