Skip to content

Commit e060061

Browse files
G-RathSimenB
authored andcommitted
chore(snapshot-processor): convert to typescript (#371)
1 parent b61ec87 commit e060061

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

src/processors/__tests__/snapshot-processor.test.js renamed to src/processors/__tests__/snapshot-processor.test.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,9 @@ describe('snapshot-processor', () => {
2222
it('should only return messages about snapshot specific rules', () => {
2323
const { postprocess } = snapshotProcessor;
2424
const result = postprocess([
25-
[
26-
{ ruleId: 'no-console' },
27-
{ ruleId: 'global-require' },
28-
{ ruleId: 'jest/no-large-snapshots' },
29-
],
25+
['no-console', 'global-require', 'jest/no-large-snapshots'].map(
26+
ruleId => ({ ruleId }),
27+
),
3028
]);
3129

3230
expect(result).toEqual([{ ruleId: 'jest/no-large-snapshots' }]);

src/processors/snapshot-processor.js

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/processors/snapshot-processor.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// https://eslint.org/docs/developer-guide/working-with-plugins#processors-in-plugins
2+
// https://github.com/typescript-eslint/typescript-eslint/issues/808
3+
4+
type PostprocessMessage = { ruleId: string };
5+
6+
export const preprocess = (source: string): string[] => [source];
7+
export const postprocess = (messages: PostprocessMessage[][]) =>
8+
// snapshot files should only be linted with snapshot specific rules
9+
messages[0].filter(message => message.ruleId === 'jest/no-large-snapshots');

0 commit comments

Comments
 (0)