|
1 | 1 | import Module from "module"
|
2 | 2 | import path from "path"
|
3 |
| -import { VisitorKeys } from "svelte-eslint-parser" |
4 |
| -import type { SourceCode } from "../types" |
5 | 3 | import { createRule } from "../utils"
|
6 | 4 | import * as compiler from "svelte/compiler"
|
7 | 5 | import type typescript from "typescript"
|
@@ -120,14 +118,14 @@ export default createRule("valid-compile", {
|
120 | 118 | }
|
121 | 119 | }
|
122 | 120 |
|
123 |
| - const parserVisitorKeys = sourceCode.visitorKeys |
124 |
| - if (isEqualKeys(parserVisitorKeys, VisitorKeys)) { |
| 121 | + if (!context.parserServices.esTreeNodeToTSNodeMap) { |
125 | 122 | return {
|
126 | 123 | "Program:exit"() {
|
127 | 124 | report(getWarnings(text))
|
128 | 125 | },
|
129 | 126 | }
|
130 | 127 | }
|
| 128 | + |
131 | 129 | let ts: TS
|
132 | 130 | try {
|
133 | 131 | const createRequire: (filename: string) => (modName: string) => unknown =
|
@@ -375,37 +373,6 @@ export default createRule("valid-compile", {
|
375 | 373 | },
|
376 | 374 | })
|
377 | 375 |
|
378 |
| -/** |
379 |
| - * Checks if the given visitorKeys are the equals. |
380 |
| - */ |
381 |
| -function isEqualKeys( |
382 |
| - a: SourceCode["visitorKeys"], |
383 |
| - b: SourceCode["visitorKeys"], |
384 |
| -): boolean { |
385 |
| - const keysA = new Set(Object.keys(a)) |
386 |
| - const keysB = new Set(Object.keys(a)) |
387 |
| - if (keysA.size !== keysB.size) { |
388 |
| - return false |
389 |
| - } |
390 |
| - for (const key of keysA) { |
391 |
| - if (!keysB.has(key)) { |
392 |
| - return false |
393 |
| - } |
394 |
| - const vKeysA = new Set(a[key]) |
395 |
| - const vKeysB = new Set(b[key]) |
396 |
| - if (vKeysA.size !== vKeysB.size) { |
397 |
| - return false |
398 |
| - } |
399 |
| - |
400 |
| - for (const vKey of vKeysA) { |
401 |
| - if (!vKeysB.has(vKey)) { |
402 |
| - return false |
403 |
| - } |
404 |
| - } |
405 |
| - } |
406 |
| - return true |
407 |
| -} |
408 |
| - |
409 | 376 | /**
|
410 | 377 | * @see https://github.com/sveltejs/eslint-plugin-svelte3/blob/259263ccaf69c59e473d9bfa39706b0955eccfbd/src/preprocess.js#L194
|
411 | 378 | * MIT License @ Conduitry
|
|
0 commit comments