Skip to content

Commit cafd6c7

Browse files
committed
refactor: exclude new rules from recommended config
New rules (prefer-pressed, prefer-partially-pressed, prefer-partially-checked) are in the 'all' config only, avoiding a breaking change for existing users.
1 parent 5357791 commit cafd6c7

File tree

9 files changed

+18
-16
lines changed

9 files changed

+18
-16
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,9 @@ module.exports = [
130130
| [prefer-enabled-disabled](docs/rules/prefer-enabled-disabled.md) | prefer toBeDisabled or toBeEnabled over checking attributes || 🔧 | |
131131
| [prefer-focus](docs/rules/prefer-focus.md) | prefer toHaveFocus over checking document.activeElement || 🔧 | |
132132
| [prefer-in-document](docs/rules/prefer-in-document.md) | Prefer .toBeInTheDocument() for asserting the existence of a DOM node || 🔧 | 💡 |
133-
| [prefer-partially-checked](docs/rules/prefer-partially-checked.md) | prefer toBePartiallyChecked over checking aria-checked for mixed state | | 🔧 | |
134-
| [prefer-partially-pressed](docs/rules/prefer-partially-pressed.md) | prefer toBePartiallyPressed over checking aria-pressed for mixed state | | 🔧 | |
135-
| [prefer-pressed](docs/rules/prefer-pressed.md) | prefer toBePressed over checking attributes | | 🔧 | |
133+
| [prefer-partially-checked](docs/rules/prefer-partially-checked.md) | prefer toBePartiallyChecked over checking aria-checked for mixed state | | 🔧 | |
134+
| [prefer-partially-pressed](docs/rules/prefer-partially-pressed.md) | prefer toBePartiallyPressed over checking aria-pressed for mixed state | | 🔧 | |
135+
| [prefer-pressed](docs/rules/prefer-pressed.md) | prefer toBePressed over checking attributes | | 🔧 | |
136136
| [prefer-required](docs/rules/prefer-required.md) | prefer toBeRequired over checking properties || 🔧 | |
137137
| [prefer-to-have-attribute](docs/rules/prefer-to-have-attribute.md) | prefer toHaveAttribute over checking getAttribute/hasAttribute || 🔧 | |
138138
| [prefer-to-have-class](docs/rules/prefer-to-have-class.md) | prefer toHaveClass over checking element className || 🔧 | |

docs/rules/prefer-partially-checked.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Prefer toBePartiallyChecked over checking attributes (`jest-dom/prefer-partially-checked`)
22

3-
💼 This rule is enabled in the `recommended` config.
3+
💼 This rule is enabled in the `all` config.
44

55
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
66

docs/rules/prefer-partially-pressed.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Prefer toBePartiallyPressed over checking attributes (`jest-dom/prefer-partially-pressed`)
22

3-
💼 This rule is enabled in the `recommended` config.
3+
💼 This rule is enabled in the `all` config.
44

55
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
66

docs/rules/prefer-pressed.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Prefer toBePressed over checking attributes (`jest-dom/prefer-pressed`)
22

3-
💼 This rule is enabled in the `recommended` config.
3+
💼 This rule is enabled in the `all` config.
44

55
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
66

src/__tests__/index.test.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ it("has the expected recommended config", () => {
3131
jest-dom/prefer-enabled-disabled: error,
3232
jest-dom/prefer-focus: error,
3333
jest-dom/prefer-in-document: error,
34-
jest-dom/prefer-partially-checked: error,
35-
jest-dom/prefer-partially-pressed: error,
36-
jest-dom/prefer-pressed: error,
3734
jest-dom/prefer-required: error,
3835
jest-dom/prefer-to-have-attribute: error,
3936
jest-dom/prefer-to-have-class: error,
@@ -71,9 +68,6 @@ it("has the expected recommended flat config", () => {
7168
jest-dom/prefer-enabled-disabled: error,
7269
jest-dom/prefer-focus: error,
7370
jest-dom/prefer-in-document: error,
74-
jest-dom/prefer-partially-checked: error,
75-
jest-dom/prefer-partially-pressed: error,
76-
jest-dom/prefer-pressed: error,
7771
jest-dom/prefer-required: error,
7872
jest-dom/prefer-to-have-attribute: error,
7973
jest-dom/prefer-to-have-class: error,

src/index.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,15 @@ const allRules = Object.entries(rules).reduce(
2828
{}
2929
);
3030

31-
const recommendedRules = allRules;
31+
const newRules = [
32+
"jest-dom/prefer-pressed",
33+
"jest-dom/prefer-partially-pressed",
34+
"jest-dom/prefer-partially-checked",
35+
];
36+
37+
const recommendedRules = Object.fromEntries(
38+
Object.entries(allRules).filter(([name]) => !newRules.includes(name))
39+
);
3240

3341
const plugin = {
3442
meta: {

src/rules/prefer-partially-checked.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const meta = {
99
description:
1010
"prefer toBePartiallyChecked over checking aria-checked attribute for mixed state",
1111
category: "Best Practices",
12-
recommended: true,
12+
recommended: false,
1313
url: "prefer-partially-checked",
1414
},
1515
fixable: "code",

src/rules/prefer-partially-pressed.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const meta = {
99
description:
1010
"prefer toBePartiallyPressed over checking aria-pressed attribute for mixed state",
1111
category: "Best Practices",
12-
recommended: true,
12+
recommended: false,
1313
url: "prefer-partially-pressed",
1414
},
1515
fixable: "code",

src/rules/prefer-pressed.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const meta = {
88
docs: {
99
description: "prefer toBePressed over checking attributes",
1010
category: "Best Practices",
11-
recommended: true,
11+
recommended: false,
1212
url: "prefer-pressed",
1313
},
1414
fixable: "code",

0 commit comments

Comments
 (0)