Skip to content

Commit

Permalink
fix: replace usage of deprecated Context#getFilename
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Rath committed Jan 1, 2024
1 parent 86197f6 commit 375e6b6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/rules/no-large-snapshots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
import {
createRule,
getAccessorValue,
getFilename,
isSupportedAccessor,
parseJestFnCall,
} from './utils';
Expand Down Expand Up @@ -46,7 +47,7 @@ const reportOnViolation = (
node.expression.left.type === AST_NODE_TYPES.MemberExpression &&
isSupportedAccessor(node.expression.left.property)
) {
const fileName = context.getFilename();
const fileName = getFilename(context);
const allowedSnapshotsInFile = allowedSnapshots[fileName];

if (allowedSnapshotsInFile) {
Expand Down
8 changes: 8 additions & 0 deletions src/rules/utils/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,14 @@ export const getFirstMatcherArg = (
return followTypeAssertionChain(firstArg);
};

export const getFilename = (
context: TSESLint.RuleContext<string, unknown[]>,
) => {
return 'filename' in context
? (context.filename as string)
: context.getFilename();
};

export const getSourceCode = (
context: TSESLint.RuleContext<string, unknown[]>,
) => {
Expand Down

0 comments on commit 375e6b6

Please sign in to comment.