Skip to content

Commit 1051c12

Browse files
authored
feat: Merge pull request #3 from nickmccurdy/add-recommended-config
Add recommended config
2 parents 95cf425 + d60a4a4 commit 1051c12

File tree

2 files changed

+38
-18
lines changed

2 files changed

+38
-18
lines changed

README.md

+27-18
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,34 @@ Add `jest-dom` to the plugins section of your `.eslintrc` configuration file. Yo
2424

2525
```json
2626
{
27-
"plugins": [
28-
"jest-dom"
29-
]
27+
"plugins": ["jest-dom"]
3028
}
3129
```
3230

33-
3431
Then configure the rules you want to use under the rules section.
3532

3633
```json
3734
{
38-
"rules": {
39-
"jest-dom/prefer-checked": "error",
40-
"jest-dom/prefer-enabled-disabled": "error",
41-
"jest-dom/prefer-required": "error"
42-
}
35+
"rules": {
36+
"jest-dom/prefer-checked": "error",
37+
"jest-dom/prefer-enabled-disabled": "error",
38+
"jest-dom/prefer-required": "error"
39+
}
40+
}
41+
```
42+
43+
## Recommended Configuration
44+
45+
This plugin exports a recommended configuration that enforces good
46+
`jest-dom` practices _(you can find more info about enabled rules
47+
in [Supported Rules section](#supported-rules))_.
48+
49+
To enable this configuration use the `extends` property in your
50+
`.eslintrc` config file:
51+
52+
```json
53+
{
54+
"extends": ["plugin:jest-dom/recommended"]
4355
}
4456
```
4557

@@ -50,14 +62,11 @@ Then configure the rules you want to use under the rules section.
5062
🛠 indicates that a rule is fixable.
5163

5264
<!-- __BEGIN AUTOGENERATED TABLE__ -->
53-
Name | ✔️ | 🛠 | Description
54-
----- | ----- | ----- | -----
55-
[prefer-checked](https://github.com/testing-library/eslint-plugin-jest-dom/blob/master/docs/rules/prefer-checked.md) | ✔️ | 🛠 | prefer toBeChecked over checking attributes
56-
[prefer-enabled-disabled](https://github.com/testing-library/eslint-plugin-jest-dom/blob/master/docs/rules/prefer-enabled-disabled.md) | ✔️ | 🛠 | prefer toBeDisabled or toBeEnabled over checking attributes
57-
[prefer-required](https://github.com/testing-library/eslint-plugin-jest-dom/blob/master/docs/rules/prefer-required.md) | ✔️ | 🛠 | prefer toBeRequired over checking properties
58-
<!-- __END AUTOGENERATED TABLE__ -->
59-
60-
61-
6265

66+
| Name | ✔️ | 🛠 | Description |
67+
| -------------------------------------------------------------------------------------------------------------------------------------- | --- | --- | ----------------------------------------------------------- |
68+
| [prefer-checked](https://github.com/testing-library/eslint-plugin-jest-dom/blob/master/docs/rules/prefer-checked.md) | ✔️ | 🛠 | prefer toBeChecked over checking attributes |
69+
| [prefer-enabled-disabled](https://github.com/testing-library/eslint-plugin-jest-dom/blob/master/docs/rules/prefer-enabled-disabled.md) | ✔️ | 🛠 | prefer toBeDisabled or toBeEnabled over checking attributes |
70+
| [prefer-required](https://github.com/testing-library/eslint-plugin-jest-dom/blob/master/docs/rules/prefer-required.md) | ✔️ | 🛠 | prefer toBeRequired over checking properties |
6371

72+
<!-- __END AUTOGENERATED TABLE__ -->

lib/index.js

+11
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,14 @@ let requireIndex = require('requireindex');
1616

1717
// import all rules in lib/rules
1818
module.exports.rules = requireIndex(__dirname + '/rules');
19+
20+
module.exports.configs = {
21+
recommended: {
22+
plugins: ['jest-dom'],
23+
rules: {
24+
'jest-dom/prefer-checked': 'error',
25+
'jest-dom/prefer-enabled-disabled': 'error',
26+
'jest-dom/prefer-required': 'error',
27+
},
28+
},
29+
};

0 commit comments

Comments
 (0)