diff --git a/src/processors/__tests__/snapshot-processor.test.js b/src/processors/__tests__/snapshot-processor.test.ts similarity index 86% rename from src/processors/__tests__/snapshot-processor.test.js rename to src/processors/__tests__/snapshot-processor.test.ts index 787f6182d..b4a807af5 100644 --- a/src/processors/__tests__/snapshot-processor.test.js +++ b/src/processors/__tests__/snapshot-processor.test.ts @@ -22,11 +22,9 @@ describe('snapshot-processor', () => { it('should only return messages about snapshot specific rules', () => { const { postprocess } = snapshotProcessor; const result = postprocess([ - [ - { ruleId: 'no-console' }, - { ruleId: 'global-require' }, - { ruleId: 'jest/no-large-snapshots' }, - ], + ['no-console', 'global-require', 'jest/no-large-snapshots'].map( + ruleId => ({ ruleId }), + ), ]); expect(result).toEqual([{ ruleId: 'jest/no-large-snapshots' }]); diff --git a/src/processors/snapshot-processor.js b/src/processors/snapshot-processor.js deleted file mode 100644 index f49843073..000000000 --- a/src/processors/snapshot-processor.js +++ /dev/null @@ -1,8 +0,0 @@ -// https://eslint.org/docs/developer-guide/working-with-plugins#processors-in-plugins -export const preprocess = source => [source]; - -export const postprocess = messages => - messages[0].filter( - // snapshot files should only be linted with snapshot specific rules - message => message.ruleId === 'jest/no-large-snapshots', - ); diff --git a/src/processors/snapshot-processor.ts b/src/processors/snapshot-processor.ts new file mode 100644 index 000000000..8bf53fc33 --- /dev/null +++ b/src/processors/snapshot-processor.ts @@ -0,0 +1,9 @@ +// https://eslint.org/docs/developer-guide/working-with-plugins#processors-in-plugins +// https://github.com/typescript-eslint/typescript-eslint/issues/808 + +type PostprocessMessage = { ruleId: string }; + +export const preprocess = (source: string): string[] => [source]; +export const postprocess = (messages: PostprocessMessage[][]) => + // snapshot files should only be linted with snapshot specific rules + messages[0].filter(message => message.ruleId === 'jest/no-large-snapshots');