@gspothq/cli 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (205) hide show
  1. package/README.md +58 -11
  2. package/configurations/database/postgres/manifest.toml +51 -57
  3. package/configurations/database/postgres/rules/POSTGRES.md +14 -13
  4. package/configurations/framework/astro/manifest.toml +33 -35
  5. package/configurations/framework/astro/rules/ASTRO.md +2 -2
  6. package/configurations/framework/expo/manifest.toml +19 -19
  7. package/configurations/framework/express/manifest.toml +10 -4
  8. package/configurations/framework/express/rules/EXPRESS.md +9 -7
  9. package/configurations/framework/fastapi/manifest.toml +9 -3
  10. package/configurations/framework/fastapi/rules/FASTAPI.md +19 -18
  11. package/configurations/framework/nestjs/manifest.toml +12 -12
  12. package/configurations/framework/nestjs/rules/NESTJS.md +9 -9
  13. package/configurations/framework/nextjs/manifest.toml +39 -79
  14. package/configurations/framework/nextjs/rules/NEXTJS.md +9 -7
  15. package/configurations/framework/nextjs/tool-files/semgrep/nextjs.yml +35 -0
  16. package/configurations/framework/react/manifest.toml +33 -43
  17. package/configurations/framework/react/rules/REACT.md +14 -20
  18. package/configurations/framework/react-dom/manifest.toml +6 -6
  19. package/configurations/framework/react-native/manifest.toml +11 -11
  20. package/configurations/framework/react-native/rules/REACT-NATIVE.md +3 -5
  21. package/configurations/framework/site/manifest.toml +57 -110
  22. package/configurations/framework/site/rules/SITE.md +1 -1
  23. package/configurations/framework/svelte/manifest.toml +29 -31
  24. package/configurations/framework/svelte/rules/SVELTE.md +6 -6
  25. package/configurations/framework/vue/manifest.toml +37 -37
  26. package/configurations/framework/vue/rules/VUE.md +6 -6
  27. package/configurations/general/commits/manifest.toml +20 -84
  28. package/configurations/general/commits/rules/GIT.md +24 -13
  29. package/configurations/general/coverage/manifest.toml +1 -1
  30. package/configurations/general/dependencies/manifest.toml +47 -107
  31. package/configurations/general/dependencies/rules/DEPENDENCIES.md +13 -7
  32. package/configurations/general/docs/manifest.toml +28 -43
  33. package/configurations/general/docs/rules/DOCS.md +16 -9
  34. package/configurations/general/duplication/manifest.toml +12 -14
  35. package/configurations/general/engineering/manifest.toml +6 -2
  36. package/configurations/general/engineering/rules/agent/PLANNING.md +9 -6
  37. package/configurations/general/engineering/rules/agent/SUPPRESSIONS.md +20 -11
  38. package/configurations/general/engineering/rules/agent/TASKS.md +6 -2
  39. package/configurations/general/engineering/rules/agent/WORKING.md +34 -29
  40. package/configurations/general/engineering/rules/code/ACCESSIBILITY.md +9 -7
  41. package/configurations/general/engineering/rules/code/CLI.md +12 -9
  42. package/configurations/general/engineering/rules/code/COMMENTS.md +11 -1
  43. package/configurations/general/engineering/rules/code/CONFIGURATION.md +2 -0
  44. package/configurations/general/engineering/rules/code/ERRORS.md +5 -3
  45. package/configurations/general/engineering/rules/code/HTTP.md +9 -10
  46. package/configurations/general/engineering/rules/code/LOGGING.md +10 -9
  47. package/configurations/general/engineering/rules/code/TESTING.md +18 -11
  48. package/configurations/general/files/manifest.toml +45 -73
  49. package/configurations/general/files/rules/YAML.md +20 -10
  50. package/configurations/general/format/manifest.toml +53 -106
  51. package/configurations/general/gspot/manifest.toml +19 -39
  52. package/configurations/general/gspot/rules/GENERATED.md +14 -4
  53. package/configurations/general/licenses/manifest.toml +12 -14
  54. package/configurations/general/naming/defaults.json +14 -13
  55. package/configurations/general/naming/manifest.toml +17 -17
  56. package/configurations/general/naming/rules/NAMING.md +87 -67
  57. package/configurations/general/prose/manifest.toml +166 -25
  58. package/configurations/general/prose/rules/WRITING.md +6 -2
  59. package/configurations/general/repository/manifest.toml +12 -12
  60. package/configurations/general/secrets/manifest.toml +52 -73
  61. package/configurations/general/secrets/rules/SECRETS.md +3 -1
  62. package/configurations/general/security/manifest.toml +29 -52
  63. package/configurations/general/security/rules/SECURITY.md +8 -6
  64. package/configurations/general/spelling/manifest.toml +15 -25
  65. package/configurations/general/structure/manifest.toml +31 -31
  66. package/configurations/infrastructure/ansible/manifest.toml +15 -15
  67. package/configurations/infrastructure/docker/manifest.toml +55 -67
  68. package/configurations/infrastructure/docker/rules/DOCKER.md +15 -13
  69. package/configurations/infrastructure/github-actions/manifest.toml +21 -41
  70. package/configurations/infrastructure/github-actions/rules/GITHUB-ACTIONS.md +16 -12
  71. package/configurations/infrastructure/github-actions/tool-files/zizmor.yml +5 -0
  72. package/configurations/infrastructure/nginx/manifest.toml +20 -20
  73. package/configurations/infrastructure/nginx/rules/NGINX.md +5 -4
  74. package/configurations/infrastructure/openapi/manifest.toml +20 -20
  75. package/configurations/infrastructure/openapi/rules/OPENAPI.md +3 -1
  76. package/configurations/infrastructure/xcode/manifest.toml +55 -75
  77. package/configurations/infrastructure/xcode/rules/XCODE.md +5 -3
  78. package/configurations/language/bash/manifest.toml +89 -170
  79. package/configurations/language/bash/rules/BASH.md +79 -17
  80. package/configurations/language/bash/rules/LANGUAGE.md +30 -26
  81. package/configurations/language/bash/rules/OPERATIONS.md +10 -8
  82. package/configurations/language/bash/rules/SAFETY.md +39 -35
  83. package/configurations/language/css/manifest.toml +22 -61
  84. package/configurations/language/css/rules/CSS.md +21 -2
  85. package/configurations/language/css/rules/TAILWIND.md +7 -5
  86. package/configurations/language/html/manifest.toml +16 -35
  87. package/configurations/language/html/rules/HTML.md +23 -5
  88. package/configurations/language/javascript/eslint-runtime-names.json +66 -61
  89. package/configurations/language/javascript/eslint-runtime.mjs +118 -0
  90. package/configurations/language/javascript/manifest.toml +135 -207
  91. package/configurations/language/javascript/rules/BUN.md +2 -2
  92. package/configurations/language/javascript/rules/COMPONENTS.md +4 -4
  93. package/configurations/language/javascript/rules/DENO.md +1 -1
  94. package/configurations/language/javascript/rules/JAVASCRIPT.md +30 -17
  95. package/configurations/language/javascript/rules/NODE.md +2 -2
  96. package/configurations/language/javascript/rules/PLAYWRIGHT.md +10 -9
  97. package/configurations/language/markdown/manifest.toml +20 -51
  98. package/configurations/language/python/manifest.toml +231 -342
  99. package/configurations/language/python/rules/DESIGN.md +40 -33
  100. package/configurations/language/python/rules/FLOW.md +8 -6
  101. package/configurations/language/python/rules/PACKAGING.md +14 -7
  102. package/configurations/language/python/rules/PYTHON.md +83 -33
  103. package/configurations/language/python/rules/TYPING.md +25 -23
  104. package/configurations/language/sql/manifest.toml +19 -37
  105. package/configurations/language/sql/rules/SQL.md +90 -2
  106. package/configurations/language/swift/manifest.toml +67 -78
  107. package/configurations/language/swift/rules/SWIFT.md +138 -40
  108. package/configurations/language/swift/rules/SWIFTUI.md +11 -9
  109. package/configurations/language/swift/rules/UIKIT.md +21 -19
  110. package/configurations/language/typescript/manifest.toml +34 -34
  111. package/configurations/language/typescript/rules/TYPESCRIPT.md +62 -10
  112. package/configurations/library/drizzle/manifest.toml +25 -38
  113. package/configurations/library/drizzle/rules/DRIZZLE.md +4 -2
  114. package/configurations/library/react-hook-form/manifest.toml +4 -4
  115. package/configurations/library/react-hook-form/rules/REACT-HOOK-FORM.md +15 -13
  116. package/configurations/library/tanstack-query/manifest.toml +6 -6
  117. package/configurations/library/tanstack-query/rules/TANSTACK-QUERY.md +5 -3
  118. package/configurations/library/testing-library/manifest.toml +6 -6
  119. package/configurations/library/translations/manifest.toml +22 -22
  120. package/configurations/library/translations/rules/NEXT-INTL.md +6 -8
  121. package/configurations/library/translations/rules/TRANSLATIONS.md +22 -23
  122. package/configurations/library/trpc/manifest.toml +3 -3
  123. package/configurations/library/trpc/rules/TRPC.md +8 -6
  124. package/configurations/library/zod/manifest.toml +6 -6
  125. package/configurations/library/zod/rules/ZOD.md +4 -2
  126. package/configurations/library/zustand/manifest.toml +4 -4
  127. package/configurations/library/zustand/rules/ZUSTAND.md +16 -14
  128. package/configurations/platform/cloudflare/manifest.toml +28 -47
  129. package/configurations/platform/cloudflare/rules/CLOUDFLARE.md +11 -6
  130. package/configurations/platform/supabase/manifest.toml +48 -61
  131. package/configurations/platform/supabase/rules/SUPABASE.md +27 -28
  132. package/configurations/testing/jest/manifest.toml +21 -22
  133. package/configurations/testing/pytest/manifest.toml +28 -28
  134. package/configurations/testing/swift-tests/manifest.toml +18 -29
  135. package/configurations/testing/swift-tests/rules/SWIFT-TESTS.md +7 -5
  136. package/configurations/testing/vitest/manifest.toml +32 -32
  137. package/configurations/testing/vitest/rules/VITEST.md +3 -1
  138. package/dist/gspot.js +22297 -24707
  139. package/dist/{linkinator-program.js → linkinator-process.js} +5 -7
  140. package/dist/{purgecss-program.js → purgecss-process.js} +12 -12
  141. package/package.json +7 -9
  142. package/configurations/infrastructure/github-actions/zizmor.yml +0 -3
  143. package/configurations/language/bash/rules/NAMING.md +0 -62
  144. package/configurations/language/css/rules/NAMING.md +0 -17
  145. package/configurations/language/html/rules/NAMING.md +0 -16
  146. package/configurations/language/javascript/rules/NAMING.md +0 -31
  147. package/configurations/language/markdown/markdownlint-cli2.mjs +0 -19
  148. package/configurations/language/python/rules/NAMING.md +0 -53
  149. package/configurations/language/sql/rules/NAMING.md +0 -90
  150. package/configurations/language/swift/rules/NAMING.md +0 -88
  151. package/configurations/language/typescript/rules/NAMING.md +0 -73
  152. package/configurations/library/swift-snapshot-testing/manifest.toml +0 -32
  153. package/dist/THIRD-PARTY-NOTICES.md +0 -25
  154. package/dist/eslint-rule-levels.json +0 -10
  155. package/dist/tool-versions.json +0 -3
  156. package/gspot.schema.json +0 -45991
  157. /package/{dist/LICENSE.md → LICENSE.md} +0 -0
  158. /package/configurations/framework/express/{semgrep → tool-files/semgrep}/express.yml +0 -0
  159. /package/configurations/framework/fastapi/{semgrep → tool-files/semgrep}/fastapi.yml +0 -0
  160. /package/configurations/general/dependencies/{syncpack.json → tool-files/syncpack.json} +0 -0
  161. /package/configurations/general/prose/{vale → tool-files/vale}/styles/LICENSES.md +0 -0
  162. /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/ampm.yml +0 -0
  163. /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/conscious-language.yml +0 -0
  164. /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/contractions.yml +0 -0
  165. /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/currency.yml +0 -0
  166. /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/dashes.yml +0 -0
  167. /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/date-ordinals.yml +0 -0
  168. /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/dates.yml +0 -0
  169. /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/file-paths.yml +0 -0
  170. /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/future.yml +0 -0
  171. /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/hedging.yml +0 -0
  172. /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/history.yml +0 -0
  173. /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/idioms.yml +0 -0
  174. /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/interface-verbs.yml +0 -0
  175. /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/jargon.yml +0 -0
  176. /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/leading-conjunctions.yml +0 -0
  177. /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/link-text.yml +0 -0
  178. /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/locations.yml +0 -0
  179. /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/marketing.yml +0 -0
  180. /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/merge-conflict-markers.yml +0 -0
  181. /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/militaristic-language.yml +0 -0
  182. /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/modals.yml +0 -0
  183. /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/numbered-units.yml +0 -0
  184. /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/obvious-fields.yml +0 -0
  185. /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/ordinal-adverbs.yml +0 -0
  186. /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/percentage-numbers.yml +0 -0
  187. /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/placeholders.yml +0 -0
  188. /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/product-centric-writing.yml +0 -0
  189. /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/punctuated-headings.yml +0 -0
  190. /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/self-reference.yml +0 -0
  191. /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/session-identifiers.yml +0 -0
  192. /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/since.yml +0 -0
  193. /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/straight-quotes.yml +0 -0
  194. /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/suspended-hyphens.yml +0 -0
  195. /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/symbols.yml +0 -0
  196. /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/time-ranges.yml +0 -0
  197. /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/url-prepositions.yml +0 -0
  198. /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/version-range.yml +0 -0
  199. /package/configurations/general/secrets/{gitleaks.toml → tool-files/gitleaks.toml} +0 -0
  200. /package/configurations/infrastructure/docker/{trivyignore → tool-files/trivyignore} +0 -0
  201. /package/configurations/language/bash/{semgrep → tool-files/semgrep}/bash.yml +0 -0
  202. /package/configurations/language/javascript/{semgrep → tool-files/semgrep}/javascript.yml +0 -0
  203. /package/configurations/language/swift/{semgrep → tool-files/semgrep}/swift.yml +0 -0
  204. /package/configurations/platform/cloudflare/{semgrep → tool-files/semgrep}/cloudflare.yml +0 -0
  205. /package/configurations/platform/supabase/{semgrep → tool-files/semgrep}/supabase.yml +0 -0
@@ -1,61 +1,66 @@
1
- [
2
- "amd",
3
- "applescript",
4
- "astro",
5
- "atomtest",
6
- "audioWorklet",
7
- "browser",
8
- "builtin",
9
- "bunBuiltin",
10
- "chai",
11
- "commonjs",
12
- "couch",
13
- "denoBuiltin",
14
- "devtools",
15
- "embertest",
16
- "es2015",
17
- "es2016",
18
- "es2017",
19
- "es2018",
20
- "es2019",
21
- "es2020",
22
- "es2021",
23
- "es2022",
24
- "es2023",
25
- "es2024",
26
- "es2025",
27
- "es2026",
28
- "es2027",
29
- "es3",
30
- "es5",
31
- "greasemonkey",
32
- "jasmine",
33
- "jest",
34
- "jquery",
35
- "meteor",
36
- "mocha",
37
- "mongo",
38
- "nashorn",
39
- "node",
40
- "nodeBuiltin",
41
- "paintWorklet",
42
- "phantomjs",
43
- "prototypejs",
44
- "protractor",
45
- "qunit",
46
- "react-native",
47
- "rhino",
48
- "rspack",
49
- "serviceworker",
50
- "shared-node-browser",
51
- "sharedWorker",
52
- "shelljs",
53
- "svelte",
54
- "vitest",
55
- "vue",
56
- "webextensions",
57
- "webpack",
58
- "worker",
59
- "wsh",
60
- "yui"
61
- ]
1
+ {
2
+ "package": "globals",
3
+ "version": "17.12.0",
4
+ "source": "default",
5
+ "rules": [
6
+ "amd",
7
+ "applescript",
8
+ "astro",
9
+ "atomtest",
10
+ "audioWorklet",
11
+ "browser",
12
+ "builtin",
13
+ "bunBuiltin",
14
+ "chai",
15
+ "commonjs",
16
+ "couch",
17
+ "denoBuiltin",
18
+ "devtools",
19
+ "embertest",
20
+ "es2015",
21
+ "es2016",
22
+ "es2017",
23
+ "es2018",
24
+ "es2019",
25
+ "es2020",
26
+ "es2021",
27
+ "es2022",
28
+ "es2023",
29
+ "es2024",
30
+ "es2025",
31
+ "es2026",
32
+ "es2027",
33
+ "es3",
34
+ "es5",
35
+ "greasemonkey",
36
+ "jasmine",
37
+ "jest",
38
+ "jquery",
39
+ "meteor",
40
+ "mocha",
41
+ "mongo",
42
+ "nashorn",
43
+ "node",
44
+ "nodeBuiltin",
45
+ "paintWorklet",
46
+ "phantomjs",
47
+ "prototypejs",
48
+ "protractor",
49
+ "qunit",
50
+ "react-native",
51
+ "rhino",
52
+ "rspack",
53
+ "serviceworker",
54
+ "shared-node-browser",
55
+ "sharedWorker",
56
+ "shelljs",
57
+ "svelte",
58
+ "vitest",
59
+ "vue",
60
+ "webextensions",
61
+ "webpack",
62
+ "worker",
63
+ "wsh",
64
+ "yui"
65
+ ]
66
+ }
@@ -0,0 +1,118 @@
1
+ /** @typedef {{languageOptions?: {globals?: Record<string, unknown>}}} FrameworkBlock */
2
+ /** @typedef {{key?: {name?: string}, value?: {value?: string} | null}} VueAttribute */
3
+ /** @typedef {{key?: {name?: string}, value: {value?: string}[]}} SvelteAttribute */
4
+ /** @typedef {{type: string, name?: string, startTag: {attributes: VueAttribute[]}}} VueScript */
5
+ /** @typedef {{type: string, startTag: {attributes: SvelteAttribute[]}}} SvelteScript */
6
+ /** @typedef {{services: {getDocumentFragment: () => {children: VueScript[]}}}} VueProgram */
7
+ /** @typedef {{ast: {body: SvelteScript[]}}} SvelteProgram */
8
+
9
+ import picomatch from 'picomatch';
10
+ import { readFileSync } from 'node:fs';
11
+ import { fileURLToPath } from 'node:url';
12
+ import { sep, relative } from 'node:path';
13
+
14
+ // TypeScript resolves the project service from the repository root without a closing separator.
15
+ const root = fileURLToPath(new URL('../..', import.meta.url)).replace(/[\\/]$/u, '');
16
+ /** @type {WeakMap<object, Set<string>>} */
17
+ const runtimeGlobalNames = new WeakMap();
18
+ /** @type {WeakMap<object, ((path: string) => boolean)[]>} */
19
+ const runtimeMatcherGroups = new WeakMap();
20
+
21
+ // Framework presets retain compiler and test globals; runtime APIs use their own file selectors.
22
+ /**
23
+ * Remove host runtime globals while retaining framework compiler and test names.
24
+ * @param {FrameworkBlock} block the framework ESLint configuration block.
25
+ * @param {Record<string, object>} library the globals tables keyed by runtime name.
26
+ * @returns {FrameworkBlock} the same block with runtime names removed from its globals.
27
+ */
28
+ function stripRuntimeGlobals(block, library) {
29
+ const names = block.languageOptions?.globals;
30
+ if (names === undefined) return block;
31
+ let runtimeNames = runtimeGlobalNames.get(library);
32
+ if (runtimeNames === undefined) {
33
+ runtimeNames = new Set(
34
+ Object.keys({
35
+ ...library['node'],
36
+ ...library['browser'],
37
+ ...library['worker'],
38
+ ...library['serviceworker'],
39
+ ...library['react-native'],
40
+ }),
41
+ );
42
+ runtimeGlobalNames.set(library, runtimeNames);
43
+ }
44
+ return {
45
+ ...block,
46
+ languageOptions: {
47
+ ...block.languageOptions,
48
+ globals: Object.fromEntries(Object.entries(names).filter(([name]) => !runtimeNames.has(name))),
49
+ },
50
+ };
51
+ }
52
+
53
+ /**
54
+ * Select the last runtime declaration that covers each file path.
55
+ * @param {number} index the position of the runtime declaration represented by this matcher.
56
+ * @param {{scope: string, includes: string[], excludes: string[]}[]} declarations the ordered runtime declarations.
57
+ * @returns {function(string): boolean} whether a file belongs to this declaration after later overrides.
58
+ */
59
+ function runtimeMatches(index, declarations) {
60
+ let matchers = runtimeMatcherGroups.get(declarations);
61
+ if (matchers === undefined) {
62
+ matchers = declarations.map(({ scope, includes, excludes }) => {
63
+ const included = includes.map((glob) => picomatch(glob, { dot: true, flags: 's' }));
64
+ const excluded = excludes.map((glob) => picomatch(glob, { dot: true, flags: 's' }));
65
+ return (path) => {
66
+ if (scope !== '' && !path.startsWith(`${scope}/`)) return false;
67
+ return included.some((pattern) => pattern(path)) && !excluded.some((pattern) => pattern(path));
68
+ };
69
+ });
70
+ runtimeMatcherGroups.set(declarations, matchers);
71
+ }
72
+ return (file) => matchers.findLastIndex((matches) => matches(relative(root, file).split(sep).join('/'))) === index;
73
+ }
74
+
75
+ // Component parsers preserve script-language attributes. The final parser reports syntax errors.
76
+ /**
77
+ * Select component files whose script attributes request TypeScript parsing.
78
+ * @param {{parseForESLint: (text: string, options: object) => VueProgram | SvelteProgram}} parser the Vue or Svelte parser that preserves component script attributes.
79
+ * @param {string} framework the component format name.
80
+ * @param {object} typescriptParser the TypeScript parser supplied to typed script blocks.
81
+ * @returns {function(string): boolean} whether a file contains a typed script block.
82
+ */
83
+ function componentMatches(parser, framework, typescriptParser) {
84
+ return (file) => {
85
+ try {
86
+ const parsed = parser.parseForESLint(readFileSync(file, 'utf8'), {
87
+ filePath: file,
88
+ tsconfigRootDir: root,
89
+ ecmaVersion: 'latest',
90
+ sourceType: 'module',
91
+ parser: framework === 'vue' ? false : { ts: typescriptParser, typescript: typescriptParser },
92
+ });
93
+ const scripts =
94
+ framework === 'vue'
95
+ ? /** @type {VueProgram} */ (parsed).services
96
+ .getDocumentFragment()
97
+ .children.filter((node) => node.type === 'VElement' && node.name === 'script')
98
+ : /** @type {SvelteProgram} */ (parsed).ast.body.filter(
99
+ (node) => node.type === 'SvelteScriptElement',
100
+ );
101
+ return scripts.some((script) =>
102
+ script.startTag.attributes.some((attribute) => {
103
+ if (attribute.key?.name !== 'lang') return false;
104
+ const language =
105
+ framework === 'vue'
106
+ ? /** @type {VueAttribute} */ (attribute).value?.value
107
+ : /** @type {SvelteAttribute} */ (attribute).value[0]?.value;
108
+ return language === 'ts' || language === 'typescript';
109
+ }),
110
+ );
111
+ } catch (error) {
112
+ if (error instanceof SyntaxError || (error instanceof Error && error.name === 'TSError')) return false;
113
+ throw error;
114
+ }
115
+ };
116
+ }
117
+
118
+ export { root, runtimeMatches, componentMatches, stripRuntimeGlobals };