@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.
- package/README.md +58 -11
- package/configurations/database/postgres/manifest.toml +51 -57
- package/configurations/database/postgres/rules/POSTGRES.md +14 -13
- package/configurations/framework/astro/manifest.toml +33 -35
- package/configurations/framework/astro/rules/ASTRO.md +2 -2
- package/configurations/framework/expo/manifest.toml +19 -19
- package/configurations/framework/express/manifest.toml +10 -4
- package/configurations/framework/express/rules/EXPRESS.md +9 -7
- package/configurations/framework/fastapi/manifest.toml +9 -3
- package/configurations/framework/fastapi/rules/FASTAPI.md +19 -18
- package/configurations/framework/nestjs/manifest.toml +12 -12
- package/configurations/framework/nestjs/rules/NESTJS.md +9 -9
- package/configurations/framework/nextjs/manifest.toml +39 -79
- package/configurations/framework/nextjs/rules/NEXTJS.md +9 -7
- package/configurations/framework/nextjs/tool-files/semgrep/nextjs.yml +35 -0
- package/configurations/framework/react/manifest.toml +33 -43
- package/configurations/framework/react/rules/REACT.md +14 -20
- package/configurations/framework/react-dom/manifest.toml +6 -6
- package/configurations/framework/react-native/manifest.toml +11 -11
- package/configurations/framework/react-native/rules/REACT-NATIVE.md +3 -5
- package/configurations/framework/site/manifest.toml +57 -110
- package/configurations/framework/site/rules/SITE.md +1 -1
- package/configurations/framework/svelte/manifest.toml +29 -31
- package/configurations/framework/svelte/rules/SVELTE.md +6 -6
- package/configurations/framework/vue/manifest.toml +37 -37
- package/configurations/framework/vue/rules/VUE.md +6 -6
- package/configurations/general/commits/manifest.toml +20 -84
- package/configurations/general/commits/rules/GIT.md +24 -13
- package/configurations/general/coverage/manifest.toml +1 -1
- package/configurations/general/dependencies/manifest.toml +47 -107
- package/configurations/general/dependencies/rules/DEPENDENCIES.md +13 -7
- package/configurations/general/docs/manifest.toml +28 -43
- package/configurations/general/docs/rules/DOCS.md +16 -9
- package/configurations/general/duplication/manifest.toml +12 -14
- package/configurations/general/engineering/manifest.toml +6 -2
- package/configurations/general/engineering/rules/agent/PLANNING.md +9 -6
- package/configurations/general/engineering/rules/agent/SUPPRESSIONS.md +20 -11
- package/configurations/general/engineering/rules/agent/TASKS.md +6 -2
- package/configurations/general/engineering/rules/agent/WORKING.md +34 -29
- package/configurations/general/engineering/rules/code/ACCESSIBILITY.md +9 -7
- package/configurations/general/engineering/rules/code/CLI.md +12 -9
- package/configurations/general/engineering/rules/code/COMMENTS.md +11 -1
- package/configurations/general/engineering/rules/code/CONFIGURATION.md +2 -0
- package/configurations/general/engineering/rules/code/ERRORS.md +5 -3
- package/configurations/general/engineering/rules/code/HTTP.md +9 -10
- package/configurations/general/engineering/rules/code/LOGGING.md +10 -9
- package/configurations/general/engineering/rules/code/TESTING.md +18 -11
- package/configurations/general/files/manifest.toml +45 -73
- package/configurations/general/files/rules/YAML.md +20 -10
- package/configurations/general/format/manifest.toml +53 -106
- package/configurations/general/gspot/manifest.toml +19 -39
- package/configurations/general/gspot/rules/GENERATED.md +14 -4
- package/configurations/general/licenses/manifest.toml +12 -14
- package/configurations/general/naming/defaults.json +14 -13
- package/configurations/general/naming/manifest.toml +17 -17
- package/configurations/general/naming/rules/NAMING.md +87 -67
- package/configurations/general/prose/manifest.toml +166 -25
- package/configurations/general/prose/rules/WRITING.md +6 -2
- package/configurations/general/repository/manifest.toml +12 -12
- package/configurations/general/secrets/manifest.toml +52 -73
- package/configurations/general/secrets/rules/SECRETS.md +3 -1
- package/configurations/general/security/manifest.toml +29 -52
- package/configurations/general/security/rules/SECURITY.md +8 -6
- package/configurations/general/spelling/manifest.toml +15 -25
- package/configurations/general/structure/manifest.toml +31 -31
- package/configurations/infrastructure/ansible/manifest.toml +15 -15
- package/configurations/infrastructure/docker/manifest.toml +55 -67
- package/configurations/infrastructure/docker/rules/DOCKER.md +15 -13
- package/configurations/infrastructure/github-actions/manifest.toml +21 -41
- package/configurations/infrastructure/github-actions/rules/GITHUB-ACTIONS.md +16 -12
- package/configurations/infrastructure/github-actions/tool-files/zizmor.yml +5 -0
- package/configurations/infrastructure/nginx/manifest.toml +20 -20
- package/configurations/infrastructure/nginx/rules/NGINX.md +5 -4
- package/configurations/infrastructure/openapi/manifest.toml +20 -20
- package/configurations/infrastructure/openapi/rules/OPENAPI.md +3 -1
- package/configurations/infrastructure/xcode/manifest.toml +55 -75
- package/configurations/infrastructure/xcode/rules/XCODE.md +5 -3
- package/configurations/language/bash/manifest.toml +89 -170
- package/configurations/language/bash/rules/BASH.md +79 -17
- package/configurations/language/bash/rules/LANGUAGE.md +30 -26
- package/configurations/language/bash/rules/OPERATIONS.md +10 -8
- package/configurations/language/bash/rules/SAFETY.md +39 -35
- package/configurations/language/css/manifest.toml +22 -61
- package/configurations/language/css/rules/CSS.md +21 -2
- package/configurations/language/css/rules/TAILWIND.md +7 -5
- package/configurations/language/html/manifest.toml +16 -35
- package/configurations/language/html/rules/HTML.md +23 -5
- package/configurations/language/javascript/eslint-runtime-names.json +66 -61
- package/configurations/language/javascript/eslint-runtime.mjs +118 -0
- package/configurations/language/javascript/manifest.toml +135 -207
- package/configurations/language/javascript/rules/BUN.md +2 -2
- package/configurations/language/javascript/rules/COMPONENTS.md +4 -4
- package/configurations/language/javascript/rules/DENO.md +1 -1
- package/configurations/language/javascript/rules/JAVASCRIPT.md +30 -17
- package/configurations/language/javascript/rules/NODE.md +2 -2
- package/configurations/language/javascript/rules/PLAYWRIGHT.md +10 -9
- package/configurations/language/markdown/manifest.toml +20 -51
- package/configurations/language/python/manifest.toml +231 -342
- package/configurations/language/python/rules/DESIGN.md +40 -33
- package/configurations/language/python/rules/FLOW.md +8 -6
- package/configurations/language/python/rules/PACKAGING.md +14 -7
- package/configurations/language/python/rules/PYTHON.md +83 -33
- package/configurations/language/python/rules/TYPING.md +25 -23
- package/configurations/language/sql/manifest.toml +19 -37
- package/configurations/language/sql/rules/SQL.md +90 -2
- package/configurations/language/swift/manifest.toml +67 -78
- package/configurations/language/swift/rules/SWIFT.md +138 -40
- package/configurations/language/swift/rules/SWIFTUI.md +11 -9
- package/configurations/language/swift/rules/UIKIT.md +21 -19
- package/configurations/language/typescript/manifest.toml +34 -34
- package/configurations/language/typescript/rules/TYPESCRIPT.md +62 -10
- package/configurations/library/drizzle/manifest.toml +25 -38
- package/configurations/library/drizzle/rules/DRIZZLE.md +4 -2
- package/configurations/library/react-hook-form/manifest.toml +4 -4
- package/configurations/library/react-hook-form/rules/REACT-HOOK-FORM.md +15 -13
- package/configurations/library/tanstack-query/manifest.toml +6 -6
- package/configurations/library/tanstack-query/rules/TANSTACK-QUERY.md +5 -3
- package/configurations/library/testing-library/manifest.toml +6 -6
- package/configurations/library/translations/manifest.toml +22 -22
- package/configurations/library/translations/rules/NEXT-INTL.md +6 -8
- package/configurations/library/translations/rules/TRANSLATIONS.md +22 -23
- package/configurations/library/trpc/manifest.toml +3 -3
- package/configurations/library/trpc/rules/TRPC.md +8 -6
- package/configurations/library/zod/manifest.toml +6 -6
- package/configurations/library/zod/rules/ZOD.md +4 -2
- package/configurations/library/zustand/manifest.toml +4 -4
- package/configurations/library/zustand/rules/ZUSTAND.md +16 -14
- package/configurations/platform/cloudflare/manifest.toml +28 -47
- package/configurations/platform/cloudflare/rules/CLOUDFLARE.md +11 -6
- package/configurations/platform/supabase/manifest.toml +48 -61
- package/configurations/platform/supabase/rules/SUPABASE.md +27 -28
- package/configurations/testing/jest/manifest.toml +21 -22
- package/configurations/testing/pytest/manifest.toml +28 -28
- package/configurations/testing/swift-tests/manifest.toml +18 -29
- package/configurations/testing/swift-tests/rules/SWIFT-TESTS.md +7 -5
- package/configurations/testing/vitest/manifest.toml +32 -32
- package/configurations/testing/vitest/rules/VITEST.md +3 -1
- package/dist/gspot.js +22297 -24707
- package/dist/{linkinator-program.js → linkinator-process.js} +5 -7
- package/dist/{purgecss-program.js → purgecss-process.js} +12 -12
- package/package.json +7 -9
- package/configurations/infrastructure/github-actions/zizmor.yml +0 -3
- package/configurations/language/bash/rules/NAMING.md +0 -62
- package/configurations/language/css/rules/NAMING.md +0 -17
- package/configurations/language/html/rules/NAMING.md +0 -16
- package/configurations/language/javascript/rules/NAMING.md +0 -31
- package/configurations/language/markdown/markdownlint-cli2.mjs +0 -19
- package/configurations/language/python/rules/NAMING.md +0 -53
- package/configurations/language/sql/rules/NAMING.md +0 -90
- package/configurations/language/swift/rules/NAMING.md +0 -88
- package/configurations/language/typescript/rules/NAMING.md +0 -73
- package/configurations/library/swift-snapshot-testing/manifest.toml +0 -32
- package/dist/THIRD-PARTY-NOTICES.md +0 -25
- package/dist/eslint-rule-levels.json +0 -10
- package/dist/tool-versions.json +0 -3
- package/gspot.schema.json +0 -45991
- /package/{dist/LICENSE.md → LICENSE.md} +0 -0
- /package/configurations/framework/express/{semgrep → tool-files/semgrep}/express.yml +0 -0
- /package/configurations/framework/fastapi/{semgrep → tool-files/semgrep}/fastapi.yml +0 -0
- /package/configurations/general/dependencies/{syncpack.json → tool-files/syncpack.json} +0 -0
- /package/configurations/general/prose/{vale → tool-files/vale}/styles/LICENSES.md +0 -0
- /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/ampm.yml +0 -0
- /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/conscious-language.yml +0 -0
- /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/contractions.yml +0 -0
- /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/currency.yml +0 -0
- /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/dashes.yml +0 -0
- /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/date-ordinals.yml +0 -0
- /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/dates.yml +0 -0
- /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/file-paths.yml +0 -0
- /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/future.yml +0 -0
- /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/hedging.yml +0 -0
- /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/history.yml +0 -0
- /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/idioms.yml +0 -0
- /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/interface-verbs.yml +0 -0
- /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/jargon.yml +0 -0
- /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/leading-conjunctions.yml +0 -0
- /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/link-text.yml +0 -0
- /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/locations.yml +0 -0
- /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/marketing.yml +0 -0
- /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/merge-conflict-markers.yml +0 -0
- /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/militaristic-language.yml +0 -0
- /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/modals.yml +0 -0
- /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/numbered-units.yml +0 -0
- /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/obvious-fields.yml +0 -0
- /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/ordinal-adverbs.yml +0 -0
- /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/percentage-numbers.yml +0 -0
- /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/placeholders.yml +0 -0
- /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/product-centric-writing.yml +0 -0
- /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/punctuated-headings.yml +0 -0
- /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/self-reference.yml +0 -0
- /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/session-identifiers.yml +0 -0
- /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/since.yml +0 -0
- /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/straight-quotes.yml +0 -0
- /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/suspended-hyphens.yml +0 -0
- /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/symbols.yml +0 -0
- /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/time-ranges.yml +0 -0
- /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/url-prepositions.yml +0 -0
- /package/configurations/general/prose/{vale → tool-files/vale}/styles/gspot/version-range.yml +0 -0
- /package/configurations/general/secrets/{gitleaks.toml → tool-files/gitleaks.toml} +0 -0
- /package/configurations/infrastructure/docker/{trivyignore → tool-files/trivyignore} +0 -0
- /package/configurations/language/bash/{semgrep → tool-files/semgrep}/bash.yml +0 -0
- /package/configurations/language/javascript/{semgrep → tool-files/semgrep}/javascript.yml +0 -0
- /package/configurations/language/swift/{semgrep → tool-files/semgrep}/swift.yml +0 -0
- /package/configurations/platform/cloudflare/{semgrep → tool-files/semgrep}/cloudflare.yml +0 -0
- /package/configurations/platform/supabase/{semgrep → tool-files/semgrep}/supabase.yml +0 -0
|
@@ -1,61 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
"
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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 };
|