Skip to content

Commit 1360e9b

Browse files
committed
feat: deprecate prefer-inline-snapshots rule
1 parent a67d92d commit 1360e9b

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ installations requiring long-term consistency.
155155
| [prefer-called-with](docs/rules/prefer-called-with.md) | Suggest using `toBeCalledWith()` OR `toHaveBeenCalledWith()` | | |
156156
| [prefer-expect-assertions](docs/rules/prefer-expect-assertions.md) | Suggest using `expect.assertions()` OR `expect.hasAssertions()` | | |
157157
| [prefer-hooks-on-top](docs/rules/prefer-hooks-on-top.md) | Suggest to have all hooks at top level | | |
158-
| [prefer-inline-snapshots](docs/rules/prefer-inline-snapshots.md) | Suggest using inline snapshots | | ![fixable][] |
159158
| [prefer-spy-on](docs/rules/prefer-spy-on.md) | Suggest using `jest.spyOn()` | | ![fixable][] |
160159
| [prefer-strict-equal](docs/rules/prefer-strict-equal.md) | Suggest using toStrictEqual() | | ![fixable][] |
161160
| [prefer-to-be-null](docs/rules/prefer-to-be-null.md) | Suggest using `toBeNull()` | ![style][] | ![fixable][] |

docs/rules/prefer-inline-snapshots.md

+21
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
11
# Suggest using inline snapshots (`prefer-inline-snapshots`)
22

3+
## Deprecated
4+
5+
This rule has been deprecated in favor of
6+
[`no-restricted-matchers`](no-restricted-matchers.md) with the following config:
7+
8+
```json
9+
{
10+
"rules": {
11+
"jest/no-restricted-matchers": [
12+
"error",
13+
{
14+
"toThrowErrorMatchingSnapshot": "Use `toThrowErrorMatchingInlineSnapshot()` instead",
15+
"toMatchSnapshot": "Use `toMatchInlineSnapshot()` instead"
16+
}
17+
]
18+
}
19+
}
20+
```
21+
22+
---
23+
324
In order to make snapshot tests more managable and reviewable
425
`toMatchInlineSnapshot()` and `toThrowErrorMatchingInlineSnapshot` should be
526
used to write the snapshots inline in the test file.

src/rules/prefer-inline-snapshots.ts

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ export default createRule({
99
description: 'Suggest using inline snapshots',
1010
recommended: false,
1111
},
12+
deprecated: true,
13+
replacedBy: ['no-restricted-matchers'],
1214
messages: {
1315
toMatch: 'Use toMatchInlineSnapshot() instead',
1416
toMatchError: 'Use toThrowErrorMatchingInlineSnapshot() instead',

0 commit comments

Comments
 (0)