Skip to content

Commit

Permalink
feat(no-large-snapshots): remove whitelistedSnapshots option
Browse files Browse the repository at this point in the history
BREAKING CHANGE
  • Loading branch information
G-Rath authored and SimenB committed Sep 4, 2020
1 parent 0385aac commit 8c1c0c9
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 59 deletions.
41 changes: 0 additions & 41 deletions src/rules/__tests__/no-large-snapshots.test.ts
Expand Up @@ -210,27 +210,6 @@ ruleTester.run('no-large-snapshots', rule, {
},
],
},
{
// "should not report whitelisted large snapshots based on regexp"
filename: '/mock-component.jsx.snap',
code: [
generateExportsSnapshotString(58, 'a big component w/ text'),
generateExportsSnapshotString(58, 'a big component 2'),
].join('\n\n'),
options: [
{
whitelistedSnapshots: {
'/mock-component.jsx.snap': [/a big component \d+/u],
},
},
],
errors: [
{
messageId: 'tooLongSnapshots',
data: { lineLimit: 50, lineCount: 58 },
},
],
},
{
filename: '/mock-component.jsx.snap',
code: [
Expand All @@ -251,26 +230,6 @@ ruleTester.run('no-large-snapshots', rule, {
},
],
},
{
filename: '/mock-component.jsx.snap',
code: [
generateExportsSnapshotString(58, 'a big component w/ text'),
generateExportsSnapshotString(58, 'a big component 2'),
].join('\n\n'),
options: [
{
whitelistedSnapshots: {
'/mock-component.jsx.snap': ['a big component 2'],
},
},
],
errors: [
{
messageId: 'tooLongSnapshots',
data: { lineLimit: 50, lineCount: 58 },
},
],
},
],
});

Expand Down
19 changes: 1 addition & 18 deletions src/rules/no-large-snapshots.ts
Expand Up @@ -15,7 +15,6 @@ interface RuleOptions {
maxSize?: number;
inlineMaxSize?: number;
allowedSnapshots?: Record<string, Array<string | RegExp>>;
whitelistedSnapshots?: Record<string, Array<string | RegExp>>;
}

type MessageId = 'noSnapshot' | 'tooLongSnapshots';
Expand All @@ -25,11 +24,7 @@ type RuleContext = TSESLint.RuleContext<MessageId, [RuleOptions]>;
const reportOnViolation = (
context: RuleContext,
node: TSESTree.CallExpression | TSESTree.ExpressionStatement,
{
maxSize: lineLimit = 50,
whitelistedSnapshots = {},
allowedSnapshots = whitelistedSnapshots,
}: RuleOptions,
{ maxSize: lineLimit = 50, allowedSnapshots = {} }: RuleOptions,
) => {
const startLine = node.loc.start.line;
const endLine = node.loc.end.line;
Expand Down Expand Up @@ -103,25 +98,13 @@ export default createRule<[RuleOptions], MessageId>({
type: 'object',
additionalProperties: { type: 'array' },
},
whitelistedSnapshots: {
type: 'object',
patternProperties: {
'.*': { type: 'array' },
},
},
},
additionalProperties: false,
},
],
},
defaultOptions: [{}],
create(context, [options]) {
if ('whitelistedSnapshots' in options) {
console.warn(
'jest/no-large-snapshots: the "whitelistedSnapshots" option has been renamed to "allowedSnapshots"',
);
}

if (context.getFilename().endsWith('.snap')) {
return {
ExpressionStatement(node) {
Expand Down

0 comments on commit 8c1c0c9

Please sign in to comment.