Skip to content

Commit 8c1c0c9

Browse files
G-RathSimenB
authored andcommitted
feat(no-large-snapshots): remove whitelistedSnapshots option
BREAKING CHANGE
1 parent 0385aac commit 8c1c0c9

File tree

2 files changed

+1
-59
lines changed

2 files changed

+1
-59
lines changed

src/rules/__tests__/no-large-snapshots.test.ts

-41
Original file line numberDiff line numberDiff line change
@@ -210,27 +210,6 @@ ruleTester.run('no-large-snapshots', rule, {
210210
},
211211
],
212212
},
213-
{
214-
// "should not report whitelisted large snapshots based on regexp"
215-
filename: '/mock-component.jsx.snap',
216-
code: [
217-
generateExportsSnapshotString(58, 'a big component w/ text'),
218-
generateExportsSnapshotString(58, 'a big component 2'),
219-
].join('\n\n'),
220-
options: [
221-
{
222-
whitelistedSnapshots: {
223-
'/mock-component.jsx.snap': [/a big component \d+/u],
224-
},
225-
},
226-
],
227-
errors: [
228-
{
229-
messageId: 'tooLongSnapshots',
230-
data: { lineLimit: 50, lineCount: 58 },
231-
},
232-
],
233-
},
234213
{
235214
filename: '/mock-component.jsx.snap',
236215
code: [
@@ -251,26 +230,6 @@ ruleTester.run('no-large-snapshots', rule, {
251230
},
252231
],
253232
},
254-
{
255-
filename: '/mock-component.jsx.snap',
256-
code: [
257-
generateExportsSnapshotString(58, 'a big component w/ text'),
258-
generateExportsSnapshotString(58, 'a big component 2'),
259-
].join('\n\n'),
260-
options: [
261-
{
262-
whitelistedSnapshots: {
263-
'/mock-component.jsx.snap': ['a big component 2'],
264-
},
265-
},
266-
],
267-
errors: [
268-
{
269-
messageId: 'tooLongSnapshots',
270-
data: { lineLimit: 50, lineCount: 58 },
271-
},
272-
],
273-
},
274233
],
275234
});
276235

src/rules/no-large-snapshots.ts

+1-18
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ interface RuleOptions {
1515
maxSize?: number;
1616
inlineMaxSize?: number;
1717
allowedSnapshots?: Record<string, Array<string | RegExp>>;
18-
whitelistedSnapshots?: Record<string, Array<string | RegExp>>;
1918
}
2019

2120
type MessageId = 'noSnapshot' | 'tooLongSnapshots';
@@ -25,11 +24,7 @@ type RuleContext = TSESLint.RuleContext<MessageId, [RuleOptions]>;
2524
const reportOnViolation = (
2625
context: RuleContext,
2726
node: TSESTree.CallExpression | TSESTree.ExpressionStatement,
28-
{
29-
maxSize: lineLimit = 50,
30-
whitelistedSnapshots = {},
31-
allowedSnapshots = whitelistedSnapshots,
32-
}: RuleOptions,
27+
{ maxSize: lineLimit = 50, allowedSnapshots = {} }: RuleOptions,
3328
) => {
3429
const startLine = node.loc.start.line;
3530
const endLine = node.loc.end.line;
@@ -103,25 +98,13 @@ export default createRule<[RuleOptions], MessageId>({
10398
type: 'object',
10499
additionalProperties: { type: 'array' },
105100
},
106-
whitelistedSnapshots: {
107-
type: 'object',
108-
patternProperties: {
109-
'.*': { type: 'array' },
110-
},
111-
},
112101
},
113102
additionalProperties: false,
114103
},
115104
],
116105
},
117106
defaultOptions: [{}],
118107
create(context, [options]) {
119-
if ('whitelistedSnapshots' in options) {
120-
console.warn(
121-
'jest/no-large-snapshots: the "whitelistedSnapshots" option has been renamed to "allowedSnapshots"',
122-
);
123-
}
124-
125108
if (context.getFilename().endsWith('.snap')) {
126109
return {
127110
ExpressionStatement(node) {

0 commit comments

Comments
 (0)