-
Notifications
You must be signed in to change notification settings - Fork 236
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: use types from
@typescript-eslint/utils
for snapshot proc…
…essor (#1504)
- Loading branch information
Showing
2 changed files
with
33 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
// https://eslint.org/docs/developer-guide/working-with-plugins#processors-in-plugins | ||
// https://github.com/typescript-eslint/typescript-eslint/issues/808 | ||
import type { TSESLint } from '@typescript-eslint/utils'; | ||
import { | ||
name as packageName, | ||
version as packageVersion, | ||
} from '../../package.json'; | ||
|
||
type PostprocessMessage = { ruleId: string }; | ||
type SnapshotProcessor = Required<TSESLint.Linter.Processor>; | ||
|
||
export const meta = { name: packageName, version: packageVersion }; | ||
export const preprocess = (source: string): string[] => [source]; | ||
export const postprocess = (messages: PostprocessMessage[][]) => | ||
export const preprocess: SnapshotProcessor['preprocess'] = source => [source]; | ||
export const postprocess: SnapshotProcessor['postprocess'] = messages => | ||
// snapshot files should only be linted with snapshot specific rules | ||
messages[0].filter(message => message.ruleId === 'jest/no-large-snapshots'); |