Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove snapshot processor and flat/snapshot config #1532

Merged
merged 1 commit into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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.