Skip to content

Commit

Permalink
feat: remove snapshot processor and flat/snapshot config
Browse files Browse the repository at this point in the history
BREAKING CHANGE: removed `snapshot` processor and `flat/snapshot` config
  • Loading branch information
G-Rath committed Mar 23, 2024
1 parent 4d6f79a commit 5921d9b
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 128 deletions.
29 changes: 0 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,35 +275,6 @@ While the `recommended` and `style` configurations only change in major versions
the `all` configuration may change in any release and is thus unsuited for
installations requiring long-term consistency.

## Snapshot processing

> [!NOTE]
>
> This is only relevant for `eslint.config.js`
This plugin provides a
[custom processor](https://eslint.org/docs/latest/extend/custom-processors) to
allow rules to "lint" snapshot files.

For `.eslintrc` based configs, this is automatically enabled out of the box but
must be opted into for `eslint.config.js` using the `flat/snapshots` config:

```js
const jest = require('eslint-plugin-jest');

module.exports = [
{
...jest.configs['flat/snapshots'],
rules: {
'jest/no-large-snapshots': ['error', { maxSize: 1 }],
},
},
];
```

Unlike other configs, this includes a `files` array that matches `.snap` files
meaning you can use it directly

## Rules

<!-- begin auto-generated rules list -->
Expand Down
14 changes: 0 additions & 14 deletions src/__tests__/__snapshots__/rules.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -193,20 +193,6 @@ exports[`rules should export configs that refer to actual rules 1`] = `
"jest/valid-title": "error",
},
},
"flat/snapshots": {
"files": [
"**/*.snap",
],
"plugins": {
"jest": ObjectContaining {
"meta": {
"name": "eslint-plugin-jest",
"version": Any<String>,
},
},
},
"processor": "jest/snapshots",
},
"flat/style": {
"languageOptions": {
"globals": {
Expand Down
2 changes: 0 additions & 2 deletions src/__tests__/rules.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ describe('rules', () => {
'flat/recommended': { plugins: { jest: expectJestPlugin } },
'flat/style': { plugins: { jest: expectJestPlugin } },
'flat/all': { plugins: { jest: expectJestPlugin } },
'flat/snapshots': { plugins: { jest: expectJestPlugin } },
});
expect(Object.keys(recommendedConfigs)).toEqual([
'all',
Expand All @@ -70,7 +69,6 @@ describe('rules', () => {
'flat/all',
'flat/recommended',
'flat/style',
'flat/snapshots',
]);
expect(Object.keys(recommendedConfigs.all.rules)).toHaveLength(
ruleNames.length - deprecatedRules.length,
Expand Down
14 changes: 1 addition & 13 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
version as packageVersion,
} from '../package.json';
import globals from './globals.json';
import * as snapshotProcessor from './processors/snapshot-processor';

type RuleModule = TSESLint.RuleModule<string, unknown[]> & {
meta: Required<Pick<TSESLint.RuleMetaData<string>, 'docs'>>;
Expand Down Expand Up @@ -76,19 +75,14 @@ const plugin = {
| 'style'
| 'flat/all'
| 'flat/recommended'
| 'flat/style'
| 'flat/snapshots',
| 'flat/style',
Pick<Required<TSESLint.Linter.Config>, 'rules'>
>,
environments: {
globals: {
globals,
},
},
processors: {
snapshots: snapshotProcessor,
'.snap': snapshotProcessor,
},
rules,
};

Expand All @@ -113,12 +107,6 @@ plugin.configs = {
'flat/all': createFlatConfig(allRules),
'flat/recommended': createFlatConfig(recommendedRules),
'flat/style': createFlatConfig(styleRules),
'flat/snapshots': {
// @ts-expect-error this is introduced in flat config
files: ['**/*.snap'],
plugins: { jest: plugin },
processor: 'jest/snapshots',
},
};

export = plugin;
55 changes: 0 additions & 55 deletions src/processors/__tests__/snapshot-processor.test.ts

This file was deleted.

15 changes: 0 additions & 15 deletions src/processors/snapshot-processor.ts

This file was deleted.

0 comments on commit 5921d9b

Please sign in to comment.