Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(utils): revert removal of backwards-compat functions #8399

Merged
merged 1 commit into from
Feb 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
48 changes: 48 additions & 0 deletions packages/utils/src/eslint-utils/context.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Wrappers around ESLint's deprecation of existing methods
/* eslint-disable deprecation/deprecation -- TODO - delete in the next major (v8) */
import type { Scope, SourceCode } from '../ts-eslint';
import type { RuleContext } from '../ts-eslint/Rule';
import type { TSESTree } from '../ts-estree';

/** @deprecated use `context.sourceCode.getAncestors(node)` */
export function getAncestors(
context: Readonly<RuleContext<string, unknown[]>>,
): TSESTree.Node[] {
return context.getAncestors();

Check warning on line 11 in packages/utils/src/eslint-utils/context.ts

View check run for this annotation

Codecov / codecov/patch

packages/utils/src/eslint-utils/context.ts#L11

Added line #L11 was not covered by tests
}

/** @deprecated use `context.sourceCode.getCwd()` */
export function getCwd(
context: Readonly<RuleContext<string, unknown[]>>,
): string {
return context.getCwd();

Check warning on line 18 in packages/utils/src/eslint-utils/context.ts

View check run for this annotation

Codecov / codecov/patch

packages/utils/src/eslint-utils/context.ts#L18

Added line #L18 was not covered by tests
}

/** @deprecated use `context.sourceCode.getDeclaredVariables(node)` */
export function getDeclaredVariables(
context: Readonly<RuleContext<string, unknown[]>>,
node: TSESTree.Node,
): readonly Scope.Variable[] {
return context.sourceCode.getDeclaredVariables(node);

Check warning on line 26 in packages/utils/src/eslint-utils/context.ts

View check run for this annotation

Codecov / codecov/patch

packages/utils/src/eslint-utils/context.ts#L26

Added line #L26 was not covered by tests
}

/** @deprecated use `context.filename` */
export function getFilename(
context: Readonly<RuleContext<string, unknown[]>>,
): string {
return context.filename;

Check warning on line 33 in packages/utils/src/eslint-utils/context.ts

View check run for this annotation

Codecov / codecov/patch

packages/utils/src/eslint-utils/context.ts#L33

Added line #L33 was not covered by tests
}

/** @deprecated use `context.sourceCode.getScope(node) */
export function getScope(
context: Readonly<RuleContext<string, readonly unknown[]>>,
): Scope.Scope {
return context.getScope();

Check warning on line 40 in packages/utils/src/eslint-utils/context.ts

View check run for this annotation

Codecov / codecov/patch

packages/utils/src/eslint-utils/context.ts#L40

Added line #L40 was not covered by tests
}

/** @deprecated use `context.sourceCode` */
export function getSourceCode(
context: Readonly<RuleContext<string, readonly unknown[]>>,
): Readonly<SourceCode> {
return context.sourceCode;

Check warning on line 47 in packages/utils/src/eslint-utils/context.ts

View check run for this annotation

Codecov / codecov/patch

packages/utils/src/eslint-utils/context.ts#L47

Added line #L47 was not covered by tests
}