Skip to content

Commit 75b71d4

Browse files
authored
Merge branch 'main' into fix--infinite-loop
2 parents 7fbb9e9 + f92689e commit 75b71d4

39 files changed

+20
-344959
lines changed

Diff for: tests/fixtures/parser/ast/await04-scope-output.json

-9,318
Large diffs are not rendered by default.

Diff for: tests/fixtures/parser/ast/docs/template-syntax/11-element-directives/07-transition-fn/05-ts-scope-output.json

-9,366
Large diffs are not rendered by default.

Diff for: tests/fixtures/parser/ast/i18n-test-scope-output.json

-9,318
Large diffs are not rendered by default.

Diff for: tests/fixtures/parser/ast/issue325-eslint-plugin-svelte-scope-output.json

-9,342
Large diffs are not rendered by default.

Diff for: tests/fixtures/parser/ast/issue338-eslint-plugin-svelte-scope-output.json

-9,318
Large diffs are not rendered by default.

Diff for: tests/fixtures/parser/ast/reactive-with-var04-ts-scope-output.json

-9,318
Large diffs are not rendered by default.

Diff for: tests/fixtures/parser/ast/ts-$$props01-scope-output.json

-9,318
Large diffs are not rendered by default.

Diff for: tests/fixtures/parser/ast/ts-$$slots01-scope-output.json

-9,318
Large diffs are not rendered by default.

Diff for: tests/fixtures/parser/ast/ts-$$slots02-no-slot-scope-output.json

-9,318
Large diffs are not rendered by default.

Diff for: tests/fixtures/parser/ast/ts-$$slots03-named-scope-output.json

-9,318
Large diffs are not rendered by default.

Diff for: tests/fixtures/parser/ast/ts-$$slots04-named-scope-output.json

-9,318
Large diffs are not rendered by default.

Diff for: tests/fixtures/parser/ast/ts-await-non-promise01-scope-output.json

-9,342
Large diffs are not rendered by default.

Diff for: tests/fixtures/parser/ast/ts-each01-scope-output.json

-9,318
Large diffs are not rendered by default.

Diff for: tests/fixtures/parser/ast/ts-event01-scope-output.json

-9,318
Large diffs are not rendered by default.

Diff for: tests/fixtures/parser/ast/ts-event02-scope-output.json

-9,318
Large diffs are not rendered by default.

Diff for: tests/fixtures/parser/ast/ts-event03-scope-output.json

-9,318
Large diffs are not rendered by default.

Diff for: tests/fixtures/parser/ast/ts-event04-scope-output.json

-9,318
Large diffs are not rendered by default.

Diff for: tests/fixtures/parser/ast/ts-event05-scope-output.json

-9,318
Large diffs are not rendered by default.

Diff for: tests/fixtures/parser/ast/ts-event06-scope-output.json

-9,318
Large diffs are not rendered by default.

Diff for: tests/fixtures/parser/ast/ts-issue226-scope-output.json

-9,342
Large diffs are not rendered by default.

Diff for: tests/fixtures/parser/ast/ts-let/ts-let01-scope-output.json

-9,318
Large diffs are not rendered by default.

Diff for: tests/fixtures/parser/ast/ts-newline-scope-output.json

-9,318
Large diffs are not rendered by default.

Diff for: tests/fixtures/parser/ast/ts-not-reactive01-scope-output.json

-9,318
Large diffs are not rendered by default.

Diff for: tests/fixtures/parser/ast/ts-promise01-scope-output.json

-9,342
Large diffs are not rendered by default.

Diff for: tests/fixtures/parser/ast/ts-promise02-scope-output.json

-9,318
Large diffs are not rendered by default.

Diff for: tests/fixtures/parser/ast/ts-reactive01-scope-output.json

-9,318
Large diffs are not rendered by default.

Diff for: tests/fixtures/parser/ast/ts-reactive02-scope-output.json

-9,318
Large diffs are not rendered by default.

Diff for: tests/fixtures/parser/ast/ts-reactive03-scope-output.json

-9,318
Large diffs are not rendered by default.

Diff for: tests/fixtures/parser/ast/ts-reactive04-scope-output.json

-9,318
Large diffs are not rendered by default.

Diff for: tests/fixtures/parser/ast/ts-reactive05-scope-output.json

-9,318
Large diffs are not rendered by default.

Diff for: tests/fixtures/parser/ast/ts-reactive06-scope-output.json

-9,318
Large diffs are not rendered by default.

Diff for: tests/fixtures/parser/ast/ts-scope-issue01-scope-output.json

-9,318
Large diffs are not rendered by default.

Diff for: tests/fixtures/parser/ast/ts-shorthand-attr01-scope-output.json

-9,318
Large diffs are not rendered by default.

Diff for: tests/fixtures/parser/ast/ts-store01-scope-output.json

-9,318
Large diffs are not rendered by default.

Diff for: tests/fixtures/parser/ast/ts-store02-scope-output.json

-9,318
Large diffs are not rendered by default.

Diff for: tests/fixtures/parser/ast/ts-store03-scope-output.json

-9,318
Large diffs are not rendered by default.

Diff for: tests/fixtures/parser/ast/ts-use01-scope-output.json

-9,366
Large diffs are not rendered by default.

Diff for: tests/src/parser/test-utils.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import type { Reference, Scope, ScopeManager, Variable } from "eslint-scope";
88
import type * as TSESScopes from "@typescript-eslint/scope-manager";
99
import type { SvelteNode } from "../../../src/ast";
1010
import type { StyleContext } from "../../../src";
11+
import { TS_GLOBALS } from "./ts-vars";
1112

1213
const AST_FIXTURE_ROOT = path.resolve(__dirname, "../../fixtures/parser/ast");
1314
const BASIC_PARSER_OPTIONS: Linter.ParserOptions = {
@@ -290,9 +291,14 @@ export function styleContextToJson(styleContext: StyleContext): string {
290291
}
291292

292293
function normalizeScope(scope: Scope | TSESScopes.Scope): any {
294+
let variables = scope.variables as TSESScopes.Variable[];
295+
if (scope.type === "global") {
296+
// Exclude well-known variables as they do not need to be tested.
297+
variables = variables.filter((v) => !TS_GLOBALS.includes(v.name));
298+
}
293299
return {
294300
type: scope.type,
295-
variables: scope.variables.map(normalizeVar),
301+
variables: variables.map(normalizeVar),
296302
references: scope.references.map(normalizeReference),
297303
childScopes: scope.childScopes.map(normalizeScope),
298304
through: scope.through.map(normalizeReference),

Diff for: tests/src/parser/ts-vars.ts

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import * as parser from "@typescript-eslint/parser";
2+
import * as scope from "@typescript-eslint/scope-manager";
3+
4+
const result = parser.parseForESLint("", { lib: ["lib", "esnext", "dom"] });
5+
const scopeManager =
6+
result.scopeManager ??
7+
scope.analyze(result.ast as any, {
8+
lib: ["lib", "esnext", "dom"],
9+
});
10+
11+
export const TS_GLOBALS = scopeManager
12+
.globalScope!.variables.map((v) => v.name)
13+
.sort();

0 commit comments

Comments
 (0)