Repository: eslint/eslint
File: tests/lib/types/types.test.ts (TypeScript)

Code before:
            "MemberExpression[object.name=\"req\"]": (node: Rule.Node) => {
                node.parent;
            },
            PrivateIdentifier(node) {
                const expected: PrivateIdentifier & Rule.NodeParentExtension = node;
                expected.parent;
            },
            PropertyDefinition(node) {
                const expected: PropertyDefinition & Rule.NodeParentExtension = node;
                expected.parent;
            },
            StaticBlock(node) {
                const expected: StaticBlock & Rule.NodeParentExtension = node;
                expected.parent;
            },
        };
    },
};

type DeprecatedRuleContextKeys = "getAncestors" | "getDeclaredVariables" | "getScope" | "markVariableAsUsed";
(): RuleDefinition => ({
    create(context) {
        // Ensure that deprecated RuleContext methods are not defined when using RuleDefinition
        context satisfies {
            [Key in keyof typeof context]: Key extends DeprecatedRuleContextKeys ? never : typeof context[Key];
        };
        return {};
    }
});

// #endregion

// #region Linter

const linter = new Linter();
const eslinter = new ESLinter();

linter.version;

linter.verify(SOURCE, {});
linter.verify(new SourceCode(SOURCE, AST), {});

linter.verify(SOURCE, {}, "test.js");
linter.verify(SOURCE, {}, {});
linter.verify(SOURCE, {}, { filename: "test.js" });
linter.verify(SOURCE, {}, { allowInlineConfig: false });
linter.verify(SOURCE, {}, { reportUnusedDisableDirectives: true });
linter.verify(SOURCE, {}, { preprocess: input => input.split(" ") });
linter.verify(SOURCE, {}, { postprocess: problemList => problemList[0] });

linter.verify(SOURCE, { parserOptions: { ecmaVersion: 2021 } }, "test.js");

Review comment (suggestion):
Is there any minimum typescript version that we support? `satisies` was introduced in [v4.9.0](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-9.html)

Code after:
	create(context: Rule.RuleContext) {
		context.getAncestors();

		context.getDeclaredVariables(AST);

		context.filename;

		context.getFilename();

		context.physicalFilename;

		context.getPhysicalFilename();

		context.cwd;

		context.getCwd();

		context.languageOptions;
		context.languageOptions
			.ecmaVersion satisfies Linter.LanguageOptions["ecmaVersion"];

		context.sourceCode;
		context.sourceCode.getLocFromIndex(42);

		context.getSourceCode();
		context.getSourceCode().getLocFromIndex(42);

		context.getScope();

		if (typeof context.parserPath === "string") {
			context.parserPath;
		} else {
			context.languageOptions?.parser;
		}

		context.markVariableAsUsed("foo");

		// @ts-expect-error wrong `node` type
		context.report({ message: "foo", node: {} });

		context.report({ message: "foo", node: AST });
		context.report({
			message: "foo",
			loc: { start: { line: 0, column: 0 }, end: { line: 1, column: 1 } },
		});
		context.report({ message: "foo", node: AST, data: { foo: "bar" } });
		context.report({ message: "foo", node: AST, fix: () => null });
		context.report({
			message: "foo",
			node: AST,
			fix: ruleFixer => ruleFixer.replaceText(AST, "foo"),