Skip to content

Commit

Permalink
chore(snapshot-processor): convert to typescript (#371)
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Rath authored and SimenB committed Aug 6, 2019
1 parent b61ec87 commit e060061
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
Expand Up @@ -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' }]);
Expand Down
8 changes: 0 additions & 8 deletions src/processors/snapshot-processor.js

This file was deleted.

9 changes: 9 additions & 0 deletions 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');

0 comments on commit e060061

Please sign in to comment.