Leon4gr45 commited on
Commit
1fbcf0f
·
verified ·
1 Parent(s): 9a362eb

Upload folder using huggingface_hub (part 2)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +2 -0
  2. package-lock.json +0 -0
  3. package.json +41 -0
  4. scripts/analyze-devtool-profiler.cjs +133 -0
  5. scripts/analyze-react-profiler.cjs +96 -0
  6. scripts/migrate-i18n.mts +117 -0
  7. server/.env.example +45 -0
  8. server/.gitignore +1 -0
  9. server/.prettierrc +18 -0
  10. server/assets/airports.json +0 -0
  11. server/assets/atlas/admin0.geojson.gz +3 -0
  12. server/assets/atlas/admin1.geojson.gz +3 -0
  13. server/eslint.config.mjs +47 -0
  14. server/node_modules/.bin/eslint +196 -0
  15. server/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -0
  16. server/node_modules/@eslint/config-array/LICENSE +201 -0
  17. server/node_modules/@eslint/config-array/README.md +368 -0
  18. server/node_modules/@eslint/config-array/dist/cjs/index.cjs +1539 -0
  19. server/node_modules/@eslint/config-array/dist/cjs/index.d.cts +145 -0
  20. server/node_modules/@eslint/config-array/dist/cjs/std__path/posix.cjs +1336 -0
  21. server/node_modules/@eslint/config-array/dist/cjs/std__path/windows.cjs +1678 -0
  22. server/node_modules/@eslint/config-array/dist/cjs/types.cts +29 -0
  23. server/node_modules/@eslint/config-array/dist/esm/index.d.ts +145 -0
  24. server/node_modules/@eslint/config-array/dist/esm/index.js +1514 -0
  25. server/node_modules/@eslint/config-array/dist/esm/std__path/posix.js +1314 -0
  26. server/node_modules/@eslint/config-array/dist/esm/std__path/windows.js +1656 -0
  27. server/node_modules/@eslint/config-array/dist/esm/types.d.ts +23 -0
  28. server/node_modules/@eslint/config-array/dist/esm/types.ts +29 -0
  29. server/node_modules/@eslint/config-array/package.json +64 -0
  30. server/node_modules/@eslint/config-helpers/LICENSE +201 -0
  31. server/node_modules/@eslint/config-helpers/README.md +97 -0
  32. server/node_modules/@eslint/config-helpers/dist/cjs/index.cjs +588 -0
  33. server/node_modules/@eslint/config-helpers/dist/cjs/index.d.cts +26 -0
  34. server/node_modules/@eslint/config-helpers/dist/cjs/types.cts +29 -0
  35. server/node_modules/@eslint/config-helpers/dist/esm/index.d.ts +26 -0
  36. server/node_modules/@eslint/config-helpers/dist/esm/index.js +586 -0
  37. server/node_modules/@eslint/config-helpers/dist/esm/types.d.ts +23 -0
  38. server/node_modules/@eslint/config-helpers/dist/esm/types.ts +29 -0
  39. server/node_modules/@eslint/config-helpers/package.json +60 -0
  40. server/node_modules/@eslint/core/LICENSE +201 -0
  41. server/node_modules/@eslint/core/README.md +29 -0
  42. server/node_modules/@eslint/core/dist/cjs/types.d.cts +1179 -0
  43. server/node_modules/@eslint/core/dist/esm/types.d.ts +1179 -0
  44. server/node_modules/@eslint/core/package.json +49 -0
  45. server/node_modules/@eslint/object-schema/LICENSE +201 -0
  46. server/node_modules/@eslint/object-schema/README.md +242 -0
  47. server/node_modules/@eslint/object-schema/dist/cjs/index.cjs +457 -0
  48. server/node_modules/@eslint/object-schema/dist/cjs/index.d.cts +125 -0
  49. server/node_modules/@eslint/object-schema/dist/cjs/types.cts +57 -0
  50. server/node_modules/@eslint/object-schema/dist/esm/index.d.ts +125 -0
.gitattributes CHANGED
@@ -25,3 +25,5 @@
25
  *.eot binary
26
  *.pdf binary
27
  *.zip binary
 
 
 
25
  *.eot binary
26
  *.pdf binary
27
  *.zip binary
28
+ server/assets/atlas/admin0.geojson.gz filter=lfs diff=lfs merge=lfs -text
29
+ server/assets/atlas/admin1.geojson.gz filter=lfs diff=lfs merge=lfs -text
package-lock.json ADDED
The diff for this file is too large to render. See raw diff
 
package.json ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@trek/root",
3
+ "private": true,
4
+ "version": "3.1.0",
5
+ "workspaces": [
6
+ "client",
7
+ "server",
8
+ "shared"
9
+ ],
10
+ "scripts": {
11
+ "version:major": "npm version major --workspaces --include-workspace-root --no-git-tag-version",
12
+ "version:minor": "npm version minor --workspaces --include-workspace-root --no-git-tag-version",
13
+ "version:patch": "npm version patch --workspaces --include-workspace-root --no-git-tag-version",
14
+ "version:premajor": "npm version premajor --preid=rc --workspaces --include-workspace-root --no-git-tag-version",
15
+ "version:preminor": "npm version preminor --preid=beta --workspaces --include-workspace-root --no-git-tag-version",
16
+ "version:prepatch": "npm version prepatch --preid=alpha --workspaces --include-workspace-root --no-git-tag-version",
17
+ "version:prerelease": "npm version prerelease --preid=pre --workspaces --include-workspace-root --no-git-tag-version",
18
+ "dev": "npm run build --workspace=shared && concurrently --names shared,server,client \"npm run build:watch --workspace=shared\" \"npm run dev --workspace=server\" \"npm run dev --workspace=client\"",
19
+ "build": "npm run build --workspace=shared && npm run build --workspace=server && npm run build --workspace=client",
20
+ "test": "npm run test --workspace=shared && npm run test --workspace=server && npm run test --workspace=client",
21
+ "test:cov": "npm run test:coverage --workspace=server && npm run test:coverage --workspace=client",
22
+ "test:e2e": "npm run test:e2e --workspace=server",
23
+ "lint": "npm run lint --workspace=shared && npm run lint --workspace=server && npm run lint --workspace=client",
24
+ "format": "npm run format --workspace=shared && npm run format --workspace=server && npm run format --workspace=client",
25
+ "format:check": "npm run format:check --workspace=shared && npm run format:check --workspace=server && npm run format:check --workspace=client"
26
+ },
27
+ "devDependencies": {
28
+ "concurrently": "^10.0.3"
29
+ },
30
+ "comment:overrides": "Force a single React 19 across the workspace so the test renderer (@testing-library/react) and the app share one react-dom.",
31
+ "overrides": {
32
+ "react": "19.2.6",
33
+ "react-dom": "19.2.6"
34
+ },
35
+ "optionalDependencies": {
36
+ "@rollup/rollup-linux-x64-musl": "4.62.0",
37
+ "@rollup/rollup-linux-arm64-musl": "4.62.0",
38
+ "@img/sharp-linuxmusl-x64": "0.35.1",
39
+ "@img/sharp-linuxmusl-arm64": "0.35.1"
40
+ }
41
+ }
scripts/analyze-devtool-profiler.cjs ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env node
2
+ // Chrome Performance Trace Analyzer — outputs a compact summary
3
+ // Usage: node analyze-trace.js <trace.json>
4
+
5
+ const fs = require('fs')
6
+ const path = require('path')
7
+
8
+ const file = process.argv[2]
9
+ if (!file) { console.error('Usage: node analyze-trace.js <trace.json>'); process.exit(1) }
10
+
11
+ console.log(`Reading ${path.basename(file)} (${(fs.statSync(file).size / 1e6).toFixed(1)} MB)...`)
12
+ const raw = fs.readFileSync(file, 'utf8')
13
+ console.log('Parsing...')
14
+ const trace = JSON.parse(raw)
15
+ const events = Array.isArray(trace) ? trace : (trace.traceEvents || [])
16
+ console.log(`Total events: ${events.length.toLocaleString()}\n`)
17
+
18
+ // ── 1. Long Tasks (> 50ms on main thread) ────────────────────────────────────
19
+ const LONG_TASK_MS = 50
20
+ const tasks = events
21
+ .filter(e => e.ph === 'X' && e.dur && e.dur > LONG_TASK_MS * 1000)
22
+ .sort((a, b) => b.dur - a.dur)
23
+ .slice(0, 30)
24
+
25
+ console.log(`═══ TOP LONG TASKS (>${LONG_TASK_MS}ms) ═══`)
26
+ for (const t of tasks) {
27
+ const ms = (t.dur / 1000).toFixed(1)
28
+ const name = t.name || '(unknown)'
29
+ const cat = t.cat || ''
30
+ console.log(` ${ms.padStart(8)}ms ${name} [${cat}]`)
31
+ }
32
+
33
+ // ── 2. Summarise all complete events by name ──────────────────────────────────
34
+ const byName = new Map()
35
+ for (const e of events) {
36
+ if (e.ph !== 'X' || !e.dur) continue
37
+ const key = e.name
38
+ const existing = byName.get(key)
39
+ if (existing) {
40
+ existing.totalMs += e.dur / 1000
41
+ existing.count++
42
+ if (e.dur > existing.maxMs * 1000) existing.maxMs = e.dur / 1000
43
+ } else {
44
+ byName.set(key, { totalMs: e.dur / 1000, count: 1, maxMs: e.dur / 1000 })
45
+ }
46
+ }
47
+ const topByTotal = [...byName.entries()]
48
+ .sort((a, b) => b[1].totalMs - a[1].totalMs)
49
+ .slice(0, 40)
50
+
51
+ console.log('\n═══ TOP EVENTS BY TOTAL TIME ═══')
52
+ console.log(' Total(ms) Max(ms) Count Name')
53
+ for (const [name, s] of topByTotal) {
54
+ console.log(
55
+ ` ${s.totalMs.toFixed(1).padStart(9)} ${s.maxMs.toFixed(1).padStart(7)} ${String(s.count).padStart(5)} ${name}`
56
+ )
57
+ }
58
+
59
+ // ── 3. React-specific events ──────────────────────────────────────────────────
60
+ const reactKeywords = ['react', 'React', 'setState', 'useState', 'useMemo', 'useEffect',
61
+ 'reconcil', 'Reconcil', 'render', 'Render', 'commit', 'Commit', 'fiber', 'Fiber',
62
+ 'Marker', 'MapView', 'photoUrl', 'createPlace', 'markers']
63
+ const reactEvents = [...byName.entries()]
64
+ .filter(([name]) => reactKeywords.some(k => name.includes(k)))
65
+ .sort((a, b) => b[1].totalMs - a[1].totalMs)
66
+ .slice(0, 30)
67
+
68
+ if (reactEvents.length > 0) {
69
+ console.log('\n═══ REACT / MAP EVENTS ═══')
70
+ for (const [name, s] of reactEvents) {
71
+ console.log(` ${s.totalMs.toFixed(1).padStart(9)}ms total ${s.maxMs.toFixed(1).padStart(7)}ms max ${s.count}x ${name}`)
72
+ }
73
+ }
74
+
75
+ // ── 4. V8 / JS heavy hitters ─────────────────────────────────────────────────
76
+ const jsEvents = [...byName.entries()]
77
+ .filter(([, s]) => s.totalMs > 20)
78
+ .filter(([name]) => {
79
+ const cat = (events.find(e => e.name === name)?.cat || '')
80
+ return cat.includes('v8') || cat.includes('devtools.timeline') || name.includes('JS') || name.includes('Compile') || name.includes('GC')
81
+ })
82
+ .sort((a, b) => b[1].totalMs - a[1].totalMs)
83
+ .slice(0, 20)
84
+
85
+ if (jsEvents.length > 0) {
86
+ console.log('\n═══ V8 / JS EVENTS (>20ms total) ═══')
87
+ for (const [name, s] of jsEvents) {
88
+ console.log(` ${s.totalMs.toFixed(1).padStart(9)}ms ${s.count}x ${name}`)
89
+ }
90
+ }
91
+
92
+ // ── 5. CPU profile — top self-time functions ─────────────────────────────────
93
+ const profileChunks = events.filter(e => e.name === 'ProfileChunk')
94
+ if (profileChunks.length > 0) {
95
+ const selfTime = new Map()
96
+ for (const chunk of profileChunks) {
97
+ const nodes = chunk.args?.data?.cpuProfile?.nodes || []
98
+ const samples = chunk.args?.data?.cpuProfile?.samples || []
99
+ const timeDeltas = chunk.args?.data?.timeDeltas || []
100
+ // Build node map
101
+ const nodeMap = new Map(nodes.map(n => [n.id, n]))
102
+ // Accumulate self time per node
103
+ for (let i = 0; i < samples.length; i++) {
104
+ const nodeId = samples[i]
105
+ const dt = (timeDeltas[i] || 0) / 1000 // µs → ms
106
+ const node = nodeMap.get(nodeId)
107
+ if (!node) continue
108
+ const fn = node.callFrame?.functionName || '(anonymous)'
109
+ const url = node.callFrame?.url || ''
110
+ const line = node.callFrame?.lineNumber || 0
111
+ const key = `${fn} @ ${url.split('/').slice(-2).join('/')}:${line}`
112
+ selfTime.set(key, (selfTime.get(key) || 0) + dt)
113
+ }
114
+ }
115
+ const topSelf = [...selfTime.entries()]
116
+ .sort((a, b) => b[1] - a[1])
117
+ .slice(0, 40)
118
+
119
+ console.log('\n═══ CPU PROFILE — TOP SELF-TIME FUNCTIONS ═══')
120
+ for (const [name, ms] of topSelf) {
121
+ console.log(` ${ms.toFixed(1).padStart(8)}ms ${name}`)
122
+ }
123
+ }
124
+
125
+ // ── 6. Paint / Layout costs ───────────────────────────────────────────────────
126
+ const renderCats = ['Layout', 'UpdateLayoutTree', 'Paint', 'CompositeLayers', 'RasterTask']
127
+ console.log('\n═══ RENDERING COSTS ═══')
128
+ for (const cat of renderCats) {
129
+ const s = byName.get(cat)
130
+ if (s) console.log(` ${s.totalMs.toFixed(1).padStart(9)}ms total ${s.maxMs.toFixed(1).padStart(7)}ms max ${s.count}x ${cat}`)
131
+ }
132
+
133
+ console.log('\nDone.')
scripts/analyze-react-profiler.cjs ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env node
2
+ const fs = require('fs')
3
+ const path = require('path')
4
+
5
+ const file = process.argv[2]
6
+ if (!file) { console.error('Usage: node analyze-react-profiler.cjs <profile.json>'); process.exit(1) }
7
+
8
+ const raw = JSON.parse(fs.readFileSync(path.resolve(file), 'utf8'))
9
+ const root = raw.dataForRoots[0]
10
+ const commits = root.commitData
11
+
12
+ // snapshots: array of [fiberId, {displayName, ...}]
13
+ const nameMap = new Map()
14
+ for (const snap of root.snapshots) {
15
+ const id = snap[0]
16
+ const data = snap[1]
17
+ if (data?.displayName) nameMap.set(id, data.displayName)
18
+ }
19
+
20
+ console.log(`Commits: ${commits.length} Tracked components: ${nameMap.size}`)
21
+
22
+ // Probe the unit of fiberActualDurations against the known commit duration
23
+ // fiberActualDurations contains durations for the subtree — the root fiber's
24
+ // actual duration should be >= commit.duration. Find a plausible scale factor.
25
+ const c0 = commits[0]
26
+ const knownDur = c0.duration // already in ms per React DevTools spec
27
+ const rootId = root.rootID ?? 1
28
+ // Check a few values to pick scale
29
+ const sampleDurs = c0.fiberActualDurations.slice(0, 10).map(e => e[1])
30
+ console.log(`\nDebug — commit[0].duration=${knownDur}ms, first 5 raw fiberActualDurations values:`, sampleDurs.slice(0,5))
31
+ // If max sample > 10*knownDur, values are in units of 1/100 ms; otherwise already ms
32
+ const maxSample = Math.max(...c0.fiberActualDurations.map(e => e[1]))
33
+ const scale = maxSample > knownDur * 10 ? 0.01 : 1
34
+
35
+ console.log(`Unit scale: ${scale === 0.01 ? '1/100 ms (dividing by 100)' : 'ms (no conversion)'}\n`)
36
+
37
+ // --- 1. Commit summary ---
38
+ const fmt = (v) => v == null ? ' -' : (v * 1).toFixed(1).padStart(7)
39
+ console.log('=== Commit summary ===')
40
+ console.log(' # t(s) dur(ms) passive(ms) effects(ms) priority')
41
+ const sorted = [...commits].map((c, i) => ({ i, ...c })).sort((a, b) => b.duration - a.duration)
42
+ for (const c of sorted.slice(0, 15)) {
43
+ const ts = (c.timestamp / 1000).toFixed(3)
44
+ console.log(` ${String(c.i).padStart(2)} ${ts} ${fmt(c.duration)} ${fmt(c.passiveEffectDuration)} ${fmt(c.effectDuration)} ${c.priorityLevel ?? ''}`)
45
+ }
46
+
47
+ // --- 2. Aggregate self + actual duration per component ---
48
+ const selfTotals = new Map() // name → { total, count, max }
49
+ const actualTotals = new Map()
50
+
51
+ for (const commit of commits) {
52
+ for (const [id, raw] of commit.fiberActualDurations) {
53
+ const dur = raw * scale
54
+ const name = nameMap.get(id) ?? `(fiber#${id})`
55
+ const e = actualTotals.get(name) ?? { total: 0, count: 0, max: 0 }
56
+ e.total += dur; e.count += 1; e.max = Math.max(e.max, dur)
57
+ actualTotals.set(name, e)
58
+ }
59
+ for (const [id, raw] of commit.fiberSelfDurations) {
60
+ const dur = raw * scale
61
+ const name = nameMap.get(id) ?? `(fiber#${id})`
62
+ const e = selfTotals.get(name) ?? { total: 0, count: 0, max: 0 }
63
+ e.total += dur; e.count += 1; e.max = Math.max(e.max, dur)
64
+ selfTotals.set(name, e)
65
+ }
66
+ }
67
+
68
+ const ranked = [...selfTotals.entries()]
69
+ .sort((a, b) => b[1].total - a[1].total)
70
+ .filter(([, s]) => s.total > 0.5)
71
+
72
+ console.log('\n=== Top 40 components by SELF render time (excludes children) ===')
73
+ console.log(' Component Self total Renders Self max Actual total')
74
+ for (const [name, s] of ranked.slice(0, 40)) {
75
+ const actual = actualTotals.get(name) ?? { total: 0 }
76
+ console.log(
77
+ ` ${name.padEnd(48)} ${s.total.toFixed(1).padStart(8)} ms` +
78
+ ` ${String(s.count).padStart(6)}x` +
79
+ ` ${s.max.toFixed(1).padStart(7)} ms` +
80
+ ` ${actual.total.toFixed(1).padStart(10)} ms`
81
+ )
82
+ }
83
+
84
+ console.log('\n=== Most frequently re-rendering components (top 20) ===')
85
+ const byCount = [...selfTotals.entries()].sort((a, b) => b[1].count - a[1].count)
86
+ console.log(' Component Renders Self total')
87
+ for (const [name, s] of byCount.slice(0, 20)) {
88
+ console.log(` ${name.padEnd(48)} ${String(s.count).padStart(6)}x ${s.total.toFixed(1).padStart(8)} ms`)
89
+ }
90
+
91
+ const totalPassive = commits.reduce((a, c) => a + (c.passiveEffectDuration ?? 0), 0)
92
+ const totalCommit = commits.reduce((a, c) => a + c.duration, 0)
93
+ console.log(`\n=== Totals ===`)
94
+ console.log(` Total commit render time: ${totalCommit.toFixed(1)} ms (${commits.length} commits)`)
95
+ console.log(` Total passive effect time: ${totalPassive.toFixed(1)} ms (useEffect)`)
96
+ console.log(` Avg commit duration: ${(totalCommit / commits.length).toFixed(1)} ms`)
scripts/migrate-i18n.mts ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Extracts client locale files into per-namespace files under shared/src/i18n/{locale}/.
4
+ * Run with: npx tsx scripts/migrate-i18n.mts
5
+ *
6
+ * Safe to re-run — locale dirs are cleaned first. Hand-authored files
7
+ * (types.ts, languages.ts, index.ts) in shared/src/i18n/ are never touched.
8
+ */
9
+ import { mkdir, rm, writeFile } from 'fs/promises'
10
+ import { dirname, join } from 'path'
11
+ import { fileURLToPath, pathToFileURL } from 'url'
12
+
13
+ const __dirname = dirname(fileURLToPath(import.meta.url))
14
+ const ROOT = join(__dirname, '..')
15
+ const TRANSLATIONS_DIR = join(ROOT, 'client/src/i18n/translations')
16
+ const I18N_OUT = join(ROOT, 'shared/src/i18n')
17
+
18
+ // Maps locale code → source filename (without .ts) in client/src/i18n/translations/
19
+ const LOCALE_FILE_MAP: Record<string, string> = {
20
+ de: 'de', en: 'en', es: 'es', fr: 'fr', hu: 'hu',
21
+ it: 'it', tr: 'tr', ru: 'ru', zh: 'zh', 'zh-TW': 'zhTw',
22
+ nl: 'nl', id: 'id', ar: 'ar', br: 'br', cs: 'cs',
23
+ pl: 'pl', ja: 'ja', ko: 'ko', uk: 'uk',
24
+ }
25
+
26
+ type TranslationValue = string | { name: string; category: string }[]
27
+ type LocaleStrings = Record<string, TranslationValue>
28
+
29
+ async function loadLocale(code: string): Promise<LocaleStrings> {
30
+ const filename = LOCALE_FILE_MAP[code]
31
+ if (!filename) throw new Error(`Unknown locale code: ${code}`)
32
+ const file = join(TRANSLATIONS_DIR, `${filename}.ts`)
33
+ const mod = await import(pathToFileURL(file).href)
34
+ return mod.default as LocaleStrings
35
+ }
36
+
37
+ function serializeValue(value: TranslationValue, innerIndent: string): string {
38
+ if (Array.isArray(value)) {
39
+ // Pretty-print the array then re-indent each line after the first
40
+ const lines = JSON.stringify(value, null, 2).split('\n')
41
+ return lines.map((l, i) => (i === 0 ? l : innerIndent + l)).join('\n')
42
+ }
43
+ return JSON.stringify(value)
44
+ }
45
+
46
+ async function writeLocaleDir(code: string, strings: LocaleStrings): Promise<void> {
47
+ const outDir = join(I18N_OUT, code)
48
+ await mkdir(outDir, { recursive: true })
49
+
50
+ // Group keys by top-level namespace prefix (everything before the first dot)
51
+ const namespaces = new Map<string, Array<[string, TranslationValue]>>()
52
+ for (const [key, value] of Object.entries(strings)) {
53
+ const ns = key.split('.')[0] ?? key
54
+ if (!namespaces.has(ns)) namespaces.set(ns, [])
55
+ namespaces.get(ns)!.push([key, value])
56
+ }
57
+
58
+ // Write one file per namespace
59
+ for (const [ns, entries] of namespaces) {
60
+ const lines: string[] = [
61
+ `import type { TranslationStrings } from '../types'`,
62
+ ``,
63
+ `const ${ns}: TranslationStrings = {`,
64
+ ...entries.map(([k, v]) => ` ${JSON.stringify(k)}: ${serializeValue(v, ' ')},`),
65
+ `}`,
66
+ `export default ${ns}`,
67
+ ]
68
+ await writeFile(join(outDir, `${ns}.ts`), lines.join('\n') + '\n')
69
+ }
70
+
71
+ // Write index.ts that merges all namespace files into a single locale object
72
+ const nsNames = [...namespaces.keys()]
73
+ const indexLines: string[] = [
74
+ ...nsNames.map(ns => `import ${ns} from './${ns}'`),
75
+ ``,
76
+ `const locale = {`,
77
+ ...nsNames.map(ns => ` ...${ns},`),
78
+ `}`,
79
+ `export default locale`,
80
+ ]
81
+ await writeFile(join(outDir, 'index.ts'), indexLines.join('\n') + '\n')
82
+ }
83
+
84
+ async function main(): Promise<void> {
85
+ console.log('Loading English base...')
86
+ const en = await loadLocale('en')
87
+ const codes = Object.keys(LOCALE_FILE_MAP)
88
+
89
+ // Clean existing locale dirs; leave hand-authored files (types.ts, languages.ts, index.ts) alone
90
+ await Promise.all(codes.map(code => rm(join(I18N_OUT, code), { recursive: true, force: true })))
91
+
92
+ for (const code of codes) {
93
+ process.stdout.write(`Processing ${code}...`)
94
+ let strings = await loadLocale(code)
95
+
96
+ if (code === 'ar') {
97
+ // ar.ts spreads en — keep only keys that ar actually translates (value differs from en)
98
+ const pruned: LocaleStrings = {}
99
+ for (const [key, val] of Object.entries(strings)) {
100
+ if (JSON.stringify(val) !== JSON.stringify(en[key])) {
101
+ pruned[key] = val
102
+ }
103
+ }
104
+ strings = pruned
105
+ console.log(` ${Object.keys(strings).length} own keys (pruned from ${Object.keys(en).length} en total)`)
106
+ } else {
107
+ const nsCount = new Set(Object.keys(strings).map(k => k.split('.')[0])).size
108
+ console.log(` ${Object.keys(strings).length} keys, ${nsCount} namespaces`)
109
+ }
110
+
111
+ await writeLocaleDir(code, strings)
112
+ }
113
+
114
+ console.log('\nDone! Run: cd shared && npm run build')
115
+ }
116
+
117
+ main().catch(err => { console.error(err); process.exit(1) })
server/.env.example ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ PORT=3001 # Port to run the server on
2
+ # HOST=0.0.0.0 # Bind address for the HTTP server. Only set this when running TREK from sources or via the Proxmox community script — never in Docker (the container handles binding).
3
+ NODE_ENV=development # development = development mode; production = production mode
4
+ # ENCRYPTION_KEY=<random-256-bit-hex> # Separate key for encrypting stored secrets (API keys, MFA, SMTP, OIDC, etc.)
5
+ # Auto-generated and persisted to ./data/.encryption_key if not set.
6
+ # Upgrade from a version that used JWT_SECRET for encryption: set to your old JWT_SECRET value so
7
+ # existing encrypted data remains readable, then re-save credentials via the admin panel.
8
+ # Generate with: node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
9
+ TZ=UTC # Timezone for logs, reminders and scheduled tasks (e.g. Europe/Berlin)
10
+ # DEFAULT_LANGUAGE=en # Default language on the login page for users with no saved preference (default: en)
11
+ # SESSION_DURATION=30d # How long users stay logged in — sets the trek_session JWT exp + cookie maxAge. Accepts 1h, 12h, 7d, 30d, 90d. Default: 24h
12
+ # SESSION_DURATION_REMEMBER=30d # Session length when "Remember me" is ticked at login — longer-lived JWT + persistent cookie that survives browser restarts. Same format as SESSION_DURATION. Default: 30d
13
+ # Supported values: de, en, es, fr, hu, nl, br, cs, pl, ru, zh, zh-TW, it, ar
14
+ # Note: browser/OS language is detected automatically first; this is the fallback when no match is found.
15
+ LOG_LEVEL=info # info = concise user actions; debug = verbose admin-level details
16
+
17
+ ALLOWED_ORIGINS=https://trek.example.com # Comma-separated origins for CORS and email links
18
+ FORCE_HTTPS=false # Optional. When true: HTTPS redirect + HSTS + CSP upgrade-insecure-requests + secure cookies. Only behind a TLS proxy.
19
+ # HSTS_INCLUDE_SUBDOMAINS=false # When true: adds includeSubDomains to the HSTS header. Only effective when HSTS is active (FORCE_HTTPS=true or NODE_ENV=production). Leave false if you run other services on sibling subdomains over plain HTTP.
20
+ COOKIE_SECURE=true # Auto-derived (true when NODE_ENV=production or FORCE_HTTPS=true). Set false to force cookies over plain HTTP.
21
+ TRUST_PROXY=1 # Trusted proxy hops (parseInt or 1). Active in production by default; off in dev unless set. Needed for FORCE_HTTPS.
22
+ ALLOW_INTERNAL_NETWORK=false # Allow outbound requests to private/RFC1918 IPs (e.g. Immich hosted on your LAN). Loopback and link-local addresses are always blocked.
23
+
24
+ APP_URL=https://trek.example.com # Base URL of this instance — required when OIDC is enabled; must match the redirect URI registered with your IdP
25
+
26
+ OIDC_ISSUER=https://auth.example.com # OpenID Connect provider URL
27
+ OIDC_CLIENT_ID=trek # OpenID Connect client ID
28
+ OIDC_CLIENT_SECRET=supersecret # OpenID Connect client secret
29
+ OIDC_DISPLAY_NAME=SSO # Label shown on the SSO login button
30
+ OIDC_ONLY=true # Disable local password auth entirely (SSO only). Equivalent to setting password_login=false and password_registration=false in Admin > Settings.
31
+ OIDC_ADMIN_CLAIM=groups # OIDC claim used to identify admin users
32
+ OIDC_ADMIN_VALUE=app-trek-admins # Value of the OIDC claim that grants admin role
33
+ OIDC_DISCOVERY_URL= # Override the auto-constructed OIDC discovery endpoint. Useful for providers (e.g. Authentik) that expose it at a non-standard path. Example: https://auth.example.com/application/o/trek/.well-known/openid-configuration
34
+ OIDC_SCOPE=openid email profile # Fully overrides the default. Add extra scopes as needed (e.g. add groups if using OIDC_ADMIN_CLAIM)
35
+
36
+ DEMO_MODE=false # Demo mode - resets data hourly
37
+
38
+ # MCP_RATE_LIMIT=300 # Max MCP API requests per user per minute (default: 300)
39
+ # MCP_MAX_SESSION_PER_USER=20 # Max concurrent MCP sessions per user (default: 20)
40
+
41
+ # Initial admin account — only used on first boot when no users exist yet.
42
+ # If both are set the admin account is created with these credentials.
43
+ # If either is omitted a random password is generated and printed to the server log.
44
+ # ADMIN_EMAIL=admin@trek.local
45
+ # ADMIN_PASSWORD=changeme
server/.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ .atlas-geo-cache/
server/.prettierrc ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "printWidth": 120,
3
+ "singleQuote": true,
4
+ "trailingComma": "all",
5
+ "plugins": [
6
+ "prettier-plugin-organize-imports",
7
+ "@trivago/prettier-plugin-sort-imports"
8
+ ],
9
+ "importOrder": [
10
+ "^[a-zA-Z]",
11
+ "^@/.*"
12
+ ],
13
+ "importOrderSeparation": true,
14
+ "importOrderParserPlugins": [
15
+ "typescript",
16
+ "decorators-legacy"
17
+ ]
18
+ }
server/assets/airports.json ADDED
The diff for this file is too large to render. See raw diff
 
server/assets/atlas/admin0.geojson.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f17d1f8042810ce14555c52e25fabf39e9c720a4a6df0fea015d9b55235f1763
3
+ size 4355588
server/assets/atlas/admin1.geojson.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fde1f094ba26c007ffbad01d7fc84894d39fdb50655117dc38fcdb5b8f51b806
3
+ size 14767863
server/eslint.config.mjs ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import js from '@eslint/js';
2
+
3
+ import gitignore from 'eslint-config-flat-gitignore';
4
+ import eslintConfigPrettier from 'eslint-config-prettier';
5
+ import tseslint from 'typescript-eslint';
6
+
7
+ export default tseslint.config(
8
+ gitignore({ strict: false }),
9
+ {
10
+ ignores: [
11
+ 'node_modules',
12
+ 'dist',
13
+ 'coverage',
14
+ 'public',
15
+ 'data',
16
+ 'uploads',
17
+ 'assets',
18
+ 'scripts/**',
19
+ 'reset-admin.js',
20
+ '**/*.config.js',
21
+ '**/*.config.ts',
22
+ '**/*.config.mjs',
23
+ ],
24
+ },
25
+ js.configs.recommended,
26
+ ...tseslint.configs.recommended,
27
+ eslintConfigPrettier,
28
+ {
29
+ files: ['src/**/*.ts', 'tests/**/*.ts'],
30
+ rules: {
31
+ // --- Severities tuned to keep CI green on a codebase that was never linted ---
32
+ // (each rule below has pre-existing violations; surfaced as warnings, not blockers)
33
+ '@typescript-eslint/no-explicit-any': 'warn',
34
+ '@typescript-eslint/no-unused-vars': [
35
+ 'warn',
36
+ { argsIgnorePattern: '^_', varsIgnorePattern: '^_', caughtErrorsIgnorePattern: '^_' },
37
+ ],
38
+ // The server is CommonJS (tsconfig module: commonjs); require() is intentional throughout.
39
+ '@typescript-eslint/no-require-imports': 'warn',
40
+ '@typescript-eslint/no-unsafe-function-type': 'warn',
41
+ // js.recommended rules with pre-existing hits in the never-linted codebase.
42
+ 'no-empty': 'warn',
43
+ 'no-useless-escape': 'warn',
44
+ 'prefer-const': 'warn',
45
+ },
46
+ },
47
+ );
server/node_modules/.bin/eslint ADDED
@@ -0,0 +1,196 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * @fileoverview Main CLI that is run via the eslint command.
5
+ * @author Nicholas C. Zakas
6
+ */
7
+
8
+ /* eslint no-console:off -- CLI */
9
+
10
+ "use strict";
11
+
12
+ const mod = require("node:module");
13
+
14
+ // to use V8's code cache to speed up instantiation time
15
+ mod.enableCompileCache?.();
16
+
17
+ // must do this initialization *before* other requires in order to work
18
+ if (process.argv.includes("--debug")) {
19
+ require("debug").enable("eslint:*,-eslint:code-path,eslintrc:*");
20
+ }
21
+
22
+ //------------------------------------------------------------------------------
23
+ // Helpers
24
+ //------------------------------------------------------------------------------
25
+
26
+ /**
27
+ * Read data from stdin til the end.
28
+ *
29
+ * Note: See
30
+ * - https://github.com/nodejs/node/blob/master/doc/api/process.md#processstdin
31
+ * - https://github.com/nodejs/node/blob/master/doc/api/process.md#a-note-on-process-io
32
+ * - https://lists.gnu.org/archive/html/bug-gnu-emacs/2016-01/msg00419.html
33
+ * - https://github.com/nodejs/node/issues/7439 (historical)
34
+ *
35
+ * On Windows using `fs.readFileSync(STDIN_FILE_DESCRIPTOR, "utf8")` seems
36
+ * to read 4096 bytes before blocking and never drains to read further data.
37
+ *
38
+ * The investigation on the Emacs thread indicates:
39
+ *
40
+ * > Emacs on MS-Windows uses pipes to communicate with subprocesses; a
41
+ * > pipe on Windows has a 4K buffer. So as soon as Emacs writes more than
42
+ * > 4096 bytes to the pipe, the pipe becomes full, and Emacs then waits for
43
+ * > the subprocess to read its end of the pipe, at which time Emacs will
44
+ * > write the rest of the stuff.
45
+ * @returns {Promise<string>} The read text.
46
+ */
47
+ function readStdin() {
48
+ return new Promise((resolve, reject) => {
49
+ let content = "";
50
+ let chunk = "";
51
+
52
+ process.stdin
53
+ .setEncoding("utf8")
54
+ .on("readable", () => {
55
+ while ((chunk = process.stdin.read()) !== null) {
56
+ content += chunk;
57
+ }
58
+ })
59
+ .on("end", () => resolve(content))
60
+ .on("error", reject);
61
+ });
62
+ }
63
+
64
+ /**
65
+ * Get the error message of a given value.
66
+ * @param {any} error The value to get.
67
+ * @returns {string} The error message.
68
+ */
69
+ function getErrorMessage(error) {
70
+ // Lazy loading because this is used only if an error happened.
71
+ const util = require("node:util");
72
+
73
+ // Foolproof -- third-party module might throw non-object.
74
+ if (typeof error !== "object" || error === null) {
75
+ return String(error);
76
+ }
77
+
78
+ // Use templates if `error.messageTemplate` is present.
79
+ if (typeof error.messageTemplate === "string") {
80
+ try {
81
+ const template = require(`../messages/${error.messageTemplate}.js`);
82
+
83
+ return template(error.messageData || {});
84
+ } catch {
85
+ // Ignore template error then fallback to use `error.stack`.
86
+ }
87
+ }
88
+
89
+ // Use the stacktrace if it's an error object.
90
+ if (typeof error.stack === "string") {
91
+ return error.stack;
92
+ }
93
+
94
+ // Otherwise, dump the object.
95
+ return util.format("%o", error);
96
+ }
97
+
98
+ /**
99
+ * Tracks error messages that are shown to the user so we only ever show the
100
+ * same message once.
101
+ * @type {Set<string>}
102
+ */
103
+ const displayedErrors = new Set();
104
+
105
+ /**
106
+ * Tracks whether an unexpected error was caught
107
+ * @type {boolean}
108
+ */
109
+ let hadFatalError = false;
110
+
111
+ /**
112
+ * Catch and report unexpected error.
113
+ * @param {any} error The thrown error object.
114
+ * @returns {void}
115
+ */
116
+ function onFatalError(error) {
117
+ process.exitCode = 2;
118
+ hadFatalError = true;
119
+
120
+ const { version } = require("../package.json");
121
+ const message = `
122
+ Oops! Something went wrong! :(
123
+
124
+ ESLint: ${version}
125
+
126
+ ${getErrorMessage(error)}`;
127
+
128
+ if (!displayedErrors.has(message)) {
129
+ console.error(message);
130
+ displayedErrors.add(message);
131
+ }
132
+ }
133
+
134
+ //------------------------------------------------------------------------------
135
+ // Execution
136
+ //------------------------------------------------------------------------------
137
+
138
+ (async function main() {
139
+ process.on("uncaughtException", onFatalError);
140
+ process.on("unhandledRejection", onFatalError);
141
+
142
+ // Call the config initializer if `--init` is present.
143
+ if (process.argv.includes("--init")) {
144
+ // `eslint --init` has been moved to `@eslint/create-config`
145
+ console.warn(
146
+ "You can also run this command directly using 'npm init @eslint/config@latest'.",
147
+ );
148
+
149
+ const spawn = require("cross-spawn");
150
+
151
+ spawn.sync("npm", ["init", "@eslint/config@latest"], {
152
+ encoding: "utf8",
153
+ stdio: "inherit",
154
+ });
155
+ return;
156
+ }
157
+
158
+ // start the MCP server if `--mcp` is present
159
+ if (process.argv.includes("--mcp")) {
160
+ console.warn(
161
+ "You can also run this command directly using 'npx @eslint/mcp@latest'.",
162
+ );
163
+
164
+ const spawn = require("cross-spawn");
165
+
166
+ spawn.sync("npx", ["@eslint/mcp@latest"], {
167
+ encoding: "utf8",
168
+ stdio: "inherit",
169
+ });
170
+ return;
171
+ }
172
+
173
+ // Otherwise, call the CLI.
174
+ const cli = require("../lib/cli");
175
+ const exitCode = await cli.execute(
176
+ process.argv,
177
+ process.argv.includes("--stdin") ? await readStdin() : null,
178
+ true,
179
+ );
180
+
181
+ /*
182
+ * If an uncaught exception or unhandled rejection was detected in the meantime,
183
+ * keep the fatal exit code 2 that is already assigned to `process.exitCode`.
184
+ * Without this condition, exit code 2 (unsuccessful execution) could be overwritten with
185
+ * 1 (successful execution, lint problems found) or even 0 (successful execution, no lint problems found).
186
+ * This ensures that unexpected errors that seemingly don't affect the success
187
+ * of the execution will still cause a non-zero exit code, as it's a common
188
+ * practice and the default behavior of Node.js to exit with non-zero
189
+ * in case of an uncaught exception or unhandled rejection.
190
+ *
191
+ * Otherwise, assign the exit code returned from CLI.
192
+ */
193
+ if (!hadFatalError) {
194
+ process.exitCode = exitCode;
195
+ }
196
+ })().catch(onFatalError);
server/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":"4.1.9","results":[[":tests/unit/services/backupService.test.ts",{"duration":72.88777700000003,"failed":false}],[":tests/unit/services/journeyService.test.ts",{"duration":544.2470840000001,"failed":false}],[":tests/unit/services/mapsService.test.ts",{"duration":561.086721,"failed":false}],[":tests/unit/nest/memories.controller.test.ts",{"duration":46.69720899999993,"failed":false}],[":tests/unit/services/oauthService.test.ts",{"duration":390.3670400000001,"failed":false}],[":tests/unit/services/authServiceDb.test.ts",{"duration":1116.110368,"failed":false}],[":tests/unit/services/adminService.test.ts",{"duration":710.777752,"failed":false}],[":tests/unit/nest/journey.controller.test.ts",{"duration":54.650020999999924,"failed":false}],[":tests/unit/services/vacayService.test.ts",{"duration":316.27010799999994,"failed":false}],[":tests/unit/nest/oauth.controller.test.ts",{"duration":52.714594000000034,"failed":false}],[":tests/unit/services/weatherService.test.ts",{"duration":44.26596200000003,"failed":false}],[":tests/unit/services/notificationService.test.ts",{"duration":273.0619570000001,"failed":false}],[":tests/unit/services/placeService.test.ts",{"duration":335.6753960000001,"failed":false}],[":tests/unit/nest/auth.controller.test.ts",{"duration":2852.7422529999994,"failed":false}],[":tests/unit/services/atlasService.test.ts",{"duration":7072.837670999999,"failed":false}],[":tests/unit/services/oidcService.test.ts",{"duration":725.6601959999998,"failed":false}],[":tests/unit/nest/platform.controller.test.ts",{"duration":29.73896000000002,"failed":false}],[":tests/unit/nest/admin.controller.test.ts",{"duration":43.59301599999981,"failed":false}],[":tests/unit/services/notifications.test.ts",{"duration":28.404417999999993,"failed":false}],[":tests/unit/mcp/tools-collab-polls-chat.test.ts",{"duration":1995.609863,"failed":false}],[":tests/unit/mcp/resources.test.ts",{"duration":398.65050299999984,"failed":false}],[":tests/unit/services/journeyShareService.test.ts",{"duration":212.63990200000012,"failed":false}],[":tests/unit/mcp/tools-prompts.test.ts",{"duration":284.1428639999999,"failed":false}],[":tests/unit/mcp/tools-trips.test.ts",{"duration":1797.3274649999998,"failed":false}],[":tests/unit/mcp/tools-reservations.test.ts",{"duration":2005.1644890000002,"failed":false}],[":tests/unit/mcp/tools-vacay.test.ts",{"duration":2130.8184880000003,"failed":false}],[":tests/unit/nest/trips.controller.test.ts",{"duration":36.15199500000017,"failed":false}],[":tests/unit/mcp/tools-notes.test.ts",{"duration":1921.6359830000001,"failed":false}],[":tests/unit/nest/oidc.controller.test.ts",{"duration":41.665124000000105,"failed":false}],[":tests/unit/mcp/tools-packing-advanced.test.ts",{"duration":1755.3046669999999,"failed":false}],[":tests/unit/mcp/tools-places.test.ts",{"duration":1755.6623260000001,"failed":false}],[":tests/unit/services/tripService.test.ts",{"duration":210.72755399999983,"failed":false}],[":tests/unit/mcp/tools-todos.test.ts",{"duration":2856.983482,"failed":false}],[":tests/unit/services/dayService.test.ts",{"duration":215.53433999999993,"failed":false}],[":tests/unit/nest/packing.controller.test.ts",{"duration":31.118511000000126,"failed":false}],[":tests/unit/services/notificationPreferencesService.test.ts",{"duration":198.356223,"failed":false}],[":tests/unit/nest/maps.controller.test.ts",{"duration":33.95025600000008,"failed":false}],[":tests/unit/nest/files.controller.test.ts",{"duration":30.609980999999607,"failed":false}],[":tests/unit/services/collabService.test.ts",{"duration":257.8435280000001,"failed":false}],[":tests/unit/mcp/tools-assignments.test.ts",{"duration":1785.2703060000003,"failed":false}],[":tests/unit/mcp/tools-trip-members.test.ts",{"duration":1825.7453980000005,"failed":false}],[":tests/unit/nest/places.controller.test.ts",{"duration":32.401038999999855,"failed":false}],[":tests/unit/nest/backup.controller.test.ts",{"duration":68.95481400000017,"failed":false}],[":tests/unit/utils/ssrfGuard.test.ts",{"duration":27.78876200000002,"failed":false}],[":tests/unit/nest/collab.controller.test.ts",{"duration":24.988418000000365,"failed":false}],[":tests/unit/nest/auth-guard.test.ts",{"duration":726.2256990000001,"failed":false}],[":tests/unit/nest/budget.controller.test.ts",{"duration":21.524109000000408,"failed":false}],[":tests/unit/services/inAppNotificationPrefs.test.ts",{"duration":192.0378900000003,"failed":false}],[":tests/unit/mcp/tools-atlas-expanded.test.ts",{"duration":1373.343107,"failed":false}],[":tests/unit/services/packingService.test.ts",{"duration":184.82261799999992,"failed":false}],[":tests/unit/mcp/tools-packing.test.ts",{"duration":1405.6847829999997,"failed":false}],[":tests/unit/mcp/tools-tags-maps-weather.test.ts",{"duration":1172.0812379999998,"failed":false}],[":tests/unit/mcp/tools-days-accommodations.test.ts",{"duration":1162.0188549999998,"failed":false}],[":tests/unit/services/todoService.test.ts",{"duration":226.73333200000002,"failed":false}],[":tests/unit/mcp/tools-notifications.test.ts",{"duration":982.487104,"failed":false}],[":tests/unit/mcp/tools-addon-gating.test.ts",{"duration":1399.9524490000001,"failed":false}],[":tests/unit/nest/days.controller.test.ts",{"duration":24.480055999999877,"failed":false}],[":tests/unit/services/authService.test.ts",{"duration":19.503897999999936,"failed":false}],[":tests/unit/db/migration-hygiene.test.ts",{"duration":127.4783580000003,"failed":false}],[":tests/unit/mcp/tools-assignments-reservations-extra.test.ts",{"duration":1332.537511,"failed":false}],[":tests/unit/services/migration.test.ts",{"duration":21.06457499999999,"failed":false}],[":tests/unit/services/settingsService.test.ts",{"duration":205.26999899999987,"failed":false}],[":tests/unit/mcp/tools-budget.test.ts",{"duration":1018.6066659999999,"failed":false}],[":tests/unit/mcp/tools-atlas.test.ts",{"duration":1038.3976239999997,"failed":false}],[":tests/unit/scheduler.test.ts",{"duration":14.453812000000028,"failed":false}],[":tests/unit/mcp/tools-budget-advanced.test.ts",{"duration":819.8394349999999,"failed":false}],[":tests/unit/mcp/scopes.test.ts",{"duration":19.062081000000006,"failed":false}],[":tests/unit/services/memoriesUnified.test.ts",{"duration":157.2455070000001,"failed":false}],[":tests/unit/nest/memories.service.test.ts",{"duration":16.25730900000002,"failed":false}],[":tests/unit/nest/vacay.controller.test.ts",{"duration":19.178429999999935,"failed":false}],[":tests/unit/nest/notifications.controller.test.ts",{"duration":18.472768000000087,"failed":false}],[":tests/unit/services/memoriesHelpers.test.ts",{"duration":163.00971700000014,"failed":false}],[":tests/unit/middleware/auth.test.ts",{"duration":33.21620100000001,"failed":false}],[":tests/unit/services/budgetService.test.ts",{"duration":17.086539000000016,"failed":false}],[":tests/unit/services/categoryService.test.ts",{"duration":170.20973900000013,"failed":false}],[":tests/unit/nest/oauth.service.test.ts",{"duration":2018.3614579999999,"failed":false}],[":tests/unit/nest/budget.service.test.ts",{"duration":24.091949,"failed":false}],[":tests/unit/nest/assignments.controller.test.ts",{"duration":17.92524800000001,"failed":false}],[":tests/unit/nest/addons.service.test.ts",{"duration":10.926625000000001,"failed":false}],[":tests/unit/middleware/idempotency.test.ts",{"duration":18.685696999999976,"failed":false}],[":tests/unit/services/tagService.test.ts",{"duration":175.73593899999992,"failed":false}],[":tests/unit/nest/idempotency.interceptor.test.ts",{"duration":18.84929699999975,"failed":false}],[":tests/unit/nest/share.controller.test.ts",{"duration":17.332100000000082,"failed":false}],[":tests/unit/nest/reservations.controller.test.ts",{"duration":16.331610000000182,"failed":false}],[":tests/unit/services/versionNotification.test.ts",{"duration":171.08108900000002,"failed":false}],[":tests/unit/nest/oidc.service.test.ts",{"duration":14.911024999999995,"failed":false}],[":tests/unit/nest/atlas.controller.test.ts",{"duration":21.60403099999985,"failed":false}],[":tests/unit/services/placePhotoCache.test.ts",{"duration":1776.965209,"failed":false}],[":tests/unit/middleware/tripAccess.test.ts",{"duration":15.71427700000001,"failed":false}],[":tests/unit/nest/packing.service.test.ts",{"duration":17.085651999999982,"failed":false}],[":tests/unit/nest/files.service.test.ts",{"duration":14.918774999999982,"failed":false}],[":tests/unit/nest/todo.controller.test.ts",{"duration":17.41115899999977,"failed":false}],[":tests/unit/db/atlas-region-crosswalk.test.ts",{"duration":19472.390927,"failed":false}],[":tests/unit/nest/accommodations.controller.test.ts",{"duration":15.396150999999918,"failed":false}],[":tests/unit/services/airtrailMapper.test.ts",{"duration":43.537079999999975,"failed":false}],[":tests/unit/nest/reservations.service.test.ts",{"duration":15.022680999999977,"failed":false}],[":tests/unit/nest/exception-filter.test.ts",{"duration":21.46296000000001,"failed":false}],[":tests/unit/mcp/tools-days.test.ts",{"duration":586.2772440000001,"failed":false}],[":tests/unit/nest/trips.service.test.ts",{"duration":14.646309999999971,"failed":false}],[":tests/unit/nest/maps.service.test.ts",{"duration":17.30807200000004,"failed":false}],[":tests/unit/services/trimUserWhitespace.test.ts",{"duration":24.423379999999952,"failed":false}],[":tests/unit/services/ephemeralTokens.test.ts",{"duration":26.238873000000012,"failed":false}],[":tests/unit/services/passwordPolicy.test.ts",{"duration":10.647951000000006,"failed":false}],[":tests/unit/middleware/validate.test.ts",{"duration":14.795862,"failed":false}],[":tests/unit/mcp/sessionManager.test.ts",{"duration":11.748085000000003,"failed":false}],[":tests/unit/services/permissions.test.ts",{"duration":13.147329999999982,"failed":false}],[":tests/unit/nest/weather.controller.test.ts",{"duration":12.558528000000024,"failed":false}],[":tests/unit/services/webauthnConfig.test.ts",{"duration":10.579936000000004,"failed":false}],[":tests/unit/systemNotices/conditions.test.ts",{"duration":9.895058999999947,"failed":false}],[":tests/unit/middleware/mfaPolicy.test.ts",{"duration":11.071757999999988,"failed":false}],[":tests/unit/services/kmlImportUtils.test.ts",{"duration":13.071401000000009,"failed":false}],[":tests/unit/nest/tags.controller.test.ts",{"duration":11.65871900000002,"failed":false}],[":tests/unit/nest/categories.controller.test.ts",{"duration":11.382887999999866,"failed":false}],[":tests/unit/nest/share.service.test.ts",{"duration":10.803216999999961,"failed":false}],[":tests/unit/services/queryHelpers.test.ts",{"duration":6.998162000000008,"failed":false}],[":tests/unit/services/budgetServiceDb.test.ts",{"duration":137.62916900000005,"failed":false}],[":tests/unit/nest/settings.controller.test.ts",{"duration":11.166807000000063,"failed":false}],[":tests/unit/services/kitineraryMapper.test.ts",{"duration":15.954038000000082,"failed":false}],[":tests/unit/services/apiKeyCrypto.test.ts",{"duration":13.725144999999998,"failed":false}],[":tests/unit/nest/airports.controller.test.ts",{"duration":9.22424299999966,"failed":false}],[":tests/unit/systemNotices/registry.test.ts",{"duration":10.899081999999908,"failed":false}],[":tests/unit/services/cookie.test.ts",{"duration":16.844744999999875,"failed":false}],[":tests/unit/services/kmzUnpack.test.ts",{"duration":90.81008199999997,"failed":false}],[":tests/unit/nest/health.controller.test.ts",{"duration":7.507801999999629,"failed":false}],[":tests/unit/services/mfaCrypto.test.ts",{"duration":11.037395000000004,"failed":false}],[":tests/unit/idempotency-cleanup.test.ts",{"duration":7.435261999999966,"failed":false}],[":tests/unit/services/auditLog.test.ts",{"duration":5.731927999999982,"failed":false}],[":tests/unit/nest/system-notices.controller.test.ts",{"duration":8.683585000000221,"failed":false}],[":tests/unit/systemNotices/versionRange.test.ts",{"duration":9.310621000000083,"failed":false}],[":tests/unit/services/placeEnrichment.test.ts",{"duration":5.686984999999993,"failed":false}],[":tests/unit/nest/zod-pipe.test.ts",{"duration":10.00463400000001,"failed":false}],[":tests/unit/nest/wiring.test.ts",{"duration":41.917357000000266,"failed":false}],[":tests/unit/nest/database-service.test.ts",{"duration":6.418112999999948,"failed":false}],[":tests/unit/nest/addons.controller.test.ts",{"duration":5.9913489999999,"failed":false}],[":tests/unit/nest/health.di.test.ts",{"duration":17.67393600000014,"failed":false}],[":tests/unit/services/inAppNotificationActions.test.ts",{"duration":4.260765000000021,"failed":false}],[":tests/unit/nest/config.controller.test.ts",{"duration":16.033494999999903,"failed":false}],[":tests/unit/shared-contract.test.ts",{"duration":6.262807000000066,"failed":false}],[":tests/integration/oauth.test.ts",{"duration":1197.3883210000004,"failed":false}],[":tests/integration/memories-synology.test.ts",{"duration":968.255631,"failed":false}],[":tests/integration/auth.test.ts",{"duration":10857.045075999999,"failed":false}],[":tests/integration/admin.test.ts",{"duration":1765.4210950000002,"failed":false}],[":tests/integration/journey.test.ts",{"duration":928.8340909999997,"failed":false}],[":tests/integration/trips.test.ts",{"duration":1009.0605539999997,"failed":false}],[":tests/integration/places.test.ts",{"duration":1442.8168049999995,"failed":false}],[":tests/integration/memories-immich.test.ts",{"duration":793.2848629999999,"failed":false}],[":tests/integration/collab.test.ts",{"duration":1004.1223410000002,"failed":false}],[":tests/integration/budget.test.ts",{"duration":1016.4831139999997,"failed":false}],[":tests/integration/notifications.test.ts",{"duration":1163.672481,"failed":false}],[":tests/integration/days.test.ts",{"duration":768.8326939999997,"failed":false}],[":tests/integration/packing.test.ts",{"duration":826.0881530000001,"failed":false}],[":tests/integration/vacay.test.ts",{"duration":944.087399,"failed":false}],[":tests/integration/reservations.test.ts",{"duration":776.8815330000002,"failed":false}],[":tests/integration/files.test.ts",{"duration":894.084605,"failed":false}],[":tests/integration/assignments.test.ts",{"duration":704.2677530000001,"failed":false}],[":tests/integration/share.test.ts",{"duration":812.031947,"failed":false}],[":tests/integration/backup.test.ts",{"duration":735.8040339999998,"failed":false}],[":tests/integration/systemNotices.test.ts",{"duration":669.3220999999999,"failed":false}],[":tests/integration/atlas.test.ts",{"duration":3032.956958,"failed":false}],[":tests/integration/oidc.test.ts",{"duration":750.1101020000001,"failed":false}],[":tests/integration/maps.test.ts",{"duration":727.8061249999996,"failed":false}],[":tests/integration/memories-unified.test.ts",{"duration":722.7453399999999,"failed":false}],[":tests/integration/immich.test.ts",{"duration":633.9089379999996,"failed":false}],[":tests/integration/mcp.test.ts",{"duration":2627.9210030000004,"failed":false}],[":tests/integration/todo.test.ts",{"duration":789.750372,"failed":false}],[":tests/integration/profile.test.ts",{"duration":1549.6802660000003,"failed":false}],[":tests/integration/dayNotes.test.ts",{"duration":673.7739369999995,"failed":false}],[":tests/integration/security.test.ts",{"duration":669.5037120000006,"failed":false}],[":tests/integration/settings.test.ts",{"duration":650.2043699999999,"failed":false}],[":tests/integration/tags.test.ts",{"duration":619.7359840000004,"failed":false}],[":tests/integration/categories.test.ts",{"duration":646.8843860000002,"failed":false}],[":tests/integration/dayReorder.test.ts",{"duration":158.8958610000002,"failed":false}],[":tests/integration/misc.test.ts",{"duration":921.5608969999998,"failed":false}],[":tests/integration/bootstrap.test.ts",{"duration":736.41939,"failed":false}]]}
server/node_modules/@eslint/config-array/LICENSE ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
server/node_modules/@eslint/config-array/README.md ADDED
@@ -0,0 +1,368 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Config Array
2
+
3
+ ## Description
4
+
5
+ A config array is a way of managing configurations that are based on glob pattern matching of filenames. Each config array contains the information needed to determine the correct configuration for any file based on the filename.
6
+
7
+ **Note:** This is a generic package that can be used outside of ESLint. It contains no ESLint-specific functionality.
8
+
9
+ ## Installation
10
+
11
+ For Node.js and compatible runtimes:
12
+
13
+ ```shell
14
+ npm install @eslint/config-array
15
+ # or
16
+ yarn add @eslint/config-array
17
+ # or
18
+ pnpm install @eslint/config-array
19
+ # or
20
+ bun add @eslint/config-array
21
+ ```
22
+
23
+ For Deno:
24
+
25
+ ```shell
26
+ deno add @eslint/config-array
27
+ ```
28
+
29
+ ## Background
30
+
31
+ The basic idea is that all configuration, including overrides, can be represented by a single array where each item in the array is a config object. Config objects appearing later in the array override config objects appearing earlier in the array. You can calculate a config for a given file by traversing all config objects in the array to find the ones that match the filename. Matching is done by specifying glob patterns in `files` and `ignores` properties on each config object. Here's an example:
32
+
33
+ ```js
34
+ export default [
35
+ // match all JSON files
36
+ {
37
+ name: "JSON Handler",
38
+ files: ["**/*.json"],
39
+ handler: jsonHandler,
40
+ },
41
+
42
+ // match only package.json
43
+ {
44
+ name: "package.json Handler",
45
+ files: ["package.json"],
46
+ handler: packageJsonHandler,
47
+ },
48
+ ];
49
+ ```
50
+
51
+ In this example, there are two config objects: the first matches all JSON files in all directories and the second matches just `package.json` in the base path directory (all the globs are evaluated as relative to a base path that can be specified). When you retrieve a configuration for `foo.json`, only the first config object matches so `handler` is equal to `jsonHandler`; when you retrieve a configuration for `package.json`, `handler` is equal to `packageJsonHandler` (because both config objects match, the second one wins).
52
+
53
+ ## Usage
54
+
55
+ First, import the `ConfigArray` constructor:
56
+
57
+ ```js
58
+ import { ConfigArray } from "@eslint/config-array";
59
+
60
+ // or using CommonJS
61
+
62
+ const { ConfigArray } = require("@eslint/config-array");
63
+ ```
64
+
65
+ When you create a new instance of `ConfigArray`, you must pass in two arguments: an array of configs and an options object. The array of configs is most likely read in from a configuration file, so here's a typical example:
66
+
67
+ ```js
68
+ const configFilename = path.resolve(process.cwd(), "my.config.js");
69
+ const { default: rawConfigs } = await import(configFilename);
70
+ const configs = new ConfigArray(rawConfigs, {
71
+ // the path to match filenames from
72
+ basePath: process.cwd(),
73
+
74
+ // additional items in each config
75
+ schema: mySchema,
76
+ });
77
+ ```
78
+
79
+ This example reads in an object or array from `my.config.js` and passes it into the `ConfigArray` constructor as the first argument. The second argument is an object specifying the `basePath` (the directory in which `my.config.js` is found) and a `schema` to define the additional properties of a config object beyond `files`, `ignores`, `basePath`, and `name`.
80
+
81
+ ### Specifying a Schema
82
+
83
+ The `schema` option is required for you to use additional properties in config objects. The schema is an object that follows the format of an [`ObjectSchema`](https://npmjs.com/package/@eslint/object-schema). The schema specifies both validation and merge rules that the `ConfigArray` instance needs to combine configs when there are multiple matches. Here's an example:
84
+
85
+ ```js
86
+ const configFilename = path.resolve(process.cwd(), "my.config.js");
87
+ const { default: rawConfigs } = await import(configFilename);
88
+
89
+ const mySchema = {
90
+
91
+ // define the handler key in configs
92
+ handler: {
93
+ required: true,
94
+ merge(a, b) {
95
+ if (!b) return a;
96
+ if (!a) return b;
97
+ },
98
+ validate(value) {
99
+ if (typeof value !== "function") {
100
+ throw new TypeError("Function expected.");
101
+ }
102
+ }
103
+ }
104
+ };
105
+
106
+ const configs = new ConfigArray(rawConfigs, {
107
+
108
+ // the path to match filenames from
109
+ basePath: process.cwd(),
110
+
111
+ // additional item schemas in each config
112
+ schema: mySchema,
113
+
114
+ // additional config types supported (default: [])
115
+ extraConfigTypes: ["array", "function"];
116
+ });
117
+ ```
118
+
119
+ ### Config Arrays
120
+
121
+ Config arrays can be multidimensional, so it's possible for a config array to contain another config array when `extraConfigTypes` contains `"array"`, such as:
122
+
123
+ ```js
124
+ export default [
125
+ // JS config
126
+ {
127
+ files: ["**/*.js"],
128
+ handler: jsHandler,
129
+ },
130
+
131
+ // JSON configs
132
+ [
133
+ // match all JSON files
134
+ {
135
+ name: "JSON Handler",
136
+ files: ["**/*.json"],
137
+ handler: jsonHandler,
138
+ },
139
+
140
+ // match only package.json
141
+ {
142
+ name: "package.json Handler",
143
+ files: ["package.json"],
144
+ handler: packageJsonHandler,
145
+ },
146
+ ],
147
+
148
+ // filename must match function
149
+ {
150
+ files: [filePath => filePath.endsWith(".md")],
151
+ handler: markdownHandler,
152
+ },
153
+
154
+ // filename must match all patterns in subarray
155
+ {
156
+ files: [["*.test.*", "*.js"]],
157
+ handler: jsTestHandler,
158
+ },
159
+
160
+ // filename must not match patterns beginning with !
161
+ {
162
+ name: "Non-JS files",
163
+ files: ["!*.js"],
164
+ settings: {
165
+ js: false,
166
+ },
167
+ },
168
+
169
+ // specific settings for files inside `src` directory
170
+ {
171
+ name: "Source files",
172
+ basePath: "src",
173
+ files: ["**/*"],
174
+ settings: {
175
+ source: true,
176
+ },
177
+ },
178
+ ];
179
+ ```
180
+
181
+ In this example, the array contains both config objects and a config array. When a config array is normalized (see details below), it is flattened so only config objects remain. However, the order of evaluation remains the same.
182
+
183
+ If the `files` array contains a function, then that function is called with the path of the file as it was passed in. The function is expected to return `true` if there is a match and `false` if not. (The `ignores` array can also contain functions.)
184
+
185
+ If the `files` array contains an item that is an array of strings and functions, then all patterns must match in order for the config to match. In the preceding examples, both `*.test.*` and `*.js` must match in order for the config object to be used.
186
+
187
+ If a pattern in the files array begins with `!` then it excludes that pattern. In the preceding example, any filename that doesn't end with `.js` will automatically get a `settings.js` property set to `false`.
188
+
189
+ You can also specify an `ignores` key that will force files matching those patterns to not be included. If the `ignores` key is in a config object without any other keys, then those ignores will always be applied; otherwise those ignores act as exclusions. Here's an example:
190
+
191
+ ```js
192
+ export default [
193
+
194
+ // Always ignored
195
+ {
196
+ ignores: ["**/.git/**", "**/node_modules/**"]
197
+ },
198
+
199
+ // .eslintrc.js file is ignored only when .js file matches
200
+ {
201
+ files: ["**/*.js"],
202
+ ignores: [".eslintrc.js"]
203
+ handler: jsHandler
204
+ }
205
+ ];
206
+ ```
207
+
208
+ You can use negated patterns in `ignores` to exclude a file that was already ignored, such as:
209
+
210
+ ```js
211
+ export default [
212
+ // Ignore all JSON files except tsconfig.json
213
+ {
214
+ files: ["**/*"],
215
+ ignores: ["**/*.json", "!tsconfig.json"],
216
+ },
217
+ ];
218
+ ```
219
+
220
+ ### Config Functions
221
+
222
+ Config arrays can also include config functions when `extraConfigTypes` contains `"function"`. A config function accepts a single parameter, `context` (defined by you), and must return either a config object or a config array (it cannot return another function). Config functions allow end users to execute code in the creation of appropriate config objects. Here's an example:
223
+
224
+ ```js
225
+ export default [
226
+ // JS config
227
+ {
228
+ files: ["**/*.js"],
229
+ handler: jsHandler,
230
+ },
231
+
232
+ // JSON configs
233
+ function (context) {
234
+ return [
235
+ // match all JSON files
236
+ {
237
+ name: context.name + " JSON Handler",
238
+ files: ["**/*.json"],
239
+ handler: jsonHandler,
240
+ },
241
+
242
+ // match only package.json
243
+ {
244
+ name: context.name + " package.json Handler",
245
+ files: ["package.json"],
246
+ handler: packageJsonHandler,
247
+ },
248
+ ];
249
+ },
250
+ ];
251
+ ```
252
+
253
+ When a config array is normalized, each function is executed and replaced in the config array with the return value.
254
+
255
+ **Note:** Config functions can also be async.
256
+
257
+ ### Normalizing Config Arrays
258
+
259
+ Once a config array has been created and loaded with all of the raw config data, it must be normalized before it can be used. The normalization process goes through and flattens the config array as well as executing all config functions to get their final values.
260
+
261
+ To normalize a config array, call the `normalize()` method and pass in a context object:
262
+
263
+ ```js
264
+ await configs.normalize({
265
+ name: "MyApp",
266
+ });
267
+ ```
268
+
269
+ The `normalize()` method returns a promise, so be sure to use the `await` operator. The config array instance is normalized in-place, so you don't need to create a new variable.
270
+
271
+ If you want to disallow async config functions, you can call `normalizeSync()` instead. This method is completely synchronous and does not require using the `await` operator as it does not return a promise:
272
+
273
+ ```js
274
+ await configs.normalizeSync({
275
+ name: "MyApp",
276
+ });
277
+ ```
278
+
279
+ **Important:** Once a `ConfigArray` is normalized, it cannot be changed further. You can, however, create a new `ConfigArray` and pass in the normalized instance to create an unnormalized copy.
280
+
281
+ ### Getting Config for a File
282
+
283
+ To get the config for a file, use the `getConfig()` method on a normalized config array and pass in the filename to get a config for:
284
+
285
+ ```js
286
+ // pass in filename
287
+ const fileConfig = configs.getConfig(
288
+ path.resolve(process.cwd(), "package.json"),
289
+ );
290
+ ```
291
+
292
+ The config array always returns an object, even if there are no configs matching the given filename. You can then inspect the returned config object to determine how to proceed.
293
+
294
+ A few things to keep in mind:
295
+
296
+ - If a filename is not an absolute path, it will be resolved relative to the base path directory.
297
+ - The returned config object never has `files`, `ignores`, `basePath`, or `name` properties; the only properties on the object will be the other configuration options specified.
298
+ - The config array caches configs, so subsequent calls to `getConfig()` with the same filename will return in a fast lookup rather than another calculation.
299
+ - A config will only be generated if the filename matches an entry in a `files` key. A config will not be generated without matching a `files` key (configs without a `files` key are only applied when another config with a `files` key is applied; configs without `files` are never applied on their own). Any config with a `files` key entry that is `*` or ends with `/**` or `/*` will only be applied if another entry in the same `files` key matches or another config matches.
300
+
301
+ ## Determining Ignored Paths
302
+
303
+ You can determine if a file is ignored by using the `isFileIgnored()` method and passing in the path of any file, as in this example:
304
+
305
+ ```js
306
+ const ignored = configs.isFileIgnored("/foo/bar/baz.txt");
307
+ ```
308
+
309
+ A file is considered ignored if any of the following is true:
310
+
311
+ - **It's parent directory is ignored.** For example, if `foo` is in `ignores`, then `foo/a.js` is considered ignored.
312
+ - **It has an ancestor directory that is ignored.** For example, if `foo` is in `ignores`, then `foo/baz/a.js` is considered ignored.
313
+ - **It matches an ignored file pattern.** For example, if `**/a.js` is in `ignores`, then `foo/a.js` and `foo/baz/a.js` are considered ignored.
314
+ - **If it matches an entry in `files` and also in `ignores`.** For example, if `**/*.js` is in `files` and `**/a.js` is in `ignores`, then `foo/a.js` and `foo/baz/a.js` are considered ignored.
315
+ - **The file is outside the `basePath`.** If the `basePath` is `/usr/me`, then `/foo/a.js` is considered ignored.
316
+
317
+ For directories, use the `isDirectoryIgnored()` method and pass in the path of any directory, as in this example:
318
+
319
+ ```js
320
+ const ignored = configs.isDirectoryIgnored("/foo/bar/");
321
+ ```
322
+
323
+ A directory is considered ignored if any of the following is true:
324
+
325
+ - **It's parent directory is ignored.** For example, if `foo` is in `ignores`, then `foo/baz` is considered ignored.
326
+ - **It has an ancestor directory that is ignored.** For example, if `foo` is in `ignores`, then `foo/bar/baz/a.js` is considered ignored.
327
+ - **It matches and ignored file pattern.** For example, if `**/a.js` is in `ignores`, then `foo/a.js` and `foo/baz/a.js` are considered ignored.
328
+ - **If it matches an entry in `files` and also in `ignores`.** For example, if `**/*.js` is in `files` and `**/a.js` is in `ignores`, then `foo/a.js` and `foo/baz/a.js` are considered ignored.
329
+ - **The file is outside the `basePath`.** If the `basePath` is `/usr/me`, then `/foo/a.js` is considered ignored.
330
+
331
+ **Important:** A pattern such as `foo/**` means that `foo` and `foo/` are _not_ ignored whereas `foo/bar` is ignored. If you want to ignore `foo` and all of its subdirectories, use the pattern `foo` or `foo/` in `ignores`.
332
+
333
+ ## Caching Mechanisms
334
+
335
+ Each `ConfigArray` aggressively caches configuration objects to avoid unnecessary work. This caching occurs in two ways:
336
+
337
+ 1. **File-based Caching.** For each filename that is passed into a method, the resulting config is cached against that filename so you're always guaranteed to get the same object returned from `getConfig()` whenever you pass the same filename in.
338
+ 2. **Index-based Caching.** Whenever a config is calculated, the config elements that were used to create the config are also cached. So if a given filename matches elements 1, 5, and 7, the resulting config is cached with a key of `1,5,7`. That way, if another file is passed that matches the same config elements, the result is already known and doesn't have to be recalculated. That means two files that match all the same elements will return the same config from `getConfig()`.
339
+
340
+ ## Acknowledgements
341
+
342
+ The design of this project was influenced by feedback on the ESLint RFC, and incorporates ideas from:
343
+
344
+ - Teddy Katz (@not-an-aardvark)
345
+ - Toru Nagashima (@mysticatea)
346
+ - Kai Cataldo (@kaicataldo)
347
+
348
+ ## License
349
+
350
+ Apache 2.0
351
+
352
+ <!-- NOTE: This section is autogenerated. Do not manually edit.-->
353
+ <!--sponsorsstart-->
354
+
355
+ ## Sponsors
356
+
357
+ The following companies, organizations, and individuals support ESLint's ongoing maintenance and development. [Become a Sponsor](https://eslint.org/donate)
358
+ to get your logo on our READMEs and [website](https://eslint.org/sponsors).
359
+
360
+ <h3>Platinum Sponsors</h3>
361
+ <p><a href="https://automattic.com"><img src="https://images.opencollective.com/automattic/d0ef3e1/logo.png" alt="Automattic" height="128"></a> <a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/airbnb/d327d66/logo.png" alt="Airbnb" height="128"></a></p><h3>Gold Sponsors</h3>
362
+ <p><a href="https://qlty.sh/"><img src="https://images.opencollective.com/qltysh/33d157d/logo.png" alt="Qlty Software" height="96"></a> <a href="https://trunk.io/"><img src="https://images.opencollective.com/trunkio/fb92d60/avatar.png" alt="trunk.io" height="96"></a> <a href="https://shopify.engineering/"><img src="https://avatars.githubusercontent.com/u/8085" alt="Shopify" height="96"></a></p><h3>Silver Sponsors</h3>
363
+ <p><a href="https://vite.dev/"><img src="https://images.opencollective.com/vite/e6d15e1/logo.png" alt="Vite" height="64"></a> <a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/5c4fa84/logo.png" alt="Liftoff" height="64"></a> <a href="https://americanexpress.io"><img src="https://avatars.githubusercontent.com/u/3853301" alt="American Express" height="64"></a> <a href="https://stackblitz.com"><img src="https://avatars.githubusercontent.com/u/28635252" alt="StackBlitz" height="64"></a></p><h3>Bronze Sponsors</h3>
364
+ <p><a href="https://syntax.fm"><img src="https://github.com/syntaxfm.png" alt="Syntax" height="32"></a> <a href="https://cybozu.co.jp/"><img src="https://images.opencollective.com/cybozu/933e46d/logo.png" alt="Cybozu" height="32"></a> <a href="https://sentry.io"><img src="https://github.com/getsentry.png" alt="Sentry" height="32"></a> <a href="https://discord.com"><img src="https://images.opencollective.com/discordapp/f9645d9/logo.png" alt="Discord" height="32"></a> <a href="https://www.gitbook.com"><img src="https://avatars.githubusercontent.com/u/7111340" alt="GitBook" height="32"></a> <a href="https://nx.dev"><img src="https://avatars.githubusercontent.com/u/23692104" alt="Nx" height="32"></a> <a href="https://opensource.mercedes-benz.com/"><img src="https://avatars.githubusercontent.com/u/34240465" alt="Mercedes-Benz Group" height="32"></a> <a href="https://herocoders.com"><img src="https://avatars.githubusercontent.com/u/37549774" alt="HeroCoders" height="32"></a> <a href="https://www.lambdatest.com"><img src="https://avatars.githubusercontent.com/u/171592363" alt="LambdaTest" height="32"></a></p>
365
+ <h3>Technology Sponsors</h3>
366
+ Technology sponsors allow us to use their products and services for free as part of a contribution to the open source ecosystem and our work.
367
+ <p><a href="https://netlify.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/netlify-icon.svg" alt="Netlify" height="32"></a> <a href="https://algolia.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/algolia-icon.svg" alt="Algolia" height="32"></a> <a href="https://1password.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/1password-icon.svg" alt="1Password" height="32"></a></p>
368
+ <!--sponsorsend-->
server/node_modules/@eslint/config-array/dist/cjs/index.cjs ADDED
@@ -0,0 +1,1539 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict';
2
+
3
+ var posixPath = require('./std__path/posix.cjs');
4
+ var windowsPath = require('./std__path/windows.cjs');
5
+ var minimatch = require('minimatch');
6
+ var createDebug = require('debug');
7
+ var objectSchema = require('@eslint/object-schema');
8
+
9
+ function _interopNamespaceDefault(e) {
10
+ var n = Object.create(null);
11
+ if (e) {
12
+ Object.keys(e).forEach(function (k) {
13
+ if (k !== 'default') {
14
+ var d = Object.getOwnPropertyDescriptor(e, k);
15
+ Object.defineProperty(n, k, d.get ? d : {
16
+ enumerable: true,
17
+ get: function () { return e[k]; }
18
+ });
19
+ }
20
+ });
21
+ }
22
+ n.default = e;
23
+ return Object.freeze(n);
24
+ }
25
+
26
+ var posixPath__namespace = /*#__PURE__*/_interopNamespaceDefault(posixPath);
27
+ var windowsPath__namespace = /*#__PURE__*/_interopNamespaceDefault(windowsPath);
28
+
29
+ /**
30
+ * @fileoverview ConfigSchema
31
+ * @author Nicholas C. Zakas
32
+ */
33
+
34
+ //------------------------------------------------------------------------------
35
+ // Types
36
+ //------------------------------------------------------------------------------
37
+
38
+ /** @import * as $eslintobjectschema from "@eslint/object-schema"; */
39
+ /** @typedef {$eslintobjectschema.PropertyDefinition} PropertyDefinition */
40
+ /** @typedef {$eslintobjectschema.ObjectDefinition} ObjectDefinition */
41
+
42
+ //------------------------------------------------------------------------------
43
+ // Helpers
44
+ //------------------------------------------------------------------------------
45
+
46
+ /**
47
+ * A strategy that does nothing.
48
+ * @type {PropertyDefinition}
49
+ */
50
+ const NOOP_STRATEGY = {
51
+ required: false,
52
+ merge() {
53
+ return undefined;
54
+ },
55
+ validate() {},
56
+ };
57
+
58
+ //------------------------------------------------------------------------------
59
+ // Exports
60
+ //------------------------------------------------------------------------------
61
+
62
+ /**
63
+ * The base schema that every ConfigArray uses.
64
+ * @type {ObjectDefinition}
65
+ */
66
+ const baseSchema = Object.freeze({
67
+ name: {
68
+ required: false,
69
+ merge() {
70
+ return undefined;
71
+ },
72
+ validate(value) {
73
+ if (typeof value !== "string") {
74
+ throw new TypeError("Property must be a string.");
75
+ }
76
+ },
77
+ },
78
+ basePath: NOOP_STRATEGY,
79
+ files: NOOP_STRATEGY,
80
+ ignores: NOOP_STRATEGY,
81
+ });
82
+
83
+ /**
84
+ * @fileoverview ConfigSchema
85
+ * @author Nicholas C. Zakas
86
+ */
87
+
88
+ //------------------------------------------------------------------------------
89
+ // Types
90
+ //------------------------------------------------------------------------------
91
+
92
+
93
+ //------------------------------------------------------------------------------
94
+ // Helpers
95
+ //------------------------------------------------------------------------------
96
+
97
+ /**
98
+ * Asserts that a given value is an array.
99
+ * @param {*} value The value to check.
100
+ * @returns {void}
101
+ * @throws {TypeError} When the value is not an array.
102
+ */
103
+ function assertIsArray(value) {
104
+ if (!Array.isArray(value)) {
105
+ throw new TypeError("Expected value to be an array.");
106
+ }
107
+ }
108
+
109
+ /**
110
+ * Asserts that a given value is an array containing only strings and functions.
111
+ * @param {*} value The value to check.
112
+ * @returns {void}
113
+ * @throws {TypeError} When the value is not an array of strings and functions.
114
+ */
115
+ function assertIsArrayOfStringsAndFunctions(value) {
116
+ assertIsArray(value);
117
+
118
+ if (
119
+ value.some(
120
+ item => typeof item !== "string" && typeof item !== "function",
121
+ )
122
+ ) {
123
+ throw new TypeError(
124
+ "Expected array to only contain strings and functions.",
125
+ );
126
+ }
127
+ }
128
+
129
+ /**
130
+ * Asserts that a given value is a non-empty array.
131
+ * @param {*} value The value to check.
132
+ * @returns {void}
133
+ * @throws {TypeError} When the value is not an array or an empty array.
134
+ */
135
+ function assertIsNonEmptyArray(value) {
136
+ if (!Array.isArray(value) || value.length === 0) {
137
+ throw new TypeError("Expected value to be a non-empty array.");
138
+ }
139
+ }
140
+
141
+ //------------------------------------------------------------------------------
142
+ // Exports
143
+ //------------------------------------------------------------------------------
144
+
145
+ /**
146
+ * The schema for `files` and `ignores` that every ConfigArray uses.
147
+ * @type {ObjectDefinition}
148
+ */
149
+ const filesAndIgnoresSchema = Object.freeze({
150
+ basePath: {
151
+ required: false,
152
+ merge() {
153
+ return undefined;
154
+ },
155
+ validate(value) {
156
+ if (typeof value !== "string") {
157
+ throw new TypeError("Expected value to be a string.");
158
+ }
159
+ },
160
+ },
161
+ files: {
162
+ required: false,
163
+ merge() {
164
+ return undefined;
165
+ },
166
+ validate(value) {
167
+ // first check if it's an array
168
+ assertIsNonEmptyArray(value);
169
+
170
+ // then check each member
171
+ value.forEach(item => {
172
+ if (Array.isArray(item)) {
173
+ assertIsArrayOfStringsAndFunctions(item);
174
+ } else if (
175
+ typeof item !== "string" &&
176
+ typeof item !== "function"
177
+ ) {
178
+ throw new TypeError(
179
+ "Items must be a string, a function, or an array of strings and functions.",
180
+ );
181
+ }
182
+ });
183
+ },
184
+ },
185
+ ignores: {
186
+ required: false,
187
+ merge() {
188
+ return undefined;
189
+ },
190
+ validate: assertIsArrayOfStringsAndFunctions,
191
+ },
192
+ });
193
+
194
+ /**
195
+ * @fileoverview ConfigArray
196
+ * @author Nicholas C. Zakas
197
+ */
198
+
199
+
200
+ //------------------------------------------------------------------------------
201
+ // Types
202
+ //------------------------------------------------------------------------------
203
+
204
+ /** @import * as $typests from "./types.ts"; */
205
+ /** @typedef {$typests.ConfigObject} ConfigObject */
206
+ /** @import * as $minimatch from "minimatch"; */
207
+ /** @typedef {$minimatch.IMinimatchStatic} IMinimatchStatic */
208
+ /** @typedef {$minimatch.IMinimatch} IMinimatch */
209
+ /** @import * as PathImpl from "@jsr/std__path" */
210
+
211
+ /*
212
+ * This is a bit of a hack to make TypeScript happy with the Rollup-created
213
+ * CommonJS file. Rollup doesn't do object destructuring for imported files
214
+ * and instead imports the default via `require()`. This messes up type checking
215
+ * for `ObjectSchema`. To work around that, we just import the type manually
216
+ * and give it a different name to use in the JSDoc comments.
217
+ */
218
+ /** @typedef {ObjectSchema} ObjectSchemaInstance */
219
+
220
+ //------------------------------------------------------------------------------
221
+ // Helpers
222
+ //------------------------------------------------------------------------------
223
+
224
+ const Minimatch = minimatch.Minimatch;
225
+ const debug = createDebug("@eslint/config-array");
226
+
227
+ /**
228
+ * A cache for minimatch instances.
229
+ * @type {Map<string, IMinimatch>}
230
+ */
231
+ const minimatchCache = new Map();
232
+
233
+ /**
234
+ * A cache for negated minimatch instances.
235
+ * @type {Map<string, IMinimatch>}
236
+ */
237
+ const negatedMinimatchCache = new Map();
238
+
239
+ /**
240
+ * Options to use with minimatch.
241
+ * @type {Object}
242
+ */
243
+ const MINIMATCH_OPTIONS = {
244
+ // matchBase: true,
245
+ dot: true,
246
+ allowWindowsEscape: true,
247
+ };
248
+
249
+ /**
250
+ * The types of config objects that are supported.
251
+ * @type {Set<string>}
252
+ */
253
+ const CONFIG_TYPES = new Set(["array", "function"]);
254
+
255
+ /**
256
+ * Fields that are considered metadata and not part of the config object.
257
+ * @type {Set<string>}
258
+ */
259
+ const META_FIELDS = new Set(["name", "basePath"]);
260
+
261
+ /**
262
+ * A schema containing just files and ignores for early validation.
263
+ * @type {ObjectSchemaInstance}
264
+ */
265
+ const FILES_AND_IGNORES_SCHEMA = new objectSchema.ObjectSchema(filesAndIgnoresSchema);
266
+
267
+ // Precomputed constant objects returned by `ConfigArray.getConfigWithStatus`.
268
+
269
+ const CONFIG_WITH_STATUS_EXTERNAL = Object.freeze({ status: "external" });
270
+ const CONFIG_WITH_STATUS_IGNORED = Object.freeze({ status: "ignored" });
271
+ const CONFIG_WITH_STATUS_UNCONFIGURED = Object.freeze({
272
+ status: "unconfigured",
273
+ });
274
+
275
+ // Match two leading dots followed by a slash or the end of input.
276
+ const EXTERNAL_PATH_REGEX = /^\.\.(?:\/|$)/u;
277
+
278
+ /**
279
+ * Wrapper error for config validation errors that adds a name to the front of the
280
+ * error message.
281
+ */
282
+ class ConfigError extends Error {
283
+ /**
284
+ * Creates a new instance.
285
+ * @param {string} name The config object name causing the error.
286
+ * @param {number} index The index of the config object in the array.
287
+ * @param {Object} options The options for the error.
288
+ * @param {Error} [options.cause] The error that caused this error.
289
+ * @param {string} [options.message] The message to use for the error.
290
+ */
291
+ constructor(name, index, { cause, message }) {
292
+ const finalMessage = message || cause.message;
293
+
294
+ super(`Config ${name}: ${finalMessage}`, { cause });
295
+
296
+ // copy over custom properties that aren't represented
297
+ if (cause) {
298
+ for (const key of Object.keys(cause)) {
299
+ if (!(key in this)) {
300
+ this[key] = cause[key];
301
+ }
302
+ }
303
+ }
304
+
305
+ /**
306
+ * The name of the error.
307
+ * @type {string}
308
+ * @readonly
309
+ */
310
+ this.name = "ConfigError";
311
+
312
+ /**
313
+ * The index of the config object in the array.
314
+ * @type {number}
315
+ * @readonly
316
+ */
317
+ this.index = index;
318
+ }
319
+ }
320
+
321
+ /**
322
+ * Gets the name of a config object.
323
+ * @param {ConfigObject} config The config object to get the name of.
324
+ * @returns {string} The name of the config object.
325
+ */
326
+ function getConfigName(config) {
327
+ if (config && typeof config.name === "string" && config.name) {
328
+ return `"${config.name}"`;
329
+ }
330
+
331
+ return "(unnamed)";
332
+ }
333
+
334
+ /**
335
+ * Rethrows a config error with additional information about the config object.
336
+ * @param {object} config The config object to get the name of.
337
+ * @param {number} index The index of the config object in the array.
338
+ * @param {Error} error The error to rethrow.
339
+ * @throws {ConfigError} When the error is rethrown for a config.
340
+ */
341
+ function rethrowConfigError(config, index, error) {
342
+ const configName = getConfigName(config);
343
+ throw new ConfigError(configName, index, { cause: error });
344
+ }
345
+
346
+ /**
347
+ * Shorthand for checking if a value is a string.
348
+ * @param {any} value The value to check.
349
+ * @returns {boolean} True if a string, false if not.
350
+ */
351
+ function isString(value) {
352
+ return typeof value === "string";
353
+ }
354
+
355
+ /**
356
+ * Creates a function that asserts that the config is valid
357
+ * during normalization. This checks that the config is not nullish
358
+ * and that files and ignores keys of a config object are valid as per base schema.
359
+ * @param {Object} config The config object to check.
360
+ * @param {number} index The index of the config object in the array.
361
+ * @returns {void}
362
+ * @throws {ConfigError} If the files and ignores keys of a config object are not valid.
363
+ */
364
+ function assertValidBaseConfig(config, index) {
365
+ if (config === null) {
366
+ throw new ConfigError(getConfigName(config), index, {
367
+ message: "Unexpected null config.",
368
+ });
369
+ }
370
+
371
+ if (config === undefined) {
372
+ throw new ConfigError(getConfigName(config), index, {
373
+ message: "Unexpected undefined config.",
374
+ });
375
+ }
376
+
377
+ if (typeof config !== "object") {
378
+ throw new ConfigError(getConfigName(config), index, {
379
+ message: "Unexpected non-object config.",
380
+ });
381
+ }
382
+
383
+ const validateConfig = {};
384
+
385
+ if ("basePath" in config) {
386
+ validateConfig.basePath = config.basePath;
387
+ }
388
+
389
+ if ("files" in config) {
390
+ validateConfig.files = config.files;
391
+ }
392
+
393
+ if ("ignores" in config) {
394
+ validateConfig.ignores = config.ignores;
395
+ }
396
+
397
+ try {
398
+ FILES_AND_IGNORES_SCHEMA.validate(validateConfig);
399
+ } catch (validationError) {
400
+ rethrowConfigError(config, index, validationError);
401
+ }
402
+ }
403
+
404
+ /**
405
+ * Wrapper around minimatch that caches minimatch patterns for
406
+ * faster matching speed over multiple file path evaluations.
407
+ * @param {string} filepath The file path to match.
408
+ * @param {string} pattern The glob pattern to match against.
409
+ * @param {object} options The minimatch options to use.
410
+ * @returns
411
+ */
412
+ function doMatch(filepath, pattern, options = {}) {
413
+ let cache = minimatchCache;
414
+
415
+ if (options.flipNegate) {
416
+ cache = negatedMinimatchCache;
417
+ }
418
+
419
+ let matcher = cache.get(pattern);
420
+
421
+ if (!matcher) {
422
+ matcher = new Minimatch(
423
+ pattern,
424
+ Object.assign({}, MINIMATCH_OPTIONS, options),
425
+ );
426
+ cache.set(pattern, matcher);
427
+ }
428
+
429
+ return matcher.match(filepath);
430
+ }
431
+
432
+ /**
433
+ * Normalizes a pattern by removing the leading "./" if present.
434
+ * @param {string} pattern The pattern to normalize.
435
+ * @returns {string} The normalized pattern.
436
+ */
437
+ function normalizePattern(pattern) {
438
+ if (isString(pattern)) {
439
+ if (pattern.startsWith("./")) {
440
+ return pattern.slice(2);
441
+ }
442
+
443
+ if (pattern.startsWith("!./")) {
444
+ return `!${pattern.slice(3)}`;
445
+ }
446
+ }
447
+
448
+ return pattern;
449
+ }
450
+
451
+ /**
452
+ * Checks if a given pattern requires normalization.
453
+ * @param {any} pattern The pattern to check.
454
+ * @returns {boolean} True if the pattern needs normalization, false otherwise.
455
+ *
456
+ */
457
+ function needsPatternNormalization(pattern) {
458
+ return (
459
+ isString(pattern) &&
460
+ (pattern.startsWith("./") || pattern.startsWith("!./"))
461
+ );
462
+ }
463
+
464
+ /**
465
+ * Normalizes `files` and `ignores` patterns in a config by removing "./" prefixes.
466
+ * @param {Object} config The config object to normalize patterns in.
467
+ * @param {string} namespacedBasePath The namespaced base path of the directory to which config base path is relative.
468
+ * @param {PathImpl} path Path-handling implementation.
469
+ * @returns {Object} The normalized config object.
470
+ */
471
+ function normalizeConfigPatterns(config, namespacedBasePath, path) {
472
+ if (!config) {
473
+ return config;
474
+ }
475
+
476
+ const hasBasePath = typeof config.basePath === "string";
477
+
478
+ let needsNormalization = false;
479
+
480
+ if (hasBasePath) {
481
+ needsNormalization = true;
482
+ }
483
+
484
+ if (!needsNormalization && Array.isArray(config.files)) {
485
+ needsNormalization = config.files.some(pattern => {
486
+ if (Array.isArray(pattern)) {
487
+ return pattern.some(needsPatternNormalization);
488
+ }
489
+ return needsPatternNormalization(pattern);
490
+ });
491
+ }
492
+
493
+ if (!needsNormalization && Array.isArray(config.ignores)) {
494
+ needsNormalization = config.ignores.some(needsPatternNormalization);
495
+ }
496
+
497
+ if (!needsNormalization) {
498
+ return config;
499
+ }
500
+
501
+ const newConfig = { ...config };
502
+
503
+ if (hasBasePath) {
504
+ if (path.isAbsolute(config.basePath)) {
505
+ newConfig.basePath = path.toNamespacedPath(config.basePath);
506
+ } else {
507
+ newConfig.basePath = path.resolve(
508
+ namespacedBasePath,
509
+ config.basePath,
510
+ );
511
+ }
512
+ }
513
+
514
+ if (Array.isArray(newConfig.files)) {
515
+ newConfig.files = newConfig.files.map(pattern => {
516
+ if (Array.isArray(pattern)) {
517
+ return pattern.map(normalizePattern);
518
+ }
519
+ return normalizePattern(pattern);
520
+ });
521
+ }
522
+
523
+ if (Array.isArray(newConfig.ignores)) {
524
+ newConfig.ignores = newConfig.ignores.map(normalizePattern);
525
+ }
526
+
527
+ return newConfig;
528
+ }
529
+
530
+ /**
531
+ * Normalizes a `ConfigArray` by flattening it and executing any functions
532
+ * that are found inside.
533
+ * @param {Array} items The items in a `ConfigArray`.
534
+ * @param {Object} context The context object to pass into any function
535
+ * found.
536
+ * @param {Array<string>} extraConfigTypes The config types to check.
537
+ * @param {string} namespacedBasePath The namespaced base path of the directory to which config base paths are relative.
538
+ * @param {PathImpl} path Path-handling implementation.
539
+ * @returns {Promise<Array>} A flattened array containing only config objects.
540
+ * @throws {TypeError} When a config function returns a function.
541
+ */
542
+ async function normalize(
543
+ items,
544
+ context,
545
+ extraConfigTypes,
546
+ namespacedBasePath,
547
+ path,
548
+ ) {
549
+ const allowFunctions = extraConfigTypes.includes("function");
550
+ const allowArrays = extraConfigTypes.includes("array");
551
+
552
+ async function* flatTraverse(array) {
553
+ for (let item of array) {
554
+ if (typeof item === "function") {
555
+ if (!allowFunctions) {
556
+ throw new TypeError("Unexpected function.");
557
+ }
558
+
559
+ item = item(context);
560
+ if (item.then) {
561
+ item = await item;
562
+ }
563
+ }
564
+
565
+ if (Array.isArray(item)) {
566
+ if (!allowArrays) {
567
+ throw new TypeError("Unexpected array.");
568
+ }
569
+ yield* flatTraverse(item);
570
+ } else if (typeof item === "function") {
571
+ throw new TypeError(
572
+ "A config function can only return an object or array.",
573
+ );
574
+ } else {
575
+ yield item;
576
+ }
577
+ }
578
+ }
579
+
580
+ /*
581
+ * Async iterables cannot be used with the spread operator, so we need to manually
582
+ * create the array to return.
583
+ */
584
+ const asyncIterable = await flatTraverse(items);
585
+ const configs = [];
586
+
587
+ for await (const config of asyncIterable) {
588
+ configs.push(normalizeConfigPatterns(config, namespacedBasePath, path));
589
+ }
590
+
591
+ return configs;
592
+ }
593
+
594
+ /**
595
+ * Normalizes a `ConfigArray` by flattening it and executing any functions
596
+ * that are found inside.
597
+ * @param {Array} items The items in a `ConfigArray`.
598
+ * @param {Object} context The context object to pass into any function
599
+ * found.
600
+ * @param {Array<string>} extraConfigTypes The config types to check.
601
+ * @param {string} namespacedBasePath The namespaced base path of the directory to which config base paths are relative.
602
+ * @param {PathImpl} path Path-handling implementation
603
+ * @returns {Array} A flattened array containing only config objects.
604
+ * @throws {TypeError} When a config function returns a function.
605
+ */
606
+ function normalizeSync(
607
+ items,
608
+ context,
609
+ extraConfigTypes,
610
+ namespacedBasePath,
611
+ path,
612
+ ) {
613
+ const allowFunctions = extraConfigTypes.includes("function");
614
+ const allowArrays = extraConfigTypes.includes("array");
615
+
616
+ function* flatTraverse(array) {
617
+ for (let item of array) {
618
+ if (typeof item === "function") {
619
+ if (!allowFunctions) {
620
+ throw new TypeError("Unexpected function.");
621
+ }
622
+
623
+ item = item(context);
624
+ if (item.then) {
625
+ throw new TypeError(
626
+ "Async config functions are not supported.",
627
+ );
628
+ }
629
+ }
630
+
631
+ if (Array.isArray(item)) {
632
+ if (!allowArrays) {
633
+ throw new TypeError("Unexpected array.");
634
+ }
635
+
636
+ yield* flatTraverse(item);
637
+ } else if (typeof item === "function") {
638
+ throw new TypeError(
639
+ "A config function can only return an object or array.",
640
+ );
641
+ } else {
642
+ yield item;
643
+ }
644
+ }
645
+ }
646
+
647
+ const configs = [];
648
+
649
+ for (const config of flatTraverse(items)) {
650
+ configs.push(normalizeConfigPatterns(config, namespacedBasePath, path));
651
+ }
652
+
653
+ return configs;
654
+ }
655
+
656
+ /**
657
+ * Converts a given path to a relative path with all separator characters replaced by forward slashes (`"/"`).
658
+ * @param {string} fileOrDirPath The unprocessed path to convert.
659
+ * @param {string} namespacedBasePath The namespaced base path of the directory to which the calculated path shall be relative.
660
+ * @param {PathImpl} path Path-handling implementations.
661
+ * @returns {string} A relative path with all separator characters replaced by forward slashes.
662
+ */
663
+ function toRelativePath(fileOrDirPath, namespacedBasePath, path) {
664
+ const fullPath = path.resolve(namespacedBasePath, fileOrDirPath);
665
+ const namespacedFullPath = path.toNamespacedPath(fullPath);
666
+ const relativePath = path.relative(namespacedBasePath, namespacedFullPath);
667
+ return relativePath.replaceAll(path.SEPARATOR, "/");
668
+ }
669
+
670
+ /**
671
+ * Determines if a given file path should be ignored based on the given
672
+ * matcher.
673
+ * @param {Array<{ basePath?: string, ignores: Array<string|((string) => boolean)>}>} configs Configuration objects containing `ignores`.
674
+ * @param {string} filePath The unprocessed file path to check.
675
+ * @param {string} relativeFilePath The path of the file to check relative to the base path,
676
+ * using forward slash (`"/"`) as a separator.
677
+ * @param {Object} [basePathData] Additional data needed to recalculate paths for configuration objects
678
+ * that have `basePath` property.
679
+ * @param {string} [basePathData.basePath] Namespaced path to witch `relativeFilePath` is relative.
680
+ * @param {PathImpl} [basePathData.path] Path-handling implementation.
681
+ * @returns {boolean} True if the path should be ignored and false if not.
682
+ */
683
+ function shouldIgnorePath(
684
+ configs,
685
+ filePath,
686
+ relativeFilePath,
687
+ { basePath, path } = {},
688
+ ) {
689
+ let shouldIgnore = false;
690
+
691
+ for (const config of configs) {
692
+ let relativeFilePathToCheck = relativeFilePath;
693
+ if (config.basePath) {
694
+ relativeFilePathToCheck = toRelativePath(
695
+ path.resolve(basePath, relativeFilePath),
696
+ config.basePath,
697
+ path,
698
+ );
699
+
700
+ if (
701
+ relativeFilePathToCheck === "" ||
702
+ EXTERNAL_PATH_REGEX.test(relativeFilePathToCheck)
703
+ ) {
704
+ continue;
705
+ }
706
+
707
+ if (relativeFilePath.endsWith("/")) {
708
+ relativeFilePathToCheck += "/";
709
+ }
710
+ }
711
+ shouldIgnore = config.ignores.reduce((ignored, matcher) => {
712
+ if (!ignored) {
713
+ if (typeof matcher === "function") {
714
+ return matcher(filePath);
715
+ }
716
+
717
+ // don't check negated patterns because we're not ignored yet
718
+ if (!matcher.startsWith("!")) {
719
+ return doMatch(relativeFilePathToCheck, matcher);
720
+ }
721
+
722
+ // otherwise we're still not ignored
723
+ return false;
724
+ }
725
+
726
+ // only need to check negated patterns because we're ignored
727
+ if (typeof matcher === "string" && matcher.startsWith("!")) {
728
+ return !doMatch(relativeFilePathToCheck, matcher, {
729
+ flipNegate: true,
730
+ });
731
+ }
732
+
733
+ return ignored;
734
+ }, shouldIgnore);
735
+ }
736
+
737
+ return shouldIgnore;
738
+ }
739
+
740
+ /**
741
+ * Determines if a given file path is matched by a config. If the config
742
+ * has no `files` field, then it matches; otherwise, if a `files` field
743
+ * is present then we match the globs in `files` and exclude any globs in
744
+ * `ignores`.
745
+ * @param {string} filePath The unprocessed file path to check.
746
+ * @param {string} relativeFilePath The path of the file to check relative to the base path,
747
+ * using forward slash (`"/"`) as a separator.
748
+ * @param {Object} config The config object to check.
749
+ * @returns {boolean} True if the file path is matched by the config,
750
+ * false if not.
751
+ */
752
+ function pathMatches(filePath, relativeFilePath, config) {
753
+ // match both strings and functions
754
+ function match(pattern) {
755
+ if (isString(pattern)) {
756
+ return doMatch(relativeFilePath, pattern);
757
+ }
758
+
759
+ if (typeof pattern === "function") {
760
+ return pattern(filePath);
761
+ }
762
+
763
+ throw new TypeError(`Unexpected matcher type ${pattern}.`);
764
+ }
765
+
766
+ // check for all matches to config.files
767
+ let filePathMatchesPattern = config.files.some(pattern => {
768
+ if (Array.isArray(pattern)) {
769
+ return pattern.every(match);
770
+ }
771
+
772
+ return match(pattern);
773
+ });
774
+
775
+ /*
776
+ * If the file path matches the config.files patterns, then check to see
777
+ * if there are any files to ignore.
778
+ */
779
+ if (filePathMatchesPattern && config.ignores) {
780
+ /*
781
+ * Pass config object without `basePath`, because `relativeFilePath` is already
782
+ * calculated as relative to it.
783
+ */
784
+ filePathMatchesPattern = !shouldIgnorePath(
785
+ [{ ignores: config.ignores }],
786
+ filePath,
787
+ relativeFilePath,
788
+ );
789
+ }
790
+
791
+ return filePathMatchesPattern;
792
+ }
793
+
794
+ /**
795
+ * Ensures that a ConfigArray has been normalized.
796
+ * @param {ConfigArray} configArray The ConfigArray to check.
797
+ * @returns {void}
798
+ * @throws {Error} When the `ConfigArray` is not normalized.
799
+ */
800
+ function assertNormalized(configArray) {
801
+ // TODO: Throw more verbose error
802
+ if (!configArray.isNormalized()) {
803
+ throw new Error(
804
+ "ConfigArray must be normalized to perform this operation.",
805
+ );
806
+ }
807
+ }
808
+
809
+ /**
810
+ * Ensures that config types are valid.
811
+ * @param {Array<string>} extraConfigTypes The config types to check.
812
+ * @returns {void}
813
+ * @throws {TypeError} When the config types array is invalid.
814
+ */
815
+ function assertExtraConfigTypes(extraConfigTypes) {
816
+ if (extraConfigTypes.length > 2) {
817
+ throw new TypeError(
818
+ "configTypes must be an array with at most two items.",
819
+ );
820
+ }
821
+
822
+ for (const configType of extraConfigTypes) {
823
+ if (!CONFIG_TYPES.has(configType)) {
824
+ throw new TypeError(
825
+ `Unexpected config type "${configType}" found. Expected one of: "object", "array", "function".`,
826
+ );
827
+ }
828
+ }
829
+ }
830
+
831
+ /**
832
+ * Returns path-handling implementations for Unix or Windows, depending on a given absolute path.
833
+ * @param {string} fileOrDirPath The absolute path to check.
834
+ * @returns {PathImpl} Path-handling implementations for the specified path.
835
+ * @throws {Error} An error is thrown if the specified argument is not an absolute path.
836
+ */
837
+ function getPathImpl(fileOrDirPath) {
838
+ // Posix absolute paths always start with a slash.
839
+ if (fileOrDirPath.startsWith("/")) {
840
+ return posixPath__namespace;
841
+ }
842
+
843
+ // Windows absolute paths start with a letter followed by a colon and at least one backslash,
844
+ // or with two backslashes in the case of UNC paths.
845
+ // Forward slashed are automatically normalized to backslashes.
846
+ if (/^(?:[A-Za-z]:[/\\]|[/\\]{2})/u.test(fileOrDirPath)) {
847
+ return windowsPath__namespace;
848
+ }
849
+
850
+ throw new Error(
851
+ `Expected an absolute path but received "${fileOrDirPath}"`,
852
+ );
853
+ }
854
+
855
+ //------------------------------------------------------------------------------
856
+ // Public Interface
857
+ //------------------------------------------------------------------------------
858
+
859
+ const ConfigArraySymbol = {
860
+ isNormalized: Symbol("isNormalized"),
861
+ configCache: Symbol("configCache"),
862
+ schema: Symbol("schema"),
863
+ finalizeConfig: Symbol("finalizeConfig"),
864
+ preprocessConfig: Symbol("preprocessConfig"),
865
+ };
866
+
867
+ // used to store calculate data for faster lookup
868
+ const dataCache = new WeakMap();
869
+
870
+ /**
871
+ * Represents an array of config objects and provides method for working with
872
+ * those config objects.
873
+ */
874
+ class ConfigArray extends Array {
875
+ /**
876
+ * The namespaced path of the config file directory.
877
+ * @type {string}
878
+ */
879
+ #namespacedBasePath;
880
+
881
+ /**
882
+ * Path-handling implementations.
883
+ * @type {PathImpl}
884
+ */
885
+ #path;
886
+
887
+ /**
888
+ * Creates a new instance of ConfigArray.
889
+ * @param {Iterable|Function|Object} configs An iterable yielding config
890
+ * objects, or a config function, or a config object.
891
+ * @param {Object} options The options for the ConfigArray.
892
+ * @param {string} [options.basePath="/"] The absolute path of the config file directory.
893
+ * Defaults to `"/"`.
894
+ * @param {boolean} [options.normalized=false] Flag indicating if the
895
+ * configs have already been normalized.
896
+ * @param {Object} [options.schema] The additional schema
897
+ * definitions to use for the ConfigArray schema.
898
+ * @param {Array<string>} [options.extraConfigTypes] List of config types supported.
899
+ * @throws {TypeError} When the `basePath` is not a non-empty string,
900
+ */
901
+ constructor(
902
+ configs,
903
+ {
904
+ basePath = "/",
905
+ normalized = false,
906
+ schema: customSchema,
907
+ extraConfigTypes = [],
908
+ } = {},
909
+ ) {
910
+ super();
911
+
912
+ /**
913
+ * Tracks if the array has been normalized.
914
+ * @property isNormalized
915
+ * @type {boolean}
916
+ * @private
917
+ */
918
+ this[ConfigArraySymbol.isNormalized] = normalized;
919
+
920
+ /**
921
+ * The schema used for validating and merging configs.
922
+ * @property schema
923
+ * @type {ObjectSchemaInstance}
924
+ * @private
925
+ */
926
+ this[ConfigArraySymbol.schema] = new objectSchema.ObjectSchema(
927
+ Object.assign({}, customSchema, baseSchema),
928
+ );
929
+
930
+ if (!isString(basePath) || !basePath) {
931
+ throw new TypeError("basePath must be a non-empty string");
932
+ }
933
+
934
+ /**
935
+ * The path of the config file that this array was loaded from.
936
+ * This is used to calculate filename matches.
937
+ * @property basePath
938
+ * @type {string}
939
+ */
940
+ this.basePath = basePath;
941
+
942
+ assertExtraConfigTypes(extraConfigTypes);
943
+
944
+ /**
945
+ * The supported config types.
946
+ * @type {Array<string>}
947
+ */
948
+ this.extraConfigTypes = [...extraConfigTypes];
949
+ Object.freeze(this.extraConfigTypes);
950
+
951
+ /**
952
+ * A cache to store calculated configs for faster repeat lookup.
953
+ * @property configCache
954
+ * @type {Map<string, Object>}
955
+ * @private
956
+ */
957
+ this[ConfigArraySymbol.configCache] = new Map();
958
+
959
+ // init cache
960
+ dataCache.set(this, {
961
+ explicitMatches: new Map(),
962
+ directoryMatches: new Map(),
963
+ files: undefined,
964
+ ignores: undefined,
965
+ });
966
+
967
+ // load the configs into this array
968
+ if (Array.isArray(configs)) {
969
+ this.push(...configs);
970
+ } else {
971
+ this.push(configs);
972
+ }
973
+
974
+ // select path-handling implementations depending on the base path
975
+ this.#path = getPathImpl(basePath);
976
+
977
+ // On Windows, `path.relative()` returns an absolute path when given two paths on different drives.
978
+ // The namespaced base path is useful to make sure that calculated relative paths are always relative.
979
+ // On Unix, it is identical to the base path.
980
+ this.#namespacedBasePath = this.#path.toNamespacedPath(basePath);
981
+ }
982
+
983
+ /**
984
+ * Prevent normal array methods from creating a new `ConfigArray` instance.
985
+ * This is to ensure that methods such as `slice()` won't try to create a
986
+ * new instance of `ConfigArray` behind the scenes as doing so may throw
987
+ * an error due to the different constructor signature.
988
+ * @type {ArrayConstructor} The `Array` constructor.
989
+ */
990
+ static get [Symbol.species]() {
991
+ return Array;
992
+ }
993
+
994
+ /**
995
+ * Returns the `files` globs from every config object in the array.
996
+ * This can be used to determine which files will be matched by a
997
+ * config array or to use as a glob pattern when no patterns are provided
998
+ * for a command line interface.
999
+ * @returns {Array<string|Function>} An array of matchers.
1000
+ */
1001
+ get files() {
1002
+ assertNormalized(this);
1003
+
1004
+ // if this data has been cached, retrieve it
1005
+ const cache = dataCache.get(this);
1006
+
1007
+ if (cache.files) {
1008
+ return cache.files;
1009
+ }
1010
+
1011
+ // otherwise calculate it
1012
+
1013
+ const result = [];
1014
+
1015
+ for (const config of this) {
1016
+ if (config.files) {
1017
+ config.files.forEach(filePattern => {
1018
+ result.push(filePattern);
1019
+ });
1020
+ }
1021
+ }
1022
+
1023
+ // store result
1024
+ cache.files = result;
1025
+ dataCache.set(this, cache);
1026
+
1027
+ return result;
1028
+ }
1029
+
1030
+ /**
1031
+ * Returns ignore matchers that should always be ignored regardless of
1032
+ * the matching `files` fields in any configs. This is necessary to mimic
1033
+ * the behavior of things like .gitignore and .eslintignore, allowing a
1034
+ * globbing operation to be faster.
1035
+ * @returns {Object[]} An array of config objects representing global ignores.
1036
+ */
1037
+ get ignores() {
1038
+ assertNormalized(this);
1039
+
1040
+ // if this data has been cached, retrieve it
1041
+ const cache = dataCache.get(this);
1042
+
1043
+ if (cache.ignores) {
1044
+ return cache.ignores;
1045
+ }
1046
+
1047
+ // otherwise calculate it
1048
+
1049
+ const result = [];
1050
+
1051
+ for (const config of this) {
1052
+ /*
1053
+ * We only count ignores if there are no other keys in the object.
1054
+ * In this case, it acts list a globally ignored pattern. If there
1055
+ * are additional keys, then ignores act like exclusions.
1056
+ */
1057
+ if (
1058
+ config.ignores &&
1059
+ Object.keys(config).filter(key => !META_FIELDS.has(key))
1060
+ .length === 1
1061
+ ) {
1062
+ result.push(config);
1063
+ }
1064
+ }
1065
+
1066
+ // store result
1067
+ cache.ignores = result;
1068
+ dataCache.set(this, cache);
1069
+
1070
+ return result;
1071
+ }
1072
+
1073
+ /**
1074
+ * Indicates if the config array has been normalized.
1075
+ * @returns {boolean} True if the config array is normalized, false if not.
1076
+ */
1077
+ isNormalized() {
1078
+ return this[ConfigArraySymbol.isNormalized];
1079
+ }
1080
+
1081
+ /**
1082
+ * Normalizes a config array by flattening embedded arrays and executing
1083
+ * config functions.
1084
+ * @param {Object} [context] The context object for config functions.
1085
+ * @returns {Promise<ConfigArray>} The current ConfigArray instance.
1086
+ */
1087
+ async normalize(context = {}) {
1088
+ if (!this.isNormalized()) {
1089
+ const normalizedConfigs = await normalize(
1090
+ this,
1091
+ context,
1092
+ this.extraConfigTypes,
1093
+ this.#namespacedBasePath,
1094
+ this.#path,
1095
+ );
1096
+ this.length = 0;
1097
+ this.push(
1098
+ ...normalizedConfigs.map(
1099
+ this[ConfigArraySymbol.preprocessConfig].bind(this),
1100
+ ),
1101
+ );
1102
+ this.forEach(assertValidBaseConfig);
1103
+ this[ConfigArraySymbol.isNormalized] = true;
1104
+
1105
+ // prevent further changes
1106
+ Object.freeze(this);
1107
+ }
1108
+
1109
+ return this;
1110
+ }
1111
+
1112
+ /**
1113
+ * Normalizes a config array by flattening embedded arrays and executing
1114
+ * config functions.
1115
+ * @param {Object} [context] The context object for config functions.
1116
+ * @returns {ConfigArray} The current ConfigArray instance.
1117
+ */
1118
+ normalizeSync(context = {}) {
1119
+ if (!this.isNormalized()) {
1120
+ const normalizedConfigs = normalizeSync(
1121
+ this,
1122
+ context,
1123
+ this.extraConfigTypes,
1124
+ this.#namespacedBasePath,
1125
+ this.#path,
1126
+ );
1127
+ this.length = 0;
1128
+ this.push(
1129
+ ...normalizedConfigs.map(
1130
+ this[ConfigArraySymbol.preprocessConfig].bind(this),
1131
+ ),
1132
+ );
1133
+ this.forEach(assertValidBaseConfig);
1134
+ this[ConfigArraySymbol.isNormalized] = true;
1135
+
1136
+ // prevent further changes
1137
+ Object.freeze(this);
1138
+ }
1139
+
1140
+ return this;
1141
+ }
1142
+
1143
+ /* eslint-disable class-methods-use-this -- Desired as instance methods */
1144
+
1145
+ /**
1146
+ * Finalizes the state of a config before being cached and returned by
1147
+ * `getConfig()`. Does nothing by default but is provided to be
1148
+ * overridden by subclasses as necessary.
1149
+ * @param {Object} config The config to finalize.
1150
+ * @returns {Object} The finalized config.
1151
+ */
1152
+ // Cast key to `never` to prevent TypeScript from adding the signature `[x: symbol]: (config: any) => any` to the type of the class.
1153
+ [/** @type {never} */ (ConfigArraySymbol.finalizeConfig)](config) {
1154
+ return config;
1155
+ }
1156
+
1157
+ /**
1158
+ * Preprocesses a config during the normalization process. This is the
1159
+ * method to override if you want to convert an array item before it is
1160
+ * validated for the first time. For example, if you want to replace a
1161
+ * string with an object, this is the method to override.
1162
+ * @param {Object} config The config to preprocess.
1163
+ * @returns {Object} The config to use in place of the argument.
1164
+ */
1165
+ // Cast key to `never` to prevent TypeScript from adding the signature `[x: symbol]: (config: any) => any` to the type of the class.
1166
+ [/** @type {never} */ (ConfigArraySymbol.preprocessConfig)](config) {
1167
+ return config;
1168
+ }
1169
+
1170
+ /* eslint-enable class-methods-use-this -- Desired as instance methods */
1171
+
1172
+ /**
1173
+ * Returns the config object for a given file path and a status that can be used to determine why a file has no config.
1174
+ * @param {string} filePath The path of a file to get a config for.
1175
+ * @returns {{ config?: Object, status: "ignored"|"external"|"unconfigured"|"matched" }}
1176
+ * An object with an optional property `config` and property `status`.
1177
+ * `config` is the config object for the specified file as returned by {@linkcode ConfigArray.getConfig},
1178
+ * `status` a is one of the constants returned by {@linkcode ConfigArray.getConfigStatus}.
1179
+ */
1180
+ getConfigWithStatus(filePath) {
1181
+ assertNormalized(this);
1182
+
1183
+ const cache = this[ConfigArraySymbol.configCache];
1184
+
1185
+ // first check the cache for a filename match to avoid duplicate work
1186
+ if (cache.has(filePath)) {
1187
+ return cache.get(filePath);
1188
+ }
1189
+
1190
+ // check to see if the file is outside the base path
1191
+
1192
+ const relativeToBaseFilePath = toRelativePath(
1193
+ filePath,
1194
+ this.#namespacedBasePath,
1195
+ this.#path,
1196
+ );
1197
+
1198
+ if (EXTERNAL_PATH_REGEX.test(relativeToBaseFilePath)) {
1199
+ debug(`No config for file ${filePath} outside of base path`);
1200
+
1201
+ // cache and return result
1202
+ cache.set(filePath, CONFIG_WITH_STATUS_EXTERNAL);
1203
+ return CONFIG_WITH_STATUS_EXTERNAL;
1204
+ }
1205
+
1206
+ // next check to see if the file should be ignored
1207
+
1208
+ // check if this should be ignored due to its directory
1209
+ if (this.isDirectoryIgnored(this.#path.dirname(filePath))) {
1210
+ debug(`Ignoring ${filePath} based on directory pattern`);
1211
+
1212
+ // cache and return result
1213
+ cache.set(filePath, CONFIG_WITH_STATUS_IGNORED);
1214
+ return CONFIG_WITH_STATUS_IGNORED;
1215
+ }
1216
+
1217
+ if (
1218
+ shouldIgnorePath(this.ignores, filePath, relativeToBaseFilePath, {
1219
+ basePath: this.#namespacedBasePath,
1220
+ path: this.#path,
1221
+ })
1222
+ ) {
1223
+ debug(`Ignoring ${filePath} based on file pattern`);
1224
+
1225
+ // cache and return result
1226
+ cache.set(filePath, CONFIG_WITH_STATUS_IGNORED);
1227
+ return CONFIG_WITH_STATUS_IGNORED;
1228
+ }
1229
+
1230
+ // filePath isn't automatically ignored, so try to construct config
1231
+
1232
+ const matchingConfigIndices = [];
1233
+ let matchFound = false;
1234
+ const universalPattern = /^\*$|^!|\/\*{1,2}$/u;
1235
+
1236
+ this.forEach((config, index) => {
1237
+ const relativeFilePath = config.basePath
1238
+ ? toRelativePath(
1239
+ this.#path.resolve(this.#namespacedBasePath, filePath),
1240
+ config.basePath,
1241
+ this.#path,
1242
+ )
1243
+ : relativeToBaseFilePath;
1244
+
1245
+ if (config.basePath && EXTERNAL_PATH_REGEX.test(relativeFilePath)) {
1246
+ debug(
1247
+ `Skipped config found for ${filePath} (based on config's base path: ${config.basePath}`,
1248
+ );
1249
+ return;
1250
+ }
1251
+
1252
+ if (!config.files) {
1253
+ if (!config.ignores) {
1254
+ debug(`Universal config found for ${filePath}`);
1255
+ matchingConfigIndices.push(index);
1256
+ return;
1257
+ }
1258
+
1259
+ if (
1260
+ Object.keys(config).filter(key => !META_FIELDS.has(key))
1261
+ .length === 1
1262
+ ) {
1263
+ debug(
1264
+ `Skipped config found for ${filePath} (global ignores)`,
1265
+ );
1266
+ return;
1267
+ }
1268
+
1269
+ /*
1270
+ * Pass config object without `basePath`, because `relativeFilePath` is already
1271
+ * calculated as relative to it.
1272
+ */
1273
+ if (
1274
+ shouldIgnorePath(
1275
+ [{ ignores: config.ignores }],
1276
+ filePath,
1277
+ relativeFilePath,
1278
+ )
1279
+ ) {
1280
+ debug(
1281
+ `Skipped config found for ${filePath} (based on ignores: ${config.ignores})`,
1282
+ );
1283
+ return;
1284
+ }
1285
+
1286
+ debug(
1287
+ `Matching config found for ${filePath} (based on ignores: ${config.ignores})`,
1288
+ );
1289
+ matchingConfigIndices.push(index);
1290
+ return;
1291
+ }
1292
+
1293
+ /*
1294
+ * If a config has a files pattern * or patterns ending in /** or /*,
1295
+ * and the filePath only matches those patterns, then the config is only
1296
+ * applied if there is another config where the filePath matches
1297
+ * a file with a specific extensions such as *.js.
1298
+ */
1299
+
1300
+ const nonUniversalFiles = [];
1301
+ const universalFiles = config.files.filter(element => {
1302
+ if (Array.isArray(element)) {
1303
+ /*
1304
+ * filePath matches an element that is an array only if it matches
1305
+ * all patterns in it (AND operation). Therefore, if there is at least
1306
+ * one non-universal pattern in the array, and filePath matches the array,
1307
+ * then we know for sure that filePath matches at least one non-universal
1308
+ * pattern, so we can consider the entire array to be non-universal.
1309
+ * In other words, all patterns in the array need to be universal
1310
+ * for it to be considered universal.
1311
+ */
1312
+ if (
1313
+ element.every(pattern => universalPattern.test(pattern))
1314
+ ) {
1315
+ return true;
1316
+ }
1317
+
1318
+ nonUniversalFiles.push(element);
1319
+ return false;
1320
+ }
1321
+
1322
+ // element is a string
1323
+
1324
+ if (universalPattern.test(element)) {
1325
+ return true;
1326
+ }
1327
+
1328
+ nonUniversalFiles.push(element);
1329
+ return false;
1330
+ });
1331
+
1332
+ // universal patterns were found so we need to check the config twice
1333
+ if (universalFiles.length) {
1334
+ debug("Universal files patterns found. Checking carefully.");
1335
+
1336
+ // check that the config matches without the non-universal files first
1337
+ if (
1338
+ nonUniversalFiles.length &&
1339
+ pathMatches(filePath, relativeFilePath, {
1340
+ files: nonUniversalFiles,
1341
+ ignores: config.ignores,
1342
+ })
1343
+ ) {
1344
+ debug(`Matching config found for ${filePath}`);
1345
+ matchingConfigIndices.push(index);
1346
+ matchFound = true;
1347
+ return;
1348
+ }
1349
+
1350
+ // if there wasn't a match then check if it matches with universal files
1351
+ if (
1352
+ universalFiles.length &&
1353
+ pathMatches(filePath, relativeFilePath, {
1354
+ files: universalFiles,
1355
+ ignores: config.ignores,
1356
+ })
1357
+ ) {
1358
+ debug(`Matching config found for ${filePath}`);
1359
+ matchingConfigIndices.push(index);
1360
+ return;
1361
+ }
1362
+
1363
+ // if we make here, then there was no match
1364
+ return;
1365
+ }
1366
+
1367
+ // the normal case
1368
+ if (pathMatches(filePath, relativeFilePath, config)) {
1369
+ debug(`Matching config found for ${filePath}`);
1370
+ matchingConfigIndices.push(index);
1371
+ matchFound = true;
1372
+ }
1373
+ });
1374
+
1375
+ // if matching both files and ignores, there will be no config to create
1376
+ if (!matchFound) {
1377
+ debug(`No matching configs found for ${filePath}`);
1378
+
1379
+ // cache and return result
1380
+ cache.set(filePath, CONFIG_WITH_STATUS_UNCONFIGURED);
1381
+ return CONFIG_WITH_STATUS_UNCONFIGURED;
1382
+ }
1383
+
1384
+ // check to see if there is a config cached by indices
1385
+ const indicesKey = matchingConfigIndices.toString();
1386
+ let configWithStatus = cache.get(indicesKey);
1387
+
1388
+ if (configWithStatus) {
1389
+ // also store for filename for faster lookup next time
1390
+ cache.set(filePath, configWithStatus);
1391
+
1392
+ return configWithStatus;
1393
+ }
1394
+
1395
+ // otherwise construct the config
1396
+
1397
+ // eslint-disable-next-line array-callback-return, consistent-return -- rethrowConfigError always throws an error
1398
+ let finalConfig = matchingConfigIndices.reduce((result, index) => {
1399
+ try {
1400
+ return this[ConfigArraySymbol.schema].merge(
1401
+ result,
1402
+ this[index],
1403
+ );
1404
+ } catch (validationError) {
1405
+ rethrowConfigError(this[index], index, validationError);
1406
+ }
1407
+ }, {});
1408
+
1409
+ finalConfig = this[ConfigArraySymbol.finalizeConfig](finalConfig);
1410
+
1411
+ configWithStatus = Object.freeze({
1412
+ config: finalConfig,
1413
+ status: "matched",
1414
+ });
1415
+ cache.set(filePath, configWithStatus);
1416
+ cache.set(indicesKey, configWithStatus);
1417
+
1418
+ return configWithStatus;
1419
+ }
1420
+
1421
+ /**
1422
+ * Returns the config object for a given file path.
1423
+ * @param {string} filePath The path of a file to get a config for.
1424
+ * @returns {Object|undefined} The config object for this file or `undefined`.
1425
+ */
1426
+ getConfig(filePath) {
1427
+ return this.getConfigWithStatus(filePath).config;
1428
+ }
1429
+
1430
+ /**
1431
+ * Determines whether a file has a config or why it doesn't.
1432
+ * @param {string} filePath The path of the file to check.
1433
+ * @returns {"ignored"|"external"|"unconfigured"|"matched"} One of the following values:
1434
+ * * `"ignored"`: the file is ignored
1435
+ * * `"external"`: the file is outside the base path
1436
+ * * `"unconfigured"`: the file is not matched by any config
1437
+ * * `"matched"`: the file has a matching config
1438
+ */
1439
+ getConfigStatus(filePath) {
1440
+ return this.getConfigWithStatus(filePath).status;
1441
+ }
1442
+
1443
+ /**
1444
+ * Determines if the given filepath is ignored based on the configs.
1445
+ * @param {string} filePath The path of a file to check.
1446
+ * @returns {boolean} True if the path is ignored, false if not.
1447
+ * @deprecated Use `isFileIgnored` instead.
1448
+ */
1449
+ isIgnored(filePath) {
1450
+ return this.isFileIgnored(filePath);
1451
+ }
1452
+
1453
+ /**
1454
+ * Determines if the given filepath is ignored based on the configs.
1455
+ * @param {string} filePath The path of a file to check.
1456
+ * @returns {boolean} True if the path is ignored, false if not.
1457
+ */
1458
+ isFileIgnored(filePath) {
1459
+ return this.getConfigStatus(filePath) === "ignored";
1460
+ }
1461
+
1462
+ /**
1463
+ * Determines if the given directory is ignored based on the configs.
1464
+ * This checks only default `ignores` that don't have `files` in the
1465
+ * same config. A pattern such as `/foo` be considered to ignore the directory
1466
+ * while a pattern such as `/foo/**` is not considered to ignore the
1467
+ * directory because it is matching files.
1468
+ * @param {string} directoryPath The path of a directory to check.
1469
+ * @returns {boolean} True if the directory is ignored, false if not. Will
1470
+ * return true for any directory that is not inside of `basePath`.
1471
+ * @throws {Error} When the `ConfigArray` is not normalized.
1472
+ */
1473
+ isDirectoryIgnored(directoryPath) {
1474
+ assertNormalized(this);
1475
+
1476
+ const relativeDirectoryPath = toRelativePath(
1477
+ directoryPath,
1478
+ this.#namespacedBasePath,
1479
+ this.#path,
1480
+ );
1481
+
1482
+ // basePath directory can never be ignored
1483
+ if (relativeDirectoryPath === "") {
1484
+ return false;
1485
+ }
1486
+
1487
+ if (EXTERNAL_PATH_REGEX.test(relativeDirectoryPath)) {
1488
+ return true;
1489
+ }
1490
+
1491
+ // first check the cache
1492
+ const cache = dataCache.get(this).directoryMatches;
1493
+
1494
+ if (cache.has(relativeDirectoryPath)) {
1495
+ return cache.get(relativeDirectoryPath);
1496
+ }
1497
+
1498
+ const directoryParts = relativeDirectoryPath.split("/");
1499
+ let relativeDirectoryToCheck = "";
1500
+ let result;
1501
+
1502
+ /*
1503
+ * In order to get the correct gitignore-style ignores, where an
1504
+ * ignored parent directory cannot have any descendants unignored,
1505
+ * we need to check every directory starting at the parent all
1506
+ * the way down to the actual requested directory.
1507
+ *
1508
+ * We aggressively cache all of this info to make sure we don't
1509
+ * have to recalculate everything for every call.
1510
+ */
1511
+ do {
1512
+ relativeDirectoryToCheck += `${directoryParts.shift()}/`;
1513
+
1514
+ result = shouldIgnorePath(
1515
+ this.ignores,
1516
+ this.#path.join(this.basePath, relativeDirectoryToCheck),
1517
+ relativeDirectoryToCheck,
1518
+ {
1519
+ basePath: this.#namespacedBasePath,
1520
+ path: this.#path,
1521
+ },
1522
+ );
1523
+
1524
+ cache.set(relativeDirectoryToCheck, result);
1525
+ } while (!result && directoryParts.length);
1526
+
1527
+ // also cache the result for the requested path
1528
+ cache.set(relativeDirectoryPath, result);
1529
+
1530
+ return result;
1531
+ }
1532
+ }
1533
+
1534
+ Object.defineProperty(exports, "ObjectSchema", {
1535
+ enumerable: true,
1536
+ get: function () { return objectSchema.ObjectSchema; }
1537
+ });
1538
+ exports.ConfigArray = ConfigArray;
1539
+ exports.ConfigArraySymbol = ConfigArraySymbol;
server/node_modules/@eslint/config-array/dist/cjs/index.d.cts ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export { ObjectSchema } from "@eslint/object-schema";
2
+ export type PropertyDefinition = $eslintobjectschema.PropertyDefinition;
3
+ export type ObjectDefinition = $eslintobjectschema.ObjectDefinition;
4
+ export type ConfigObject = $typests.ConfigObject;
5
+ export type IMinimatchStatic = minimatch.IMinimatchStatic;
6
+ export type IMinimatch = minimatch.IMinimatch;
7
+ export type ObjectSchemaInstance = ObjectSchema;
8
+ /**
9
+ * Represents an array of config objects and provides method for working with
10
+ * those config objects.
11
+ */
12
+ export class ConfigArray extends Array<any> {
13
+ /**
14
+ * Creates a new instance of ConfigArray.
15
+ * @param {Iterable|Function|Object} configs An iterable yielding config
16
+ * objects, or a config function, or a config object.
17
+ * @param {Object} options The options for the ConfigArray.
18
+ * @param {string} [options.basePath="/"] The absolute path of the config file directory.
19
+ * Defaults to `"/"`.
20
+ * @param {boolean} [options.normalized=false] Flag indicating if the
21
+ * configs have already been normalized.
22
+ * @param {Object} [options.schema] The additional schema
23
+ * definitions to use for the ConfigArray schema.
24
+ * @param {Array<string>} [options.extraConfigTypes] List of config types supported.
25
+ * @throws {TypeError} When the `basePath` is not a non-empty string,
26
+ */
27
+ constructor(configs: Iterable<any> | Function | any, { basePath, normalized, schema: customSchema, extraConfigTypes, }?: {
28
+ basePath?: string;
29
+ normalized?: boolean;
30
+ schema?: any;
31
+ extraConfigTypes?: Array<string>;
32
+ });
33
+ /**
34
+ * The path of the config file that this array was loaded from.
35
+ * This is used to calculate filename matches.
36
+ * @property basePath
37
+ * @type {string}
38
+ */
39
+ basePath: string;
40
+ /**
41
+ * The supported config types.
42
+ * @type {Array<string>}
43
+ */
44
+ extraConfigTypes: Array<string>;
45
+ /**
46
+ * Returns the `files` globs from every config object in the array.
47
+ * This can be used to determine which files will be matched by a
48
+ * config array or to use as a glob pattern when no patterns are provided
49
+ * for a command line interface.
50
+ * @returns {Array<string|Function>} An array of matchers.
51
+ */
52
+ get files(): Array<string | Function>;
53
+ /**
54
+ * Returns ignore matchers that should always be ignored regardless of
55
+ * the matching `files` fields in any configs. This is necessary to mimic
56
+ * the behavior of things like .gitignore and .eslintignore, allowing a
57
+ * globbing operation to be faster.
58
+ * @returns {Object[]} An array of config objects representing global ignores.
59
+ */
60
+ get ignores(): any[];
61
+ /**
62
+ * Indicates if the config array has been normalized.
63
+ * @returns {boolean} True if the config array is normalized, false if not.
64
+ */
65
+ isNormalized(): boolean;
66
+ /**
67
+ * Normalizes a config array by flattening embedded arrays and executing
68
+ * config functions.
69
+ * @param {Object} [context] The context object for config functions.
70
+ * @returns {Promise<ConfigArray>} The current ConfigArray instance.
71
+ */
72
+ normalize(context?: any): Promise<ConfigArray>;
73
+ /**
74
+ * Normalizes a config array by flattening embedded arrays and executing
75
+ * config functions.
76
+ * @param {Object} [context] The context object for config functions.
77
+ * @returns {ConfigArray} The current ConfigArray instance.
78
+ */
79
+ normalizeSync(context?: any): ConfigArray;
80
+ /**
81
+ * Returns the config object for a given file path and a status that can be used to determine why a file has no config.
82
+ * @param {string} filePath The path of a file to get a config for.
83
+ * @returns {{ config?: Object, status: "ignored"|"external"|"unconfigured"|"matched" }}
84
+ * An object with an optional property `config` and property `status`.
85
+ * `config` is the config object for the specified file as returned by {@linkcode ConfigArray.getConfig},
86
+ * `status` a is one of the constants returned by {@linkcode ConfigArray.getConfigStatus}.
87
+ */
88
+ getConfigWithStatus(filePath: string): {
89
+ config?: any;
90
+ status: "ignored" | "external" | "unconfigured" | "matched";
91
+ };
92
+ /**
93
+ * Returns the config object for a given file path.
94
+ * @param {string} filePath The path of a file to get a config for.
95
+ * @returns {Object|undefined} The config object for this file or `undefined`.
96
+ */
97
+ getConfig(filePath: string): any | undefined;
98
+ /**
99
+ * Determines whether a file has a config or why it doesn't.
100
+ * @param {string} filePath The path of the file to check.
101
+ * @returns {"ignored"|"external"|"unconfigured"|"matched"} One of the following values:
102
+ * * `"ignored"`: the file is ignored
103
+ * * `"external"`: the file is outside the base path
104
+ * * `"unconfigured"`: the file is not matched by any config
105
+ * * `"matched"`: the file has a matching config
106
+ */
107
+ getConfigStatus(filePath: string): "ignored" | "external" | "unconfigured" | "matched";
108
+ /**
109
+ * Determines if the given filepath is ignored based on the configs.
110
+ * @param {string} filePath The path of a file to check.
111
+ * @returns {boolean} True if the path is ignored, false if not.
112
+ * @deprecated Use `isFileIgnored` instead.
113
+ */
114
+ isIgnored(filePath: string): boolean;
115
+ /**
116
+ * Determines if the given filepath is ignored based on the configs.
117
+ * @param {string} filePath The path of a file to check.
118
+ * @returns {boolean} True if the path is ignored, false if not.
119
+ */
120
+ isFileIgnored(filePath: string): boolean;
121
+ /**
122
+ * Determines if the given directory is ignored based on the configs.
123
+ * This checks only default `ignores` that don't have `files` in the
124
+ * same config. A pattern such as `/foo` be considered to ignore the directory
125
+ * while a pattern such as `/foo/**` is not considered to ignore the
126
+ * directory because it is matching files.
127
+ * @param {string} directoryPath The path of a directory to check.
128
+ * @returns {boolean} True if the directory is ignored, false if not. Will
129
+ * return true for any directory that is not inside of `basePath`.
130
+ * @throws {Error} When the `ConfigArray` is not normalized.
131
+ */
132
+ isDirectoryIgnored(directoryPath: string): boolean;
133
+ #private;
134
+ }
135
+ export namespace ConfigArraySymbol {
136
+ let isNormalized: symbol;
137
+ let configCache: symbol;
138
+ let schema: symbol;
139
+ let finalizeConfig: symbol;
140
+ let preprocessConfig: symbol;
141
+ }
142
+ import type * as $eslintobjectschema from "@eslint/object-schema";
143
+ import type * as $typests from "./types.cts";
144
+ import minimatch from 'minimatch';
145
+ import { ObjectSchema } from '@eslint/object-schema';
server/node_modules/@eslint/config-array/dist/cjs/std__path/posix.cjs ADDED
@@ -0,0 +1,1336 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-nocheck
2
+ 'use strict';
3
+
4
+ // Copyright 2018-2025 the Deno authors. MIT license.
5
+ // Copyright the Browserify authors. MIT License.
6
+ function assertPath(path) {
7
+ if (typeof path !== "string") {
8
+ throw new TypeError(`Path must be a string, received "${JSON.stringify(path)}"`);
9
+ }
10
+ }
11
+
12
+ // Copyright 2018-2025 the Deno authors. MIT license.
13
+ // This module is browser compatible.
14
+ function stripSuffix(name, suffix) {
15
+ if (suffix.length >= name.length) {
16
+ return name;
17
+ }
18
+ const lenDiff = name.length - suffix.length;
19
+ for(let i = suffix.length - 1; i >= 0; --i){
20
+ if (name.charCodeAt(lenDiff + i) !== suffix.charCodeAt(i)) {
21
+ return name;
22
+ }
23
+ }
24
+ return name.slice(0, -suffix.length);
25
+ }
26
+ function lastPathSegment(path, isSep, start = 0) {
27
+ let matchedNonSeparator = false;
28
+ let end = path.length;
29
+ for(let i = path.length - 1; i >= start; --i){
30
+ if (isSep(path.charCodeAt(i))) {
31
+ if (matchedNonSeparator) {
32
+ start = i + 1;
33
+ break;
34
+ }
35
+ } else if (!matchedNonSeparator) {
36
+ matchedNonSeparator = true;
37
+ end = i + 1;
38
+ }
39
+ }
40
+ return path.slice(start, end);
41
+ }
42
+ function assertArgs$1(path, suffix) {
43
+ assertPath(path);
44
+ if (path.length === 0) return path;
45
+ if (typeof suffix !== "string") {
46
+ throw new TypeError(`Suffix must be a string, received "${JSON.stringify(suffix)}"`);
47
+ }
48
+ }
49
+
50
+ // Copyright 2018-2025 the Deno authors. MIT license.
51
+ // This module is browser compatible.
52
+ function assertArg$3(url) {
53
+ url = url instanceof URL ? url : new URL(url);
54
+ if (url.protocol !== "file:") {
55
+ throw new TypeError(`URL must be a file URL: received "${url.protocol}"`);
56
+ }
57
+ return url;
58
+ }
59
+
60
+ // Copyright 2018-2025 the Deno authors. MIT license.
61
+ // This module is browser compatible.
62
+ /**
63
+ * Converts a file URL to a path string.
64
+ *
65
+ * @example Usage
66
+ * ```ts
67
+ * import { fromFileUrl } from "@std/path/posix/from-file-url";
68
+ * import { assertEquals } from "@std/assert";
69
+ *
70
+ * assertEquals(fromFileUrl(new URL("file:///home/foo")), "/home/foo");
71
+ * ```
72
+ *
73
+ * @param url The file URL to convert.
74
+ * @returns The path string.
75
+ */ function fromFileUrl(url) {
76
+ url = assertArg$3(url);
77
+ return decodeURIComponent(url.pathname.replace(/%(?![0-9A-Fa-f]{2})/g, "%25"));
78
+ }
79
+
80
+ // Copyright 2018-2025 the Deno authors. MIT license.
81
+ // Copyright the Browserify authors. MIT License.
82
+ // Ported from https://github.com/browserify/path-browserify/
83
+ // This module is browser compatible.
84
+ function stripTrailingSeparators(segment, isSep) {
85
+ if (segment.length <= 1) {
86
+ return segment;
87
+ }
88
+ let end = segment.length;
89
+ for(let i = segment.length - 1; i > 0; i--){
90
+ if (isSep(segment.charCodeAt(i))) {
91
+ end = i;
92
+ } else {
93
+ break;
94
+ }
95
+ }
96
+ return segment.slice(0, end);
97
+ }
98
+
99
+ // Copyright 2018-2025 the Deno authors. MIT license.
100
+ // Copyright the Browserify authors. MIT License.
101
+ // Ported from https://github.com/browserify/path-browserify/
102
+ // This module is browser compatible.
103
+ // Alphabet chars.
104
+ // Non-alphabetic chars.
105
+ const CHAR_DOT = 46; /* . */
106
+ const CHAR_FORWARD_SLASH = 47; /* / */
107
+
108
+ // Copyright 2018-2025 the Deno authors. MIT license.
109
+ // Copyright the Browserify authors. MIT License.
110
+ // Ported from https://github.com/browserify/path-browserify/
111
+ // This module is browser compatible.
112
+ function isPosixPathSeparator(code) {
113
+ return code === CHAR_FORWARD_SLASH;
114
+ }
115
+
116
+ // Copyright 2018-2025 the Deno authors. MIT license.
117
+ // This module is browser compatible.
118
+ /**
119
+ * Return the last portion of a `path`.
120
+ * Trailing directory separators are ignored, and optional suffix is removed.
121
+ *
122
+ * @example Usage
123
+ * ```ts
124
+ * import { basename } from "@std/path/posix/basename";
125
+ * import { assertEquals } from "@std/assert";
126
+ *
127
+ * assertEquals(basename("/home/user/Documents/"), "Documents");
128
+ * assertEquals(basename("/home/user/Documents/image.png"), "image.png");
129
+ * assertEquals(basename("/home/user/Documents/image.png", ".png"), "image");
130
+ * assertEquals(basename(new URL("file:///home/user/Documents/image.png")), "image.png");
131
+ * assertEquals(basename(new URL("file:///home/user/Documents/image.png"), ".png"), "image");
132
+ * ```
133
+ *
134
+ * @example Working with URLs
135
+ *
136
+ * Note: This function doesn't automatically strip hash and query parts from
137
+ * URLs. If your URL contains a hash or query, remove them before passing the
138
+ * URL to the function. This can be done by passing the URL to `new URL(url)`,
139
+ * and setting the `hash` and `search` properties to empty strings.
140
+ *
141
+ * ```ts
142
+ * import { basename } from "@std/path/posix/basename";
143
+ * import { assertEquals } from "@std/assert";
144
+ *
145
+ * assertEquals(basename("https://deno.land/std/path/mod.ts"), "mod.ts");
146
+ * assertEquals(basename("https://deno.land/std/path/mod.ts", ".ts"), "mod");
147
+ * assertEquals(basename("https://deno.land/std/path/mod.ts?a=b"), "mod.ts?a=b");
148
+ * assertEquals(basename("https://deno.land/std/path/mod.ts#header"), "mod.ts#header");
149
+ * ```
150
+ *
151
+ * @param path The path to extract the name from.
152
+ * @param suffix The suffix to remove from extracted name.
153
+ * @returns The extracted name.
154
+ */ function basename(path, suffix = "") {
155
+ if (path instanceof URL) {
156
+ path = fromFileUrl(path);
157
+ }
158
+ assertArgs$1(path, suffix);
159
+ const lastSegment = lastPathSegment(path, isPosixPathSeparator);
160
+ const strippedSegment = stripTrailingSeparators(lastSegment, isPosixPathSeparator);
161
+ return suffix ? stripSuffix(strippedSegment, suffix) : strippedSegment;
162
+ }
163
+
164
+ // Copyright 2018-2025 the Deno authors. MIT license.
165
+ // This module is browser compatible.
166
+ /**
167
+ * The character used to separate entries in the PATH environment variable.
168
+ */ const DELIMITER = ":";
169
+ /**
170
+ * The character used to separate components of a file path.
171
+ */ const SEPARATOR = "/";
172
+ /**
173
+ * A regular expression that matches one or more path separators.
174
+ */ const SEPARATOR_PATTERN = /\/+/;
175
+
176
+ // Copyright 2018-2025 the Deno authors. MIT license.
177
+ // This module is browser compatible.
178
+ function assertArg$2(path) {
179
+ assertPath(path);
180
+ if (path.length === 0) return ".";
181
+ }
182
+
183
+ // Copyright 2018-2025 the Deno authors. MIT license.
184
+ // This module is browser compatible.
185
+ /**
186
+ * Return the directory path of a `path`.
187
+ *
188
+ * @example Usage
189
+ * ```ts
190
+ * import { dirname } from "@std/path/posix/dirname";
191
+ * import { assertEquals } from "@std/assert";
192
+ *
193
+ * assertEquals(dirname("/home/user/Documents/"), "/home/user");
194
+ * assertEquals(dirname("/home/user/Documents/image.png"), "/home/user/Documents");
195
+ * assertEquals(dirname("https://deno.land/std/path/mod.ts"), "https://deno.land/std/path");
196
+ * assertEquals(dirname(new URL("file:///home/user/Documents/image.png")), "/home/user/Documents");
197
+ * ```
198
+ *
199
+ * @example Working with URLs
200
+ *
201
+ * ```ts
202
+ * import { dirname } from "@std/path/posix/dirname";
203
+ * import { assertEquals } from "@std/assert";
204
+ *
205
+ * assertEquals(dirname("https://deno.land/std/path/mod.ts"), "https://deno.land/std/path");
206
+ * assertEquals(dirname("https://deno.land/std/path/mod.ts?a=b"), "https://deno.land/std/path");
207
+ * assertEquals(dirname("https://deno.land/std/path/mod.ts#header"), "https://deno.land/std/path");
208
+ * ```
209
+ *
210
+ * @param path The path to get the directory from.
211
+ * @returns The directory path.
212
+ */ function dirname(path) {
213
+ if (path instanceof URL) {
214
+ path = fromFileUrl(path);
215
+ }
216
+ assertArg$2(path);
217
+ let end = -1;
218
+ let matchedNonSeparator = false;
219
+ for(let i = path.length - 1; i >= 1; --i){
220
+ if (isPosixPathSeparator(path.charCodeAt(i))) {
221
+ if (matchedNonSeparator) {
222
+ end = i;
223
+ break;
224
+ }
225
+ } else {
226
+ matchedNonSeparator = true;
227
+ }
228
+ }
229
+ // No matches. Fallback based on provided path:
230
+ //
231
+ // - leading slashes paths
232
+ // "/foo" => "/"
233
+ // "///foo" => "/"
234
+ // - no slash path
235
+ // "foo" => "."
236
+ if (end === -1) {
237
+ return isPosixPathSeparator(path.charCodeAt(0)) ? "/" : ".";
238
+ }
239
+ return stripTrailingSeparators(path.slice(0, end), isPosixPathSeparator);
240
+ }
241
+
242
+ // Copyright 2018-2025 the Deno authors. MIT license.
243
+ // This module is browser compatible.
244
+ /**
245
+ * Return the extension of the `path` with leading period.
246
+ *
247
+ * @example Usage
248
+ * ```ts
249
+ * import { extname } from "@std/path/posix/extname";
250
+ * import { assertEquals } from "@std/assert";
251
+ *
252
+ * assertEquals(extname("/home/user/Documents/file.ts"), ".ts");
253
+ * assertEquals(extname("/home/user/Documents/"), "");
254
+ * assertEquals(extname("/home/user/Documents/image.png"), ".png");
255
+ * assertEquals(extname(new URL("file:///home/user/Documents/file.ts")), ".ts");
256
+ * assertEquals(extname(new URL("file:///home/user/Documents/file.ts?a=b")), ".ts");
257
+ * assertEquals(extname(new URL("file:///home/user/Documents/file.ts#header")), ".ts");
258
+ * ```
259
+ *
260
+ * @example Working with URLs
261
+ *
262
+ * Note: This function doesn't automatically strip hash and query parts from
263
+ * URLs. If your URL contains a hash or query, remove them before passing the
264
+ * URL to the function. This can be done by passing the URL to `new URL(url)`,
265
+ * and setting the `hash` and `search` properties to empty strings.
266
+ *
267
+ * ```ts
268
+ * import { extname } from "@std/path/posix/extname";
269
+ * import { assertEquals } from "@std/assert";
270
+ *
271
+ * assertEquals(extname("https://deno.land/std/path/mod.ts"), ".ts");
272
+ * assertEquals(extname("https://deno.land/std/path/mod.ts?a=b"), ".ts?a=b");
273
+ * assertEquals(extname("https://deno.land/std/path/mod.ts#header"), ".ts#header");
274
+ * ```
275
+ *
276
+ * @param path The path to get the extension from.
277
+ * @returns The extension (ex. for `file.ts` returns `.ts`).
278
+ */ function extname(path) {
279
+ if (path instanceof URL) {
280
+ path = fromFileUrl(path);
281
+ }
282
+ assertPath(path);
283
+ let startDot = -1;
284
+ let startPart = 0;
285
+ let end = -1;
286
+ let matchedSlash = true;
287
+ // Track the state of characters (if any) we see before our first dot and
288
+ // after any path separator we find
289
+ let preDotState = 0;
290
+ for(let i = path.length - 1; i >= 0; --i){
291
+ const code = path.charCodeAt(i);
292
+ if (isPosixPathSeparator(code)) {
293
+ // If we reached a path separator that was not part of a set of path
294
+ // separators at the end of the string, stop now
295
+ if (!matchedSlash) {
296
+ startPart = i + 1;
297
+ break;
298
+ }
299
+ continue;
300
+ }
301
+ if (end === -1) {
302
+ // We saw the first non-path separator, mark this as the end of our
303
+ // extension
304
+ matchedSlash = false;
305
+ end = i + 1;
306
+ }
307
+ if (code === CHAR_DOT) {
308
+ // If this is our first dot, mark it as the start of our extension
309
+ if (startDot === -1) startDot = i;
310
+ else if (preDotState !== 1) preDotState = 1;
311
+ } else if (startDot !== -1) {
312
+ // We saw a non-dot and non-path separator before our dot, so we should
313
+ // have a good chance at having a non-empty extension
314
+ preDotState = -1;
315
+ }
316
+ }
317
+ if (startDot === -1 || end === -1 || // We saw a non-dot character immediately before the dot
318
+ preDotState === 0 || // The (right-most) trimmed path component is exactly '..'
319
+ preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
320
+ return "";
321
+ }
322
+ return path.slice(startDot, end);
323
+ }
324
+
325
+ // Copyright 2018-2025 the Deno authors. MIT license.
326
+ // This module is browser compatible.
327
+ function _format(sep, pathObject) {
328
+ const dir = pathObject.dir || pathObject.root;
329
+ const base = pathObject.base || (pathObject.name ?? "") + (pathObject.ext ?? "");
330
+ if (!dir) return base;
331
+ if (base === sep) return dir;
332
+ if (dir === pathObject.root) return dir + base;
333
+ return dir + sep + base;
334
+ }
335
+ function assertArg$1(pathObject) {
336
+ if (pathObject === null || typeof pathObject !== "object") {
337
+ throw new TypeError(`The "pathObject" argument must be of type Object, received type "${typeof pathObject}"`);
338
+ }
339
+ }
340
+
341
+ // Copyright 2018-2025 the Deno authors. MIT license.
342
+ // This module is browser compatible.
343
+ /**
344
+ * Generate a path from `ParsedPath` object.
345
+ *
346
+ * @example Usage
347
+ * ```ts
348
+ * import { format } from "@std/path/posix/format";
349
+ * import { assertEquals } from "@std/assert";
350
+ *
351
+ * const path = format({
352
+ * root: "/",
353
+ * dir: "/path/dir",
354
+ * base: "file.txt",
355
+ * ext: ".txt",
356
+ * name: "file"
357
+ * });
358
+ * assertEquals(path, "/path/dir/file.txt");
359
+ * ```
360
+ *
361
+ * @param pathObject The path object to format.
362
+ * @returns The formatted path.
363
+ */ function format(pathObject) {
364
+ assertArg$1(pathObject);
365
+ return _format("/", pathObject);
366
+ }
367
+
368
+ // Copyright 2018-2025 the Deno authors. MIT license.
369
+ // This module is browser compatible.
370
+ /**
371
+ * Verifies whether provided path is absolute.
372
+ *
373
+ * @example Usage
374
+ * ```ts
375
+ * import { isAbsolute } from "@std/path/posix/is-absolute";
376
+ * import { assert, assertFalse } from "@std/assert";
377
+ *
378
+ * assert(isAbsolute("/home/user/Documents/"));
379
+ * assertFalse(isAbsolute("home/user/Documents/"));
380
+ * ```
381
+ *
382
+ * @param path The path to verify.
383
+ * @returns Whether the path is absolute.
384
+ */ function isAbsolute(path) {
385
+ assertPath(path);
386
+ return path.length > 0 && isPosixPathSeparator(path.charCodeAt(0));
387
+ }
388
+
389
+ // Copyright 2018-2025 the Deno authors. MIT license.
390
+ // This module is browser compatible.
391
+ function assertArg(path) {
392
+ assertPath(path);
393
+ if (path.length === 0) return ".";
394
+ }
395
+
396
+ // Copyright 2018-2025 the Deno authors. MIT license.
397
+ // Copyright the Browserify authors. MIT License.
398
+ // Ported from https://github.com/browserify/path-browserify/
399
+ // This module is browser compatible.
400
+ // Resolves . and .. elements in a path with directory names
401
+ function normalizeString(path, allowAboveRoot, separator, isPathSeparator) {
402
+ let res = "";
403
+ let lastSegmentLength = 0;
404
+ let lastSlash = -1;
405
+ let dots = 0;
406
+ let code;
407
+ for(let i = 0; i <= path.length; ++i){
408
+ if (i < path.length) code = path.charCodeAt(i);
409
+ else if (isPathSeparator(code)) break;
410
+ else code = CHAR_FORWARD_SLASH;
411
+ if (isPathSeparator(code)) {
412
+ if (lastSlash === i - 1 || dots === 1) ; else if (lastSlash !== i - 1 && dots === 2) {
413
+ if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== CHAR_DOT || res.charCodeAt(res.length - 2) !== CHAR_DOT) {
414
+ if (res.length > 2) {
415
+ const lastSlashIndex = res.lastIndexOf(separator);
416
+ if (lastSlashIndex === -1) {
417
+ res = "";
418
+ lastSegmentLength = 0;
419
+ } else {
420
+ res = res.slice(0, lastSlashIndex);
421
+ lastSegmentLength = res.length - 1 - res.lastIndexOf(separator);
422
+ }
423
+ lastSlash = i;
424
+ dots = 0;
425
+ continue;
426
+ } else if (res.length === 2 || res.length === 1) {
427
+ res = "";
428
+ lastSegmentLength = 0;
429
+ lastSlash = i;
430
+ dots = 0;
431
+ continue;
432
+ }
433
+ }
434
+ if (allowAboveRoot) {
435
+ if (res.length > 0) res += `${separator}..`;
436
+ else res = "..";
437
+ lastSegmentLength = 2;
438
+ }
439
+ } else {
440
+ if (res.length > 0) res += separator + path.slice(lastSlash + 1, i);
441
+ else res = path.slice(lastSlash + 1, i);
442
+ lastSegmentLength = i - lastSlash - 1;
443
+ }
444
+ lastSlash = i;
445
+ dots = 0;
446
+ } else if (code === CHAR_DOT && dots !== -1) {
447
+ ++dots;
448
+ } else {
449
+ dots = -1;
450
+ }
451
+ }
452
+ return res;
453
+ }
454
+
455
+ // Copyright 2018-2025 the Deno authors. MIT license.
456
+ // This module is browser compatible.
457
+ /**
458
+ * Normalize the `path`, resolving `'..'` and `'.'` segments.
459
+ * Note that resolving these segments does not necessarily mean that all will be eliminated.
460
+ * A `'..'` at the top-level will be preserved, and an empty path is canonically `'.'`.
461
+ *
462
+ * @example Usage
463
+ * ```ts
464
+ * import { normalize } from "@std/path/posix/normalize";
465
+ * import { assertEquals } from "@std/assert";
466
+ *
467
+ * assertEquals(normalize("/foo/bar//baz/asdf/quux/.."), "/foo/bar/baz/asdf");
468
+ * assertEquals(normalize(new URL("file:///foo/bar//baz/asdf/quux/..")), "/foo/bar/baz/asdf/");
469
+ * ```
470
+ *
471
+ * @example Working with URLs
472
+ *
473
+ * Note: This function will remove the double slashes from a URL's scheme.
474
+ * Hence, do not pass a full URL to this function. Instead, pass the pathname of
475
+ * the URL.
476
+ *
477
+ * ```ts
478
+ * import { normalize } from "@std/path/posix/normalize";
479
+ * import { assertEquals } from "@std/assert";
480
+ *
481
+ * const url = new URL("https://deno.land");
482
+ * url.pathname = normalize("//std//assert//.//mod.ts");
483
+ * assertEquals(url.href, "https://deno.land/std/assert/mod.ts");
484
+ *
485
+ * url.pathname = normalize("std/assert/../async/retry.ts");
486
+ * assertEquals(url.href, "https://deno.land/std/async/retry.ts");
487
+ * ```
488
+ *
489
+ * @param path The path to normalize.
490
+ * @returns The normalized path.
491
+ */ function normalize(path) {
492
+ if (path instanceof URL) {
493
+ path = fromFileUrl(path);
494
+ }
495
+ assertArg(path);
496
+ const isAbsolute = isPosixPathSeparator(path.charCodeAt(0));
497
+ const trailingSeparator = isPosixPathSeparator(path.charCodeAt(path.length - 1));
498
+ // Normalize the path
499
+ path = normalizeString(path, !isAbsolute, "/", isPosixPathSeparator);
500
+ if (path.length === 0 && !isAbsolute) path = ".";
501
+ if (path.length > 0 && trailingSeparator) path += "/";
502
+ if (isAbsolute) return `/${path}`;
503
+ return path;
504
+ }
505
+
506
+ // Copyright 2018-2025 the Deno authors. MIT license.
507
+ // This module is browser compatible.
508
+ /**
509
+ * Join all given a sequence of `paths`,then normalizes the resulting path.
510
+ *
511
+ * @example Usage
512
+ * ```ts
513
+ * import { join } from "@std/path/posix/join";
514
+ * import { assertEquals } from "@std/assert";
515
+ *
516
+ * assertEquals(join("/foo", "bar", "baz/asdf", "quux", ".."), "/foo/bar/baz/asdf");
517
+ * assertEquals(join(new URL("file:///foo"), "bar", "baz/asdf", "quux", ".."), "/foo/bar/baz/asdf");
518
+ * ```
519
+ *
520
+ * @example Working with URLs
521
+ * ```ts
522
+ * import { join } from "@std/path/posix/join";
523
+ * import { assertEquals } from "@std/assert";
524
+ *
525
+ * const url = new URL("https://deno.land");
526
+ * url.pathname = join("std", "path", "mod.ts");
527
+ * assertEquals(url.href, "https://deno.land/std/path/mod.ts");
528
+ *
529
+ * url.pathname = join("//std", "path/", "/mod.ts");
530
+ * assertEquals(url.href, "https://deno.land/std/path/mod.ts");
531
+ * ```
532
+ *
533
+ * @param path The path to join. This can be string or file URL.
534
+ * @param paths The paths to join.
535
+ * @returns The joined path.
536
+ */ function join(path, ...paths) {
537
+ if (path === undefined) return ".";
538
+ if (path instanceof URL) {
539
+ path = fromFileUrl(path);
540
+ }
541
+ paths = path ? [
542
+ path,
543
+ ...paths
544
+ ] : paths;
545
+ paths.forEach((path)=>assertPath(path));
546
+ const joined = paths.filter((path)=>path.length > 0).join("/");
547
+ return joined === "" ? "." : normalize(joined);
548
+ }
549
+
550
+ // Copyright 2018-2025 the Deno authors. MIT license.
551
+ // This module is browser compatible.
552
+ /**
553
+ * Return a `ParsedPath` object of the `path`.
554
+ *
555
+ * @example Usage
556
+ * ```ts
557
+ * import { parse } from "@std/path/posix/parse";
558
+ * import { assertEquals } from "@std/assert";
559
+ *
560
+ * const path = parse("/home/user/file.txt");
561
+ * assertEquals(path, {
562
+ * root: "/",
563
+ * dir: "/home/user",
564
+ * base: "file.txt",
565
+ * ext: ".txt",
566
+ * name: "file"
567
+ * });
568
+ * ```
569
+ *
570
+ * @param path The path to parse.
571
+ * @returns The parsed path object.
572
+ */ function parse(path) {
573
+ assertPath(path);
574
+ const ret = {
575
+ root: "",
576
+ dir: "",
577
+ base: "",
578
+ ext: "",
579
+ name: ""
580
+ };
581
+ if (path.length === 0) return ret;
582
+ const isAbsolute = isPosixPathSeparator(path.charCodeAt(0));
583
+ let start;
584
+ if (isAbsolute) {
585
+ ret.root = "/";
586
+ start = 1;
587
+ } else {
588
+ start = 0;
589
+ }
590
+ let startDot = -1;
591
+ let startPart = 0;
592
+ let end = -1;
593
+ let matchedSlash = true;
594
+ let i = path.length - 1;
595
+ // Track the state of characters (if any) we see before our first dot and
596
+ // after any path separator we find
597
+ let preDotState = 0;
598
+ // Get non-dir info
599
+ for(; i >= start; --i){
600
+ const code = path.charCodeAt(i);
601
+ if (isPosixPathSeparator(code)) {
602
+ // If we reached a path separator that was not part of a set of path
603
+ // separators at the end of the string, stop now
604
+ if (!matchedSlash) {
605
+ startPart = i + 1;
606
+ break;
607
+ }
608
+ continue;
609
+ }
610
+ if (end === -1) {
611
+ // We saw the first non-path separator, mark this as the end of our
612
+ // extension
613
+ matchedSlash = false;
614
+ end = i + 1;
615
+ }
616
+ if (code === CHAR_DOT) {
617
+ // If this is our first dot, mark it as the start of our extension
618
+ if (startDot === -1) startDot = i;
619
+ else if (preDotState !== 1) preDotState = 1;
620
+ } else if (startDot !== -1) {
621
+ // We saw a non-dot and non-path separator before our dot, so we should
622
+ // have a good chance at having a non-empty extension
623
+ preDotState = -1;
624
+ }
625
+ }
626
+ if (startDot === -1 || end === -1 || // We saw a non-dot character immediately before the dot
627
+ preDotState === 0 || // The (right-most) trimmed path component is exactly '..'
628
+ preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
629
+ if (end !== -1) {
630
+ if (startPart === 0 && isAbsolute) {
631
+ ret.base = ret.name = path.slice(1, end);
632
+ } else {
633
+ ret.base = ret.name = path.slice(startPart, end);
634
+ }
635
+ }
636
+ // Fallback to '/' in case there is no basename
637
+ ret.base = ret.base || "/";
638
+ } else {
639
+ if (startPart === 0 && isAbsolute) {
640
+ ret.name = path.slice(1, startDot);
641
+ ret.base = path.slice(1, end);
642
+ } else {
643
+ ret.name = path.slice(startPart, startDot);
644
+ ret.base = path.slice(startPart, end);
645
+ }
646
+ ret.ext = path.slice(startDot, end);
647
+ }
648
+ if (startPart > 0) {
649
+ ret.dir = stripTrailingSeparators(path.slice(0, startPart - 1), isPosixPathSeparator);
650
+ } else if (isAbsolute) ret.dir = "/";
651
+ return ret;
652
+ }
653
+
654
+ // Copyright 2018-2025 the Deno authors. MIT license.
655
+ // This module is browser compatible.
656
+ /**
657
+ * Resolves path segments into a `path`.
658
+ *
659
+ * @example Usage
660
+ * ```ts
661
+ * import { resolve } from "@std/path/posix/resolve";
662
+ * import { assertEquals } from "@std/assert";
663
+ *
664
+ * const path = resolve("/foo", "bar", "baz/asdf", "quux", "..");
665
+ * assertEquals(path, "/foo/bar/baz/asdf");
666
+ * ```
667
+ *
668
+ * @param pathSegments The path segments to resolve.
669
+ * @returns The resolved path.
670
+ */ function resolve(...pathSegments) {
671
+ let resolvedPath = "";
672
+ let resolvedAbsolute = false;
673
+ for(let i = pathSegments.length - 1; i >= -1 && !resolvedAbsolute; i--){
674
+ let path;
675
+ if (i >= 0) path = pathSegments[i];
676
+ else {
677
+ // deno-lint-ignore no-explicit-any
678
+ const { Deno } = globalThis;
679
+ if (typeof Deno?.cwd !== "function") {
680
+ throw new TypeError("Resolved a relative path without a current working directory (CWD)");
681
+ }
682
+ path = Deno.cwd();
683
+ }
684
+ assertPath(path);
685
+ // Skip empty entries
686
+ if (path.length === 0) {
687
+ continue;
688
+ }
689
+ resolvedPath = `${path}/${resolvedPath}`;
690
+ resolvedAbsolute = isPosixPathSeparator(path.charCodeAt(0));
691
+ }
692
+ // At this point the path should be resolved to a full absolute path, but
693
+ // handle relative paths to be safe (might happen when Deno.cwd() fails)
694
+ // Normalize the path
695
+ resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute, "/", isPosixPathSeparator);
696
+ if (resolvedAbsolute) {
697
+ if (resolvedPath.length > 0) return `/${resolvedPath}`;
698
+ else return "/";
699
+ } else if (resolvedPath.length > 0) return resolvedPath;
700
+ else return ".";
701
+ }
702
+
703
+ // Copyright 2018-2025 the Deno authors. MIT license.
704
+ // This module is browser compatible.
705
+ function assertArgs(from, to) {
706
+ assertPath(from);
707
+ assertPath(to);
708
+ if (from === to) return "";
709
+ }
710
+
711
+ // Copyright 2018-2025 the Deno authors. MIT license.
712
+ // This module is browser compatible.
713
+ /**
714
+ * Return the relative path from `from` to `to` based on current working directory.
715
+ *
716
+ * If `from` and `to` are the same, return an empty string.
717
+ *
718
+ * @example Usage
719
+ * ```ts
720
+ * import { relative } from "@std/path/posix/relative";
721
+ * import { assertEquals } from "@std/assert";
722
+ *
723
+ * const path = relative("/data/orandea/test/aaa", "/data/orandea/impl/bbb");
724
+ * assertEquals(path, "../../impl/bbb");
725
+ * ```
726
+ *
727
+ * @param from The path to start from.
728
+ * @param to The path to reach.
729
+ * @returns The relative path.
730
+ */ function relative(from, to) {
731
+ assertArgs(from, to);
732
+ from = resolve(from);
733
+ to = resolve(to);
734
+ if (from === to) return "";
735
+ // Trim any leading backslashes
736
+ let fromStart = 1;
737
+ const fromEnd = from.length;
738
+ for(; fromStart < fromEnd; ++fromStart){
739
+ if (!isPosixPathSeparator(from.charCodeAt(fromStart))) break;
740
+ }
741
+ const fromLen = fromEnd - fromStart;
742
+ // Trim any leading backslashes
743
+ let toStart = 1;
744
+ const toEnd = to.length;
745
+ for(; toStart < toEnd; ++toStart){
746
+ if (!isPosixPathSeparator(to.charCodeAt(toStart))) break;
747
+ }
748
+ const toLen = toEnd - toStart;
749
+ // Compare paths to find the longest common path from root
750
+ const length = fromLen < toLen ? fromLen : toLen;
751
+ let lastCommonSep = -1;
752
+ let i = 0;
753
+ for(; i <= length; ++i){
754
+ if (i === length) {
755
+ if (toLen > length) {
756
+ if (isPosixPathSeparator(to.charCodeAt(toStart + i))) {
757
+ // We get here if `from` is the exact base path for `to`.
758
+ // For example: from='/foo/bar'; to='/foo/bar/baz'
759
+ return to.slice(toStart + i + 1);
760
+ } else if (i === 0) {
761
+ // We get here if `from` is the root
762
+ // For example: from='/'; to='/foo'
763
+ return to.slice(toStart + i);
764
+ }
765
+ } else if (fromLen > length) {
766
+ if (isPosixPathSeparator(from.charCodeAt(fromStart + i))) {
767
+ // We get here if `to` is the exact base path for `from`.
768
+ // For example: from='/foo/bar/baz'; to='/foo/bar'
769
+ lastCommonSep = i;
770
+ } else if (i === 0) {
771
+ // We get here if `to` is the root.
772
+ // For example: from='/foo'; to='/'
773
+ lastCommonSep = 0;
774
+ }
775
+ }
776
+ break;
777
+ }
778
+ const fromCode = from.charCodeAt(fromStart + i);
779
+ const toCode = to.charCodeAt(toStart + i);
780
+ if (fromCode !== toCode) break;
781
+ else if (isPosixPathSeparator(fromCode)) lastCommonSep = i;
782
+ }
783
+ let out = "";
784
+ // Generate the relative path based on the path difference between `to`
785
+ // and `from`
786
+ for(i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i){
787
+ if (i === fromEnd || isPosixPathSeparator(from.charCodeAt(i))) {
788
+ if (out.length === 0) out += "..";
789
+ else out += "/..";
790
+ }
791
+ }
792
+ // Lastly, append the rest of the destination (`to`) path that comes after
793
+ // the common path parts
794
+ if (out.length > 0) return out + to.slice(toStart + lastCommonSep);
795
+ else {
796
+ toStart += lastCommonSep;
797
+ if (isPosixPathSeparator(to.charCodeAt(toStart))) ++toStart;
798
+ return to.slice(toStart);
799
+ }
800
+ }
801
+
802
+ // Copyright 2018-2025 the Deno authors. MIT license.
803
+ // This module is browser compatible.
804
+ const WHITESPACE_ENCODINGS = {
805
+ "\u0009": "%09",
806
+ "\u000A": "%0A",
807
+ "\u000B": "%0B",
808
+ "\u000C": "%0C",
809
+ "\u000D": "%0D",
810
+ "\u0020": "%20"
811
+ };
812
+ function encodeWhitespace(string) {
813
+ return string.replaceAll(/[\s]/g, (c)=>{
814
+ return WHITESPACE_ENCODINGS[c] ?? c;
815
+ });
816
+ }
817
+
818
+ // Copyright 2018-2025 the Deno authors. MIT license.
819
+ // This module is browser compatible.
820
+ /**
821
+ * Converts a path string to a file URL.
822
+ *
823
+ * @example Usage
824
+ * ```ts
825
+ * import { toFileUrl } from "@std/path/posix/to-file-url";
826
+ * import { assertEquals } from "@std/assert";
827
+ *
828
+ * assertEquals(toFileUrl("/home/foo"), new URL("file:///home/foo"));
829
+ * assertEquals(toFileUrl("/home/foo bar"), new URL("file:///home/foo%20bar"));
830
+ * ```
831
+ *
832
+ * @param path The path to convert.
833
+ * @returns The file URL.
834
+ */ function toFileUrl(path) {
835
+ if (!isAbsolute(path)) {
836
+ throw new TypeError(`Path must be absolute: received "${path}"`);
837
+ }
838
+ const url = new URL("file:///");
839
+ url.pathname = encodeWhitespace(path.replace(/%/g, "%25").replace(/\\/g, "%5C"));
840
+ return url;
841
+ }
842
+
843
+ // Copyright 2018-2025 the Deno authors. MIT license.
844
+ // This module is browser compatible.
845
+ /**
846
+ * Converts a path to a namespaced path. This function returns the path as is on posix.
847
+ *
848
+ * @example Usage
849
+ * ```ts
850
+ * import { toNamespacedPath } from "@std/path/posix/to-namespaced-path";
851
+ * import { assertEquals } from "@std/assert";
852
+ *
853
+ * assertEquals(toNamespacedPath("/home/foo"), "/home/foo");
854
+ * ```
855
+ *
856
+ * @param path The path.
857
+ * @returns The namespaced path.
858
+ */ function toNamespacedPath(path) {
859
+ // Non-op on posix systems
860
+ return path;
861
+ }
862
+
863
+ // Copyright 2018-2025 the Deno authors. MIT license.
864
+ // This module is browser compatible.
865
+ function common$1(paths, sep) {
866
+ const [first = "", ...remaining] = paths;
867
+ const parts = first.split(sep);
868
+ let endOfPrefix = parts.length;
869
+ let append = "";
870
+ for (const path of remaining){
871
+ const compare = path.split(sep);
872
+ if (compare.length <= endOfPrefix) {
873
+ endOfPrefix = compare.length;
874
+ append = "";
875
+ }
876
+ for(let i = 0; i < endOfPrefix; i++){
877
+ if (compare[i] !== parts[i]) {
878
+ endOfPrefix = i;
879
+ append = i === 0 ? "" : sep;
880
+ break;
881
+ }
882
+ }
883
+ }
884
+ return parts.slice(0, endOfPrefix).join(sep) + append;
885
+ }
886
+
887
+ // Copyright 2018-2025 the Deno authors. MIT license.
888
+ // This module is browser compatible.
889
+ /** Determines the common path from a set of paths for POSIX systems.
890
+ *
891
+ * @example Usage
892
+ * ```ts
893
+ * import { common } from "@std/path/posix/common";
894
+ * import { assertEquals } from "@std/assert";
895
+ *
896
+ * const path = common([
897
+ * "./deno/std/path/mod.ts",
898
+ * "./deno/std/fs/mod.ts",
899
+ * ]);
900
+ * assertEquals(path, "./deno/std/");
901
+ * ```
902
+ *
903
+ * @param paths The paths to compare.
904
+ * @returns The common path.
905
+ */ function common(paths) {
906
+ return common$1(paths, SEPARATOR);
907
+ }
908
+
909
+ // Copyright 2018-2025 the Deno authors. MIT license.
910
+ // This module is browser compatible.
911
+ /**
912
+ * Options for {@linkcode globToRegExp}, {@linkcode joinGlobs},
913
+ * {@linkcode normalizeGlob} and {@linkcode expandGlob}.
914
+ */ const REG_EXP_ESCAPE_CHARS = [
915
+ "!",
916
+ "$",
917
+ "(",
918
+ ")",
919
+ "*",
920
+ "+",
921
+ ".",
922
+ "=",
923
+ "?",
924
+ "[",
925
+ "\\",
926
+ "^",
927
+ "{",
928
+ "|"
929
+ ];
930
+ const RANGE_ESCAPE_CHARS = [
931
+ "-",
932
+ "\\",
933
+ "]"
934
+ ];
935
+ function _globToRegExp(c, glob, { extended = true, globstar: globstarOption = true, // os = osType,
936
+ caseInsensitive = false } = {}) {
937
+ if (glob === "") {
938
+ return /(?!)/;
939
+ }
940
+ // Remove trailing separators.
941
+ let newLength = glob.length;
942
+ for(; newLength > 1 && c.seps.includes(glob[newLength - 1]); newLength--);
943
+ glob = glob.slice(0, newLength);
944
+ let regExpString = "";
945
+ // Terminates correctly. Trust that `j` is incremented every iteration.
946
+ for(let j = 0; j < glob.length;){
947
+ let segment = "";
948
+ const groupStack = [];
949
+ let inRange = false;
950
+ let inEscape = false;
951
+ let endsWithSep = false;
952
+ let i = j;
953
+ // Terminates with `i` at the non-inclusive end of the current segment.
954
+ for(; i < glob.length && !(c.seps.includes(glob[i]) && groupStack.length === 0); i++){
955
+ if (inEscape) {
956
+ inEscape = false;
957
+ const escapeChars = inRange ? RANGE_ESCAPE_CHARS : REG_EXP_ESCAPE_CHARS;
958
+ segment += escapeChars.includes(glob[i]) ? `\\${glob[i]}` : glob[i];
959
+ continue;
960
+ }
961
+ if (glob[i] === c.escapePrefix) {
962
+ inEscape = true;
963
+ continue;
964
+ }
965
+ if (glob[i] === "[") {
966
+ if (!inRange) {
967
+ inRange = true;
968
+ segment += "[";
969
+ if (glob[i + 1] === "!") {
970
+ i++;
971
+ segment += "^";
972
+ } else if (glob[i + 1] === "^") {
973
+ i++;
974
+ segment += "\\^";
975
+ }
976
+ continue;
977
+ } else if (glob[i + 1] === ":") {
978
+ let k = i + 1;
979
+ let value = "";
980
+ while(glob[k + 1] !== undefined && glob[k + 1] !== ":"){
981
+ value += glob[k + 1];
982
+ k++;
983
+ }
984
+ if (glob[k + 1] === ":" && glob[k + 2] === "]") {
985
+ i = k + 2;
986
+ if (value === "alnum") segment += "\\dA-Za-z";
987
+ else if (value === "alpha") segment += "A-Za-z";
988
+ else if (value === "ascii") segment += "\x00-\x7F";
989
+ else if (value === "blank") segment += "\t ";
990
+ else if (value === "cntrl") segment += "\x00-\x1F\x7F";
991
+ else if (value === "digit") segment += "\\d";
992
+ else if (value === "graph") segment += "\x21-\x7E";
993
+ else if (value === "lower") segment += "a-z";
994
+ else if (value === "print") segment += "\x20-\x7E";
995
+ else if (value === "punct") {
996
+ segment += "!\"#$%&'()*+,\\-./:;<=>?@[\\\\\\]^_‘{|}~";
997
+ } else if (value === "space") segment += "\\s\v";
998
+ else if (value === "upper") segment += "A-Z";
999
+ else if (value === "word") segment += "\\w";
1000
+ else if (value === "xdigit") segment += "\\dA-Fa-f";
1001
+ continue;
1002
+ }
1003
+ }
1004
+ }
1005
+ if (glob[i] === "]" && inRange) {
1006
+ inRange = false;
1007
+ segment += "]";
1008
+ continue;
1009
+ }
1010
+ if (inRange) {
1011
+ segment += glob[i];
1012
+ continue;
1013
+ }
1014
+ if (glob[i] === ")" && groupStack.length > 0 && groupStack[groupStack.length - 1] !== "BRACE") {
1015
+ segment += ")";
1016
+ const type = groupStack.pop();
1017
+ if (type === "!") {
1018
+ segment += c.wildcard;
1019
+ } else if (type !== "@") {
1020
+ segment += type;
1021
+ }
1022
+ continue;
1023
+ }
1024
+ if (glob[i] === "|" && groupStack.length > 0 && groupStack[groupStack.length - 1] !== "BRACE") {
1025
+ segment += "|";
1026
+ continue;
1027
+ }
1028
+ if (glob[i] === "+" && extended && glob[i + 1] === "(") {
1029
+ i++;
1030
+ groupStack.push("+");
1031
+ segment += "(?:";
1032
+ continue;
1033
+ }
1034
+ if (glob[i] === "@" && extended && glob[i + 1] === "(") {
1035
+ i++;
1036
+ groupStack.push("@");
1037
+ segment += "(?:";
1038
+ continue;
1039
+ }
1040
+ if (glob[i] === "?") {
1041
+ if (extended && glob[i + 1] === "(") {
1042
+ i++;
1043
+ groupStack.push("?");
1044
+ segment += "(?:";
1045
+ } else {
1046
+ segment += ".";
1047
+ }
1048
+ continue;
1049
+ }
1050
+ if (glob[i] === "!" && extended && glob[i + 1] === "(") {
1051
+ i++;
1052
+ groupStack.push("!");
1053
+ segment += "(?!";
1054
+ continue;
1055
+ }
1056
+ if (glob[i] === "{") {
1057
+ groupStack.push("BRACE");
1058
+ segment += "(?:";
1059
+ continue;
1060
+ }
1061
+ if (glob[i] === "}" && groupStack[groupStack.length - 1] === "BRACE") {
1062
+ groupStack.pop();
1063
+ segment += ")";
1064
+ continue;
1065
+ }
1066
+ if (glob[i] === "," && groupStack[groupStack.length - 1] === "BRACE") {
1067
+ segment += "|";
1068
+ continue;
1069
+ }
1070
+ if (glob[i] === "*") {
1071
+ if (extended && glob[i + 1] === "(") {
1072
+ i++;
1073
+ groupStack.push("*");
1074
+ segment += "(?:";
1075
+ } else {
1076
+ const prevChar = glob[i - 1];
1077
+ let numStars = 1;
1078
+ while(glob[i + 1] === "*"){
1079
+ i++;
1080
+ numStars++;
1081
+ }
1082
+ const nextChar = glob[i + 1];
1083
+ if (globstarOption && numStars === 2 && [
1084
+ ...c.seps,
1085
+ undefined
1086
+ ].includes(prevChar) && [
1087
+ ...c.seps,
1088
+ undefined
1089
+ ].includes(nextChar)) {
1090
+ segment += c.globstar;
1091
+ endsWithSep = true;
1092
+ } else {
1093
+ segment += c.wildcard;
1094
+ }
1095
+ }
1096
+ continue;
1097
+ }
1098
+ segment += REG_EXP_ESCAPE_CHARS.includes(glob[i]) ? `\\${glob[i]}` : glob[i];
1099
+ }
1100
+ // Check for unclosed groups or a dangling backslash.
1101
+ if (groupStack.length > 0 || inRange || inEscape) {
1102
+ // Parse failure. Take all characters from this segment literally.
1103
+ segment = "";
1104
+ for (const c of glob.slice(j, i)){
1105
+ segment += REG_EXP_ESCAPE_CHARS.includes(c) ? `\\${c}` : c;
1106
+ endsWithSep = false;
1107
+ }
1108
+ }
1109
+ regExpString += segment;
1110
+ if (!endsWithSep) {
1111
+ regExpString += i < glob.length ? c.sep : c.sepMaybe;
1112
+ endsWithSep = true;
1113
+ }
1114
+ // Terminates with `i` at the start of the next segment.
1115
+ while(c.seps.includes(glob[i]))i++;
1116
+ j = i;
1117
+ }
1118
+ regExpString = `^${regExpString}$`;
1119
+ return new RegExp(regExpString, caseInsensitive ? "i" : "");
1120
+ }
1121
+
1122
+ // Copyright 2018-2025 the Deno authors. MIT license.
1123
+ // This module is browser compatible.
1124
+ const constants = {
1125
+ sep: "/+",
1126
+ sepMaybe: "/*",
1127
+ seps: [
1128
+ "/"
1129
+ ],
1130
+ globstar: "(?:[^/]*(?:/|$)+)*",
1131
+ wildcard: "[^/]*",
1132
+ escapePrefix: "\\"
1133
+ };
1134
+ /** Convert a glob string to a regular expression.
1135
+ *
1136
+ * Tries to match bash glob expansion as closely as possible.
1137
+ *
1138
+ * Basic glob syntax:
1139
+ * - `*` - Matches everything without leaving the path segment.
1140
+ * - `?` - Matches any single character.
1141
+ * - `{foo,bar}` - Matches `foo` or `bar`.
1142
+ * - `[abcd]` - Matches `a`, `b`, `c` or `d`.
1143
+ * - `[a-d]` - Matches `a`, `b`, `c` or `d`.
1144
+ * - `[!abcd]` - Matches any single character besides `a`, `b`, `c` or `d`.
1145
+ * - `[[:<class>:]]` - Matches any character belonging to `<class>`.
1146
+ * - `[[:alnum:]]` - Matches any digit or letter.
1147
+ * - `[[:digit:]abc]` - Matches any digit, `a`, `b` or `c`.
1148
+ * - See https://facelessuser.github.io/wcmatch/glob/#posix-character-classes
1149
+ * for a complete list of supported character classes.
1150
+ * - `\` - Escapes the next character for an `os` other than `"windows"`.
1151
+ * - \` - Escapes the next character for `os` set to `"windows"`.
1152
+ * - `/` - Path separator.
1153
+ * - `\` - Additional path separator only for `os` set to `"windows"`.
1154
+ *
1155
+ * Extended syntax:
1156
+ * - Requires `{ extended: true }`.
1157
+ * - `?(foo|bar)` - Matches 0 or 1 instance of `{foo,bar}`.
1158
+ * - `@(foo|bar)` - Matches 1 instance of `{foo,bar}`. They behave the same.
1159
+ * - `*(foo|bar)` - Matches _n_ instances of `{foo,bar}`.
1160
+ * - `+(foo|bar)` - Matches _n > 0_ instances of `{foo,bar}`.
1161
+ * - `!(foo|bar)` - Matches anything other than `{foo,bar}`.
1162
+ * - See https://www.linuxjournal.com/content/bash-extended-globbing.
1163
+ *
1164
+ * Globstar syntax:
1165
+ * - Requires `{ globstar: true }`.
1166
+ * - `**` - Matches any number of any path segments.
1167
+ * - Must comprise its entire path segment in the provided glob.
1168
+ * - See https://www.linuxjournal.com/content/globstar-new-bash-globbing-option.
1169
+ *
1170
+ * Note the following properties:
1171
+ * - The generated `RegExp` is anchored at both start and end.
1172
+ * - Repeating and trailing separators are tolerated. Trailing separators in the
1173
+ * provided glob have no meaning and are discarded.
1174
+ * - Absolute globs will only match absolute paths, etc.
1175
+ * - Empty globs will match nothing.
1176
+ * - Any special glob syntax must be contained to one path segment. For example,
1177
+ * `?(foo|bar/baz)` is invalid. The separator will take precedence and the
1178
+ * first segment ends with an unclosed group.
1179
+ * - If a path segment ends with unclosed groups or a dangling escape prefix, a
1180
+ * parse error has occurred. Every character for that segment is taken
1181
+ * literally in this event.
1182
+ *
1183
+ * Limitations:
1184
+ * - A negative group like `!(foo|bar)` will wrongly be converted to a negative
1185
+ * look-ahead followed by a wildcard. This means that `!(foo).js` will wrongly
1186
+ * fail to match `foobar.js`, even though `foobar` is not `foo`. Effectively,
1187
+ * `!(foo|bar)` is treated like `!(@(foo|bar)*)`. This will work correctly if
1188
+ * the group occurs not nested at the end of the segment.
1189
+ *
1190
+ * @example Usage
1191
+ * ```ts
1192
+ * import { globToRegExp } from "@std/path/posix/glob-to-regexp";
1193
+ * import { assertEquals } from "@std/assert";
1194
+ *
1195
+ * assertEquals(globToRegExp("*.js"), /^[^/]*\.js\/*$/);
1196
+ * ```
1197
+ *
1198
+ * @param glob Glob string to convert.
1199
+ * @param options Conversion options.
1200
+ * @returns The regular expression equivalent to the glob.
1201
+ */ function globToRegExp(glob, options = {}) {
1202
+ return _globToRegExp(constants, glob, options);
1203
+ }
1204
+
1205
+ // Copyright 2018-2025 the Deno authors. MIT license.
1206
+ // This module is browser compatible.
1207
+ /**
1208
+ * Test whether the given string is a glob.
1209
+ *
1210
+ * @example Usage
1211
+ * ```ts
1212
+ * import { isGlob } from "@std/path/is-glob";
1213
+ * import { assert } from "@std/assert";
1214
+ *
1215
+ * assert(!isGlob("foo/bar/../baz"));
1216
+ * assert(isGlob("foo/*ar/../baz"));
1217
+ * ```
1218
+ *
1219
+ * @param str String to test.
1220
+ * @returns `true` if the given string is a glob, otherwise `false`
1221
+ */ function isGlob(str) {
1222
+ const chars = {
1223
+ "{": "}",
1224
+ "(": ")",
1225
+ "[": "]"
1226
+ };
1227
+ const regex = /\\(.)|(^!|\*|\?|[\].+)]\?|\[[^[\\\]]+\]|\{[^{\\}]+\}|\(\?[:!=][^\\)]+\)|\([^(|]+\|[^\\)]+\)|@\([^)]+\))/;
1228
+ if (str === "") {
1229
+ return false;
1230
+ }
1231
+ let match;
1232
+ while(match = regex.exec(str)){
1233
+ if (match[2]) return true;
1234
+ let idx = match.index + match[0].length;
1235
+ // if an open bracket/brace/paren is escaped,
1236
+ // set the index to the next closing character
1237
+ const open = match[1];
1238
+ const close = open ? chars[open] : null;
1239
+ if (open && close) {
1240
+ const n = str.indexOf(close, idx);
1241
+ if (n !== -1) {
1242
+ idx = n + 1;
1243
+ }
1244
+ }
1245
+ str = str.slice(idx);
1246
+ }
1247
+ return false;
1248
+ }
1249
+
1250
+ // Copyright 2018-2025 the Deno authors. MIT license.
1251
+ // This module is browser compatible.
1252
+ /**
1253
+ * Like normalize(), but doesn't collapse "**\/.." when `globstar` is true.
1254
+ *
1255
+ * @example Usage
1256
+ * ```ts
1257
+ * import { normalizeGlob } from "@std/path/posix/normalize-glob";
1258
+ * import { assertEquals } from "@std/assert";
1259
+ *
1260
+ * const path = normalizeGlob("foo/bar/../*", { globstar: true });
1261
+ * assertEquals(path, "foo/*");
1262
+ * ```
1263
+ *
1264
+ * @param glob The glob to normalize.
1265
+ * @param options The options to use.
1266
+ * @returns The normalized path.
1267
+ */ function normalizeGlob(glob, options = {}) {
1268
+ const { globstar = false } = options;
1269
+ if (glob.match(/\0/g)) {
1270
+ throw new Error(`Glob contains invalid characters: "${glob}"`);
1271
+ }
1272
+ if (!globstar) {
1273
+ return normalize(glob);
1274
+ }
1275
+ const s = SEPARATOR_PATTERN.source;
1276
+ const badParentPattern = new RegExp(`(?<=(${s}|^)\\*\\*${s})\\.\\.(?=${s}|$)`, "g");
1277
+ return normalize(glob.replace(badParentPattern, "\0")).replace(/\0/g, "..");
1278
+ }
1279
+
1280
+ // Copyright 2018-2025 the Deno authors. MIT license.
1281
+ // This module is browser compatible.
1282
+ /**
1283
+ * Like join(), but doesn't collapse "**\/.." when `globstar` is true.
1284
+ *
1285
+ * @example Usage
1286
+ * ```ts
1287
+ * import { joinGlobs } from "@std/path/posix/join-globs";
1288
+ * import { assertEquals } from "@std/assert";
1289
+ *
1290
+ * const path = joinGlobs(["foo", "bar", "**"], { globstar: true });
1291
+ * assertEquals(path, "foo/bar/**");
1292
+ * ```
1293
+ *
1294
+ * @param globs The globs to join.
1295
+ * @param options The options to use.
1296
+ * @returns The joined path.
1297
+ */ function joinGlobs(globs, options = {}) {
1298
+ const { globstar = false } = options;
1299
+ if (!globstar || globs.length === 0) {
1300
+ return join(...globs);
1301
+ }
1302
+ let joined;
1303
+ for (const glob of globs){
1304
+ const path = glob;
1305
+ if (path.length > 0) {
1306
+ if (!joined) joined = path;
1307
+ else joined += `${SEPARATOR}${path}`;
1308
+ }
1309
+ }
1310
+ if (!joined) return ".";
1311
+ return normalizeGlob(joined, {
1312
+ globstar
1313
+ });
1314
+ }
1315
+
1316
+ exports.DELIMITER = DELIMITER;
1317
+ exports.SEPARATOR = SEPARATOR;
1318
+ exports.SEPARATOR_PATTERN = SEPARATOR_PATTERN;
1319
+ exports.basename = basename;
1320
+ exports.common = common;
1321
+ exports.dirname = dirname;
1322
+ exports.extname = extname;
1323
+ exports.format = format;
1324
+ exports.fromFileUrl = fromFileUrl;
1325
+ exports.globToRegExp = globToRegExp;
1326
+ exports.isAbsolute = isAbsolute;
1327
+ exports.isGlob = isGlob;
1328
+ exports.join = join;
1329
+ exports.joinGlobs = joinGlobs;
1330
+ exports.normalize = normalize;
1331
+ exports.normalizeGlob = normalizeGlob;
1332
+ exports.parse = parse;
1333
+ exports.relative = relative;
1334
+ exports.resolve = resolve;
1335
+ exports.toFileUrl = toFileUrl;
1336
+ exports.toNamespacedPath = toNamespacedPath;
server/node_modules/@eslint/config-array/dist/cjs/std__path/windows.cjs ADDED
@@ -0,0 +1,1678 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-nocheck
2
+ 'use strict';
3
+
4
+ // Copyright 2018-2025 the Deno authors. MIT license.
5
+ // Copyright the Browserify authors. MIT License.
6
+ function assertPath(path) {
7
+ if (typeof path !== "string") {
8
+ throw new TypeError(`Path must be a string, received "${JSON.stringify(path)}"`);
9
+ }
10
+ }
11
+
12
+ // Copyright 2018-2025 the Deno authors. MIT license.
13
+ // This module is browser compatible.
14
+ function stripSuffix(name, suffix) {
15
+ if (suffix.length >= name.length) {
16
+ return name;
17
+ }
18
+ const lenDiff = name.length - suffix.length;
19
+ for(let i = suffix.length - 1; i >= 0; --i){
20
+ if (name.charCodeAt(lenDiff + i) !== suffix.charCodeAt(i)) {
21
+ return name;
22
+ }
23
+ }
24
+ return name.slice(0, -suffix.length);
25
+ }
26
+ function lastPathSegment(path, isSep, start = 0) {
27
+ let matchedNonSeparator = false;
28
+ let end = path.length;
29
+ for(let i = path.length - 1; i >= start; --i){
30
+ if (isSep(path.charCodeAt(i))) {
31
+ if (matchedNonSeparator) {
32
+ start = i + 1;
33
+ break;
34
+ }
35
+ } else if (!matchedNonSeparator) {
36
+ matchedNonSeparator = true;
37
+ end = i + 1;
38
+ }
39
+ }
40
+ return path.slice(start, end);
41
+ }
42
+ function assertArgs$1(path, suffix) {
43
+ assertPath(path);
44
+ if (path.length === 0) return path;
45
+ if (typeof suffix !== "string") {
46
+ throw new TypeError(`Suffix must be a string, received "${JSON.stringify(suffix)}"`);
47
+ }
48
+ }
49
+
50
+ // Copyright 2018-2025 the Deno authors. MIT license.
51
+ // Copyright the Browserify authors. MIT License.
52
+ // Ported from https://github.com/browserify/path-browserify/
53
+ // This module is browser compatible.
54
+ // Alphabet chars.
55
+ const CHAR_UPPERCASE_A = 65; /* A */
56
+ const CHAR_LOWERCASE_A = 97; /* a */
57
+ const CHAR_UPPERCASE_Z = 90; /* Z */
58
+ const CHAR_LOWERCASE_Z = 122; /* z */
59
+ // Non-alphabetic chars.
60
+ const CHAR_DOT = 46; /* . */
61
+ const CHAR_FORWARD_SLASH = 47; /* / */
62
+ const CHAR_BACKWARD_SLASH = 92; /* \ */
63
+ const CHAR_COLON = 58; /* : */
64
+ const CHAR_QUESTION_MARK = 63; /* ? */
65
+
66
+ // Copyright 2018-2025 the Deno authors. MIT license.
67
+ // Copyright the Browserify authors. MIT License.
68
+ // Ported from https://github.com/browserify/path-browserify/
69
+ // This module is browser compatible.
70
+ function stripTrailingSeparators(segment, isSep) {
71
+ if (segment.length <= 1) {
72
+ return segment;
73
+ }
74
+ let end = segment.length;
75
+ for(let i = segment.length - 1; i > 0; i--){
76
+ if (isSep(segment.charCodeAt(i))) {
77
+ end = i;
78
+ } else {
79
+ break;
80
+ }
81
+ }
82
+ return segment.slice(0, end);
83
+ }
84
+
85
+ // Copyright 2018-2025 the Deno authors. MIT license.
86
+ // Copyright the Browserify authors. MIT License.
87
+ // Ported from https://github.com/browserify/path-browserify/
88
+ // This module is browser compatible.
89
+ function isPosixPathSeparator(code) {
90
+ return code === CHAR_FORWARD_SLASH;
91
+ }
92
+ function isPathSeparator(code) {
93
+ return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
94
+ }
95
+ function isWindowsDeviceRoot(code) {
96
+ return code >= CHAR_LOWERCASE_A && code <= CHAR_LOWERCASE_Z || code >= CHAR_UPPERCASE_A && code <= CHAR_UPPERCASE_Z;
97
+ }
98
+
99
+ // Copyright 2018-2025 the Deno authors. MIT license.
100
+ // This module is browser compatible.
101
+ function assertArg$3(url) {
102
+ url = url instanceof URL ? url : new URL(url);
103
+ if (url.protocol !== "file:") {
104
+ throw new TypeError(`URL must be a file URL: received "${url.protocol}"`);
105
+ }
106
+ return url;
107
+ }
108
+
109
+ // Copyright 2018-2025 the Deno authors. MIT license.
110
+ // This module is browser compatible.
111
+ /**
112
+ * Converts a file URL to a path string.
113
+ *
114
+ * @example Usage
115
+ * ```ts
116
+ * import { fromFileUrl } from "@std/path/windows/from-file-url";
117
+ * import { assertEquals } from "@std/assert";
118
+ *
119
+ * assertEquals(fromFileUrl("file:///home/foo"), "\\home\\foo");
120
+ * assertEquals(fromFileUrl("file:///C:/Users/foo"), "C:\\Users\\foo");
121
+ * assertEquals(fromFileUrl("file://localhost/home/foo"), "\\home\\foo");
122
+ * ```
123
+ *
124
+ * @param url The file URL to convert.
125
+ * @returns The path string.
126
+ */ function fromFileUrl(url) {
127
+ url = assertArg$3(url);
128
+ let path = decodeURIComponent(url.pathname.replace(/\//g, "\\").replace(/%(?![0-9A-Fa-f]{2})/g, "%25")).replace(/^\\*([A-Za-z]:)(\\|$)/, "$1\\");
129
+ if (url.hostname !== "") {
130
+ // Note: The `URL` implementation guarantees that the drive letter and
131
+ // hostname are mutually exclusive. Otherwise it would not have been valid
132
+ // to append the hostname and path like this.
133
+ path = `\\\\${url.hostname}${path}`;
134
+ }
135
+ return path;
136
+ }
137
+
138
+ // Copyright 2018-2025 the Deno authors. MIT license.
139
+ // This module is browser compatible.
140
+ /**
141
+ * Return the last portion of a `path`.
142
+ * Trailing directory separators are ignored, and optional suffix is removed.
143
+ *
144
+ * @example Usage
145
+ * ```ts
146
+ * import { basename } from "@std/path/windows/basename";
147
+ * import { assertEquals } from "@std/assert";
148
+ *
149
+ * assertEquals(basename("C:\\user\\Documents\\"), "Documents");
150
+ * assertEquals(basename("C:\\user\\Documents\\image.png"), "image.png");
151
+ * assertEquals(basename("C:\\user\\Documents\\image.png", ".png"), "image");
152
+ * assertEquals(basename(new URL("file:///C:/user/Documents/image.png")), "image.png");
153
+ * assertEquals(basename(new URL("file:///C:/user/Documents/image.png"), ".png"), "image");
154
+ * ```
155
+ *
156
+ * @param path The path to extract the name from.
157
+ * @param suffix The suffix to remove from extracted name.
158
+ * @returns The extracted name.
159
+ */ function basename(path, suffix = "") {
160
+ if (path instanceof URL) {
161
+ path = fromFileUrl(path);
162
+ }
163
+ assertArgs$1(path, suffix);
164
+ // Check for a drive letter prefix so as not to mistake the following
165
+ // path separator as an extra separator at the end of the path that can be
166
+ // disregarded
167
+ let start = 0;
168
+ if (path.length >= 2) {
169
+ const drive = path.charCodeAt(0);
170
+ if (isWindowsDeviceRoot(drive)) {
171
+ if (path.charCodeAt(1) === CHAR_COLON) start = 2;
172
+ }
173
+ }
174
+ const lastSegment = lastPathSegment(path, isPathSeparator, start);
175
+ const strippedSegment = stripTrailingSeparators(lastSegment, isPathSeparator);
176
+ return suffix ? stripSuffix(strippedSegment, suffix) : strippedSegment;
177
+ }
178
+
179
+ // Copyright 2018-2025 the Deno authors. MIT license.
180
+ // This module is browser compatible.
181
+ /**
182
+ * The character used to separate entries in the PATH environment variable.
183
+ */ const DELIMITER = ";";
184
+ /**
185
+ * The character used to separate components of a file path.
186
+ */ const SEPARATOR = "\\";
187
+ /**
188
+ * A regular expression that matches one or more path separators.
189
+ */ const SEPARATOR_PATTERN = /[\\/]+/;
190
+
191
+ // Copyright 2018-2025 the Deno authors. MIT license.
192
+ // This module is browser compatible.
193
+ function assertArg$2(path) {
194
+ assertPath(path);
195
+ if (path.length === 0) return ".";
196
+ }
197
+
198
+ // Copyright 2018-2025 the Deno authors. MIT license.
199
+ // This module is browser compatible.
200
+ /**
201
+ * Return the directory path of a `path`.
202
+ *
203
+ * @example Usage
204
+ * ```ts
205
+ * import { dirname } from "@std/path/windows/dirname";
206
+ * import { assertEquals } from "@std/assert";
207
+ *
208
+ * assertEquals(dirname("C:\\foo\\bar\\baz.ext"), "C:\\foo\\bar");
209
+ * assertEquals(dirname(new URL("file:///C:/foo/bar/baz.ext")), "C:\\foo\\bar");
210
+ * ```
211
+ *
212
+ * @param path The path to get the directory from.
213
+ * @returns The directory path.
214
+ */ function dirname(path) {
215
+ if (path instanceof URL) {
216
+ path = fromFileUrl(path);
217
+ }
218
+ assertArg$2(path);
219
+ const len = path.length;
220
+ let rootEnd = -1;
221
+ let end = -1;
222
+ let matchedSlash = true;
223
+ let offset = 0;
224
+ const code = path.charCodeAt(0);
225
+ // Try to match a root
226
+ if (len > 1) {
227
+ if (isPathSeparator(code)) {
228
+ // Possible UNC root
229
+ rootEnd = offset = 1;
230
+ if (isPathSeparator(path.charCodeAt(1))) {
231
+ // Matched double path separator at beginning
232
+ let j = 2;
233
+ let last = j;
234
+ // Match 1 or more non-path separators
235
+ for(; j < len; ++j){
236
+ if (isPathSeparator(path.charCodeAt(j))) break;
237
+ }
238
+ if (j < len && j !== last) {
239
+ // Matched!
240
+ last = j;
241
+ // Match 1 or more path separators
242
+ for(; j < len; ++j){
243
+ if (!isPathSeparator(path.charCodeAt(j))) break;
244
+ }
245
+ if (j < len && j !== last) {
246
+ // Matched!
247
+ last = j;
248
+ // Match 1 or more non-path separators
249
+ for(; j < len; ++j){
250
+ if (isPathSeparator(path.charCodeAt(j))) break;
251
+ }
252
+ if (j === len) {
253
+ // We matched a UNC root only
254
+ return path;
255
+ }
256
+ if (j !== last) {
257
+ // We matched a UNC root with leftovers
258
+ // Offset by 1 to include the separator after the UNC root to
259
+ // treat it as a "normal root" on top of a (UNC) root
260
+ rootEnd = offset = j + 1;
261
+ }
262
+ }
263
+ }
264
+ }
265
+ } else if (isWindowsDeviceRoot(code)) {
266
+ // Possible device root
267
+ if (path.charCodeAt(1) === CHAR_COLON) {
268
+ rootEnd = offset = 2;
269
+ if (len > 2) {
270
+ if (isPathSeparator(path.charCodeAt(2))) rootEnd = offset = 3;
271
+ }
272
+ }
273
+ }
274
+ } else if (isPathSeparator(code)) {
275
+ // `path` contains just a path separator, exit early to avoid
276
+ // unnecessary work
277
+ return path;
278
+ }
279
+ for(let i = len - 1; i >= offset; --i){
280
+ if (isPathSeparator(path.charCodeAt(i))) {
281
+ if (!matchedSlash) {
282
+ end = i;
283
+ break;
284
+ }
285
+ } else {
286
+ // We saw the first non-path separator
287
+ matchedSlash = false;
288
+ }
289
+ }
290
+ if (end === -1) {
291
+ if (rootEnd === -1) return ".";
292
+ else end = rootEnd;
293
+ }
294
+ return stripTrailingSeparators(path.slice(0, end), isPosixPathSeparator);
295
+ }
296
+
297
+ // Copyright 2018-2025 the Deno authors. MIT license.
298
+ // This module is browser compatible.
299
+ /**
300
+ * Return the extension of the `path` with leading period.
301
+ *
302
+ * @example Usage
303
+ * ```ts
304
+ * import { extname } from "@std/path/windows/extname";
305
+ * import { assertEquals } from "@std/assert";
306
+ *
307
+ * assertEquals(extname("file.ts"), ".ts");
308
+ * assertEquals(extname(new URL("file:///C:/foo/bar/baz.ext")), ".ext");
309
+ * ```
310
+ *
311
+ * @param path The path to get the extension from.
312
+ * @returns The extension of the `path`.
313
+ */ function extname(path) {
314
+ if (path instanceof URL) {
315
+ path = fromFileUrl(path);
316
+ }
317
+ assertPath(path);
318
+ let start = 0;
319
+ let startDot = -1;
320
+ let startPart = 0;
321
+ let end = -1;
322
+ let matchedSlash = true;
323
+ // Track the state of characters (if any) we see before our first dot and
324
+ // after any path separator we find
325
+ let preDotState = 0;
326
+ // Check for a drive letter prefix so as not to mistake the following
327
+ // path separator as an extra separator at the end of the path that can be
328
+ // disregarded
329
+ if (path.length >= 2 && path.charCodeAt(1) === CHAR_COLON && isWindowsDeviceRoot(path.charCodeAt(0))) {
330
+ start = startPart = 2;
331
+ }
332
+ for(let i = path.length - 1; i >= start; --i){
333
+ const code = path.charCodeAt(i);
334
+ if (isPathSeparator(code)) {
335
+ // If we reached a path separator that was not part of a set of path
336
+ // separators at the end of the string, stop now
337
+ if (!matchedSlash) {
338
+ startPart = i + 1;
339
+ break;
340
+ }
341
+ continue;
342
+ }
343
+ if (end === -1) {
344
+ // We saw the first non-path separator, mark this as the end of our
345
+ // extension
346
+ matchedSlash = false;
347
+ end = i + 1;
348
+ }
349
+ if (code === CHAR_DOT) {
350
+ // If this is our first dot, mark it as the start of our extension
351
+ if (startDot === -1) startDot = i;
352
+ else if (preDotState !== 1) preDotState = 1;
353
+ } else if (startDot !== -1) {
354
+ // We saw a non-dot and non-path separator before our dot, so we should
355
+ // have a good chance at having a non-empty extension
356
+ preDotState = -1;
357
+ }
358
+ }
359
+ if (startDot === -1 || end === -1 || // We saw a non-dot character immediately before the dot
360
+ preDotState === 0 || // The (right-most) trimmed path component is exactly '..'
361
+ preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
362
+ return "";
363
+ }
364
+ return path.slice(startDot, end);
365
+ }
366
+
367
+ // Copyright 2018-2025 the Deno authors. MIT license.
368
+ // This module is browser compatible.
369
+ function _format(sep, pathObject) {
370
+ const dir = pathObject.dir || pathObject.root;
371
+ const base = pathObject.base || (pathObject.name ?? "") + (pathObject.ext ?? "");
372
+ if (!dir) return base;
373
+ if (base === sep) return dir;
374
+ if (dir === pathObject.root) return dir + base;
375
+ return dir + sep + base;
376
+ }
377
+ function assertArg$1(pathObject) {
378
+ if (pathObject === null || typeof pathObject !== "object") {
379
+ throw new TypeError(`The "pathObject" argument must be of type Object, received type "${typeof pathObject}"`);
380
+ }
381
+ }
382
+
383
+ // Copyright 2018-2025 the Deno authors. MIT license.
384
+ // This module is browser compatible.
385
+ /**
386
+ * Generate a path from `ParsedPath` object.
387
+ *
388
+ * @example Usage
389
+ * ```ts
390
+ * import { format } from "@std/path/windows/format";
391
+ * import { assertEquals } from "@std/assert";
392
+ *
393
+ * const path = format({
394
+ * root: "C:\\",
395
+ * dir: "C:\\path\\dir",
396
+ * base: "file.txt",
397
+ * ext: ".txt",
398
+ * name: "file"
399
+ * });
400
+ * assertEquals(path, "C:\\path\\dir\\file.txt");
401
+ * ```
402
+ *
403
+ * @param pathObject The path object to format.
404
+ * @returns The formatted path.
405
+ */ function format(pathObject) {
406
+ assertArg$1(pathObject);
407
+ return _format("\\", pathObject);
408
+ }
409
+
410
+ // Copyright 2018-2025 the Deno authors. MIT license.
411
+ // This module is browser compatible.
412
+ /**
413
+ * Verifies whether provided path is absolute.
414
+ *
415
+ * @example Usage
416
+ * ```ts
417
+ * import { isAbsolute } from "@std/path/windows/is-absolute";
418
+ * import { assert, assertFalse } from "@std/assert";
419
+ *
420
+ * assert(isAbsolute("C:\\foo\\bar"));
421
+ * assertFalse(isAbsolute("..\\baz"));
422
+ * ```
423
+ *
424
+ * @param path The path to verify.
425
+ * @returns `true` if the path is absolute, `false` otherwise.
426
+ */ function isAbsolute(path) {
427
+ assertPath(path);
428
+ const len = path.length;
429
+ if (len === 0) return false;
430
+ const code = path.charCodeAt(0);
431
+ if (isPathSeparator(code)) {
432
+ return true;
433
+ } else if (isWindowsDeviceRoot(code)) {
434
+ // Possible device root
435
+ if (len > 2 && path.charCodeAt(1) === CHAR_COLON) {
436
+ if (isPathSeparator(path.charCodeAt(2))) return true;
437
+ }
438
+ }
439
+ return false;
440
+ }
441
+
442
+ // Copyright 2018-2025 the Deno authors. MIT license.
443
+ // This module is browser compatible.
444
+ function assertArg(path) {
445
+ assertPath(path);
446
+ if (path.length === 0) return ".";
447
+ }
448
+
449
+ // Copyright 2018-2025 the Deno authors. MIT license.
450
+ // Copyright the Browserify authors. MIT License.
451
+ // Ported from https://github.com/browserify/path-browserify/
452
+ // This module is browser compatible.
453
+ // Resolves . and .. elements in a path with directory names
454
+ function normalizeString(path, allowAboveRoot, separator, isPathSeparator) {
455
+ let res = "";
456
+ let lastSegmentLength = 0;
457
+ let lastSlash = -1;
458
+ let dots = 0;
459
+ let code;
460
+ for(let i = 0; i <= path.length; ++i){
461
+ if (i < path.length) code = path.charCodeAt(i);
462
+ else if (isPathSeparator(code)) break;
463
+ else code = CHAR_FORWARD_SLASH;
464
+ if (isPathSeparator(code)) {
465
+ if (lastSlash === i - 1 || dots === 1) ; else if (lastSlash !== i - 1 && dots === 2) {
466
+ if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== CHAR_DOT || res.charCodeAt(res.length - 2) !== CHAR_DOT) {
467
+ if (res.length > 2) {
468
+ const lastSlashIndex = res.lastIndexOf(separator);
469
+ if (lastSlashIndex === -1) {
470
+ res = "";
471
+ lastSegmentLength = 0;
472
+ } else {
473
+ res = res.slice(0, lastSlashIndex);
474
+ lastSegmentLength = res.length - 1 - res.lastIndexOf(separator);
475
+ }
476
+ lastSlash = i;
477
+ dots = 0;
478
+ continue;
479
+ } else if (res.length === 2 || res.length === 1) {
480
+ res = "";
481
+ lastSegmentLength = 0;
482
+ lastSlash = i;
483
+ dots = 0;
484
+ continue;
485
+ }
486
+ }
487
+ if (allowAboveRoot) {
488
+ if (res.length > 0) res += `${separator}..`;
489
+ else res = "..";
490
+ lastSegmentLength = 2;
491
+ }
492
+ } else {
493
+ if (res.length > 0) res += separator + path.slice(lastSlash + 1, i);
494
+ else res = path.slice(lastSlash + 1, i);
495
+ lastSegmentLength = i - lastSlash - 1;
496
+ }
497
+ lastSlash = i;
498
+ dots = 0;
499
+ } else if (code === CHAR_DOT && dots !== -1) {
500
+ ++dots;
501
+ } else {
502
+ dots = -1;
503
+ }
504
+ }
505
+ return res;
506
+ }
507
+
508
+ // Copyright 2018-2025 the Deno authors. MIT license.
509
+ // This module is browser compatible.
510
+ /**
511
+ * Normalize the `path`, resolving `'..'` and `'.'` segments.
512
+ * Note that resolving these segments does not necessarily mean that all will be eliminated.
513
+ * A `'..'` at the top-level will be preserved, and an empty path is canonically `'.'`.
514
+ *
515
+ * @example Usage
516
+ * ```ts
517
+ * import { normalize } from "@std/path/windows/normalize";
518
+ * import { assertEquals } from "@std/assert";
519
+ *
520
+ * assertEquals(normalize("C:\\foo\\..\\bar"), "C:\\bar");
521
+ * assertEquals(normalize(new URL("file:///C:/foo/../bar")), "C:\\bar");
522
+ * ```
523
+ *
524
+ * @param path The path to normalize
525
+ * @returns The normalized path
526
+ */ function normalize(path) {
527
+ if (path instanceof URL) {
528
+ path = fromFileUrl(path);
529
+ }
530
+ assertArg(path);
531
+ const len = path.length;
532
+ let rootEnd = 0;
533
+ let device;
534
+ let isAbsolute = false;
535
+ const code = path.charCodeAt(0);
536
+ // Try to match a root
537
+ if (len > 1) {
538
+ if (isPathSeparator(code)) {
539
+ // Possible UNC root
540
+ // If we started with a separator, we know we at least have an absolute
541
+ // path of some kind (UNC or otherwise)
542
+ isAbsolute = true;
543
+ if (isPathSeparator(path.charCodeAt(1))) {
544
+ // Matched double path separator at beginning
545
+ let j = 2;
546
+ let last = j;
547
+ // Match 1 or more non-path separators
548
+ for(; j < len; ++j){
549
+ if (isPathSeparator(path.charCodeAt(j))) break;
550
+ }
551
+ if (j < len && j !== last) {
552
+ const firstPart = path.slice(last, j);
553
+ // Matched!
554
+ last = j;
555
+ // Match 1 or more path separators
556
+ for(; j < len; ++j){
557
+ if (!isPathSeparator(path.charCodeAt(j))) break;
558
+ }
559
+ if (j < len && j !== last) {
560
+ // Matched!
561
+ last = j;
562
+ // Match 1 or more non-path separators
563
+ for(; j < len; ++j){
564
+ if (isPathSeparator(path.charCodeAt(j))) break;
565
+ }
566
+ if (j === len) {
567
+ // We matched a UNC root only
568
+ // Return the normalized version of the UNC root since there
569
+ // is nothing left to process
570
+ return `\\\\${firstPart}\\${path.slice(last)}\\`;
571
+ } else if (j !== last) {
572
+ // We matched a UNC root with leftovers
573
+ device = `\\\\${firstPart}\\${path.slice(last, j)}`;
574
+ rootEnd = j;
575
+ }
576
+ }
577
+ }
578
+ } else {
579
+ rootEnd = 1;
580
+ }
581
+ } else if (isWindowsDeviceRoot(code)) {
582
+ // Possible device root
583
+ if (path.charCodeAt(1) === CHAR_COLON) {
584
+ device = path.slice(0, 2);
585
+ rootEnd = 2;
586
+ if (len > 2) {
587
+ if (isPathSeparator(path.charCodeAt(2))) {
588
+ // Treat separator following drive name as an absolute path
589
+ // indicator
590
+ isAbsolute = true;
591
+ rootEnd = 3;
592
+ }
593
+ }
594
+ }
595
+ }
596
+ } else if (isPathSeparator(code)) {
597
+ // `path` contains just a path separator, exit early to avoid unnecessary
598
+ // work
599
+ return "\\";
600
+ }
601
+ let tail;
602
+ if (rootEnd < len) {
603
+ tail = normalizeString(path.slice(rootEnd), !isAbsolute, "\\", isPathSeparator);
604
+ } else {
605
+ tail = "";
606
+ }
607
+ if (tail.length === 0 && !isAbsolute) tail = ".";
608
+ if (tail.length > 0 && isPathSeparator(path.charCodeAt(len - 1))) {
609
+ tail += "\\";
610
+ }
611
+ if (device === undefined) {
612
+ if (isAbsolute) {
613
+ if (tail.length > 0) return `\\${tail}`;
614
+ else return "\\";
615
+ }
616
+ return tail;
617
+ } else if (isAbsolute) {
618
+ if (tail.length > 0) return `${device}\\${tail}`;
619
+ else return `${device}\\`;
620
+ }
621
+ return device + tail;
622
+ }
623
+
624
+ // Copyright 2018-2025 the Deno authors. MIT license.
625
+ // This module is browser compatible.
626
+ /**
627
+ * Join all given a sequence of `paths`,then normalizes the resulting path.
628
+ *
629
+ * @example Usage
630
+ * ```ts
631
+ * import { join } from "@std/path/windows/join";
632
+ * import { assertEquals } from "@std/assert";
633
+ *
634
+ * assertEquals(join("C:\\foo", "bar", "baz\\.."), "C:\\foo\\bar");
635
+ * assertEquals(join(new URL("file:///C:/foo"), "bar", "baz\\.."), "C:\\foo\\bar");
636
+ * ```
637
+ *
638
+ * @param path The path to join. This can be string or file URL.
639
+ * @param paths The paths to join.
640
+ * @returns The joined path.
641
+ */ function join(path, ...paths) {
642
+ if (path instanceof URL) {
643
+ path = fromFileUrl(path);
644
+ }
645
+ paths = path ? [
646
+ path,
647
+ ...paths
648
+ ] : paths;
649
+ paths.forEach((path)=>assertPath(path));
650
+ paths = paths.filter((path)=>path.length > 0);
651
+ if (paths.length === 0) return ".";
652
+ // Make sure that the joined path doesn't start with two slashes, because
653
+ // normalize() will mistake it for an UNC path then.
654
+ //
655
+ // This step is skipped when it is very clear that the user actually
656
+ // intended to point at an UNC path. This is assumed when the first
657
+ // non-empty string arguments starts with exactly two slashes followed by
658
+ // at least one more non-slash character.
659
+ //
660
+ // Note that for normalize() to treat a path as an UNC path it needs to
661
+ // have at least 2 components, so we don't filter for that here.
662
+ // This means that the user can use join to construct UNC paths from
663
+ // a server name and a share name; for example:
664
+ // path.join('//server', 'share') -> '\\\\server\\share\\'
665
+ let needsReplace = true;
666
+ let slashCount = 0;
667
+ const firstPart = paths[0];
668
+ if (isPathSeparator(firstPart.charCodeAt(0))) {
669
+ ++slashCount;
670
+ const firstLen = firstPart.length;
671
+ if (firstLen > 1) {
672
+ if (isPathSeparator(firstPart.charCodeAt(1))) {
673
+ ++slashCount;
674
+ if (firstLen > 2) {
675
+ if (isPathSeparator(firstPart.charCodeAt(2))) ++slashCount;
676
+ else {
677
+ // We matched a UNC path in the first part
678
+ needsReplace = false;
679
+ }
680
+ }
681
+ }
682
+ }
683
+ }
684
+ let joined = paths.join("\\");
685
+ if (needsReplace) {
686
+ // Find any more consecutive slashes we need to replace
687
+ for(; slashCount < joined.length; ++slashCount){
688
+ if (!isPathSeparator(joined.charCodeAt(slashCount))) break;
689
+ }
690
+ // Replace the slashes if needed
691
+ if (slashCount >= 2) joined = `\\${joined.slice(slashCount)}`;
692
+ }
693
+ return normalize(joined);
694
+ }
695
+
696
+ // Copyright 2018-2025 the Deno authors. MIT license.
697
+ // This module is browser compatible.
698
+ /**
699
+ * Return a `ParsedPath` object of the `path`.
700
+ *
701
+ * @example Usage
702
+ * ```ts
703
+ * import { parse } from "@std/path/windows/parse";
704
+ * import { assertEquals } from "@std/assert";
705
+ *
706
+ * const parsed = parse("C:\\foo\\bar\\baz.ext");
707
+ * assertEquals(parsed, {
708
+ * root: "C:\\",
709
+ * dir: "C:\\foo\\bar",
710
+ * base: "baz.ext",
711
+ * ext: ".ext",
712
+ * name: "baz",
713
+ * });
714
+ * ```
715
+ *
716
+ * @param path The path to parse.
717
+ * @returns The `ParsedPath` object.
718
+ */ function parse(path) {
719
+ assertPath(path);
720
+ const ret = {
721
+ root: "",
722
+ dir: "",
723
+ base: "",
724
+ ext: "",
725
+ name: ""
726
+ };
727
+ const len = path.length;
728
+ if (len === 0) return ret;
729
+ let rootEnd = 0;
730
+ let code = path.charCodeAt(0);
731
+ // Try to match a root
732
+ if (len > 1) {
733
+ if (isPathSeparator(code)) {
734
+ // Possible UNC root
735
+ rootEnd = 1;
736
+ if (isPathSeparator(path.charCodeAt(1))) {
737
+ // Matched double path separator at beginning
738
+ let j = 2;
739
+ let last = j;
740
+ // Match 1 or more non-path separators
741
+ for(; j < len; ++j){
742
+ if (isPathSeparator(path.charCodeAt(j))) break;
743
+ }
744
+ if (j < len && j !== last) {
745
+ // Matched!
746
+ last = j;
747
+ // Match 1 or more path separators
748
+ for(; j < len; ++j){
749
+ if (!isPathSeparator(path.charCodeAt(j))) break;
750
+ }
751
+ if (j < len && j !== last) {
752
+ // Matched!
753
+ last = j;
754
+ // Match 1 or more non-path separators
755
+ for(; j < len; ++j){
756
+ if (isPathSeparator(path.charCodeAt(j))) break;
757
+ }
758
+ if (j === len) {
759
+ // We matched a UNC root only
760
+ rootEnd = j;
761
+ } else if (j !== last) {
762
+ // We matched a UNC root with leftovers
763
+ rootEnd = j + 1;
764
+ }
765
+ }
766
+ }
767
+ }
768
+ } else if (isWindowsDeviceRoot(code)) {
769
+ // Possible device root
770
+ if (path.charCodeAt(1) === CHAR_COLON) {
771
+ rootEnd = 2;
772
+ if (len > 2) {
773
+ if (isPathSeparator(path.charCodeAt(2))) {
774
+ if (len === 3) {
775
+ // `path` contains just a drive root, exit early to avoid
776
+ // unnecessary work
777
+ ret.root = ret.dir = path;
778
+ ret.base = "\\";
779
+ return ret;
780
+ }
781
+ rootEnd = 3;
782
+ }
783
+ } else {
784
+ // `path` contains just a relative drive root, exit early to avoid
785
+ // unnecessary work
786
+ ret.root = ret.dir = path;
787
+ return ret;
788
+ }
789
+ }
790
+ }
791
+ } else if (isPathSeparator(code)) {
792
+ // `path` contains just a path separator, exit early to avoid
793
+ // unnecessary work
794
+ ret.root = ret.dir = path;
795
+ ret.base = "\\";
796
+ return ret;
797
+ }
798
+ if (rootEnd > 0) ret.root = path.slice(0, rootEnd);
799
+ let startDot = -1;
800
+ let startPart = rootEnd;
801
+ let end = -1;
802
+ let matchedSlash = true;
803
+ let i = path.length - 1;
804
+ // Track the state of characters (if any) we see before our first dot and
805
+ // after any path separator we find
806
+ let preDotState = 0;
807
+ // Get non-dir info
808
+ for(; i >= rootEnd; --i){
809
+ code = path.charCodeAt(i);
810
+ if (isPathSeparator(code)) {
811
+ // If we reached a path separator that was not part of a set of path
812
+ // separators at the end of the string, stop now
813
+ if (!matchedSlash) {
814
+ startPart = i + 1;
815
+ break;
816
+ }
817
+ continue;
818
+ }
819
+ if (end === -1) {
820
+ // We saw the first non-path separator, mark this as the end of our
821
+ // extension
822
+ matchedSlash = false;
823
+ end = i + 1;
824
+ }
825
+ if (code === CHAR_DOT) {
826
+ // If this is our first dot, mark it as the start of our extension
827
+ if (startDot === -1) startDot = i;
828
+ else if (preDotState !== 1) preDotState = 1;
829
+ } else if (startDot !== -1) {
830
+ // We saw a non-dot and non-path separator before our dot, so we should
831
+ // have a good chance at having a non-empty extension
832
+ preDotState = -1;
833
+ }
834
+ }
835
+ if (startDot === -1 || end === -1 || // We saw a non-dot character immediately before the dot
836
+ preDotState === 0 || // The (right-most) trimmed path component is exactly '..'
837
+ preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
838
+ if (end !== -1) {
839
+ ret.base = ret.name = path.slice(startPart, end);
840
+ }
841
+ } else {
842
+ ret.name = path.slice(startPart, startDot);
843
+ ret.base = path.slice(startPart, end);
844
+ ret.ext = path.slice(startDot, end);
845
+ }
846
+ // Fallback to '\' in case there is no basename
847
+ ret.base = ret.base || "\\";
848
+ // If the directory is the root, use the entire root as the `dir` including
849
+ // the trailing slash if any (`C:\abc` -> `C:\`). Otherwise, strip out the
850
+ // trailing slash (`C:\abc\def` -> `C:\abc`).
851
+ if (startPart > 0 && startPart !== rootEnd) {
852
+ ret.dir = path.slice(0, startPart - 1);
853
+ } else ret.dir = ret.root;
854
+ return ret;
855
+ }
856
+
857
+ // Copyright 2018-2025 the Deno authors. MIT license.
858
+ // This module is browser compatible.
859
+ /**
860
+ * Resolves path segments into a `path`.
861
+ *
862
+ * @example Usage
863
+ * ```ts
864
+ * import { resolve } from "@std/path/windows/resolve";
865
+ * import { assertEquals } from "@std/assert";
866
+ *
867
+ * const resolved = resolve("C:\\foo\\bar", "..\\baz");
868
+ * assertEquals(resolved, "C:\\foo\\baz");
869
+ * ```
870
+ *
871
+ * @param pathSegments The path segments to process to path
872
+ * @returns The resolved path
873
+ */ function resolve(...pathSegments) {
874
+ let resolvedDevice = "";
875
+ let resolvedTail = "";
876
+ let resolvedAbsolute = false;
877
+ for(let i = pathSegments.length - 1; i >= -1; i--){
878
+ let path;
879
+ // deno-lint-ignore no-explicit-any
880
+ const { Deno } = globalThis;
881
+ if (i >= 0) {
882
+ path = pathSegments[i];
883
+ } else if (!resolvedDevice) {
884
+ if (typeof Deno?.cwd !== "function") {
885
+ throw new TypeError("Resolved a drive-letter-less path without a current working directory (CWD)");
886
+ }
887
+ path = Deno.cwd();
888
+ } else {
889
+ if (typeof Deno?.env?.get !== "function" || typeof Deno?.cwd !== "function") {
890
+ throw new TypeError("Resolved a relative path without a current working directory (CWD)");
891
+ }
892
+ path = Deno.cwd();
893
+ // Verify that a cwd was found and that it actually points
894
+ // to our drive. If not, default to the drive's root.
895
+ if (path === undefined || path.slice(0, 3).toLowerCase() !== `${resolvedDevice.toLowerCase()}\\`) {
896
+ path = `${resolvedDevice}\\`;
897
+ }
898
+ }
899
+ assertPath(path);
900
+ const len = path.length;
901
+ // Skip empty entries
902
+ if (len === 0) continue;
903
+ let rootEnd = 0;
904
+ let device = "";
905
+ let isAbsolute = false;
906
+ const code = path.charCodeAt(0);
907
+ // Try to match a root
908
+ if (len > 1) {
909
+ if (isPathSeparator(code)) {
910
+ // Possible UNC root
911
+ // If we started with a separator, we know we at least have an
912
+ // absolute path of some kind (UNC or otherwise)
913
+ isAbsolute = true;
914
+ if (isPathSeparator(path.charCodeAt(1))) {
915
+ // Matched double path separator at beginning
916
+ let j = 2;
917
+ let last = j;
918
+ // Match 1 or more non-path separators
919
+ for(; j < len; ++j){
920
+ if (isPathSeparator(path.charCodeAt(j))) break;
921
+ }
922
+ if (j < len && j !== last) {
923
+ const firstPart = path.slice(last, j);
924
+ // Matched!
925
+ last = j;
926
+ // Match 1 or more path separators
927
+ for(; j < len; ++j){
928
+ if (!isPathSeparator(path.charCodeAt(j))) break;
929
+ }
930
+ if (j < len && j !== last) {
931
+ // Matched!
932
+ last = j;
933
+ // Match 1 or more non-path separators
934
+ for(; j < len; ++j){
935
+ if (isPathSeparator(path.charCodeAt(j))) break;
936
+ }
937
+ if (j === len) {
938
+ // We matched a UNC root only
939
+ device = `\\\\${firstPart}\\${path.slice(last)}`;
940
+ rootEnd = j;
941
+ } else if (j !== last) {
942
+ // We matched a UNC root with leftovers
943
+ device = `\\\\${firstPart}\\${path.slice(last, j)}`;
944
+ rootEnd = j;
945
+ }
946
+ }
947
+ }
948
+ } else {
949
+ rootEnd = 1;
950
+ }
951
+ } else if (isWindowsDeviceRoot(code)) {
952
+ // Possible device root
953
+ if (path.charCodeAt(1) === CHAR_COLON) {
954
+ device = path.slice(0, 2);
955
+ rootEnd = 2;
956
+ if (len > 2) {
957
+ if (isPathSeparator(path.charCodeAt(2))) {
958
+ // Treat separator following drive name as an absolute path
959
+ // indicator
960
+ isAbsolute = true;
961
+ rootEnd = 3;
962
+ }
963
+ }
964
+ }
965
+ }
966
+ } else if (isPathSeparator(code)) {
967
+ // `path` contains just a path separator
968
+ rootEnd = 1;
969
+ isAbsolute = true;
970
+ }
971
+ if (device.length > 0 && resolvedDevice.length > 0 && device.toLowerCase() !== resolvedDevice.toLowerCase()) {
972
+ continue;
973
+ }
974
+ if (resolvedDevice.length === 0 && device.length > 0) {
975
+ resolvedDevice = device;
976
+ }
977
+ if (!resolvedAbsolute) {
978
+ resolvedTail = `${path.slice(rootEnd)}\\${resolvedTail}`;
979
+ resolvedAbsolute = isAbsolute;
980
+ }
981
+ if (resolvedAbsolute && resolvedDevice.length > 0) break;
982
+ }
983
+ // At this point the path should be resolved to a full absolute path,
984
+ // but handle relative paths to be safe (might happen when Deno.cwd()
985
+ // fails)
986
+ // Normalize the tail path
987
+ resolvedTail = normalizeString(resolvedTail, !resolvedAbsolute, "\\", isPathSeparator);
988
+ return resolvedDevice + (resolvedAbsolute ? "\\" : "") + resolvedTail || ".";
989
+ }
990
+
991
+ // Copyright 2018-2025 the Deno authors. MIT license.
992
+ // This module is browser compatible.
993
+ function assertArgs(from, to) {
994
+ assertPath(from);
995
+ assertPath(to);
996
+ if (from === to) return "";
997
+ }
998
+
999
+ // Copyright 2018-2025 the Deno authors. MIT license.
1000
+ // This module is browser compatible.
1001
+ /**
1002
+ * Return the relative path from `from` to `to` based on current working directory.
1003
+ *
1004
+ * An example in windows, for instance:
1005
+ * from = 'C:\\orandea\\test\\aaa'
1006
+ * to = 'C:\\orandea\\impl\\bbb'
1007
+ * The output of the function should be: '..\\..\\impl\\bbb'
1008
+ *
1009
+ * @example Usage
1010
+ * ```ts
1011
+ * import { relative } from "@std/path/windows/relative";
1012
+ * import { assertEquals } from "@std/assert";
1013
+ *
1014
+ * const relativePath = relative("C:\\foobar\\test\\aaa", "C:\\foobar\\impl\\bbb");
1015
+ * assertEquals(relativePath, "..\\..\\impl\\bbb");
1016
+ * ```
1017
+ *
1018
+ * @param from The path from which to calculate the relative path
1019
+ * @param to The path to which to calculate the relative path
1020
+ * @returns The relative path from `from` to `to`
1021
+ */ function relative(from, to) {
1022
+ assertArgs(from, to);
1023
+ const fromOrig = resolve(from);
1024
+ const toOrig = resolve(to);
1025
+ if (fromOrig === toOrig) return "";
1026
+ from = fromOrig.toLowerCase();
1027
+ to = toOrig.toLowerCase();
1028
+ if (from === to) return "";
1029
+ // Trim any leading backslashes
1030
+ let fromStart = 0;
1031
+ let fromEnd = from.length;
1032
+ for(; fromStart < fromEnd; ++fromStart){
1033
+ if (from.charCodeAt(fromStart) !== CHAR_BACKWARD_SLASH) break;
1034
+ }
1035
+ // Trim trailing backslashes (applicable to UNC paths only)
1036
+ for(; fromEnd - 1 > fromStart; --fromEnd){
1037
+ if (from.charCodeAt(fromEnd - 1) !== CHAR_BACKWARD_SLASH) break;
1038
+ }
1039
+ const fromLen = fromEnd - fromStart;
1040
+ // Trim any leading backslashes
1041
+ let toStart = 0;
1042
+ let toEnd = to.length;
1043
+ for(; toStart < toEnd; ++toStart){
1044
+ if (to.charCodeAt(toStart) !== CHAR_BACKWARD_SLASH) break;
1045
+ }
1046
+ // Trim trailing backslashes (applicable to UNC paths only)
1047
+ for(; toEnd - 1 > toStart; --toEnd){
1048
+ if (to.charCodeAt(toEnd - 1) !== CHAR_BACKWARD_SLASH) break;
1049
+ }
1050
+ const toLen = toEnd - toStart;
1051
+ // Compare paths to find the longest common path from root
1052
+ const length = fromLen < toLen ? fromLen : toLen;
1053
+ let lastCommonSep = -1;
1054
+ let i = 0;
1055
+ for(; i <= length; ++i){
1056
+ if (i === length) {
1057
+ if (toLen > length) {
1058
+ if (to.charCodeAt(toStart + i) === CHAR_BACKWARD_SLASH) {
1059
+ // We get here if `from` is the exact base path for `to`.
1060
+ // For example: from='C:\\foo\\bar'; to='C:\\foo\\bar\\baz'
1061
+ return toOrig.slice(toStart + i + 1);
1062
+ } else if (i === 2) {
1063
+ // We get here if `from` is the device root.
1064
+ // For example: from='C:\\'; to='C:\\foo'
1065
+ return toOrig.slice(toStart + i);
1066
+ }
1067
+ }
1068
+ if (fromLen > length) {
1069
+ if (from.charCodeAt(fromStart + i) === CHAR_BACKWARD_SLASH) {
1070
+ // We get here if `to` is the exact base path for `from`.
1071
+ // For example: from='C:\\foo\\bar'; to='C:\\foo'
1072
+ lastCommonSep = i;
1073
+ } else if (i === 2) {
1074
+ // We get here if `to` is the device root.
1075
+ // For example: from='C:\\foo\\bar'; to='C:\\'
1076
+ lastCommonSep = 3;
1077
+ }
1078
+ }
1079
+ break;
1080
+ }
1081
+ const fromCode = from.charCodeAt(fromStart + i);
1082
+ const toCode = to.charCodeAt(toStart + i);
1083
+ if (fromCode !== toCode) break;
1084
+ else if (fromCode === CHAR_BACKWARD_SLASH) lastCommonSep = i;
1085
+ }
1086
+ // We found a mismatch before the first common path separator was seen, so
1087
+ // return the original `to`.
1088
+ if (i !== length && lastCommonSep === -1) {
1089
+ return toOrig;
1090
+ }
1091
+ let out = "";
1092
+ if (lastCommonSep === -1) lastCommonSep = 0;
1093
+ // Generate the relative path based on the path difference between `to` and
1094
+ // `from`
1095
+ for(i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i){
1096
+ if (i === fromEnd || from.charCodeAt(i) === CHAR_BACKWARD_SLASH) {
1097
+ if (out.length === 0) out += "..";
1098
+ else out += "\\..";
1099
+ }
1100
+ }
1101
+ // Lastly, append the rest of the destination (`to`) path that comes after
1102
+ // the common path parts
1103
+ if (out.length > 0) {
1104
+ return out + toOrig.slice(toStart + lastCommonSep, toEnd);
1105
+ } else {
1106
+ toStart += lastCommonSep;
1107
+ if (toOrig.charCodeAt(toStart) === CHAR_BACKWARD_SLASH) ++toStart;
1108
+ return toOrig.slice(toStart, toEnd);
1109
+ }
1110
+ }
1111
+
1112
+ // Copyright 2018-2025 the Deno authors. MIT license.
1113
+ // This module is browser compatible.
1114
+ const WHITESPACE_ENCODINGS = {
1115
+ "\u0009": "%09",
1116
+ "\u000A": "%0A",
1117
+ "\u000B": "%0B",
1118
+ "\u000C": "%0C",
1119
+ "\u000D": "%0D",
1120
+ "\u0020": "%20"
1121
+ };
1122
+ function encodeWhitespace(string) {
1123
+ return string.replaceAll(/[\s]/g, (c)=>{
1124
+ return WHITESPACE_ENCODINGS[c] ?? c;
1125
+ });
1126
+ }
1127
+
1128
+ // Copyright 2018-2025 the Deno authors. MIT license.
1129
+ // This module is browser compatible.
1130
+ /**
1131
+ * Converts a path string to a file URL.
1132
+ *
1133
+ * @example Usage
1134
+ * ```ts
1135
+ * import { toFileUrl } from "@std/path/windows/to-file-url";
1136
+ * import { assertEquals } from "@std/assert";
1137
+ *
1138
+ * assertEquals(toFileUrl("\\home\\foo"), new URL("file:///home/foo"));
1139
+ * assertEquals(toFileUrl("C:\\Users\\foo"), new URL("file:///C:/Users/foo"));
1140
+ * assertEquals(toFileUrl("\\\\127.0.0.1\\home\\foo"), new URL("file://127.0.0.1/home/foo"));
1141
+ * ```
1142
+ * @param path The path to convert.
1143
+ * @returns The file URL.
1144
+ */ function toFileUrl(path) {
1145
+ if (!isAbsolute(path)) {
1146
+ throw new TypeError(`Path must be absolute: received "${path}"`);
1147
+ }
1148
+ const [, hostname, pathname] = path.match(/^(?:[/\\]{2}([^/\\]+)(?=[/\\](?:[^/\\]|$)))?(.*)/);
1149
+ const url = new URL("file:///");
1150
+ url.pathname = encodeWhitespace(pathname.replace(/%/g, "%25"));
1151
+ if (hostname !== undefined && hostname !== "localhost") {
1152
+ url.hostname = hostname;
1153
+ if (!url.hostname) {
1154
+ throw new TypeError(`Invalid hostname: "${url.hostname}"`);
1155
+ }
1156
+ }
1157
+ return url;
1158
+ }
1159
+
1160
+ // Copyright 2018-2025 the Deno authors. MIT license.
1161
+ // This module is browser compatible.
1162
+ /**
1163
+ * Resolves path to a namespace path
1164
+ *
1165
+ * @example Usage
1166
+ * ```ts
1167
+ * import { toNamespacedPath } from "@std/path/windows/to-namespaced-path";
1168
+ * import { assertEquals } from "@std/assert";
1169
+ *
1170
+ * const namespaced = toNamespacedPath("C:\\foo\\bar");
1171
+ * assertEquals(namespaced, "\\\\?\\C:\\foo\\bar");
1172
+ * ```
1173
+ *
1174
+ * @param path The path to resolve to namespaced path
1175
+ * @returns The resolved namespaced path
1176
+ */ function toNamespacedPath(path) {
1177
+ // Note: this will *probably* throw somewhere.
1178
+ if (typeof path !== "string") return path;
1179
+ if (path.length === 0) return "";
1180
+ const resolvedPath = resolve(path);
1181
+ if (resolvedPath.length >= 3) {
1182
+ if (resolvedPath.charCodeAt(0) === CHAR_BACKWARD_SLASH) {
1183
+ // Possible UNC root
1184
+ if (resolvedPath.charCodeAt(1) === CHAR_BACKWARD_SLASH) {
1185
+ const code = resolvedPath.charCodeAt(2);
1186
+ if (code !== CHAR_QUESTION_MARK && code !== CHAR_DOT) {
1187
+ // Matched non-long UNC root, convert the path to a long UNC path
1188
+ return `\\\\?\\UNC\\${resolvedPath.slice(2)}`;
1189
+ }
1190
+ }
1191
+ } else if (isWindowsDeviceRoot(resolvedPath.charCodeAt(0))) {
1192
+ // Possible device root
1193
+ if (resolvedPath.charCodeAt(1) === CHAR_COLON && resolvedPath.charCodeAt(2) === CHAR_BACKWARD_SLASH) {
1194
+ // Matched device root, convert the path to a long UNC path
1195
+ return `\\\\?\\${resolvedPath}`;
1196
+ }
1197
+ }
1198
+ }
1199
+ return path;
1200
+ }
1201
+
1202
+ // Copyright 2018-2025 the Deno authors. MIT license.
1203
+ // This module is browser compatible.
1204
+ function common$1(paths, sep) {
1205
+ const [first = "", ...remaining] = paths;
1206
+ const parts = first.split(sep);
1207
+ let endOfPrefix = parts.length;
1208
+ let append = "";
1209
+ for (const path of remaining){
1210
+ const compare = path.split(sep);
1211
+ if (compare.length <= endOfPrefix) {
1212
+ endOfPrefix = compare.length;
1213
+ append = "";
1214
+ }
1215
+ for(let i = 0; i < endOfPrefix; i++){
1216
+ if (compare[i] !== parts[i]) {
1217
+ endOfPrefix = i;
1218
+ append = i === 0 ? "" : sep;
1219
+ break;
1220
+ }
1221
+ }
1222
+ }
1223
+ return parts.slice(0, endOfPrefix).join(sep) + append;
1224
+ }
1225
+
1226
+ // Copyright 2018-2025 the Deno authors. MIT license.
1227
+ // This module is browser compatible.
1228
+ /**
1229
+ * Determines the common path from a set of paths for Windows systems.
1230
+ *
1231
+ * @example Usage
1232
+ * ```ts
1233
+ * import { common } from "@std/path/windows/common";
1234
+ * import { assertEquals } from "@std/assert";
1235
+ *
1236
+ * const path = common([
1237
+ * "C:\\foo\\bar",
1238
+ * "C:\\foo\\baz",
1239
+ * ]);
1240
+ * assertEquals(path, "C:\\foo\\");
1241
+ * ```
1242
+ *
1243
+ * @param paths The paths to compare.
1244
+ * @returns The common path.
1245
+ */ function common(paths) {
1246
+ return common$1(paths, SEPARATOR);
1247
+ }
1248
+
1249
+ // Copyright 2018-2025 the Deno authors. MIT license.
1250
+ // This module is browser compatible.
1251
+ /**
1252
+ * Options for {@linkcode globToRegExp}, {@linkcode joinGlobs},
1253
+ * {@linkcode normalizeGlob} and {@linkcode expandGlob}.
1254
+ */ const REG_EXP_ESCAPE_CHARS = [
1255
+ "!",
1256
+ "$",
1257
+ "(",
1258
+ ")",
1259
+ "*",
1260
+ "+",
1261
+ ".",
1262
+ "=",
1263
+ "?",
1264
+ "[",
1265
+ "\\",
1266
+ "^",
1267
+ "{",
1268
+ "|"
1269
+ ];
1270
+ const RANGE_ESCAPE_CHARS = [
1271
+ "-",
1272
+ "\\",
1273
+ "]"
1274
+ ];
1275
+ function _globToRegExp(c, glob, { extended = true, globstar: globstarOption = true, // os = osType,
1276
+ caseInsensitive = false } = {}) {
1277
+ if (glob === "") {
1278
+ return /(?!)/;
1279
+ }
1280
+ // Remove trailing separators.
1281
+ let newLength = glob.length;
1282
+ for(; newLength > 1 && c.seps.includes(glob[newLength - 1]); newLength--);
1283
+ glob = glob.slice(0, newLength);
1284
+ let regExpString = "";
1285
+ // Terminates correctly. Trust that `j` is incremented every iteration.
1286
+ for(let j = 0; j < glob.length;){
1287
+ let segment = "";
1288
+ const groupStack = [];
1289
+ let inRange = false;
1290
+ let inEscape = false;
1291
+ let endsWithSep = false;
1292
+ let i = j;
1293
+ // Terminates with `i` at the non-inclusive end of the current segment.
1294
+ for(; i < glob.length && !(c.seps.includes(glob[i]) && groupStack.length === 0); i++){
1295
+ if (inEscape) {
1296
+ inEscape = false;
1297
+ const escapeChars = inRange ? RANGE_ESCAPE_CHARS : REG_EXP_ESCAPE_CHARS;
1298
+ segment += escapeChars.includes(glob[i]) ? `\\${glob[i]}` : glob[i];
1299
+ continue;
1300
+ }
1301
+ if (glob[i] === c.escapePrefix) {
1302
+ inEscape = true;
1303
+ continue;
1304
+ }
1305
+ if (glob[i] === "[") {
1306
+ if (!inRange) {
1307
+ inRange = true;
1308
+ segment += "[";
1309
+ if (glob[i + 1] === "!") {
1310
+ i++;
1311
+ segment += "^";
1312
+ } else if (glob[i + 1] === "^") {
1313
+ i++;
1314
+ segment += "\\^";
1315
+ }
1316
+ continue;
1317
+ } else if (glob[i + 1] === ":") {
1318
+ let k = i + 1;
1319
+ let value = "";
1320
+ while(glob[k + 1] !== undefined && glob[k + 1] !== ":"){
1321
+ value += glob[k + 1];
1322
+ k++;
1323
+ }
1324
+ if (glob[k + 1] === ":" && glob[k + 2] === "]") {
1325
+ i = k + 2;
1326
+ if (value === "alnum") segment += "\\dA-Za-z";
1327
+ else if (value === "alpha") segment += "A-Za-z";
1328
+ else if (value === "ascii") segment += "\x00-\x7F";
1329
+ else if (value === "blank") segment += "\t ";
1330
+ else if (value === "cntrl") segment += "\x00-\x1F\x7F";
1331
+ else if (value === "digit") segment += "\\d";
1332
+ else if (value === "graph") segment += "\x21-\x7E";
1333
+ else if (value === "lower") segment += "a-z";
1334
+ else if (value === "print") segment += "\x20-\x7E";
1335
+ else if (value === "punct") {
1336
+ segment += "!\"#$%&'()*+,\\-./:;<=>?@[\\\\\\]^_‘{|}~";
1337
+ } else if (value === "space") segment += "\\s\v";
1338
+ else if (value === "upper") segment += "A-Z";
1339
+ else if (value === "word") segment += "\\w";
1340
+ else if (value === "xdigit") segment += "\\dA-Fa-f";
1341
+ continue;
1342
+ }
1343
+ }
1344
+ }
1345
+ if (glob[i] === "]" && inRange) {
1346
+ inRange = false;
1347
+ segment += "]";
1348
+ continue;
1349
+ }
1350
+ if (inRange) {
1351
+ segment += glob[i];
1352
+ continue;
1353
+ }
1354
+ if (glob[i] === ")" && groupStack.length > 0 && groupStack[groupStack.length - 1] !== "BRACE") {
1355
+ segment += ")";
1356
+ const type = groupStack.pop();
1357
+ if (type === "!") {
1358
+ segment += c.wildcard;
1359
+ } else if (type !== "@") {
1360
+ segment += type;
1361
+ }
1362
+ continue;
1363
+ }
1364
+ if (glob[i] === "|" && groupStack.length > 0 && groupStack[groupStack.length - 1] !== "BRACE") {
1365
+ segment += "|";
1366
+ continue;
1367
+ }
1368
+ if (glob[i] === "+" && extended && glob[i + 1] === "(") {
1369
+ i++;
1370
+ groupStack.push("+");
1371
+ segment += "(?:";
1372
+ continue;
1373
+ }
1374
+ if (glob[i] === "@" && extended && glob[i + 1] === "(") {
1375
+ i++;
1376
+ groupStack.push("@");
1377
+ segment += "(?:";
1378
+ continue;
1379
+ }
1380
+ if (glob[i] === "?") {
1381
+ if (extended && glob[i + 1] === "(") {
1382
+ i++;
1383
+ groupStack.push("?");
1384
+ segment += "(?:";
1385
+ } else {
1386
+ segment += ".";
1387
+ }
1388
+ continue;
1389
+ }
1390
+ if (glob[i] === "!" && extended && glob[i + 1] === "(") {
1391
+ i++;
1392
+ groupStack.push("!");
1393
+ segment += "(?!";
1394
+ continue;
1395
+ }
1396
+ if (glob[i] === "{") {
1397
+ groupStack.push("BRACE");
1398
+ segment += "(?:";
1399
+ continue;
1400
+ }
1401
+ if (glob[i] === "}" && groupStack[groupStack.length - 1] === "BRACE") {
1402
+ groupStack.pop();
1403
+ segment += ")";
1404
+ continue;
1405
+ }
1406
+ if (glob[i] === "," && groupStack[groupStack.length - 1] === "BRACE") {
1407
+ segment += "|";
1408
+ continue;
1409
+ }
1410
+ if (glob[i] === "*") {
1411
+ if (extended && glob[i + 1] === "(") {
1412
+ i++;
1413
+ groupStack.push("*");
1414
+ segment += "(?:";
1415
+ } else {
1416
+ const prevChar = glob[i - 1];
1417
+ let numStars = 1;
1418
+ while(glob[i + 1] === "*"){
1419
+ i++;
1420
+ numStars++;
1421
+ }
1422
+ const nextChar = glob[i + 1];
1423
+ if (globstarOption && numStars === 2 && [
1424
+ ...c.seps,
1425
+ undefined
1426
+ ].includes(prevChar) && [
1427
+ ...c.seps,
1428
+ undefined
1429
+ ].includes(nextChar)) {
1430
+ segment += c.globstar;
1431
+ endsWithSep = true;
1432
+ } else {
1433
+ segment += c.wildcard;
1434
+ }
1435
+ }
1436
+ continue;
1437
+ }
1438
+ segment += REG_EXP_ESCAPE_CHARS.includes(glob[i]) ? `\\${glob[i]}` : glob[i];
1439
+ }
1440
+ // Check for unclosed groups or a dangling backslash.
1441
+ if (groupStack.length > 0 || inRange || inEscape) {
1442
+ // Parse failure. Take all characters from this segment literally.
1443
+ segment = "";
1444
+ for (const c of glob.slice(j, i)){
1445
+ segment += REG_EXP_ESCAPE_CHARS.includes(c) ? `\\${c}` : c;
1446
+ endsWithSep = false;
1447
+ }
1448
+ }
1449
+ regExpString += segment;
1450
+ if (!endsWithSep) {
1451
+ regExpString += i < glob.length ? c.sep : c.sepMaybe;
1452
+ endsWithSep = true;
1453
+ }
1454
+ // Terminates with `i` at the start of the next segment.
1455
+ while(c.seps.includes(glob[i]))i++;
1456
+ j = i;
1457
+ }
1458
+ regExpString = `^${regExpString}$`;
1459
+ return new RegExp(regExpString, caseInsensitive ? "i" : "");
1460
+ }
1461
+
1462
+ // Copyright 2018-2025 the Deno authors. MIT license.
1463
+ // This module is browser compatible.
1464
+ const constants = {
1465
+ sep: "(?:\\\\|/)+",
1466
+ sepMaybe: "(?:\\\\|/)*",
1467
+ seps: [
1468
+ "\\",
1469
+ "/"
1470
+ ],
1471
+ globstar: "(?:[^\\\\/]*(?:\\\\|/|$)+)*",
1472
+ wildcard: "[^\\\\/]*",
1473
+ escapePrefix: "`"
1474
+ };
1475
+ /** Convert a glob string to a regular expression.
1476
+ *
1477
+ * Tries to match bash glob expansion as closely as possible.
1478
+ *
1479
+ * Basic glob syntax:
1480
+ * - `*` - Matches everything without leaving the path segment.
1481
+ * - `?` - Matches any single character.
1482
+ * - `{foo,bar}` - Matches `foo` or `bar`.
1483
+ * - `[abcd]` - Matches `a`, `b`, `c` or `d`.
1484
+ * - `[a-d]` - Matches `a`, `b`, `c` or `d`.
1485
+ * - `[!abcd]` - Matches any single character besides `a`, `b`, `c` or `d`.
1486
+ * - `[[:<class>:]]` - Matches any character belonging to `<class>`.
1487
+ * - `[[:alnum:]]` - Matches any digit or letter.
1488
+ * - `[[:digit:]abc]` - Matches any digit, `a`, `b` or `c`.
1489
+ * - See https://facelessuser.github.io/wcmatch/glob/#posix-character-classes
1490
+ * for a complete list of supported character classes.
1491
+ * - `\` - Escapes the next character for an `os` other than `"windows"`.
1492
+ * - \` - Escapes the next character for `os` set to `"windows"`.
1493
+ * - `/` - Path separator.
1494
+ * - `\` - Additional path separator only for `os` set to `"windows"`.
1495
+ *
1496
+ * Extended syntax:
1497
+ * - Requires `{ extended: true }`.
1498
+ * - `?(foo|bar)` - Matches 0 or 1 instance of `{foo,bar}`.
1499
+ * - `@(foo|bar)` - Matches 1 instance of `{foo,bar}`. They behave the same.
1500
+ * - `*(foo|bar)` - Matches _n_ instances of `{foo,bar}`.
1501
+ * - `+(foo|bar)` - Matches _n > 0_ instances of `{foo,bar}`.
1502
+ * - `!(foo|bar)` - Matches anything other than `{foo,bar}`.
1503
+ * - See https://www.linuxjournal.com/content/bash-extended-globbing.
1504
+ *
1505
+ * Globstar syntax:
1506
+ * - Requires `{ globstar: true }`.
1507
+ * - `**` - Matches any number of any path segments.
1508
+ * - Must comprise its entire path segment in the provided glob.
1509
+ * - See https://www.linuxjournal.com/content/globstar-new-bash-globbing-option.
1510
+ *
1511
+ * Note the following properties:
1512
+ * - The generated `RegExp` is anchored at both start and end.
1513
+ * - Repeating and trailing separators are tolerated. Trailing separators in the
1514
+ * provided glob have no meaning and are discarded.
1515
+ * - Absolute globs will only match absolute paths, etc.
1516
+ * - Empty globs will match nothing.
1517
+ * - Any special glob syntax must be contained to one path segment. For example,
1518
+ * `?(foo|bar/baz)` is invalid. The separator will take precedence and the
1519
+ * first segment ends with an unclosed group.
1520
+ * - If a path segment ends with unclosed groups or a dangling escape prefix, a
1521
+ * parse error has occurred. Every character for that segment is taken
1522
+ * literally in this event.
1523
+ *
1524
+ * Limitations:
1525
+ * - A negative group like `!(foo|bar)` will wrongly be converted to a negative
1526
+ * look-ahead followed by a wildcard. This means that `!(foo).js` will wrongly
1527
+ * fail to match `foobar.js`, even though `foobar` is not `foo`. Effectively,
1528
+ * `!(foo|bar)` is treated like `!(@(foo|bar)*)`. This will work correctly if
1529
+ * the group occurs not nested at the end of the segment.
1530
+ *
1531
+ * @example Usage
1532
+ * ```ts
1533
+ * import { globToRegExp } from "@std/path/windows/glob-to-regexp";
1534
+ * import { assertEquals } from "@std/assert";
1535
+ *
1536
+ * assertEquals(globToRegExp("*.js"), /^[^\\/]*\.js(?:\\|\/)*$/);
1537
+ * ```
1538
+ *
1539
+ * @param glob Glob string to convert.
1540
+ * @param options Conversion options.
1541
+ * @returns The regular expression equivalent to the glob.
1542
+ */ function globToRegExp(glob, options = {}) {
1543
+ return _globToRegExp(constants, glob, options);
1544
+ }
1545
+
1546
+ // Copyright 2018-2025 the Deno authors. MIT license.
1547
+ // This module is browser compatible.
1548
+ /**
1549
+ * Test whether the given string is a glob.
1550
+ *
1551
+ * @example Usage
1552
+ * ```ts
1553
+ * import { isGlob } from "@std/path/is-glob";
1554
+ * import { assert } from "@std/assert";
1555
+ *
1556
+ * assert(!isGlob("foo/bar/../baz"));
1557
+ * assert(isGlob("foo/*ar/../baz"));
1558
+ * ```
1559
+ *
1560
+ * @param str String to test.
1561
+ * @returns `true` if the given string is a glob, otherwise `false`
1562
+ */ function isGlob(str) {
1563
+ const chars = {
1564
+ "{": "}",
1565
+ "(": ")",
1566
+ "[": "]"
1567
+ };
1568
+ const regex = /\\(.)|(^!|\*|\?|[\].+)]\?|\[[^[\\\]]+\]|\{[^{\\}]+\}|\(\?[:!=][^\\)]+\)|\([^(|]+\|[^\\)]+\)|@\([^)]+\))/;
1569
+ if (str === "") {
1570
+ return false;
1571
+ }
1572
+ let match;
1573
+ while(match = regex.exec(str)){
1574
+ if (match[2]) return true;
1575
+ let idx = match.index + match[0].length;
1576
+ // if an open bracket/brace/paren is escaped,
1577
+ // set the index to the next closing character
1578
+ const open = match[1];
1579
+ const close = open ? chars[open] : null;
1580
+ if (open && close) {
1581
+ const n = str.indexOf(close, idx);
1582
+ if (n !== -1) {
1583
+ idx = n + 1;
1584
+ }
1585
+ }
1586
+ str = str.slice(idx);
1587
+ }
1588
+ return false;
1589
+ }
1590
+
1591
+ // Copyright 2018-2025 the Deno authors. MIT license.
1592
+ // This module is browser compatible.
1593
+ /**
1594
+ * Like normalize(), but doesn't collapse "**\/.." when `globstar` is true.
1595
+ *
1596
+ * @example Usage
1597
+ * ```ts
1598
+ * import { normalizeGlob } from "@std/path/windows/normalize-glob";
1599
+ * import { assertEquals } from "@std/assert";
1600
+ *
1601
+ * const normalized = normalizeGlob("**\\foo\\..\\bar", { globstar: true });
1602
+ * assertEquals(normalized, "**\\bar");
1603
+ * ```
1604
+ *
1605
+ * @param glob The glob pattern to normalize.
1606
+ * @param options The options for glob pattern.
1607
+ * @returns The normalized glob pattern.
1608
+ */ function normalizeGlob(glob, options = {}) {
1609
+ const { globstar = false } = options;
1610
+ if (glob.match(/\0/g)) {
1611
+ throw new Error(`Glob contains invalid characters: "${glob}"`);
1612
+ }
1613
+ if (!globstar) {
1614
+ return normalize(glob);
1615
+ }
1616
+ const s = SEPARATOR_PATTERN.source;
1617
+ const badParentPattern = new RegExp(`(?<=(${s}|^)\\*\\*${s})\\.\\.(?=${s}|$)`, "g");
1618
+ return normalize(glob.replace(badParentPattern, "\0")).replace(/\0/g, "..");
1619
+ }
1620
+
1621
+ // Copyright 2018-2025 the Deno authors. MIT license.
1622
+ // This module is browser compatible.
1623
+ /**
1624
+ * Like join(), but doesn't collapse "**\/.." when `globstar` is true.
1625
+ *
1626
+ * @example Usage
1627
+ *
1628
+ * ```ts
1629
+ * import { joinGlobs } from "@std/path/windows/join-globs";
1630
+ * import { assertEquals } from "@std/assert";
1631
+ *
1632
+ * const joined = joinGlobs(["foo", "**", "bar"], { globstar: true });
1633
+ * assertEquals(joined, "foo\\**\\bar");
1634
+ * ```
1635
+ *
1636
+ * @param globs The globs to join.
1637
+ * @param options The options for glob pattern.
1638
+ * @returns The joined glob pattern.
1639
+ */ function joinGlobs(globs, options = {}) {
1640
+ const { globstar = false } = options;
1641
+ if (!globstar || globs.length === 0) {
1642
+ return join(...globs);
1643
+ }
1644
+ let joined;
1645
+ for (const glob of globs){
1646
+ const path = glob;
1647
+ if (path.length > 0) {
1648
+ if (!joined) joined = path;
1649
+ else joined += `${SEPARATOR}${path}`;
1650
+ }
1651
+ }
1652
+ if (!joined) return ".";
1653
+ return normalizeGlob(joined, {
1654
+ globstar
1655
+ });
1656
+ }
1657
+
1658
+ exports.DELIMITER = DELIMITER;
1659
+ exports.SEPARATOR = SEPARATOR;
1660
+ exports.SEPARATOR_PATTERN = SEPARATOR_PATTERN;
1661
+ exports.basename = basename;
1662
+ exports.common = common;
1663
+ exports.dirname = dirname;
1664
+ exports.extname = extname;
1665
+ exports.format = format;
1666
+ exports.fromFileUrl = fromFileUrl;
1667
+ exports.globToRegExp = globToRegExp;
1668
+ exports.isAbsolute = isAbsolute;
1669
+ exports.isGlob = isGlob;
1670
+ exports.join = join;
1671
+ exports.joinGlobs = joinGlobs;
1672
+ exports.normalize = normalize;
1673
+ exports.normalizeGlob = normalizeGlob;
1674
+ exports.parse = parse;
1675
+ exports.relative = relative;
1676
+ exports.resolve = resolve;
1677
+ exports.toFileUrl = toFileUrl;
1678
+ exports.toNamespacedPath = toNamespacedPath;
server/node_modules/@eslint/config-array/dist/cjs/types.cts ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @fileoverview Types for the config-array package.
3
+ * @author Nicholas C. Zakas
4
+ */
5
+
6
+ export interface ConfigObject {
7
+ /**
8
+ * The base path for files and ignores.
9
+ */
10
+ basePath?: string;
11
+
12
+ /**
13
+ * The files to include.
14
+ */
15
+ files?: string[];
16
+
17
+ /**
18
+ * The files to exclude.
19
+ */
20
+ ignores?: string[];
21
+
22
+ /**
23
+ * The name of the config object.
24
+ */
25
+ name?: string;
26
+
27
+ // may also have any number of other properties
28
+ [key: string]: unknown;
29
+ }
server/node_modules/@eslint/config-array/dist/esm/index.d.ts ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export { ObjectSchema } from "@eslint/object-schema";
2
+ export type PropertyDefinition = $eslintobjectschema.PropertyDefinition;
3
+ export type ObjectDefinition = $eslintobjectschema.ObjectDefinition;
4
+ export type ConfigObject = $typests.ConfigObject;
5
+ export type IMinimatchStatic = minimatch.IMinimatchStatic;
6
+ export type IMinimatch = minimatch.IMinimatch;
7
+ export type ObjectSchemaInstance = ObjectSchema;
8
+ /**
9
+ * Represents an array of config objects and provides method for working with
10
+ * those config objects.
11
+ */
12
+ export class ConfigArray extends Array<any> {
13
+ /**
14
+ * Creates a new instance of ConfigArray.
15
+ * @param {Iterable|Function|Object} configs An iterable yielding config
16
+ * objects, or a config function, or a config object.
17
+ * @param {Object} options The options for the ConfigArray.
18
+ * @param {string} [options.basePath="/"] The absolute path of the config file directory.
19
+ * Defaults to `"/"`.
20
+ * @param {boolean} [options.normalized=false] Flag indicating if the
21
+ * configs have already been normalized.
22
+ * @param {Object} [options.schema] The additional schema
23
+ * definitions to use for the ConfigArray schema.
24
+ * @param {Array<string>} [options.extraConfigTypes] List of config types supported.
25
+ * @throws {TypeError} When the `basePath` is not a non-empty string,
26
+ */
27
+ constructor(configs: Iterable<any> | Function | any, { basePath, normalized, schema: customSchema, extraConfigTypes, }?: {
28
+ basePath?: string;
29
+ normalized?: boolean;
30
+ schema?: any;
31
+ extraConfigTypes?: Array<string>;
32
+ });
33
+ /**
34
+ * The path of the config file that this array was loaded from.
35
+ * This is used to calculate filename matches.
36
+ * @property basePath
37
+ * @type {string}
38
+ */
39
+ basePath: string;
40
+ /**
41
+ * The supported config types.
42
+ * @type {Array<string>}
43
+ */
44
+ extraConfigTypes: Array<string>;
45
+ /**
46
+ * Returns the `files` globs from every config object in the array.
47
+ * This can be used to determine which files will be matched by a
48
+ * config array or to use as a glob pattern when no patterns are provided
49
+ * for a command line interface.
50
+ * @returns {Array<string|Function>} An array of matchers.
51
+ */
52
+ get files(): Array<string | Function>;
53
+ /**
54
+ * Returns ignore matchers that should always be ignored regardless of
55
+ * the matching `files` fields in any configs. This is necessary to mimic
56
+ * the behavior of things like .gitignore and .eslintignore, allowing a
57
+ * globbing operation to be faster.
58
+ * @returns {Object[]} An array of config objects representing global ignores.
59
+ */
60
+ get ignores(): any[];
61
+ /**
62
+ * Indicates if the config array has been normalized.
63
+ * @returns {boolean} True if the config array is normalized, false if not.
64
+ */
65
+ isNormalized(): boolean;
66
+ /**
67
+ * Normalizes a config array by flattening embedded arrays and executing
68
+ * config functions.
69
+ * @param {Object} [context] The context object for config functions.
70
+ * @returns {Promise<ConfigArray>} The current ConfigArray instance.
71
+ */
72
+ normalize(context?: any): Promise<ConfigArray>;
73
+ /**
74
+ * Normalizes a config array by flattening embedded arrays and executing
75
+ * config functions.
76
+ * @param {Object} [context] The context object for config functions.
77
+ * @returns {ConfigArray} The current ConfigArray instance.
78
+ */
79
+ normalizeSync(context?: any): ConfigArray;
80
+ /**
81
+ * Returns the config object for a given file path and a status that can be used to determine why a file has no config.
82
+ * @param {string} filePath The path of a file to get a config for.
83
+ * @returns {{ config?: Object, status: "ignored"|"external"|"unconfigured"|"matched" }}
84
+ * An object with an optional property `config` and property `status`.
85
+ * `config` is the config object for the specified file as returned by {@linkcode ConfigArray.getConfig},
86
+ * `status` a is one of the constants returned by {@linkcode ConfigArray.getConfigStatus}.
87
+ */
88
+ getConfigWithStatus(filePath: string): {
89
+ config?: any;
90
+ status: "ignored" | "external" | "unconfigured" | "matched";
91
+ };
92
+ /**
93
+ * Returns the config object for a given file path.
94
+ * @param {string} filePath The path of a file to get a config for.
95
+ * @returns {Object|undefined} The config object for this file or `undefined`.
96
+ */
97
+ getConfig(filePath: string): any | undefined;
98
+ /**
99
+ * Determines whether a file has a config or why it doesn't.
100
+ * @param {string} filePath The path of the file to check.
101
+ * @returns {"ignored"|"external"|"unconfigured"|"matched"} One of the following values:
102
+ * * `"ignored"`: the file is ignored
103
+ * * `"external"`: the file is outside the base path
104
+ * * `"unconfigured"`: the file is not matched by any config
105
+ * * `"matched"`: the file has a matching config
106
+ */
107
+ getConfigStatus(filePath: string): "ignored" | "external" | "unconfigured" | "matched";
108
+ /**
109
+ * Determines if the given filepath is ignored based on the configs.
110
+ * @param {string} filePath The path of a file to check.
111
+ * @returns {boolean} True if the path is ignored, false if not.
112
+ * @deprecated Use `isFileIgnored` instead.
113
+ */
114
+ isIgnored(filePath: string): boolean;
115
+ /**
116
+ * Determines if the given filepath is ignored based on the configs.
117
+ * @param {string} filePath The path of a file to check.
118
+ * @returns {boolean} True if the path is ignored, false if not.
119
+ */
120
+ isFileIgnored(filePath: string): boolean;
121
+ /**
122
+ * Determines if the given directory is ignored based on the configs.
123
+ * This checks only default `ignores` that don't have `files` in the
124
+ * same config. A pattern such as `/foo` be considered to ignore the directory
125
+ * while a pattern such as `/foo/**` is not considered to ignore the
126
+ * directory because it is matching files.
127
+ * @param {string} directoryPath The path of a directory to check.
128
+ * @returns {boolean} True if the directory is ignored, false if not. Will
129
+ * return true for any directory that is not inside of `basePath`.
130
+ * @throws {Error} When the `ConfigArray` is not normalized.
131
+ */
132
+ isDirectoryIgnored(directoryPath: string): boolean;
133
+ #private;
134
+ }
135
+ export namespace ConfigArraySymbol {
136
+ let isNormalized: symbol;
137
+ let configCache: symbol;
138
+ let schema: symbol;
139
+ let finalizeConfig: symbol;
140
+ let preprocessConfig: symbol;
141
+ }
142
+ import type * as $eslintobjectschema from "@eslint/object-schema";
143
+ import type * as $typests from "./types.ts";
144
+ import minimatch from 'minimatch';
145
+ import { ObjectSchema } from '@eslint/object-schema';
server/node_modules/@eslint/config-array/dist/esm/index.js ADDED
@@ -0,0 +1,1514 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-self-types="./index.d.ts"
2
+ import * as posixPath from './std__path/posix.js';
3
+ import * as windowsPath from './std__path/windows.js';
4
+ import minimatch from 'minimatch';
5
+ import createDebug from 'debug';
6
+ import { ObjectSchema } from '@eslint/object-schema';
7
+ export { ObjectSchema } from '@eslint/object-schema';
8
+
9
+ /**
10
+ * @fileoverview ConfigSchema
11
+ * @author Nicholas C. Zakas
12
+ */
13
+
14
+ //------------------------------------------------------------------------------
15
+ // Types
16
+ //------------------------------------------------------------------------------
17
+
18
+ /** @import * as $eslintobjectschema from "@eslint/object-schema"; */
19
+ /** @typedef {$eslintobjectschema.PropertyDefinition} PropertyDefinition */
20
+ /** @typedef {$eslintobjectschema.ObjectDefinition} ObjectDefinition */
21
+
22
+ //------------------------------------------------------------------------------
23
+ // Helpers
24
+ //------------------------------------------------------------------------------
25
+
26
+ /**
27
+ * A strategy that does nothing.
28
+ * @type {PropertyDefinition}
29
+ */
30
+ const NOOP_STRATEGY = {
31
+ required: false,
32
+ merge() {
33
+ return undefined;
34
+ },
35
+ validate() {},
36
+ };
37
+
38
+ //------------------------------------------------------------------------------
39
+ // Exports
40
+ //------------------------------------------------------------------------------
41
+
42
+ /**
43
+ * The base schema that every ConfigArray uses.
44
+ * @type {ObjectDefinition}
45
+ */
46
+ const baseSchema = Object.freeze({
47
+ name: {
48
+ required: false,
49
+ merge() {
50
+ return undefined;
51
+ },
52
+ validate(value) {
53
+ if (typeof value !== "string") {
54
+ throw new TypeError("Property must be a string.");
55
+ }
56
+ },
57
+ },
58
+ basePath: NOOP_STRATEGY,
59
+ files: NOOP_STRATEGY,
60
+ ignores: NOOP_STRATEGY,
61
+ });
62
+
63
+ /**
64
+ * @fileoverview ConfigSchema
65
+ * @author Nicholas C. Zakas
66
+ */
67
+
68
+ //------------------------------------------------------------------------------
69
+ // Types
70
+ //------------------------------------------------------------------------------
71
+
72
+
73
+ //------------------------------------------------------------------------------
74
+ // Helpers
75
+ //------------------------------------------------------------------------------
76
+
77
+ /**
78
+ * Asserts that a given value is an array.
79
+ * @param {*} value The value to check.
80
+ * @returns {void}
81
+ * @throws {TypeError} When the value is not an array.
82
+ */
83
+ function assertIsArray(value) {
84
+ if (!Array.isArray(value)) {
85
+ throw new TypeError("Expected value to be an array.");
86
+ }
87
+ }
88
+
89
+ /**
90
+ * Asserts that a given value is an array containing only strings and functions.
91
+ * @param {*} value The value to check.
92
+ * @returns {void}
93
+ * @throws {TypeError} When the value is not an array of strings and functions.
94
+ */
95
+ function assertIsArrayOfStringsAndFunctions(value) {
96
+ assertIsArray(value);
97
+
98
+ if (
99
+ value.some(
100
+ item => typeof item !== "string" && typeof item !== "function",
101
+ )
102
+ ) {
103
+ throw new TypeError(
104
+ "Expected array to only contain strings and functions.",
105
+ );
106
+ }
107
+ }
108
+
109
+ /**
110
+ * Asserts that a given value is a non-empty array.
111
+ * @param {*} value The value to check.
112
+ * @returns {void}
113
+ * @throws {TypeError} When the value is not an array or an empty array.
114
+ */
115
+ function assertIsNonEmptyArray(value) {
116
+ if (!Array.isArray(value) || value.length === 0) {
117
+ throw new TypeError("Expected value to be a non-empty array.");
118
+ }
119
+ }
120
+
121
+ //------------------------------------------------------------------------------
122
+ // Exports
123
+ //------------------------------------------------------------------------------
124
+
125
+ /**
126
+ * The schema for `files` and `ignores` that every ConfigArray uses.
127
+ * @type {ObjectDefinition}
128
+ */
129
+ const filesAndIgnoresSchema = Object.freeze({
130
+ basePath: {
131
+ required: false,
132
+ merge() {
133
+ return undefined;
134
+ },
135
+ validate(value) {
136
+ if (typeof value !== "string") {
137
+ throw new TypeError("Expected value to be a string.");
138
+ }
139
+ },
140
+ },
141
+ files: {
142
+ required: false,
143
+ merge() {
144
+ return undefined;
145
+ },
146
+ validate(value) {
147
+ // first check if it's an array
148
+ assertIsNonEmptyArray(value);
149
+
150
+ // then check each member
151
+ value.forEach(item => {
152
+ if (Array.isArray(item)) {
153
+ assertIsArrayOfStringsAndFunctions(item);
154
+ } else if (
155
+ typeof item !== "string" &&
156
+ typeof item !== "function"
157
+ ) {
158
+ throw new TypeError(
159
+ "Items must be a string, a function, or an array of strings and functions.",
160
+ );
161
+ }
162
+ });
163
+ },
164
+ },
165
+ ignores: {
166
+ required: false,
167
+ merge() {
168
+ return undefined;
169
+ },
170
+ validate: assertIsArrayOfStringsAndFunctions,
171
+ },
172
+ });
173
+
174
+ /**
175
+ * @fileoverview ConfigArray
176
+ * @author Nicholas C. Zakas
177
+ */
178
+
179
+
180
+ //------------------------------------------------------------------------------
181
+ // Types
182
+ //------------------------------------------------------------------------------
183
+
184
+ /** @import * as $typests from "./types.ts"; */
185
+ /** @typedef {$typests.ConfigObject} ConfigObject */
186
+ /** @import * as $minimatch from "minimatch"; */
187
+ /** @typedef {$minimatch.IMinimatchStatic} IMinimatchStatic */
188
+ /** @typedef {$minimatch.IMinimatch} IMinimatch */
189
+ /** @import * as PathImpl from "@jsr/std__path" */
190
+
191
+ /*
192
+ * This is a bit of a hack to make TypeScript happy with the Rollup-created
193
+ * CommonJS file. Rollup doesn't do object destructuring for imported files
194
+ * and instead imports the default via `require()`. This messes up type checking
195
+ * for `ObjectSchema`. To work around that, we just import the type manually
196
+ * and give it a different name to use in the JSDoc comments.
197
+ */
198
+ /** @typedef {ObjectSchema} ObjectSchemaInstance */
199
+
200
+ //------------------------------------------------------------------------------
201
+ // Helpers
202
+ //------------------------------------------------------------------------------
203
+
204
+ const Minimatch = minimatch.Minimatch;
205
+ const debug = createDebug("@eslint/config-array");
206
+
207
+ /**
208
+ * A cache for minimatch instances.
209
+ * @type {Map<string, IMinimatch>}
210
+ */
211
+ const minimatchCache = new Map();
212
+
213
+ /**
214
+ * A cache for negated minimatch instances.
215
+ * @type {Map<string, IMinimatch>}
216
+ */
217
+ const negatedMinimatchCache = new Map();
218
+
219
+ /**
220
+ * Options to use with minimatch.
221
+ * @type {Object}
222
+ */
223
+ const MINIMATCH_OPTIONS = {
224
+ // matchBase: true,
225
+ dot: true,
226
+ allowWindowsEscape: true,
227
+ };
228
+
229
+ /**
230
+ * The types of config objects that are supported.
231
+ * @type {Set<string>}
232
+ */
233
+ const CONFIG_TYPES = new Set(["array", "function"]);
234
+
235
+ /**
236
+ * Fields that are considered metadata and not part of the config object.
237
+ * @type {Set<string>}
238
+ */
239
+ const META_FIELDS = new Set(["name", "basePath"]);
240
+
241
+ /**
242
+ * A schema containing just files and ignores for early validation.
243
+ * @type {ObjectSchemaInstance}
244
+ */
245
+ const FILES_AND_IGNORES_SCHEMA = new ObjectSchema(filesAndIgnoresSchema);
246
+
247
+ // Precomputed constant objects returned by `ConfigArray.getConfigWithStatus`.
248
+
249
+ const CONFIG_WITH_STATUS_EXTERNAL = Object.freeze({ status: "external" });
250
+ const CONFIG_WITH_STATUS_IGNORED = Object.freeze({ status: "ignored" });
251
+ const CONFIG_WITH_STATUS_UNCONFIGURED = Object.freeze({
252
+ status: "unconfigured",
253
+ });
254
+
255
+ // Match two leading dots followed by a slash or the end of input.
256
+ const EXTERNAL_PATH_REGEX = /^\.\.(?:\/|$)/u;
257
+
258
+ /**
259
+ * Wrapper error for config validation errors that adds a name to the front of the
260
+ * error message.
261
+ */
262
+ class ConfigError extends Error {
263
+ /**
264
+ * Creates a new instance.
265
+ * @param {string} name The config object name causing the error.
266
+ * @param {number} index The index of the config object in the array.
267
+ * @param {Object} options The options for the error.
268
+ * @param {Error} [options.cause] The error that caused this error.
269
+ * @param {string} [options.message] The message to use for the error.
270
+ */
271
+ constructor(name, index, { cause, message }) {
272
+ const finalMessage = message || cause.message;
273
+
274
+ super(`Config ${name}: ${finalMessage}`, { cause });
275
+
276
+ // copy over custom properties that aren't represented
277
+ if (cause) {
278
+ for (const key of Object.keys(cause)) {
279
+ if (!(key in this)) {
280
+ this[key] = cause[key];
281
+ }
282
+ }
283
+ }
284
+
285
+ /**
286
+ * The name of the error.
287
+ * @type {string}
288
+ * @readonly
289
+ */
290
+ this.name = "ConfigError";
291
+
292
+ /**
293
+ * The index of the config object in the array.
294
+ * @type {number}
295
+ * @readonly
296
+ */
297
+ this.index = index;
298
+ }
299
+ }
300
+
301
+ /**
302
+ * Gets the name of a config object.
303
+ * @param {ConfigObject} config The config object to get the name of.
304
+ * @returns {string} The name of the config object.
305
+ */
306
+ function getConfigName(config) {
307
+ if (config && typeof config.name === "string" && config.name) {
308
+ return `"${config.name}"`;
309
+ }
310
+
311
+ return "(unnamed)";
312
+ }
313
+
314
+ /**
315
+ * Rethrows a config error with additional information about the config object.
316
+ * @param {object} config The config object to get the name of.
317
+ * @param {number} index The index of the config object in the array.
318
+ * @param {Error} error The error to rethrow.
319
+ * @throws {ConfigError} When the error is rethrown for a config.
320
+ */
321
+ function rethrowConfigError(config, index, error) {
322
+ const configName = getConfigName(config);
323
+ throw new ConfigError(configName, index, { cause: error });
324
+ }
325
+
326
+ /**
327
+ * Shorthand for checking if a value is a string.
328
+ * @param {any} value The value to check.
329
+ * @returns {boolean} True if a string, false if not.
330
+ */
331
+ function isString(value) {
332
+ return typeof value === "string";
333
+ }
334
+
335
+ /**
336
+ * Creates a function that asserts that the config is valid
337
+ * during normalization. This checks that the config is not nullish
338
+ * and that files and ignores keys of a config object are valid as per base schema.
339
+ * @param {Object} config The config object to check.
340
+ * @param {number} index The index of the config object in the array.
341
+ * @returns {void}
342
+ * @throws {ConfigError} If the files and ignores keys of a config object are not valid.
343
+ */
344
+ function assertValidBaseConfig(config, index) {
345
+ if (config === null) {
346
+ throw new ConfigError(getConfigName(config), index, {
347
+ message: "Unexpected null config.",
348
+ });
349
+ }
350
+
351
+ if (config === undefined) {
352
+ throw new ConfigError(getConfigName(config), index, {
353
+ message: "Unexpected undefined config.",
354
+ });
355
+ }
356
+
357
+ if (typeof config !== "object") {
358
+ throw new ConfigError(getConfigName(config), index, {
359
+ message: "Unexpected non-object config.",
360
+ });
361
+ }
362
+
363
+ const validateConfig = {};
364
+
365
+ if ("basePath" in config) {
366
+ validateConfig.basePath = config.basePath;
367
+ }
368
+
369
+ if ("files" in config) {
370
+ validateConfig.files = config.files;
371
+ }
372
+
373
+ if ("ignores" in config) {
374
+ validateConfig.ignores = config.ignores;
375
+ }
376
+
377
+ try {
378
+ FILES_AND_IGNORES_SCHEMA.validate(validateConfig);
379
+ } catch (validationError) {
380
+ rethrowConfigError(config, index, validationError);
381
+ }
382
+ }
383
+
384
+ /**
385
+ * Wrapper around minimatch that caches minimatch patterns for
386
+ * faster matching speed over multiple file path evaluations.
387
+ * @param {string} filepath The file path to match.
388
+ * @param {string} pattern The glob pattern to match against.
389
+ * @param {object} options The minimatch options to use.
390
+ * @returns
391
+ */
392
+ function doMatch(filepath, pattern, options = {}) {
393
+ let cache = minimatchCache;
394
+
395
+ if (options.flipNegate) {
396
+ cache = negatedMinimatchCache;
397
+ }
398
+
399
+ let matcher = cache.get(pattern);
400
+
401
+ if (!matcher) {
402
+ matcher = new Minimatch(
403
+ pattern,
404
+ Object.assign({}, MINIMATCH_OPTIONS, options),
405
+ );
406
+ cache.set(pattern, matcher);
407
+ }
408
+
409
+ return matcher.match(filepath);
410
+ }
411
+
412
+ /**
413
+ * Normalizes a pattern by removing the leading "./" if present.
414
+ * @param {string} pattern The pattern to normalize.
415
+ * @returns {string} The normalized pattern.
416
+ */
417
+ function normalizePattern(pattern) {
418
+ if (isString(pattern)) {
419
+ if (pattern.startsWith("./")) {
420
+ return pattern.slice(2);
421
+ }
422
+
423
+ if (pattern.startsWith("!./")) {
424
+ return `!${pattern.slice(3)}`;
425
+ }
426
+ }
427
+
428
+ return pattern;
429
+ }
430
+
431
+ /**
432
+ * Checks if a given pattern requires normalization.
433
+ * @param {any} pattern The pattern to check.
434
+ * @returns {boolean} True if the pattern needs normalization, false otherwise.
435
+ *
436
+ */
437
+ function needsPatternNormalization(pattern) {
438
+ return (
439
+ isString(pattern) &&
440
+ (pattern.startsWith("./") || pattern.startsWith("!./"))
441
+ );
442
+ }
443
+
444
+ /**
445
+ * Normalizes `files` and `ignores` patterns in a config by removing "./" prefixes.
446
+ * @param {Object} config The config object to normalize patterns in.
447
+ * @param {string} namespacedBasePath The namespaced base path of the directory to which config base path is relative.
448
+ * @param {PathImpl} path Path-handling implementation.
449
+ * @returns {Object} The normalized config object.
450
+ */
451
+ function normalizeConfigPatterns(config, namespacedBasePath, path) {
452
+ if (!config) {
453
+ return config;
454
+ }
455
+
456
+ const hasBasePath = typeof config.basePath === "string";
457
+
458
+ let needsNormalization = false;
459
+
460
+ if (hasBasePath) {
461
+ needsNormalization = true;
462
+ }
463
+
464
+ if (!needsNormalization && Array.isArray(config.files)) {
465
+ needsNormalization = config.files.some(pattern => {
466
+ if (Array.isArray(pattern)) {
467
+ return pattern.some(needsPatternNormalization);
468
+ }
469
+ return needsPatternNormalization(pattern);
470
+ });
471
+ }
472
+
473
+ if (!needsNormalization && Array.isArray(config.ignores)) {
474
+ needsNormalization = config.ignores.some(needsPatternNormalization);
475
+ }
476
+
477
+ if (!needsNormalization) {
478
+ return config;
479
+ }
480
+
481
+ const newConfig = { ...config };
482
+
483
+ if (hasBasePath) {
484
+ if (path.isAbsolute(config.basePath)) {
485
+ newConfig.basePath = path.toNamespacedPath(config.basePath);
486
+ } else {
487
+ newConfig.basePath = path.resolve(
488
+ namespacedBasePath,
489
+ config.basePath,
490
+ );
491
+ }
492
+ }
493
+
494
+ if (Array.isArray(newConfig.files)) {
495
+ newConfig.files = newConfig.files.map(pattern => {
496
+ if (Array.isArray(pattern)) {
497
+ return pattern.map(normalizePattern);
498
+ }
499
+ return normalizePattern(pattern);
500
+ });
501
+ }
502
+
503
+ if (Array.isArray(newConfig.ignores)) {
504
+ newConfig.ignores = newConfig.ignores.map(normalizePattern);
505
+ }
506
+
507
+ return newConfig;
508
+ }
509
+
510
+ /**
511
+ * Normalizes a `ConfigArray` by flattening it and executing any functions
512
+ * that are found inside.
513
+ * @param {Array} items The items in a `ConfigArray`.
514
+ * @param {Object} context The context object to pass into any function
515
+ * found.
516
+ * @param {Array<string>} extraConfigTypes The config types to check.
517
+ * @param {string} namespacedBasePath The namespaced base path of the directory to which config base paths are relative.
518
+ * @param {PathImpl} path Path-handling implementation.
519
+ * @returns {Promise<Array>} A flattened array containing only config objects.
520
+ * @throws {TypeError} When a config function returns a function.
521
+ */
522
+ async function normalize(
523
+ items,
524
+ context,
525
+ extraConfigTypes,
526
+ namespacedBasePath,
527
+ path,
528
+ ) {
529
+ const allowFunctions = extraConfigTypes.includes("function");
530
+ const allowArrays = extraConfigTypes.includes("array");
531
+
532
+ async function* flatTraverse(array) {
533
+ for (let item of array) {
534
+ if (typeof item === "function") {
535
+ if (!allowFunctions) {
536
+ throw new TypeError("Unexpected function.");
537
+ }
538
+
539
+ item = item(context);
540
+ if (item.then) {
541
+ item = await item;
542
+ }
543
+ }
544
+
545
+ if (Array.isArray(item)) {
546
+ if (!allowArrays) {
547
+ throw new TypeError("Unexpected array.");
548
+ }
549
+ yield* flatTraverse(item);
550
+ } else if (typeof item === "function") {
551
+ throw new TypeError(
552
+ "A config function can only return an object or array.",
553
+ );
554
+ } else {
555
+ yield item;
556
+ }
557
+ }
558
+ }
559
+
560
+ /*
561
+ * Async iterables cannot be used with the spread operator, so we need to manually
562
+ * create the array to return.
563
+ */
564
+ const asyncIterable = await flatTraverse(items);
565
+ const configs = [];
566
+
567
+ for await (const config of asyncIterable) {
568
+ configs.push(normalizeConfigPatterns(config, namespacedBasePath, path));
569
+ }
570
+
571
+ return configs;
572
+ }
573
+
574
+ /**
575
+ * Normalizes a `ConfigArray` by flattening it and executing any functions
576
+ * that are found inside.
577
+ * @param {Array} items The items in a `ConfigArray`.
578
+ * @param {Object} context The context object to pass into any function
579
+ * found.
580
+ * @param {Array<string>} extraConfigTypes The config types to check.
581
+ * @param {string} namespacedBasePath The namespaced base path of the directory to which config base paths are relative.
582
+ * @param {PathImpl} path Path-handling implementation
583
+ * @returns {Array} A flattened array containing only config objects.
584
+ * @throws {TypeError} When a config function returns a function.
585
+ */
586
+ function normalizeSync(
587
+ items,
588
+ context,
589
+ extraConfigTypes,
590
+ namespacedBasePath,
591
+ path,
592
+ ) {
593
+ const allowFunctions = extraConfigTypes.includes("function");
594
+ const allowArrays = extraConfigTypes.includes("array");
595
+
596
+ function* flatTraverse(array) {
597
+ for (let item of array) {
598
+ if (typeof item === "function") {
599
+ if (!allowFunctions) {
600
+ throw new TypeError("Unexpected function.");
601
+ }
602
+
603
+ item = item(context);
604
+ if (item.then) {
605
+ throw new TypeError(
606
+ "Async config functions are not supported.",
607
+ );
608
+ }
609
+ }
610
+
611
+ if (Array.isArray(item)) {
612
+ if (!allowArrays) {
613
+ throw new TypeError("Unexpected array.");
614
+ }
615
+
616
+ yield* flatTraverse(item);
617
+ } else if (typeof item === "function") {
618
+ throw new TypeError(
619
+ "A config function can only return an object or array.",
620
+ );
621
+ } else {
622
+ yield item;
623
+ }
624
+ }
625
+ }
626
+
627
+ const configs = [];
628
+
629
+ for (const config of flatTraverse(items)) {
630
+ configs.push(normalizeConfigPatterns(config, namespacedBasePath, path));
631
+ }
632
+
633
+ return configs;
634
+ }
635
+
636
+ /**
637
+ * Converts a given path to a relative path with all separator characters replaced by forward slashes (`"/"`).
638
+ * @param {string} fileOrDirPath The unprocessed path to convert.
639
+ * @param {string} namespacedBasePath The namespaced base path of the directory to which the calculated path shall be relative.
640
+ * @param {PathImpl} path Path-handling implementations.
641
+ * @returns {string} A relative path with all separator characters replaced by forward slashes.
642
+ */
643
+ function toRelativePath(fileOrDirPath, namespacedBasePath, path) {
644
+ const fullPath = path.resolve(namespacedBasePath, fileOrDirPath);
645
+ const namespacedFullPath = path.toNamespacedPath(fullPath);
646
+ const relativePath = path.relative(namespacedBasePath, namespacedFullPath);
647
+ return relativePath.replaceAll(path.SEPARATOR, "/");
648
+ }
649
+
650
+ /**
651
+ * Determines if a given file path should be ignored based on the given
652
+ * matcher.
653
+ * @param {Array<{ basePath?: string, ignores: Array<string|((string) => boolean)>}>} configs Configuration objects containing `ignores`.
654
+ * @param {string} filePath The unprocessed file path to check.
655
+ * @param {string} relativeFilePath The path of the file to check relative to the base path,
656
+ * using forward slash (`"/"`) as a separator.
657
+ * @param {Object} [basePathData] Additional data needed to recalculate paths for configuration objects
658
+ * that have `basePath` property.
659
+ * @param {string} [basePathData.basePath] Namespaced path to witch `relativeFilePath` is relative.
660
+ * @param {PathImpl} [basePathData.path] Path-handling implementation.
661
+ * @returns {boolean} True if the path should be ignored and false if not.
662
+ */
663
+ function shouldIgnorePath(
664
+ configs,
665
+ filePath,
666
+ relativeFilePath,
667
+ { basePath, path } = {},
668
+ ) {
669
+ let shouldIgnore = false;
670
+
671
+ for (const config of configs) {
672
+ let relativeFilePathToCheck = relativeFilePath;
673
+ if (config.basePath) {
674
+ relativeFilePathToCheck = toRelativePath(
675
+ path.resolve(basePath, relativeFilePath),
676
+ config.basePath,
677
+ path,
678
+ );
679
+
680
+ if (
681
+ relativeFilePathToCheck === "" ||
682
+ EXTERNAL_PATH_REGEX.test(relativeFilePathToCheck)
683
+ ) {
684
+ continue;
685
+ }
686
+
687
+ if (relativeFilePath.endsWith("/")) {
688
+ relativeFilePathToCheck += "/";
689
+ }
690
+ }
691
+ shouldIgnore = config.ignores.reduce((ignored, matcher) => {
692
+ if (!ignored) {
693
+ if (typeof matcher === "function") {
694
+ return matcher(filePath);
695
+ }
696
+
697
+ // don't check negated patterns because we're not ignored yet
698
+ if (!matcher.startsWith("!")) {
699
+ return doMatch(relativeFilePathToCheck, matcher);
700
+ }
701
+
702
+ // otherwise we're still not ignored
703
+ return false;
704
+ }
705
+
706
+ // only need to check negated patterns because we're ignored
707
+ if (typeof matcher === "string" && matcher.startsWith("!")) {
708
+ return !doMatch(relativeFilePathToCheck, matcher, {
709
+ flipNegate: true,
710
+ });
711
+ }
712
+
713
+ return ignored;
714
+ }, shouldIgnore);
715
+ }
716
+
717
+ return shouldIgnore;
718
+ }
719
+
720
+ /**
721
+ * Determines if a given file path is matched by a config. If the config
722
+ * has no `files` field, then it matches; otherwise, if a `files` field
723
+ * is present then we match the globs in `files` and exclude any globs in
724
+ * `ignores`.
725
+ * @param {string} filePath The unprocessed file path to check.
726
+ * @param {string} relativeFilePath The path of the file to check relative to the base path,
727
+ * using forward slash (`"/"`) as a separator.
728
+ * @param {Object} config The config object to check.
729
+ * @returns {boolean} True if the file path is matched by the config,
730
+ * false if not.
731
+ */
732
+ function pathMatches(filePath, relativeFilePath, config) {
733
+ // match both strings and functions
734
+ function match(pattern) {
735
+ if (isString(pattern)) {
736
+ return doMatch(relativeFilePath, pattern);
737
+ }
738
+
739
+ if (typeof pattern === "function") {
740
+ return pattern(filePath);
741
+ }
742
+
743
+ throw new TypeError(`Unexpected matcher type ${pattern}.`);
744
+ }
745
+
746
+ // check for all matches to config.files
747
+ let filePathMatchesPattern = config.files.some(pattern => {
748
+ if (Array.isArray(pattern)) {
749
+ return pattern.every(match);
750
+ }
751
+
752
+ return match(pattern);
753
+ });
754
+
755
+ /*
756
+ * If the file path matches the config.files patterns, then check to see
757
+ * if there are any files to ignore.
758
+ */
759
+ if (filePathMatchesPattern && config.ignores) {
760
+ /*
761
+ * Pass config object without `basePath`, because `relativeFilePath` is already
762
+ * calculated as relative to it.
763
+ */
764
+ filePathMatchesPattern = !shouldIgnorePath(
765
+ [{ ignores: config.ignores }],
766
+ filePath,
767
+ relativeFilePath,
768
+ );
769
+ }
770
+
771
+ return filePathMatchesPattern;
772
+ }
773
+
774
+ /**
775
+ * Ensures that a ConfigArray has been normalized.
776
+ * @param {ConfigArray} configArray The ConfigArray to check.
777
+ * @returns {void}
778
+ * @throws {Error} When the `ConfigArray` is not normalized.
779
+ */
780
+ function assertNormalized(configArray) {
781
+ // TODO: Throw more verbose error
782
+ if (!configArray.isNormalized()) {
783
+ throw new Error(
784
+ "ConfigArray must be normalized to perform this operation.",
785
+ );
786
+ }
787
+ }
788
+
789
+ /**
790
+ * Ensures that config types are valid.
791
+ * @param {Array<string>} extraConfigTypes The config types to check.
792
+ * @returns {void}
793
+ * @throws {TypeError} When the config types array is invalid.
794
+ */
795
+ function assertExtraConfigTypes(extraConfigTypes) {
796
+ if (extraConfigTypes.length > 2) {
797
+ throw new TypeError(
798
+ "configTypes must be an array with at most two items.",
799
+ );
800
+ }
801
+
802
+ for (const configType of extraConfigTypes) {
803
+ if (!CONFIG_TYPES.has(configType)) {
804
+ throw new TypeError(
805
+ `Unexpected config type "${configType}" found. Expected one of: "object", "array", "function".`,
806
+ );
807
+ }
808
+ }
809
+ }
810
+
811
+ /**
812
+ * Returns path-handling implementations for Unix or Windows, depending on a given absolute path.
813
+ * @param {string} fileOrDirPath The absolute path to check.
814
+ * @returns {PathImpl} Path-handling implementations for the specified path.
815
+ * @throws {Error} An error is thrown if the specified argument is not an absolute path.
816
+ */
817
+ function getPathImpl(fileOrDirPath) {
818
+ // Posix absolute paths always start with a slash.
819
+ if (fileOrDirPath.startsWith("/")) {
820
+ return posixPath;
821
+ }
822
+
823
+ // Windows absolute paths start with a letter followed by a colon and at least one backslash,
824
+ // or with two backslashes in the case of UNC paths.
825
+ // Forward slashed are automatically normalized to backslashes.
826
+ if (/^(?:[A-Za-z]:[/\\]|[/\\]{2})/u.test(fileOrDirPath)) {
827
+ return windowsPath;
828
+ }
829
+
830
+ throw new Error(
831
+ `Expected an absolute path but received "${fileOrDirPath}"`,
832
+ );
833
+ }
834
+
835
+ //------------------------------------------------------------------------------
836
+ // Public Interface
837
+ //------------------------------------------------------------------------------
838
+
839
+ const ConfigArraySymbol = {
840
+ isNormalized: Symbol("isNormalized"),
841
+ configCache: Symbol("configCache"),
842
+ schema: Symbol("schema"),
843
+ finalizeConfig: Symbol("finalizeConfig"),
844
+ preprocessConfig: Symbol("preprocessConfig"),
845
+ };
846
+
847
+ // used to store calculate data for faster lookup
848
+ const dataCache = new WeakMap();
849
+
850
+ /**
851
+ * Represents an array of config objects and provides method for working with
852
+ * those config objects.
853
+ */
854
+ class ConfigArray extends Array {
855
+ /**
856
+ * The namespaced path of the config file directory.
857
+ * @type {string}
858
+ */
859
+ #namespacedBasePath;
860
+
861
+ /**
862
+ * Path-handling implementations.
863
+ * @type {PathImpl}
864
+ */
865
+ #path;
866
+
867
+ /**
868
+ * Creates a new instance of ConfigArray.
869
+ * @param {Iterable|Function|Object} configs An iterable yielding config
870
+ * objects, or a config function, or a config object.
871
+ * @param {Object} options The options for the ConfigArray.
872
+ * @param {string} [options.basePath="/"] The absolute path of the config file directory.
873
+ * Defaults to `"/"`.
874
+ * @param {boolean} [options.normalized=false] Flag indicating if the
875
+ * configs have already been normalized.
876
+ * @param {Object} [options.schema] The additional schema
877
+ * definitions to use for the ConfigArray schema.
878
+ * @param {Array<string>} [options.extraConfigTypes] List of config types supported.
879
+ * @throws {TypeError} When the `basePath` is not a non-empty string,
880
+ */
881
+ constructor(
882
+ configs,
883
+ {
884
+ basePath = "/",
885
+ normalized = false,
886
+ schema: customSchema,
887
+ extraConfigTypes = [],
888
+ } = {},
889
+ ) {
890
+ super();
891
+
892
+ /**
893
+ * Tracks if the array has been normalized.
894
+ * @property isNormalized
895
+ * @type {boolean}
896
+ * @private
897
+ */
898
+ this[ConfigArraySymbol.isNormalized] = normalized;
899
+
900
+ /**
901
+ * The schema used for validating and merging configs.
902
+ * @property schema
903
+ * @type {ObjectSchemaInstance}
904
+ * @private
905
+ */
906
+ this[ConfigArraySymbol.schema] = new ObjectSchema(
907
+ Object.assign({}, customSchema, baseSchema),
908
+ );
909
+
910
+ if (!isString(basePath) || !basePath) {
911
+ throw new TypeError("basePath must be a non-empty string");
912
+ }
913
+
914
+ /**
915
+ * The path of the config file that this array was loaded from.
916
+ * This is used to calculate filename matches.
917
+ * @property basePath
918
+ * @type {string}
919
+ */
920
+ this.basePath = basePath;
921
+
922
+ assertExtraConfigTypes(extraConfigTypes);
923
+
924
+ /**
925
+ * The supported config types.
926
+ * @type {Array<string>}
927
+ */
928
+ this.extraConfigTypes = [...extraConfigTypes];
929
+ Object.freeze(this.extraConfigTypes);
930
+
931
+ /**
932
+ * A cache to store calculated configs for faster repeat lookup.
933
+ * @property configCache
934
+ * @type {Map<string, Object>}
935
+ * @private
936
+ */
937
+ this[ConfigArraySymbol.configCache] = new Map();
938
+
939
+ // init cache
940
+ dataCache.set(this, {
941
+ explicitMatches: new Map(),
942
+ directoryMatches: new Map(),
943
+ files: undefined,
944
+ ignores: undefined,
945
+ });
946
+
947
+ // load the configs into this array
948
+ if (Array.isArray(configs)) {
949
+ this.push(...configs);
950
+ } else {
951
+ this.push(configs);
952
+ }
953
+
954
+ // select path-handling implementations depending on the base path
955
+ this.#path = getPathImpl(basePath);
956
+
957
+ // On Windows, `path.relative()` returns an absolute path when given two paths on different drives.
958
+ // The namespaced base path is useful to make sure that calculated relative paths are always relative.
959
+ // On Unix, it is identical to the base path.
960
+ this.#namespacedBasePath = this.#path.toNamespacedPath(basePath);
961
+ }
962
+
963
+ /**
964
+ * Prevent normal array methods from creating a new `ConfigArray` instance.
965
+ * This is to ensure that methods such as `slice()` won't try to create a
966
+ * new instance of `ConfigArray` behind the scenes as doing so may throw
967
+ * an error due to the different constructor signature.
968
+ * @type {ArrayConstructor} The `Array` constructor.
969
+ */
970
+ static get [Symbol.species]() {
971
+ return Array;
972
+ }
973
+
974
+ /**
975
+ * Returns the `files` globs from every config object in the array.
976
+ * This can be used to determine which files will be matched by a
977
+ * config array or to use as a glob pattern when no patterns are provided
978
+ * for a command line interface.
979
+ * @returns {Array<string|Function>} An array of matchers.
980
+ */
981
+ get files() {
982
+ assertNormalized(this);
983
+
984
+ // if this data has been cached, retrieve it
985
+ const cache = dataCache.get(this);
986
+
987
+ if (cache.files) {
988
+ return cache.files;
989
+ }
990
+
991
+ // otherwise calculate it
992
+
993
+ const result = [];
994
+
995
+ for (const config of this) {
996
+ if (config.files) {
997
+ config.files.forEach(filePattern => {
998
+ result.push(filePattern);
999
+ });
1000
+ }
1001
+ }
1002
+
1003
+ // store result
1004
+ cache.files = result;
1005
+ dataCache.set(this, cache);
1006
+
1007
+ return result;
1008
+ }
1009
+
1010
+ /**
1011
+ * Returns ignore matchers that should always be ignored regardless of
1012
+ * the matching `files` fields in any configs. This is necessary to mimic
1013
+ * the behavior of things like .gitignore and .eslintignore, allowing a
1014
+ * globbing operation to be faster.
1015
+ * @returns {Object[]} An array of config objects representing global ignores.
1016
+ */
1017
+ get ignores() {
1018
+ assertNormalized(this);
1019
+
1020
+ // if this data has been cached, retrieve it
1021
+ const cache = dataCache.get(this);
1022
+
1023
+ if (cache.ignores) {
1024
+ return cache.ignores;
1025
+ }
1026
+
1027
+ // otherwise calculate it
1028
+
1029
+ const result = [];
1030
+
1031
+ for (const config of this) {
1032
+ /*
1033
+ * We only count ignores if there are no other keys in the object.
1034
+ * In this case, it acts list a globally ignored pattern. If there
1035
+ * are additional keys, then ignores act like exclusions.
1036
+ */
1037
+ if (
1038
+ config.ignores &&
1039
+ Object.keys(config).filter(key => !META_FIELDS.has(key))
1040
+ .length === 1
1041
+ ) {
1042
+ result.push(config);
1043
+ }
1044
+ }
1045
+
1046
+ // store result
1047
+ cache.ignores = result;
1048
+ dataCache.set(this, cache);
1049
+
1050
+ return result;
1051
+ }
1052
+
1053
+ /**
1054
+ * Indicates if the config array has been normalized.
1055
+ * @returns {boolean} True if the config array is normalized, false if not.
1056
+ */
1057
+ isNormalized() {
1058
+ return this[ConfigArraySymbol.isNormalized];
1059
+ }
1060
+
1061
+ /**
1062
+ * Normalizes a config array by flattening embedded arrays and executing
1063
+ * config functions.
1064
+ * @param {Object} [context] The context object for config functions.
1065
+ * @returns {Promise<ConfigArray>} The current ConfigArray instance.
1066
+ */
1067
+ async normalize(context = {}) {
1068
+ if (!this.isNormalized()) {
1069
+ const normalizedConfigs = await normalize(
1070
+ this,
1071
+ context,
1072
+ this.extraConfigTypes,
1073
+ this.#namespacedBasePath,
1074
+ this.#path,
1075
+ );
1076
+ this.length = 0;
1077
+ this.push(
1078
+ ...normalizedConfigs.map(
1079
+ this[ConfigArraySymbol.preprocessConfig].bind(this),
1080
+ ),
1081
+ );
1082
+ this.forEach(assertValidBaseConfig);
1083
+ this[ConfigArraySymbol.isNormalized] = true;
1084
+
1085
+ // prevent further changes
1086
+ Object.freeze(this);
1087
+ }
1088
+
1089
+ return this;
1090
+ }
1091
+
1092
+ /**
1093
+ * Normalizes a config array by flattening embedded arrays and executing
1094
+ * config functions.
1095
+ * @param {Object} [context] The context object for config functions.
1096
+ * @returns {ConfigArray} The current ConfigArray instance.
1097
+ */
1098
+ normalizeSync(context = {}) {
1099
+ if (!this.isNormalized()) {
1100
+ const normalizedConfigs = normalizeSync(
1101
+ this,
1102
+ context,
1103
+ this.extraConfigTypes,
1104
+ this.#namespacedBasePath,
1105
+ this.#path,
1106
+ );
1107
+ this.length = 0;
1108
+ this.push(
1109
+ ...normalizedConfigs.map(
1110
+ this[ConfigArraySymbol.preprocessConfig].bind(this),
1111
+ ),
1112
+ );
1113
+ this.forEach(assertValidBaseConfig);
1114
+ this[ConfigArraySymbol.isNormalized] = true;
1115
+
1116
+ // prevent further changes
1117
+ Object.freeze(this);
1118
+ }
1119
+
1120
+ return this;
1121
+ }
1122
+
1123
+ /* eslint-disable class-methods-use-this -- Desired as instance methods */
1124
+
1125
+ /**
1126
+ * Finalizes the state of a config before being cached and returned by
1127
+ * `getConfig()`. Does nothing by default but is provided to be
1128
+ * overridden by subclasses as necessary.
1129
+ * @param {Object} config The config to finalize.
1130
+ * @returns {Object} The finalized config.
1131
+ */
1132
+ // Cast key to `never` to prevent TypeScript from adding the signature `[x: symbol]: (config: any) => any` to the type of the class.
1133
+ [/** @type {never} */ (ConfigArraySymbol.finalizeConfig)](config) {
1134
+ return config;
1135
+ }
1136
+
1137
+ /**
1138
+ * Preprocesses a config during the normalization process. This is the
1139
+ * method to override if you want to convert an array item before it is
1140
+ * validated for the first time. For example, if you want to replace a
1141
+ * string with an object, this is the method to override.
1142
+ * @param {Object} config The config to preprocess.
1143
+ * @returns {Object} The config to use in place of the argument.
1144
+ */
1145
+ // Cast key to `never` to prevent TypeScript from adding the signature `[x: symbol]: (config: any) => any` to the type of the class.
1146
+ [/** @type {never} */ (ConfigArraySymbol.preprocessConfig)](config) {
1147
+ return config;
1148
+ }
1149
+
1150
+ /* eslint-enable class-methods-use-this -- Desired as instance methods */
1151
+
1152
+ /**
1153
+ * Returns the config object for a given file path and a status that can be used to determine why a file has no config.
1154
+ * @param {string} filePath The path of a file to get a config for.
1155
+ * @returns {{ config?: Object, status: "ignored"|"external"|"unconfigured"|"matched" }}
1156
+ * An object with an optional property `config` and property `status`.
1157
+ * `config` is the config object for the specified file as returned by {@linkcode ConfigArray.getConfig},
1158
+ * `status` a is one of the constants returned by {@linkcode ConfigArray.getConfigStatus}.
1159
+ */
1160
+ getConfigWithStatus(filePath) {
1161
+ assertNormalized(this);
1162
+
1163
+ const cache = this[ConfigArraySymbol.configCache];
1164
+
1165
+ // first check the cache for a filename match to avoid duplicate work
1166
+ if (cache.has(filePath)) {
1167
+ return cache.get(filePath);
1168
+ }
1169
+
1170
+ // check to see if the file is outside the base path
1171
+
1172
+ const relativeToBaseFilePath = toRelativePath(
1173
+ filePath,
1174
+ this.#namespacedBasePath,
1175
+ this.#path,
1176
+ );
1177
+
1178
+ if (EXTERNAL_PATH_REGEX.test(relativeToBaseFilePath)) {
1179
+ debug(`No config for file ${filePath} outside of base path`);
1180
+
1181
+ // cache and return result
1182
+ cache.set(filePath, CONFIG_WITH_STATUS_EXTERNAL);
1183
+ return CONFIG_WITH_STATUS_EXTERNAL;
1184
+ }
1185
+
1186
+ // next check to see if the file should be ignored
1187
+
1188
+ // check if this should be ignored due to its directory
1189
+ if (this.isDirectoryIgnored(this.#path.dirname(filePath))) {
1190
+ debug(`Ignoring ${filePath} based on directory pattern`);
1191
+
1192
+ // cache and return result
1193
+ cache.set(filePath, CONFIG_WITH_STATUS_IGNORED);
1194
+ return CONFIG_WITH_STATUS_IGNORED;
1195
+ }
1196
+
1197
+ if (
1198
+ shouldIgnorePath(this.ignores, filePath, relativeToBaseFilePath, {
1199
+ basePath: this.#namespacedBasePath,
1200
+ path: this.#path,
1201
+ })
1202
+ ) {
1203
+ debug(`Ignoring ${filePath} based on file pattern`);
1204
+
1205
+ // cache and return result
1206
+ cache.set(filePath, CONFIG_WITH_STATUS_IGNORED);
1207
+ return CONFIG_WITH_STATUS_IGNORED;
1208
+ }
1209
+
1210
+ // filePath isn't automatically ignored, so try to construct config
1211
+
1212
+ const matchingConfigIndices = [];
1213
+ let matchFound = false;
1214
+ const universalPattern = /^\*$|^!|\/\*{1,2}$/u;
1215
+
1216
+ this.forEach((config, index) => {
1217
+ const relativeFilePath = config.basePath
1218
+ ? toRelativePath(
1219
+ this.#path.resolve(this.#namespacedBasePath, filePath),
1220
+ config.basePath,
1221
+ this.#path,
1222
+ )
1223
+ : relativeToBaseFilePath;
1224
+
1225
+ if (config.basePath && EXTERNAL_PATH_REGEX.test(relativeFilePath)) {
1226
+ debug(
1227
+ `Skipped config found for ${filePath} (based on config's base path: ${config.basePath}`,
1228
+ );
1229
+ return;
1230
+ }
1231
+
1232
+ if (!config.files) {
1233
+ if (!config.ignores) {
1234
+ debug(`Universal config found for ${filePath}`);
1235
+ matchingConfigIndices.push(index);
1236
+ return;
1237
+ }
1238
+
1239
+ if (
1240
+ Object.keys(config).filter(key => !META_FIELDS.has(key))
1241
+ .length === 1
1242
+ ) {
1243
+ debug(
1244
+ `Skipped config found for ${filePath} (global ignores)`,
1245
+ );
1246
+ return;
1247
+ }
1248
+
1249
+ /*
1250
+ * Pass config object without `basePath`, because `relativeFilePath` is already
1251
+ * calculated as relative to it.
1252
+ */
1253
+ if (
1254
+ shouldIgnorePath(
1255
+ [{ ignores: config.ignores }],
1256
+ filePath,
1257
+ relativeFilePath,
1258
+ )
1259
+ ) {
1260
+ debug(
1261
+ `Skipped config found for ${filePath} (based on ignores: ${config.ignores})`,
1262
+ );
1263
+ return;
1264
+ }
1265
+
1266
+ debug(
1267
+ `Matching config found for ${filePath} (based on ignores: ${config.ignores})`,
1268
+ );
1269
+ matchingConfigIndices.push(index);
1270
+ return;
1271
+ }
1272
+
1273
+ /*
1274
+ * If a config has a files pattern * or patterns ending in /** or /*,
1275
+ * and the filePath only matches those patterns, then the config is only
1276
+ * applied if there is another config where the filePath matches
1277
+ * a file with a specific extensions such as *.js.
1278
+ */
1279
+
1280
+ const nonUniversalFiles = [];
1281
+ const universalFiles = config.files.filter(element => {
1282
+ if (Array.isArray(element)) {
1283
+ /*
1284
+ * filePath matches an element that is an array only if it matches
1285
+ * all patterns in it (AND operation). Therefore, if there is at least
1286
+ * one non-universal pattern in the array, and filePath matches the array,
1287
+ * then we know for sure that filePath matches at least one non-universal
1288
+ * pattern, so we can consider the entire array to be non-universal.
1289
+ * In other words, all patterns in the array need to be universal
1290
+ * for it to be considered universal.
1291
+ */
1292
+ if (
1293
+ element.every(pattern => universalPattern.test(pattern))
1294
+ ) {
1295
+ return true;
1296
+ }
1297
+
1298
+ nonUniversalFiles.push(element);
1299
+ return false;
1300
+ }
1301
+
1302
+ // element is a string
1303
+
1304
+ if (universalPattern.test(element)) {
1305
+ return true;
1306
+ }
1307
+
1308
+ nonUniversalFiles.push(element);
1309
+ return false;
1310
+ });
1311
+
1312
+ // universal patterns were found so we need to check the config twice
1313
+ if (universalFiles.length) {
1314
+ debug("Universal files patterns found. Checking carefully.");
1315
+
1316
+ // check that the config matches without the non-universal files first
1317
+ if (
1318
+ nonUniversalFiles.length &&
1319
+ pathMatches(filePath, relativeFilePath, {
1320
+ files: nonUniversalFiles,
1321
+ ignores: config.ignores,
1322
+ })
1323
+ ) {
1324
+ debug(`Matching config found for ${filePath}`);
1325
+ matchingConfigIndices.push(index);
1326
+ matchFound = true;
1327
+ return;
1328
+ }
1329
+
1330
+ // if there wasn't a match then check if it matches with universal files
1331
+ if (
1332
+ universalFiles.length &&
1333
+ pathMatches(filePath, relativeFilePath, {
1334
+ files: universalFiles,
1335
+ ignores: config.ignores,
1336
+ })
1337
+ ) {
1338
+ debug(`Matching config found for ${filePath}`);
1339
+ matchingConfigIndices.push(index);
1340
+ return;
1341
+ }
1342
+
1343
+ // if we make here, then there was no match
1344
+ return;
1345
+ }
1346
+
1347
+ // the normal case
1348
+ if (pathMatches(filePath, relativeFilePath, config)) {
1349
+ debug(`Matching config found for ${filePath}`);
1350
+ matchingConfigIndices.push(index);
1351
+ matchFound = true;
1352
+ }
1353
+ });
1354
+
1355
+ // if matching both files and ignores, there will be no config to create
1356
+ if (!matchFound) {
1357
+ debug(`No matching configs found for ${filePath}`);
1358
+
1359
+ // cache and return result
1360
+ cache.set(filePath, CONFIG_WITH_STATUS_UNCONFIGURED);
1361
+ return CONFIG_WITH_STATUS_UNCONFIGURED;
1362
+ }
1363
+
1364
+ // check to see if there is a config cached by indices
1365
+ const indicesKey = matchingConfigIndices.toString();
1366
+ let configWithStatus = cache.get(indicesKey);
1367
+
1368
+ if (configWithStatus) {
1369
+ // also store for filename for faster lookup next time
1370
+ cache.set(filePath, configWithStatus);
1371
+
1372
+ return configWithStatus;
1373
+ }
1374
+
1375
+ // otherwise construct the config
1376
+
1377
+ // eslint-disable-next-line array-callback-return, consistent-return -- rethrowConfigError always throws an error
1378
+ let finalConfig = matchingConfigIndices.reduce((result, index) => {
1379
+ try {
1380
+ return this[ConfigArraySymbol.schema].merge(
1381
+ result,
1382
+ this[index],
1383
+ );
1384
+ } catch (validationError) {
1385
+ rethrowConfigError(this[index], index, validationError);
1386
+ }
1387
+ }, {});
1388
+
1389
+ finalConfig = this[ConfigArraySymbol.finalizeConfig](finalConfig);
1390
+
1391
+ configWithStatus = Object.freeze({
1392
+ config: finalConfig,
1393
+ status: "matched",
1394
+ });
1395
+ cache.set(filePath, configWithStatus);
1396
+ cache.set(indicesKey, configWithStatus);
1397
+
1398
+ return configWithStatus;
1399
+ }
1400
+
1401
+ /**
1402
+ * Returns the config object for a given file path.
1403
+ * @param {string} filePath The path of a file to get a config for.
1404
+ * @returns {Object|undefined} The config object for this file or `undefined`.
1405
+ */
1406
+ getConfig(filePath) {
1407
+ return this.getConfigWithStatus(filePath).config;
1408
+ }
1409
+
1410
+ /**
1411
+ * Determines whether a file has a config or why it doesn't.
1412
+ * @param {string} filePath The path of the file to check.
1413
+ * @returns {"ignored"|"external"|"unconfigured"|"matched"} One of the following values:
1414
+ * * `"ignored"`: the file is ignored
1415
+ * * `"external"`: the file is outside the base path
1416
+ * * `"unconfigured"`: the file is not matched by any config
1417
+ * * `"matched"`: the file has a matching config
1418
+ */
1419
+ getConfigStatus(filePath) {
1420
+ return this.getConfigWithStatus(filePath).status;
1421
+ }
1422
+
1423
+ /**
1424
+ * Determines if the given filepath is ignored based on the configs.
1425
+ * @param {string} filePath The path of a file to check.
1426
+ * @returns {boolean} True if the path is ignored, false if not.
1427
+ * @deprecated Use `isFileIgnored` instead.
1428
+ */
1429
+ isIgnored(filePath) {
1430
+ return this.isFileIgnored(filePath);
1431
+ }
1432
+
1433
+ /**
1434
+ * Determines if the given filepath is ignored based on the configs.
1435
+ * @param {string} filePath The path of a file to check.
1436
+ * @returns {boolean} True if the path is ignored, false if not.
1437
+ */
1438
+ isFileIgnored(filePath) {
1439
+ return this.getConfigStatus(filePath) === "ignored";
1440
+ }
1441
+
1442
+ /**
1443
+ * Determines if the given directory is ignored based on the configs.
1444
+ * This checks only default `ignores` that don't have `files` in the
1445
+ * same config. A pattern such as `/foo` be considered to ignore the directory
1446
+ * while a pattern such as `/foo/**` is not considered to ignore the
1447
+ * directory because it is matching files.
1448
+ * @param {string} directoryPath The path of a directory to check.
1449
+ * @returns {boolean} True if the directory is ignored, false if not. Will
1450
+ * return true for any directory that is not inside of `basePath`.
1451
+ * @throws {Error} When the `ConfigArray` is not normalized.
1452
+ */
1453
+ isDirectoryIgnored(directoryPath) {
1454
+ assertNormalized(this);
1455
+
1456
+ const relativeDirectoryPath = toRelativePath(
1457
+ directoryPath,
1458
+ this.#namespacedBasePath,
1459
+ this.#path,
1460
+ );
1461
+
1462
+ // basePath directory can never be ignored
1463
+ if (relativeDirectoryPath === "") {
1464
+ return false;
1465
+ }
1466
+
1467
+ if (EXTERNAL_PATH_REGEX.test(relativeDirectoryPath)) {
1468
+ return true;
1469
+ }
1470
+
1471
+ // first check the cache
1472
+ const cache = dataCache.get(this).directoryMatches;
1473
+
1474
+ if (cache.has(relativeDirectoryPath)) {
1475
+ return cache.get(relativeDirectoryPath);
1476
+ }
1477
+
1478
+ const directoryParts = relativeDirectoryPath.split("/");
1479
+ let relativeDirectoryToCheck = "";
1480
+ let result;
1481
+
1482
+ /*
1483
+ * In order to get the correct gitignore-style ignores, where an
1484
+ * ignored parent directory cannot have any descendants unignored,
1485
+ * we need to check every directory starting at the parent all
1486
+ * the way down to the actual requested directory.
1487
+ *
1488
+ * We aggressively cache all of this info to make sure we don't
1489
+ * have to recalculate everything for every call.
1490
+ */
1491
+ do {
1492
+ relativeDirectoryToCheck += `${directoryParts.shift()}/`;
1493
+
1494
+ result = shouldIgnorePath(
1495
+ this.ignores,
1496
+ this.#path.join(this.basePath, relativeDirectoryToCheck),
1497
+ relativeDirectoryToCheck,
1498
+ {
1499
+ basePath: this.#namespacedBasePath,
1500
+ path: this.#path,
1501
+ },
1502
+ );
1503
+
1504
+ cache.set(relativeDirectoryToCheck, result);
1505
+ } while (!result && directoryParts.length);
1506
+
1507
+ // also cache the result for the requested path
1508
+ cache.set(relativeDirectoryPath, result);
1509
+
1510
+ return result;
1511
+ }
1512
+ }
1513
+
1514
+ export { ConfigArray, ConfigArraySymbol };
server/node_modules/@eslint/config-array/dist/esm/std__path/posix.js ADDED
@@ -0,0 +1,1314 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-nocheck
2
+ // Copyright 2018-2025 the Deno authors. MIT license.
3
+ // Copyright the Browserify authors. MIT License.
4
+ function assertPath(path) {
5
+ if (typeof path !== "string") {
6
+ throw new TypeError(`Path must be a string, received "${JSON.stringify(path)}"`);
7
+ }
8
+ }
9
+
10
+ // Copyright 2018-2025 the Deno authors. MIT license.
11
+ // This module is browser compatible.
12
+ function stripSuffix(name, suffix) {
13
+ if (suffix.length >= name.length) {
14
+ return name;
15
+ }
16
+ const lenDiff = name.length - suffix.length;
17
+ for(let i = suffix.length - 1; i >= 0; --i){
18
+ if (name.charCodeAt(lenDiff + i) !== suffix.charCodeAt(i)) {
19
+ return name;
20
+ }
21
+ }
22
+ return name.slice(0, -suffix.length);
23
+ }
24
+ function lastPathSegment(path, isSep, start = 0) {
25
+ let matchedNonSeparator = false;
26
+ let end = path.length;
27
+ for(let i = path.length - 1; i >= start; --i){
28
+ if (isSep(path.charCodeAt(i))) {
29
+ if (matchedNonSeparator) {
30
+ start = i + 1;
31
+ break;
32
+ }
33
+ } else if (!matchedNonSeparator) {
34
+ matchedNonSeparator = true;
35
+ end = i + 1;
36
+ }
37
+ }
38
+ return path.slice(start, end);
39
+ }
40
+ function assertArgs$1(path, suffix) {
41
+ assertPath(path);
42
+ if (path.length === 0) return path;
43
+ if (typeof suffix !== "string") {
44
+ throw new TypeError(`Suffix must be a string, received "${JSON.stringify(suffix)}"`);
45
+ }
46
+ }
47
+
48
+ // Copyright 2018-2025 the Deno authors. MIT license.
49
+ // This module is browser compatible.
50
+ function assertArg$3(url) {
51
+ url = url instanceof URL ? url : new URL(url);
52
+ if (url.protocol !== "file:") {
53
+ throw new TypeError(`URL must be a file URL: received "${url.protocol}"`);
54
+ }
55
+ return url;
56
+ }
57
+
58
+ // Copyright 2018-2025 the Deno authors. MIT license.
59
+ // This module is browser compatible.
60
+ /**
61
+ * Converts a file URL to a path string.
62
+ *
63
+ * @example Usage
64
+ * ```ts
65
+ * import { fromFileUrl } from "@std/path/posix/from-file-url";
66
+ * import { assertEquals } from "@std/assert";
67
+ *
68
+ * assertEquals(fromFileUrl(new URL("file:///home/foo")), "/home/foo");
69
+ * ```
70
+ *
71
+ * @param url The file URL to convert.
72
+ * @returns The path string.
73
+ */ function fromFileUrl(url) {
74
+ url = assertArg$3(url);
75
+ return decodeURIComponent(url.pathname.replace(/%(?![0-9A-Fa-f]{2})/g, "%25"));
76
+ }
77
+
78
+ // Copyright 2018-2025 the Deno authors. MIT license.
79
+ // Copyright the Browserify authors. MIT License.
80
+ // Ported from https://github.com/browserify/path-browserify/
81
+ // This module is browser compatible.
82
+ function stripTrailingSeparators(segment, isSep) {
83
+ if (segment.length <= 1) {
84
+ return segment;
85
+ }
86
+ let end = segment.length;
87
+ for(let i = segment.length - 1; i > 0; i--){
88
+ if (isSep(segment.charCodeAt(i))) {
89
+ end = i;
90
+ } else {
91
+ break;
92
+ }
93
+ }
94
+ return segment.slice(0, end);
95
+ }
96
+
97
+ // Copyright 2018-2025 the Deno authors. MIT license.
98
+ // Copyright the Browserify authors. MIT License.
99
+ // Ported from https://github.com/browserify/path-browserify/
100
+ // This module is browser compatible.
101
+ // Alphabet chars.
102
+ // Non-alphabetic chars.
103
+ const CHAR_DOT = 46; /* . */
104
+ const CHAR_FORWARD_SLASH = 47; /* / */
105
+
106
+ // Copyright 2018-2025 the Deno authors. MIT license.
107
+ // Copyright the Browserify authors. MIT License.
108
+ // Ported from https://github.com/browserify/path-browserify/
109
+ // This module is browser compatible.
110
+ function isPosixPathSeparator(code) {
111
+ return code === CHAR_FORWARD_SLASH;
112
+ }
113
+
114
+ // Copyright 2018-2025 the Deno authors. MIT license.
115
+ // This module is browser compatible.
116
+ /**
117
+ * Return the last portion of a `path`.
118
+ * Trailing directory separators are ignored, and optional suffix is removed.
119
+ *
120
+ * @example Usage
121
+ * ```ts
122
+ * import { basename } from "@std/path/posix/basename";
123
+ * import { assertEquals } from "@std/assert";
124
+ *
125
+ * assertEquals(basename("/home/user/Documents/"), "Documents");
126
+ * assertEquals(basename("/home/user/Documents/image.png"), "image.png");
127
+ * assertEquals(basename("/home/user/Documents/image.png", ".png"), "image");
128
+ * assertEquals(basename(new URL("file:///home/user/Documents/image.png")), "image.png");
129
+ * assertEquals(basename(new URL("file:///home/user/Documents/image.png"), ".png"), "image");
130
+ * ```
131
+ *
132
+ * @example Working with URLs
133
+ *
134
+ * Note: This function doesn't automatically strip hash and query parts from
135
+ * URLs. If your URL contains a hash or query, remove them before passing the
136
+ * URL to the function. This can be done by passing the URL to `new URL(url)`,
137
+ * and setting the `hash` and `search` properties to empty strings.
138
+ *
139
+ * ```ts
140
+ * import { basename } from "@std/path/posix/basename";
141
+ * import { assertEquals } from "@std/assert";
142
+ *
143
+ * assertEquals(basename("https://deno.land/std/path/mod.ts"), "mod.ts");
144
+ * assertEquals(basename("https://deno.land/std/path/mod.ts", ".ts"), "mod");
145
+ * assertEquals(basename("https://deno.land/std/path/mod.ts?a=b"), "mod.ts?a=b");
146
+ * assertEquals(basename("https://deno.land/std/path/mod.ts#header"), "mod.ts#header");
147
+ * ```
148
+ *
149
+ * @param path The path to extract the name from.
150
+ * @param suffix The suffix to remove from extracted name.
151
+ * @returns The extracted name.
152
+ */ function basename(path, suffix = "") {
153
+ if (path instanceof URL) {
154
+ path = fromFileUrl(path);
155
+ }
156
+ assertArgs$1(path, suffix);
157
+ const lastSegment = lastPathSegment(path, isPosixPathSeparator);
158
+ const strippedSegment = stripTrailingSeparators(lastSegment, isPosixPathSeparator);
159
+ return suffix ? stripSuffix(strippedSegment, suffix) : strippedSegment;
160
+ }
161
+
162
+ // Copyright 2018-2025 the Deno authors. MIT license.
163
+ // This module is browser compatible.
164
+ /**
165
+ * The character used to separate entries in the PATH environment variable.
166
+ */ const DELIMITER = ":";
167
+ /**
168
+ * The character used to separate components of a file path.
169
+ */ const SEPARATOR = "/";
170
+ /**
171
+ * A regular expression that matches one or more path separators.
172
+ */ const SEPARATOR_PATTERN = /\/+/;
173
+
174
+ // Copyright 2018-2025 the Deno authors. MIT license.
175
+ // This module is browser compatible.
176
+ function assertArg$2(path) {
177
+ assertPath(path);
178
+ if (path.length === 0) return ".";
179
+ }
180
+
181
+ // Copyright 2018-2025 the Deno authors. MIT license.
182
+ // This module is browser compatible.
183
+ /**
184
+ * Return the directory path of a `path`.
185
+ *
186
+ * @example Usage
187
+ * ```ts
188
+ * import { dirname } from "@std/path/posix/dirname";
189
+ * import { assertEquals } from "@std/assert";
190
+ *
191
+ * assertEquals(dirname("/home/user/Documents/"), "/home/user");
192
+ * assertEquals(dirname("/home/user/Documents/image.png"), "/home/user/Documents");
193
+ * assertEquals(dirname("https://deno.land/std/path/mod.ts"), "https://deno.land/std/path");
194
+ * assertEquals(dirname(new URL("file:///home/user/Documents/image.png")), "/home/user/Documents");
195
+ * ```
196
+ *
197
+ * @example Working with URLs
198
+ *
199
+ * ```ts
200
+ * import { dirname } from "@std/path/posix/dirname";
201
+ * import { assertEquals } from "@std/assert";
202
+ *
203
+ * assertEquals(dirname("https://deno.land/std/path/mod.ts"), "https://deno.land/std/path");
204
+ * assertEquals(dirname("https://deno.land/std/path/mod.ts?a=b"), "https://deno.land/std/path");
205
+ * assertEquals(dirname("https://deno.land/std/path/mod.ts#header"), "https://deno.land/std/path");
206
+ * ```
207
+ *
208
+ * @param path The path to get the directory from.
209
+ * @returns The directory path.
210
+ */ function dirname(path) {
211
+ if (path instanceof URL) {
212
+ path = fromFileUrl(path);
213
+ }
214
+ assertArg$2(path);
215
+ let end = -1;
216
+ let matchedNonSeparator = false;
217
+ for(let i = path.length - 1; i >= 1; --i){
218
+ if (isPosixPathSeparator(path.charCodeAt(i))) {
219
+ if (matchedNonSeparator) {
220
+ end = i;
221
+ break;
222
+ }
223
+ } else {
224
+ matchedNonSeparator = true;
225
+ }
226
+ }
227
+ // No matches. Fallback based on provided path:
228
+ //
229
+ // - leading slashes paths
230
+ // "/foo" => "/"
231
+ // "///foo" => "/"
232
+ // - no slash path
233
+ // "foo" => "."
234
+ if (end === -1) {
235
+ return isPosixPathSeparator(path.charCodeAt(0)) ? "/" : ".";
236
+ }
237
+ return stripTrailingSeparators(path.slice(0, end), isPosixPathSeparator);
238
+ }
239
+
240
+ // Copyright 2018-2025 the Deno authors. MIT license.
241
+ // This module is browser compatible.
242
+ /**
243
+ * Return the extension of the `path` with leading period.
244
+ *
245
+ * @example Usage
246
+ * ```ts
247
+ * import { extname } from "@std/path/posix/extname";
248
+ * import { assertEquals } from "@std/assert";
249
+ *
250
+ * assertEquals(extname("/home/user/Documents/file.ts"), ".ts");
251
+ * assertEquals(extname("/home/user/Documents/"), "");
252
+ * assertEquals(extname("/home/user/Documents/image.png"), ".png");
253
+ * assertEquals(extname(new URL("file:///home/user/Documents/file.ts")), ".ts");
254
+ * assertEquals(extname(new URL("file:///home/user/Documents/file.ts?a=b")), ".ts");
255
+ * assertEquals(extname(new URL("file:///home/user/Documents/file.ts#header")), ".ts");
256
+ * ```
257
+ *
258
+ * @example Working with URLs
259
+ *
260
+ * Note: This function doesn't automatically strip hash and query parts from
261
+ * URLs. If your URL contains a hash or query, remove them before passing the
262
+ * URL to the function. This can be done by passing the URL to `new URL(url)`,
263
+ * and setting the `hash` and `search` properties to empty strings.
264
+ *
265
+ * ```ts
266
+ * import { extname } from "@std/path/posix/extname";
267
+ * import { assertEquals } from "@std/assert";
268
+ *
269
+ * assertEquals(extname("https://deno.land/std/path/mod.ts"), ".ts");
270
+ * assertEquals(extname("https://deno.land/std/path/mod.ts?a=b"), ".ts?a=b");
271
+ * assertEquals(extname("https://deno.land/std/path/mod.ts#header"), ".ts#header");
272
+ * ```
273
+ *
274
+ * @param path The path to get the extension from.
275
+ * @returns The extension (ex. for `file.ts` returns `.ts`).
276
+ */ function extname(path) {
277
+ if (path instanceof URL) {
278
+ path = fromFileUrl(path);
279
+ }
280
+ assertPath(path);
281
+ let startDot = -1;
282
+ let startPart = 0;
283
+ let end = -1;
284
+ let matchedSlash = true;
285
+ // Track the state of characters (if any) we see before our first dot and
286
+ // after any path separator we find
287
+ let preDotState = 0;
288
+ for(let i = path.length - 1; i >= 0; --i){
289
+ const code = path.charCodeAt(i);
290
+ if (isPosixPathSeparator(code)) {
291
+ // If we reached a path separator that was not part of a set of path
292
+ // separators at the end of the string, stop now
293
+ if (!matchedSlash) {
294
+ startPart = i + 1;
295
+ break;
296
+ }
297
+ continue;
298
+ }
299
+ if (end === -1) {
300
+ // We saw the first non-path separator, mark this as the end of our
301
+ // extension
302
+ matchedSlash = false;
303
+ end = i + 1;
304
+ }
305
+ if (code === CHAR_DOT) {
306
+ // If this is our first dot, mark it as the start of our extension
307
+ if (startDot === -1) startDot = i;
308
+ else if (preDotState !== 1) preDotState = 1;
309
+ } else if (startDot !== -1) {
310
+ // We saw a non-dot and non-path separator before our dot, so we should
311
+ // have a good chance at having a non-empty extension
312
+ preDotState = -1;
313
+ }
314
+ }
315
+ if (startDot === -1 || end === -1 || // We saw a non-dot character immediately before the dot
316
+ preDotState === 0 || // The (right-most) trimmed path component is exactly '..'
317
+ preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
318
+ return "";
319
+ }
320
+ return path.slice(startDot, end);
321
+ }
322
+
323
+ // Copyright 2018-2025 the Deno authors. MIT license.
324
+ // This module is browser compatible.
325
+ function _format(sep, pathObject) {
326
+ const dir = pathObject.dir || pathObject.root;
327
+ const base = pathObject.base || (pathObject.name ?? "") + (pathObject.ext ?? "");
328
+ if (!dir) return base;
329
+ if (base === sep) return dir;
330
+ if (dir === pathObject.root) return dir + base;
331
+ return dir + sep + base;
332
+ }
333
+ function assertArg$1(pathObject) {
334
+ if (pathObject === null || typeof pathObject !== "object") {
335
+ throw new TypeError(`The "pathObject" argument must be of type Object, received type "${typeof pathObject}"`);
336
+ }
337
+ }
338
+
339
+ // Copyright 2018-2025 the Deno authors. MIT license.
340
+ // This module is browser compatible.
341
+ /**
342
+ * Generate a path from `ParsedPath` object.
343
+ *
344
+ * @example Usage
345
+ * ```ts
346
+ * import { format } from "@std/path/posix/format";
347
+ * import { assertEquals } from "@std/assert";
348
+ *
349
+ * const path = format({
350
+ * root: "/",
351
+ * dir: "/path/dir",
352
+ * base: "file.txt",
353
+ * ext: ".txt",
354
+ * name: "file"
355
+ * });
356
+ * assertEquals(path, "/path/dir/file.txt");
357
+ * ```
358
+ *
359
+ * @param pathObject The path object to format.
360
+ * @returns The formatted path.
361
+ */ function format(pathObject) {
362
+ assertArg$1(pathObject);
363
+ return _format("/", pathObject);
364
+ }
365
+
366
+ // Copyright 2018-2025 the Deno authors. MIT license.
367
+ // This module is browser compatible.
368
+ /**
369
+ * Verifies whether provided path is absolute.
370
+ *
371
+ * @example Usage
372
+ * ```ts
373
+ * import { isAbsolute } from "@std/path/posix/is-absolute";
374
+ * import { assert, assertFalse } from "@std/assert";
375
+ *
376
+ * assert(isAbsolute("/home/user/Documents/"));
377
+ * assertFalse(isAbsolute("home/user/Documents/"));
378
+ * ```
379
+ *
380
+ * @param path The path to verify.
381
+ * @returns Whether the path is absolute.
382
+ */ function isAbsolute(path) {
383
+ assertPath(path);
384
+ return path.length > 0 && isPosixPathSeparator(path.charCodeAt(0));
385
+ }
386
+
387
+ // Copyright 2018-2025 the Deno authors. MIT license.
388
+ // This module is browser compatible.
389
+ function assertArg(path) {
390
+ assertPath(path);
391
+ if (path.length === 0) return ".";
392
+ }
393
+
394
+ // Copyright 2018-2025 the Deno authors. MIT license.
395
+ // Copyright the Browserify authors. MIT License.
396
+ // Ported from https://github.com/browserify/path-browserify/
397
+ // This module is browser compatible.
398
+ // Resolves . and .. elements in a path with directory names
399
+ function normalizeString(path, allowAboveRoot, separator, isPathSeparator) {
400
+ let res = "";
401
+ let lastSegmentLength = 0;
402
+ let lastSlash = -1;
403
+ let dots = 0;
404
+ let code;
405
+ for(let i = 0; i <= path.length; ++i){
406
+ if (i < path.length) code = path.charCodeAt(i);
407
+ else if (isPathSeparator(code)) break;
408
+ else code = CHAR_FORWARD_SLASH;
409
+ if (isPathSeparator(code)) {
410
+ if (lastSlash === i - 1 || dots === 1) ; else if (lastSlash !== i - 1 && dots === 2) {
411
+ if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== CHAR_DOT || res.charCodeAt(res.length - 2) !== CHAR_DOT) {
412
+ if (res.length > 2) {
413
+ const lastSlashIndex = res.lastIndexOf(separator);
414
+ if (lastSlashIndex === -1) {
415
+ res = "";
416
+ lastSegmentLength = 0;
417
+ } else {
418
+ res = res.slice(0, lastSlashIndex);
419
+ lastSegmentLength = res.length - 1 - res.lastIndexOf(separator);
420
+ }
421
+ lastSlash = i;
422
+ dots = 0;
423
+ continue;
424
+ } else if (res.length === 2 || res.length === 1) {
425
+ res = "";
426
+ lastSegmentLength = 0;
427
+ lastSlash = i;
428
+ dots = 0;
429
+ continue;
430
+ }
431
+ }
432
+ if (allowAboveRoot) {
433
+ if (res.length > 0) res += `${separator}..`;
434
+ else res = "..";
435
+ lastSegmentLength = 2;
436
+ }
437
+ } else {
438
+ if (res.length > 0) res += separator + path.slice(lastSlash + 1, i);
439
+ else res = path.slice(lastSlash + 1, i);
440
+ lastSegmentLength = i - lastSlash - 1;
441
+ }
442
+ lastSlash = i;
443
+ dots = 0;
444
+ } else if (code === CHAR_DOT && dots !== -1) {
445
+ ++dots;
446
+ } else {
447
+ dots = -1;
448
+ }
449
+ }
450
+ return res;
451
+ }
452
+
453
+ // Copyright 2018-2025 the Deno authors. MIT license.
454
+ // This module is browser compatible.
455
+ /**
456
+ * Normalize the `path`, resolving `'..'` and `'.'` segments.
457
+ * Note that resolving these segments does not necessarily mean that all will be eliminated.
458
+ * A `'..'` at the top-level will be preserved, and an empty path is canonically `'.'`.
459
+ *
460
+ * @example Usage
461
+ * ```ts
462
+ * import { normalize } from "@std/path/posix/normalize";
463
+ * import { assertEquals } from "@std/assert";
464
+ *
465
+ * assertEquals(normalize("/foo/bar//baz/asdf/quux/.."), "/foo/bar/baz/asdf");
466
+ * assertEquals(normalize(new URL("file:///foo/bar//baz/asdf/quux/..")), "/foo/bar/baz/asdf/");
467
+ * ```
468
+ *
469
+ * @example Working with URLs
470
+ *
471
+ * Note: This function will remove the double slashes from a URL's scheme.
472
+ * Hence, do not pass a full URL to this function. Instead, pass the pathname of
473
+ * the URL.
474
+ *
475
+ * ```ts
476
+ * import { normalize } from "@std/path/posix/normalize";
477
+ * import { assertEquals } from "@std/assert";
478
+ *
479
+ * const url = new URL("https://deno.land");
480
+ * url.pathname = normalize("//std//assert//.//mod.ts");
481
+ * assertEquals(url.href, "https://deno.land/std/assert/mod.ts");
482
+ *
483
+ * url.pathname = normalize("std/assert/../async/retry.ts");
484
+ * assertEquals(url.href, "https://deno.land/std/async/retry.ts");
485
+ * ```
486
+ *
487
+ * @param path The path to normalize.
488
+ * @returns The normalized path.
489
+ */ function normalize(path) {
490
+ if (path instanceof URL) {
491
+ path = fromFileUrl(path);
492
+ }
493
+ assertArg(path);
494
+ const isAbsolute = isPosixPathSeparator(path.charCodeAt(0));
495
+ const trailingSeparator = isPosixPathSeparator(path.charCodeAt(path.length - 1));
496
+ // Normalize the path
497
+ path = normalizeString(path, !isAbsolute, "/", isPosixPathSeparator);
498
+ if (path.length === 0 && !isAbsolute) path = ".";
499
+ if (path.length > 0 && trailingSeparator) path += "/";
500
+ if (isAbsolute) return `/${path}`;
501
+ return path;
502
+ }
503
+
504
+ // Copyright 2018-2025 the Deno authors. MIT license.
505
+ // This module is browser compatible.
506
+ /**
507
+ * Join all given a sequence of `paths`,then normalizes the resulting path.
508
+ *
509
+ * @example Usage
510
+ * ```ts
511
+ * import { join } from "@std/path/posix/join";
512
+ * import { assertEquals } from "@std/assert";
513
+ *
514
+ * assertEquals(join("/foo", "bar", "baz/asdf", "quux", ".."), "/foo/bar/baz/asdf");
515
+ * assertEquals(join(new URL("file:///foo"), "bar", "baz/asdf", "quux", ".."), "/foo/bar/baz/asdf");
516
+ * ```
517
+ *
518
+ * @example Working with URLs
519
+ * ```ts
520
+ * import { join } from "@std/path/posix/join";
521
+ * import { assertEquals } from "@std/assert";
522
+ *
523
+ * const url = new URL("https://deno.land");
524
+ * url.pathname = join("std", "path", "mod.ts");
525
+ * assertEquals(url.href, "https://deno.land/std/path/mod.ts");
526
+ *
527
+ * url.pathname = join("//std", "path/", "/mod.ts");
528
+ * assertEquals(url.href, "https://deno.land/std/path/mod.ts");
529
+ * ```
530
+ *
531
+ * @param path The path to join. This can be string or file URL.
532
+ * @param paths The paths to join.
533
+ * @returns The joined path.
534
+ */ function join(path, ...paths) {
535
+ if (path === undefined) return ".";
536
+ if (path instanceof URL) {
537
+ path = fromFileUrl(path);
538
+ }
539
+ paths = path ? [
540
+ path,
541
+ ...paths
542
+ ] : paths;
543
+ paths.forEach((path)=>assertPath(path));
544
+ const joined = paths.filter((path)=>path.length > 0).join("/");
545
+ return joined === "" ? "." : normalize(joined);
546
+ }
547
+
548
+ // Copyright 2018-2025 the Deno authors. MIT license.
549
+ // This module is browser compatible.
550
+ /**
551
+ * Return a `ParsedPath` object of the `path`.
552
+ *
553
+ * @example Usage
554
+ * ```ts
555
+ * import { parse } from "@std/path/posix/parse";
556
+ * import { assertEquals } from "@std/assert";
557
+ *
558
+ * const path = parse("/home/user/file.txt");
559
+ * assertEquals(path, {
560
+ * root: "/",
561
+ * dir: "/home/user",
562
+ * base: "file.txt",
563
+ * ext: ".txt",
564
+ * name: "file"
565
+ * });
566
+ * ```
567
+ *
568
+ * @param path The path to parse.
569
+ * @returns The parsed path object.
570
+ */ function parse(path) {
571
+ assertPath(path);
572
+ const ret = {
573
+ root: "",
574
+ dir: "",
575
+ base: "",
576
+ ext: "",
577
+ name: ""
578
+ };
579
+ if (path.length === 0) return ret;
580
+ const isAbsolute = isPosixPathSeparator(path.charCodeAt(0));
581
+ let start;
582
+ if (isAbsolute) {
583
+ ret.root = "/";
584
+ start = 1;
585
+ } else {
586
+ start = 0;
587
+ }
588
+ let startDot = -1;
589
+ let startPart = 0;
590
+ let end = -1;
591
+ let matchedSlash = true;
592
+ let i = path.length - 1;
593
+ // Track the state of characters (if any) we see before our first dot and
594
+ // after any path separator we find
595
+ let preDotState = 0;
596
+ // Get non-dir info
597
+ for(; i >= start; --i){
598
+ const code = path.charCodeAt(i);
599
+ if (isPosixPathSeparator(code)) {
600
+ // If we reached a path separator that was not part of a set of path
601
+ // separators at the end of the string, stop now
602
+ if (!matchedSlash) {
603
+ startPart = i + 1;
604
+ break;
605
+ }
606
+ continue;
607
+ }
608
+ if (end === -1) {
609
+ // We saw the first non-path separator, mark this as the end of our
610
+ // extension
611
+ matchedSlash = false;
612
+ end = i + 1;
613
+ }
614
+ if (code === CHAR_DOT) {
615
+ // If this is our first dot, mark it as the start of our extension
616
+ if (startDot === -1) startDot = i;
617
+ else if (preDotState !== 1) preDotState = 1;
618
+ } else if (startDot !== -1) {
619
+ // We saw a non-dot and non-path separator before our dot, so we should
620
+ // have a good chance at having a non-empty extension
621
+ preDotState = -1;
622
+ }
623
+ }
624
+ if (startDot === -1 || end === -1 || // We saw a non-dot character immediately before the dot
625
+ preDotState === 0 || // The (right-most) trimmed path component is exactly '..'
626
+ preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
627
+ if (end !== -1) {
628
+ if (startPart === 0 && isAbsolute) {
629
+ ret.base = ret.name = path.slice(1, end);
630
+ } else {
631
+ ret.base = ret.name = path.slice(startPart, end);
632
+ }
633
+ }
634
+ // Fallback to '/' in case there is no basename
635
+ ret.base = ret.base || "/";
636
+ } else {
637
+ if (startPart === 0 && isAbsolute) {
638
+ ret.name = path.slice(1, startDot);
639
+ ret.base = path.slice(1, end);
640
+ } else {
641
+ ret.name = path.slice(startPart, startDot);
642
+ ret.base = path.slice(startPart, end);
643
+ }
644
+ ret.ext = path.slice(startDot, end);
645
+ }
646
+ if (startPart > 0) {
647
+ ret.dir = stripTrailingSeparators(path.slice(0, startPart - 1), isPosixPathSeparator);
648
+ } else if (isAbsolute) ret.dir = "/";
649
+ return ret;
650
+ }
651
+
652
+ // Copyright 2018-2025 the Deno authors. MIT license.
653
+ // This module is browser compatible.
654
+ /**
655
+ * Resolves path segments into a `path`.
656
+ *
657
+ * @example Usage
658
+ * ```ts
659
+ * import { resolve } from "@std/path/posix/resolve";
660
+ * import { assertEquals } from "@std/assert";
661
+ *
662
+ * const path = resolve("/foo", "bar", "baz/asdf", "quux", "..");
663
+ * assertEquals(path, "/foo/bar/baz/asdf");
664
+ * ```
665
+ *
666
+ * @param pathSegments The path segments to resolve.
667
+ * @returns The resolved path.
668
+ */ function resolve(...pathSegments) {
669
+ let resolvedPath = "";
670
+ let resolvedAbsolute = false;
671
+ for(let i = pathSegments.length - 1; i >= -1 && !resolvedAbsolute; i--){
672
+ let path;
673
+ if (i >= 0) path = pathSegments[i];
674
+ else {
675
+ // deno-lint-ignore no-explicit-any
676
+ const { Deno } = globalThis;
677
+ if (typeof Deno?.cwd !== "function") {
678
+ throw new TypeError("Resolved a relative path without a current working directory (CWD)");
679
+ }
680
+ path = Deno.cwd();
681
+ }
682
+ assertPath(path);
683
+ // Skip empty entries
684
+ if (path.length === 0) {
685
+ continue;
686
+ }
687
+ resolvedPath = `${path}/${resolvedPath}`;
688
+ resolvedAbsolute = isPosixPathSeparator(path.charCodeAt(0));
689
+ }
690
+ // At this point the path should be resolved to a full absolute path, but
691
+ // handle relative paths to be safe (might happen when Deno.cwd() fails)
692
+ // Normalize the path
693
+ resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute, "/", isPosixPathSeparator);
694
+ if (resolvedAbsolute) {
695
+ if (resolvedPath.length > 0) return `/${resolvedPath}`;
696
+ else return "/";
697
+ } else if (resolvedPath.length > 0) return resolvedPath;
698
+ else return ".";
699
+ }
700
+
701
+ // Copyright 2018-2025 the Deno authors. MIT license.
702
+ // This module is browser compatible.
703
+ function assertArgs(from, to) {
704
+ assertPath(from);
705
+ assertPath(to);
706
+ if (from === to) return "";
707
+ }
708
+
709
+ // Copyright 2018-2025 the Deno authors. MIT license.
710
+ // This module is browser compatible.
711
+ /**
712
+ * Return the relative path from `from` to `to` based on current working directory.
713
+ *
714
+ * If `from` and `to` are the same, return an empty string.
715
+ *
716
+ * @example Usage
717
+ * ```ts
718
+ * import { relative } from "@std/path/posix/relative";
719
+ * import { assertEquals } from "@std/assert";
720
+ *
721
+ * const path = relative("/data/orandea/test/aaa", "/data/orandea/impl/bbb");
722
+ * assertEquals(path, "../../impl/bbb");
723
+ * ```
724
+ *
725
+ * @param from The path to start from.
726
+ * @param to The path to reach.
727
+ * @returns The relative path.
728
+ */ function relative(from, to) {
729
+ assertArgs(from, to);
730
+ from = resolve(from);
731
+ to = resolve(to);
732
+ if (from === to) return "";
733
+ // Trim any leading backslashes
734
+ let fromStart = 1;
735
+ const fromEnd = from.length;
736
+ for(; fromStart < fromEnd; ++fromStart){
737
+ if (!isPosixPathSeparator(from.charCodeAt(fromStart))) break;
738
+ }
739
+ const fromLen = fromEnd - fromStart;
740
+ // Trim any leading backslashes
741
+ let toStart = 1;
742
+ const toEnd = to.length;
743
+ for(; toStart < toEnd; ++toStart){
744
+ if (!isPosixPathSeparator(to.charCodeAt(toStart))) break;
745
+ }
746
+ const toLen = toEnd - toStart;
747
+ // Compare paths to find the longest common path from root
748
+ const length = fromLen < toLen ? fromLen : toLen;
749
+ let lastCommonSep = -1;
750
+ let i = 0;
751
+ for(; i <= length; ++i){
752
+ if (i === length) {
753
+ if (toLen > length) {
754
+ if (isPosixPathSeparator(to.charCodeAt(toStart + i))) {
755
+ // We get here if `from` is the exact base path for `to`.
756
+ // For example: from='/foo/bar'; to='/foo/bar/baz'
757
+ return to.slice(toStart + i + 1);
758
+ } else if (i === 0) {
759
+ // We get here if `from` is the root
760
+ // For example: from='/'; to='/foo'
761
+ return to.slice(toStart + i);
762
+ }
763
+ } else if (fromLen > length) {
764
+ if (isPosixPathSeparator(from.charCodeAt(fromStart + i))) {
765
+ // We get here if `to` is the exact base path for `from`.
766
+ // For example: from='/foo/bar/baz'; to='/foo/bar'
767
+ lastCommonSep = i;
768
+ } else if (i === 0) {
769
+ // We get here if `to` is the root.
770
+ // For example: from='/foo'; to='/'
771
+ lastCommonSep = 0;
772
+ }
773
+ }
774
+ break;
775
+ }
776
+ const fromCode = from.charCodeAt(fromStart + i);
777
+ const toCode = to.charCodeAt(toStart + i);
778
+ if (fromCode !== toCode) break;
779
+ else if (isPosixPathSeparator(fromCode)) lastCommonSep = i;
780
+ }
781
+ let out = "";
782
+ // Generate the relative path based on the path difference between `to`
783
+ // and `from`
784
+ for(i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i){
785
+ if (i === fromEnd || isPosixPathSeparator(from.charCodeAt(i))) {
786
+ if (out.length === 0) out += "..";
787
+ else out += "/..";
788
+ }
789
+ }
790
+ // Lastly, append the rest of the destination (`to`) path that comes after
791
+ // the common path parts
792
+ if (out.length > 0) return out + to.slice(toStart + lastCommonSep);
793
+ else {
794
+ toStart += lastCommonSep;
795
+ if (isPosixPathSeparator(to.charCodeAt(toStart))) ++toStart;
796
+ return to.slice(toStart);
797
+ }
798
+ }
799
+
800
+ // Copyright 2018-2025 the Deno authors. MIT license.
801
+ // This module is browser compatible.
802
+ const WHITESPACE_ENCODINGS = {
803
+ "\u0009": "%09",
804
+ "\u000A": "%0A",
805
+ "\u000B": "%0B",
806
+ "\u000C": "%0C",
807
+ "\u000D": "%0D",
808
+ "\u0020": "%20"
809
+ };
810
+ function encodeWhitespace(string) {
811
+ return string.replaceAll(/[\s]/g, (c)=>{
812
+ return WHITESPACE_ENCODINGS[c] ?? c;
813
+ });
814
+ }
815
+
816
+ // Copyright 2018-2025 the Deno authors. MIT license.
817
+ // This module is browser compatible.
818
+ /**
819
+ * Converts a path string to a file URL.
820
+ *
821
+ * @example Usage
822
+ * ```ts
823
+ * import { toFileUrl } from "@std/path/posix/to-file-url";
824
+ * import { assertEquals } from "@std/assert";
825
+ *
826
+ * assertEquals(toFileUrl("/home/foo"), new URL("file:///home/foo"));
827
+ * assertEquals(toFileUrl("/home/foo bar"), new URL("file:///home/foo%20bar"));
828
+ * ```
829
+ *
830
+ * @param path The path to convert.
831
+ * @returns The file URL.
832
+ */ function toFileUrl(path) {
833
+ if (!isAbsolute(path)) {
834
+ throw new TypeError(`Path must be absolute: received "${path}"`);
835
+ }
836
+ const url = new URL("file:///");
837
+ url.pathname = encodeWhitespace(path.replace(/%/g, "%25").replace(/\\/g, "%5C"));
838
+ return url;
839
+ }
840
+
841
+ // Copyright 2018-2025 the Deno authors. MIT license.
842
+ // This module is browser compatible.
843
+ /**
844
+ * Converts a path to a namespaced path. This function returns the path as is on posix.
845
+ *
846
+ * @example Usage
847
+ * ```ts
848
+ * import { toNamespacedPath } from "@std/path/posix/to-namespaced-path";
849
+ * import { assertEquals } from "@std/assert";
850
+ *
851
+ * assertEquals(toNamespacedPath("/home/foo"), "/home/foo");
852
+ * ```
853
+ *
854
+ * @param path The path.
855
+ * @returns The namespaced path.
856
+ */ function toNamespacedPath(path) {
857
+ // Non-op on posix systems
858
+ return path;
859
+ }
860
+
861
+ // Copyright 2018-2025 the Deno authors. MIT license.
862
+ // This module is browser compatible.
863
+ function common$1(paths, sep) {
864
+ const [first = "", ...remaining] = paths;
865
+ const parts = first.split(sep);
866
+ let endOfPrefix = parts.length;
867
+ let append = "";
868
+ for (const path of remaining){
869
+ const compare = path.split(sep);
870
+ if (compare.length <= endOfPrefix) {
871
+ endOfPrefix = compare.length;
872
+ append = "";
873
+ }
874
+ for(let i = 0; i < endOfPrefix; i++){
875
+ if (compare[i] !== parts[i]) {
876
+ endOfPrefix = i;
877
+ append = i === 0 ? "" : sep;
878
+ break;
879
+ }
880
+ }
881
+ }
882
+ return parts.slice(0, endOfPrefix).join(sep) + append;
883
+ }
884
+
885
+ // Copyright 2018-2025 the Deno authors. MIT license.
886
+ // This module is browser compatible.
887
+ /** Determines the common path from a set of paths for POSIX systems.
888
+ *
889
+ * @example Usage
890
+ * ```ts
891
+ * import { common } from "@std/path/posix/common";
892
+ * import { assertEquals } from "@std/assert";
893
+ *
894
+ * const path = common([
895
+ * "./deno/std/path/mod.ts",
896
+ * "./deno/std/fs/mod.ts",
897
+ * ]);
898
+ * assertEquals(path, "./deno/std/");
899
+ * ```
900
+ *
901
+ * @param paths The paths to compare.
902
+ * @returns The common path.
903
+ */ function common(paths) {
904
+ return common$1(paths, SEPARATOR);
905
+ }
906
+
907
+ // Copyright 2018-2025 the Deno authors. MIT license.
908
+ // This module is browser compatible.
909
+ /**
910
+ * Options for {@linkcode globToRegExp}, {@linkcode joinGlobs},
911
+ * {@linkcode normalizeGlob} and {@linkcode expandGlob}.
912
+ */ const REG_EXP_ESCAPE_CHARS = [
913
+ "!",
914
+ "$",
915
+ "(",
916
+ ")",
917
+ "*",
918
+ "+",
919
+ ".",
920
+ "=",
921
+ "?",
922
+ "[",
923
+ "\\",
924
+ "^",
925
+ "{",
926
+ "|"
927
+ ];
928
+ const RANGE_ESCAPE_CHARS = [
929
+ "-",
930
+ "\\",
931
+ "]"
932
+ ];
933
+ function _globToRegExp(c, glob, { extended = true, globstar: globstarOption = true, // os = osType,
934
+ caseInsensitive = false } = {}) {
935
+ if (glob === "") {
936
+ return /(?!)/;
937
+ }
938
+ // Remove trailing separators.
939
+ let newLength = glob.length;
940
+ for(; newLength > 1 && c.seps.includes(glob[newLength - 1]); newLength--);
941
+ glob = glob.slice(0, newLength);
942
+ let regExpString = "";
943
+ // Terminates correctly. Trust that `j` is incremented every iteration.
944
+ for(let j = 0; j < glob.length;){
945
+ let segment = "";
946
+ const groupStack = [];
947
+ let inRange = false;
948
+ let inEscape = false;
949
+ let endsWithSep = false;
950
+ let i = j;
951
+ // Terminates with `i` at the non-inclusive end of the current segment.
952
+ for(; i < glob.length && !(c.seps.includes(glob[i]) && groupStack.length === 0); i++){
953
+ if (inEscape) {
954
+ inEscape = false;
955
+ const escapeChars = inRange ? RANGE_ESCAPE_CHARS : REG_EXP_ESCAPE_CHARS;
956
+ segment += escapeChars.includes(glob[i]) ? `\\${glob[i]}` : glob[i];
957
+ continue;
958
+ }
959
+ if (glob[i] === c.escapePrefix) {
960
+ inEscape = true;
961
+ continue;
962
+ }
963
+ if (glob[i] === "[") {
964
+ if (!inRange) {
965
+ inRange = true;
966
+ segment += "[";
967
+ if (glob[i + 1] === "!") {
968
+ i++;
969
+ segment += "^";
970
+ } else if (glob[i + 1] === "^") {
971
+ i++;
972
+ segment += "\\^";
973
+ }
974
+ continue;
975
+ } else if (glob[i + 1] === ":") {
976
+ let k = i + 1;
977
+ let value = "";
978
+ while(glob[k + 1] !== undefined && glob[k + 1] !== ":"){
979
+ value += glob[k + 1];
980
+ k++;
981
+ }
982
+ if (glob[k + 1] === ":" && glob[k + 2] === "]") {
983
+ i = k + 2;
984
+ if (value === "alnum") segment += "\\dA-Za-z";
985
+ else if (value === "alpha") segment += "A-Za-z";
986
+ else if (value === "ascii") segment += "\x00-\x7F";
987
+ else if (value === "blank") segment += "\t ";
988
+ else if (value === "cntrl") segment += "\x00-\x1F\x7F";
989
+ else if (value === "digit") segment += "\\d";
990
+ else if (value === "graph") segment += "\x21-\x7E";
991
+ else if (value === "lower") segment += "a-z";
992
+ else if (value === "print") segment += "\x20-\x7E";
993
+ else if (value === "punct") {
994
+ segment += "!\"#$%&'()*+,\\-./:;<=>?@[\\\\\\]^_‘{|}~";
995
+ } else if (value === "space") segment += "\\s\v";
996
+ else if (value === "upper") segment += "A-Z";
997
+ else if (value === "word") segment += "\\w";
998
+ else if (value === "xdigit") segment += "\\dA-Fa-f";
999
+ continue;
1000
+ }
1001
+ }
1002
+ }
1003
+ if (glob[i] === "]" && inRange) {
1004
+ inRange = false;
1005
+ segment += "]";
1006
+ continue;
1007
+ }
1008
+ if (inRange) {
1009
+ segment += glob[i];
1010
+ continue;
1011
+ }
1012
+ if (glob[i] === ")" && groupStack.length > 0 && groupStack[groupStack.length - 1] !== "BRACE") {
1013
+ segment += ")";
1014
+ const type = groupStack.pop();
1015
+ if (type === "!") {
1016
+ segment += c.wildcard;
1017
+ } else if (type !== "@") {
1018
+ segment += type;
1019
+ }
1020
+ continue;
1021
+ }
1022
+ if (glob[i] === "|" && groupStack.length > 0 && groupStack[groupStack.length - 1] !== "BRACE") {
1023
+ segment += "|";
1024
+ continue;
1025
+ }
1026
+ if (glob[i] === "+" && extended && glob[i + 1] === "(") {
1027
+ i++;
1028
+ groupStack.push("+");
1029
+ segment += "(?:";
1030
+ continue;
1031
+ }
1032
+ if (glob[i] === "@" && extended && glob[i + 1] === "(") {
1033
+ i++;
1034
+ groupStack.push("@");
1035
+ segment += "(?:";
1036
+ continue;
1037
+ }
1038
+ if (glob[i] === "?") {
1039
+ if (extended && glob[i + 1] === "(") {
1040
+ i++;
1041
+ groupStack.push("?");
1042
+ segment += "(?:";
1043
+ } else {
1044
+ segment += ".";
1045
+ }
1046
+ continue;
1047
+ }
1048
+ if (glob[i] === "!" && extended && glob[i + 1] === "(") {
1049
+ i++;
1050
+ groupStack.push("!");
1051
+ segment += "(?!";
1052
+ continue;
1053
+ }
1054
+ if (glob[i] === "{") {
1055
+ groupStack.push("BRACE");
1056
+ segment += "(?:";
1057
+ continue;
1058
+ }
1059
+ if (glob[i] === "}" && groupStack[groupStack.length - 1] === "BRACE") {
1060
+ groupStack.pop();
1061
+ segment += ")";
1062
+ continue;
1063
+ }
1064
+ if (glob[i] === "," && groupStack[groupStack.length - 1] === "BRACE") {
1065
+ segment += "|";
1066
+ continue;
1067
+ }
1068
+ if (glob[i] === "*") {
1069
+ if (extended && glob[i + 1] === "(") {
1070
+ i++;
1071
+ groupStack.push("*");
1072
+ segment += "(?:";
1073
+ } else {
1074
+ const prevChar = glob[i - 1];
1075
+ let numStars = 1;
1076
+ while(glob[i + 1] === "*"){
1077
+ i++;
1078
+ numStars++;
1079
+ }
1080
+ const nextChar = glob[i + 1];
1081
+ if (globstarOption && numStars === 2 && [
1082
+ ...c.seps,
1083
+ undefined
1084
+ ].includes(prevChar) && [
1085
+ ...c.seps,
1086
+ undefined
1087
+ ].includes(nextChar)) {
1088
+ segment += c.globstar;
1089
+ endsWithSep = true;
1090
+ } else {
1091
+ segment += c.wildcard;
1092
+ }
1093
+ }
1094
+ continue;
1095
+ }
1096
+ segment += REG_EXP_ESCAPE_CHARS.includes(glob[i]) ? `\\${glob[i]}` : glob[i];
1097
+ }
1098
+ // Check for unclosed groups or a dangling backslash.
1099
+ if (groupStack.length > 0 || inRange || inEscape) {
1100
+ // Parse failure. Take all characters from this segment literally.
1101
+ segment = "";
1102
+ for (const c of glob.slice(j, i)){
1103
+ segment += REG_EXP_ESCAPE_CHARS.includes(c) ? `\\${c}` : c;
1104
+ endsWithSep = false;
1105
+ }
1106
+ }
1107
+ regExpString += segment;
1108
+ if (!endsWithSep) {
1109
+ regExpString += i < glob.length ? c.sep : c.sepMaybe;
1110
+ endsWithSep = true;
1111
+ }
1112
+ // Terminates with `i` at the start of the next segment.
1113
+ while(c.seps.includes(glob[i]))i++;
1114
+ j = i;
1115
+ }
1116
+ regExpString = `^${regExpString}$`;
1117
+ return new RegExp(regExpString, caseInsensitive ? "i" : "");
1118
+ }
1119
+
1120
+ // Copyright 2018-2025 the Deno authors. MIT license.
1121
+ // This module is browser compatible.
1122
+ const constants = {
1123
+ sep: "/+",
1124
+ sepMaybe: "/*",
1125
+ seps: [
1126
+ "/"
1127
+ ],
1128
+ globstar: "(?:[^/]*(?:/|$)+)*",
1129
+ wildcard: "[^/]*",
1130
+ escapePrefix: "\\"
1131
+ };
1132
+ /** Convert a glob string to a regular expression.
1133
+ *
1134
+ * Tries to match bash glob expansion as closely as possible.
1135
+ *
1136
+ * Basic glob syntax:
1137
+ * - `*` - Matches everything without leaving the path segment.
1138
+ * - `?` - Matches any single character.
1139
+ * - `{foo,bar}` - Matches `foo` or `bar`.
1140
+ * - `[abcd]` - Matches `a`, `b`, `c` or `d`.
1141
+ * - `[a-d]` - Matches `a`, `b`, `c` or `d`.
1142
+ * - `[!abcd]` - Matches any single character besides `a`, `b`, `c` or `d`.
1143
+ * - `[[:<class>:]]` - Matches any character belonging to `<class>`.
1144
+ * - `[[:alnum:]]` - Matches any digit or letter.
1145
+ * - `[[:digit:]abc]` - Matches any digit, `a`, `b` or `c`.
1146
+ * - See https://facelessuser.github.io/wcmatch/glob/#posix-character-classes
1147
+ * for a complete list of supported character classes.
1148
+ * - `\` - Escapes the next character for an `os` other than `"windows"`.
1149
+ * - \` - Escapes the next character for `os` set to `"windows"`.
1150
+ * - `/` - Path separator.
1151
+ * - `\` - Additional path separator only for `os` set to `"windows"`.
1152
+ *
1153
+ * Extended syntax:
1154
+ * - Requires `{ extended: true }`.
1155
+ * - `?(foo|bar)` - Matches 0 or 1 instance of `{foo,bar}`.
1156
+ * - `@(foo|bar)` - Matches 1 instance of `{foo,bar}`. They behave the same.
1157
+ * - `*(foo|bar)` - Matches _n_ instances of `{foo,bar}`.
1158
+ * - `+(foo|bar)` - Matches _n > 0_ instances of `{foo,bar}`.
1159
+ * - `!(foo|bar)` - Matches anything other than `{foo,bar}`.
1160
+ * - See https://www.linuxjournal.com/content/bash-extended-globbing.
1161
+ *
1162
+ * Globstar syntax:
1163
+ * - Requires `{ globstar: true }`.
1164
+ * - `**` - Matches any number of any path segments.
1165
+ * - Must comprise its entire path segment in the provided glob.
1166
+ * - See https://www.linuxjournal.com/content/globstar-new-bash-globbing-option.
1167
+ *
1168
+ * Note the following properties:
1169
+ * - The generated `RegExp` is anchored at both start and end.
1170
+ * - Repeating and trailing separators are tolerated. Trailing separators in the
1171
+ * provided glob have no meaning and are discarded.
1172
+ * - Absolute globs will only match absolute paths, etc.
1173
+ * - Empty globs will match nothing.
1174
+ * - Any special glob syntax must be contained to one path segment. For example,
1175
+ * `?(foo|bar/baz)` is invalid. The separator will take precedence and the
1176
+ * first segment ends with an unclosed group.
1177
+ * - If a path segment ends with unclosed groups or a dangling escape prefix, a
1178
+ * parse error has occurred. Every character for that segment is taken
1179
+ * literally in this event.
1180
+ *
1181
+ * Limitations:
1182
+ * - A negative group like `!(foo|bar)` will wrongly be converted to a negative
1183
+ * look-ahead followed by a wildcard. This means that `!(foo).js` will wrongly
1184
+ * fail to match `foobar.js`, even though `foobar` is not `foo`. Effectively,
1185
+ * `!(foo|bar)` is treated like `!(@(foo|bar)*)`. This will work correctly if
1186
+ * the group occurs not nested at the end of the segment.
1187
+ *
1188
+ * @example Usage
1189
+ * ```ts
1190
+ * import { globToRegExp } from "@std/path/posix/glob-to-regexp";
1191
+ * import { assertEquals } from "@std/assert";
1192
+ *
1193
+ * assertEquals(globToRegExp("*.js"), /^[^/]*\.js\/*$/);
1194
+ * ```
1195
+ *
1196
+ * @param glob Glob string to convert.
1197
+ * @param options Conversion options.
1198
+ * @returns The regular expression equivalent to the glob.
1199
+ */ function globToRegExp(glob, options = {}) {
1200
+ return _globToRegExp(constants, glob, options);
1201
+ }
1202
+
1203
+ // Copyright 2018-2025 the Deno authors. MIT license.
1204
+ // This module is browser compatible.
1205
+ /**
1206
+ * Test whether the given string is a glob.
1207
+ *
1208
+ * @example Usage
1209
+ * ```ts
1210
+ * import { isGlob } from "@std/path/is-glob";
1211
+ * import { assert } from "@std/assert";
1212
+ *
1213
+ * assert(!isGlob("foo/bar/../baz"));
1214
+ * assert(isGlob("foo/*ar/../baz"));
1215
+ * ```
1216
+ *
1217
+ * @param str String to test.
1218
+ * @returns `true` if the given string is a glob, otherwise `false`
1219
+ */ function isGlob(str) {
1220
+ const chars = {
1221
+ "{": "}",
1222
+ "(": ")",
1223
+ "[": "]"
1224
+ };
1225
+ const regex = /\\(.)|(^!|\*|\?|[\].+)]\?|\[[^[\\\]]+\]|\{[^{\\}]+\}|\(\?[:!=][^\\)]+\)|\([^(|]+\|[^\\)]+\)|@\([^)]+\))/;
1226
+ if (str === "") {
1227
+ return false;
1228
+ }
1229
+ let match;
1230
+ while(match = regex.exec(str)){
1231
+ if (match[2]) return true;
1232
+ let idx = match.index + match[0].length;
1233
+ // if an open bracket/brace/paren is escaped,
1234
+ // set the index to the next closing character
1235
+ const open = match[1];
1236
+ const close = open ? chars[open] : null;
1237
+ if (open && close) {
1238
+ const n = str.indexOf(close, idx);
1239
+ if (n !== -1) {
1240
+ idx = n + 1;
1241
+ }
1242
+ }
1243
+ str = str.slice(idx);
1244
+ }
1245
+ return false;
1246
+ }
1247
+
1248
+ // Copyright 2018-2025 the Deno authors. MIT license.
1249
+ // This module is browser compatible.
1250
+ /**
1251
+ * Like normalize(), but doesn't collapse "**\/.." when `globstar` is true.
1252
+ *
1253
+ * @example Usage
1254
+ * ```ts
1255
+ * import { normalizeGlob } from "@std/path/posix/normalize-glob";
1256
+ * import { assertEquals } from "@std/assert";
1257
+ *
1258
+ * const path = normalizeGlob("foo/bar/../*", { globstar: true });
1259
+ * assertEquals(path, "foo/*");
1260
+ * ```
1261
+ *
1262
+ * @param glob The glob to normalize.
1263
+ * @param options The options to use.
1264
+ * @returns The normalized path.
1265
+ */ function normalizeGlob(glob, options = {}) {
1266
+ const { globstar = false } = options;
1267
+ if (glob.match(/\0/g)) {
1268
+ throw new Error(`Glob contains invalid characters: "${glob}"`);
1269
+ }
1270
+ if (!globstar) {
1271
+ return normalize(glob);
1272
+ }
1273
+ const s = SEPARATOR_PATTERN.source;
1274
+ const badParentPattern = new RegExp(`(?<=(${s}|^)\\*\\*${s})\\.\\.(?=${s}|$)`, "g");
1275
+ return normalize(glob.replace(badParentPattern, "\0")).replace(/\0/g, "..");
1276
+ }
1277
+
1278
+ // Copyright 2018-2025 the Deno authors. MIT license.
1279
+ // This module is browser compatible.
1280
+ /**
1281
+ * Like join(), but doesn't collapse "**\/.." when `globstar` is true.
1282
+ *
1283
+ * @example Usage
1284
+ * ```ts
1285
+ * import { joinGlobs } from "@std/path/posix/join-globs";
1286
+ * import { assertEquals } from "@std/assert";
1287
+ *
1288
+ * const path = joinGlobs(["foo", "bar", "**"], { globstar: true });
1289
+ * assertEquals(path, "foo/bar/**");
1290
+ * ```
1291
+ *
1292
+ * @param globs The globs to join.
1293
+ * @param options The options to use.
1294
+ * @returns The joined path.
1295
+ */ function joinGlobs(globs, options = {}) {
1296
+ const { globstar = false } = options;
1297
+ if (!globstar || globs.length === 0) {
1298
+ return join(...globs);
1299
+ }
1300
+ let joined;
1301
+ for (const glob of globs){
1302
+ const path = glob;
1303
+ if (path.length > 0) {
1304
+ if (!joined) joined = path;
1305
+ else joined += `${SEPARATOR}${path}`;
1306
+ }
1307
+ }
1308
+ if (!joined) return ".";
1309
+ return normalizeGlob(joined, {
1310
+ globstar
1311
+ });
1312
+ }
1313
+
1314
+ export { DELIMITER, SEPARATOR, SEPARATOR_PATTERN, basename, common, dirname, extname, format, fromFileUrl, globToRegExp, isAbsolute, isGlob, join, joinGlobs, normalize, normalizeGlob, parse, relative, resolve, toFileUrl, toNamespacedPath };
server/node_modules/@eslint/config-array/dist/esm/std__path/windows.js ADDED
@@ -0,0 +1,1656 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-nocheck
2
+ // Copyright 2018-2025 the Deno authors. MIT license.
3
+ // Copyright the Browserify authors. MIT License.
4
+ function assertPath(path) {
5
+ if (typeof path !== "string") {
6
+ throw new TypeError(`Path must be a string, received "${JSON.stringify(path)}"`);
7
+ }
8
+ }
9
+
10
+ // Copyright 2018-2025 the Deno authors. MIT license.
11
+ // This module is browser compatible.
12
+ function stripSuffix(name, suffix) {
13
+ if (suffix.length >= name.length) {
14
+ return name;
15
+ }
16
+ const lenDiff = name.length - suffix.length;
17
+ for(let i = suffix.length - 1; i >= 0; --i){
18
+ if (name.charCodeAt(lenDiff + i) !== suffix.charCodeAt(i)) {
19
+ return name;
20
+ }
21
+ }
22
+ return name.slice(0, -suffix.length);
23
+ }
24
+ function lastPathSegment(path, isSep, start = 0) {
25
+ let matchedNonSeparator = false;
26
+ let end = path.length;
27
+ for(let i = path.length - 1; i >= start; --i){
28
+ if (isSep(path.charCodeAt(i))) {
29
+ if (matchedNonSeparator) {
30
+ start = i + 1;
31
+ break;
32
+ }
33
+ } else if (!matchedNonSeparator) {
34
+ matchedNonSeparator = true;
35
+ end = i + 1;
36
+ }
37
+ }
38
+ return path.slice(start, end);
39
+ }
40
+ function assertArgs$1(path, suffix) {
41
+ assertPath(path);
42
+ if (path.length === 0) return path;
43
+ if (typeof suffix !== "string") {
44
+ throw new TypeError(`Suffix must be a string, received "${JSON.stringify(suffix)}"`);
45
+ }
46
+ }
47
+
48
+ // Copyright 2018-2025 the Deno authors. MIT license.
49
+ // Copyright the Browserify authors. MIT License.
50
+ // Ported from https://github.com/browserify/path-browserify/
51
+ // This module is browser compatible.
52
+ // Alphabet chars.
53
+ const CHAR_UPPERCASE_A = 65; /* A */
54
+ const CHAR_LOWERCASE_A = 97; /* a */
55
+ const CHAR_UPPERCASE_Z = 90; /* Z */
56
+ const CHAR_LOWERCASE_Z = 122; /* z */
57
+ // Non-alphabetic chars.
58
+ const CHAR_DOT = 46; /* . */
59
+ const CHAR_FORWARD_SLASH = 47; /* / */
60
+ const CHAR_BACKWARD_SLASH = 92; /* \ */
61
+ const CHAR_COLON = 58; /* : */
62
+ const CHAR_QUESTION_MARK = 63; /* ? */
63
+
64
+ // Copyright 2018-2025 the Deno authors. MIT license.
65
+ // Copyright the Browserify authors. MIT License.
66
+ // Ported from https://github.com/browserify/path-browserify/
67
+ // This module is browser compatible.
68
+ function stripTrailingSeparators(segment, isSep) {
69
+ if (segment.length <= 1) {
70
+ return segment;
71
+ }
72
+ let end = segment.length;
73
+ for(let i = segment.length - 1; i > 0; i--){
74
+ if (isSep(segment.charCodeAt(i))) {
75
+ end = i;
76
+ } else {
77
+ break;
78
+ }
79
+ }
80
+ return segment.slice(0, end);
81
+ }
82
+
83
+ // Copyright 2018-2025 the Deno authors. MIT license.
84
+ // Copyright the Browserify authors. MIT License.
85
+ // Ported from https://github.com/browserify/path-browserify/
86
+ // This module is browser compatible.
87
+ function isPosixPathSeparator(code) {
88
+ return code === CHAR_FORWARD_SLASH;
89
+ }
90
+ function isPathSeparator(code) {
91
+ return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
92
+ }
93
+ function isWindowsDeviceRoot(code) {
94
+ return code >= CHAR_LOWERCASE_A && code <= CHAR_LOWERCASE_Z || code >= CHAR_UPPERCASE_A && code <= CHAR_UPPERCASE_Z;
95
+ }
96
+
97
+ // Copyright 2018-2025 the Deno authors. MIT license.
98
+ // This module is browser compatible.
99
+ function assertArg$3(url) {
100
+ url = url instanceof URL ? url : new URL(url);
101
+ if (url.protocol !== "file:") {
102
+ throw new TypeError(`URL must be a file URL: received "${url.protocol}"`);
103
+ }
104
+ return url;
105
+ }
106
+
107
+ // Copyright 2018-2025 the Deno authors. MIT license.
108
+ // This module is browser compatible.
109
+ /**
110
+ * Converts a file URL to a path string.
111
+ *
112
+ * @example Usage
113
+ * ```ts
114
+ * import { fromFileUrl } from "@std/path/windows/from-file-url";
115
+ * import { assertEquals } from "@std/assert";
116
+ *
117
+ * assertEquals(fromFileUrl("file:///home/foo"), "\\home\\foo");
118
+ * assertEquals(fromFileUrl("file:///C:/Users/foo"), "C:\\Users\\foo");
119
+ * assertEquals(fromFileUrl("file://localhost/home/foo"), "\\home\\foo");
120
+ * ```
121
+ *
122
+ * @param url The file URL to convert.
123
+ * @returns The path string.
124
+ */ function fromFileUrl(url) {
125
+ url = assertArg$3(url);
126
+ let path = decodeURIComponent(url.pathname.replace(/\//g, "\\").replace(/%(?![0-9A-Fa-f]{2})/g, "%25")).replace(/^\\*([A-Za-z]:)(\\|$)/, "$1\\");
127
+ if (url.hostname !== "") {
128
+ // Note: The `URL` implementation guarantees that the drive letter and
129
+ // hostname are mutually exclusive. Otherwise it would not have been valid
130
+ // to append the hostname and path like this.
131
+ path = `\\\\${url.hostname}${path}`;
132
+ }
133
+ return path;
134
+ }
135
+
136
+ // Copyright 2018-2025 the Deno authors. MIT license.
137
+ // This module is browser compatible.
138
+ /**
139
+ * Return the last portion of a `path`.
140
+ * Trailing directory separators are ignored, and optional suffix is removed.
141
+ *
142
+ * @example Usage
143
+ * ```ts
144
+ * import { basename } from "@std/path/windows/basename";
145
+ * import { assertEquals } from "@std/assert";
146
+ *
147
+ * assertEquals(basename("C:\\user\\Documents\\"), "Documents");
148
+ * assertEquals(basename("C:\\user\\Documents\\image.png"), "image.png");
149
+ * assertEquals(basename("C:\\user\\Documents\\image.png", ".png"), "image");
150
+ * assertEquals(basename(new URL("file:///C:/user/Documents/image.png")), "image.png");
151
+ * assertEquals(basename(new URL("file:///C:/user/Documents/image.png"), ".png"), "image");
152
+ * ```
153
+ *
154
+ * @param path The path to extract the name from.
155
+ * @param suffix The suffix to remove from extracted name.
156
+ * @returns The extracted name.
157
+ */ function basename(path, suffix = "") {
158
+ if (path instanceof URL) {
159
+ path = fromFileUrl(path);
160
+ }
161
+ assertArgs$1(path, suffix);
162
+ // Check for a drive letter prefix so as not to mistake the following
163
+ // path separator as an extra separator at the end of the path that can be
164
+ // disregarded
165
+ let start = 0;
166
+ if (path.length >= 2) {
167
+ const drive = path.charCodeAt(0);
168
+ if (isWindowsDeviceRoot(drive)) {
169
+ if (path.charCodeAt(1) === CHAR_COLON) start = 2;
170
+ }
171
+ }
172
+ const lastSegment = lastPathSegment(path, isPathSeparator, start);
173
+ const strippedSegment = stripTrailingSeparators(lastSegment, isPathSeparator);
174
+ return suffix ? stripSuffix(strippedSegment, suffix) : strippedSegment;
175
+ }
176
+
177
+ // Copyright 2018-2025 the Deno authors. MIT license.
178
+ // This module is browser compatible.
179
+ /**
180
+ * The character used to separate entries in the PATH environment variable.
181
+ */ const DELIMITER = ";";
182
+ /**
183
+ * The character used to separate components of a file path.
184
+ */ const SEPARATOR = "\\";
185
+ /**
186
+ * A regular expression that matches one or more path separators.
187
+ */ const SEPARATOR_PATTERN = /[\\/]+/;
188
+
189
+ // Copyright 2018-2025 the Deno authors. MIT license.
190
+ // This module is browser compatible.
191
+ function assertArg$2(path) {
192
+ assertPath(path);
193
+ if (path.length === 0) return ".";
194
+ }
195
+
196
+ // Copyright 2018-2025 the Deno authors. MIT license.
197
+ // This module is browser compatible.
198
+ /**
199
+ * Return the directory path of a `path`.
200
+ *
201
+ * @example Usage
202
+ * ```ts
203
+ * import { dirname } from "@std/path/windows/dirname";
204
+ * import { assertEquals } from "@std/assert";
205
+ *
206
+ * assertEquals(dirname("C:\\foo\\bar\\baz.ext"), "C:\\foo\\bar");
207
+ * assertEquals(dirname(new URL("file:///C:/foo/bar/baz.ext")), "C:\\foo\\bar");
208
+ * ```
209
+ *
210
+ * @param path The path to get the directory from.
211
+ * @returns The directory path.
212
+ */ function dirname(path) {
213
+ if (path instanceof URL) {
214
+ path = fromFileUrl(path);
215
+ }
216
+ assertArg$2(path);
217
+ const len = path.length;
218
+ let rootEnd = -1;
219
+ let end = -1;
220
+ let matchedSlash = true;
221
+ let offset = 0;
222
+ const code = path.charCodeAt(0);
223
+ // Try to match a root
224
+ if (len > 1) {
225
+ if (isPathSeparator(code)) {
226
+ // Possible UNC root
227
+ rootEnd = offset = 1;
228
+ if (isPathSeparator(path.charCodeAt(1))) {
229
+ // Matched double path separator at beginning
230
+ let j = 2;
231
+ let last = j;
232
+ // Match 1 or more non-path separators
233
+ for(; j < len; ++j){
234
+ if (isPathSeparator(path.charCodeAt(j))) break;
235
+ }
236
+ if (j < len && j !== last) {
237
+ // Matched!
238
+ last = j;
239
+ // Match 1 or more path separators
240
+ for(; j < len; ++j){
241
+ if (!isPathSeparator(path.charCodeAt(j))) break;
242
+ }
243
+ if (j < len && j !== last) {
244
+ // Matched!
245
+ last = j;
246
+ // Match 1 or more non-path separators
247
+ for(; j < len; ++j){
248
+ if (isPathSeparator(path.charCodeAt(j))) break;
249
+ }
250
+ if (j === len) {
251
+ // We matched a UNC root only
252
+ return path;
253
+ }
254
+ if (j !== last) {
255
+ // We matched a UNC root with leftovers
256
+ // Offset by 1 to include the separator after the UNC root to
257
+ // treat it as a "normal root" on top of a (UNC) root
258
+ rootEnd = offset = j + 1;
259
+ }
260
+ }
261
+ }
262
+ }
263
+ } else if (isWindowsDeviceRoot(code)) {
264
+ // Possible device root
265
+ if (path.charCodeAt(1) === CHAR_COLON) {
266
+ rootEnd = offset = 2;
267
+ if (len > 2) {
268
+ if (isPathSeparator(path.charCodeAt(2))) rootEnd = offset = 3;
269
+ }
270
+ }
271
+ }
272
+ } else if (isPathSeparator(code)) {
273
+ // `path` contains just a path separator, exit early to avoid
274
+ // unnecessary work
275
+ return path;
276
+ }
277
+ for(let i = len - 1; i >= offset; --i){
278
+ if (isPathSeparator(path.charCodeAt(i))) {
279
+ if (!matchedSlash) {
280
+ end = i;
281
+ break;
282
+ }
283
+ } else {
284
+ // We saw the first non-path separator
285
+ matchedSlash = false;
286
+ }
287
+ }
288
+ if (end === -1) {
289
+ if (rootEnd === -1) return ".";
290
+ else end = rootEnd;
291
+ }
292
+ return stripTrailingSeparators(path.slice(0, end), isPosixPathSeparator);
293
+ }
294
+
295
+ // Copyright 2018-2025 the Deno authors. MIT license.
296
+ // This module is browser compatible.
297
+ /**
298
+ * Return the extension of the `path` with leading period.
299
+ *
300
+ * @example Usage
301
+ * ```ts
302
+ * import { extname } from "@std/path/windows/extname";
303
+ * import { assertEquals } from "@std/assert";
304
+ *
305
+ * assertEquals(extname("file.ts"), ".ts");
306
+ * assertEquals(extname(new URL("file:///C:/foo/bar/baz.ext")), ".ext");
307
+ * ```
308
+ *
309
+ * @param path The path to get the extension from.
310
+ * @returns The extension of the `path`.
311
+ */ function extname(path) {
312
+ if (path instanceof URL) {
313
+ path = fromFileUrl(path);
314
+ }
315
+ assertPath(path);
316
+ let start = 0;
317
+ let startDot = -1;
318
+ let startPart = 0;
319
+ let end = -1;
320
+ let matchedSlash = true;
321
+ // Track the state of characters (if any) we see before our first dot and
322
+ // after any path separator we find
323
+ let preDotState = 0;
324
+ // Check for a drive letter prefix so as not to mistake the following
325
+ // path separator as an extra separator at the end of the path that can be
326
+ // disregarded
327
+ if (path.length >= 2 && path.charCodeAt(1) === CHAR_COLON && isWindowsDeviceRoot(path.charCodeAt(0))) {
328
+ start = startPart = 2;
329
+ }
330
+ for(let i = path.length - 1; i >= start; --i){
331
+ const code = path.charCodeAt(i);
332
+ if (isPathSeparator(code)) {
333
+ // If we reached a path separator that was not part of a set of path
334
+ // separators at the end of the string, stop now
335
+ if (!matchedSlash) {
336
+ startPart = i + 1;
337
+ break;
338
+ }
339
+ continue;
340
+ }
341
+ if (end === -1) {
342
+ // We saw the first non-path separator, mark this as the end of our
343
+ // extension
344
+ matchedSlash = false;
345
+ end = i + 1;
346
+ }
347
+ if (code === CHAR_DOT) {
348
+ // If this is our first dot, mark it as the start of our extension
349
+ if (startDot === -1) startDot = i;
350
+ else if (preDotState !== 1) preDotState = 1;
351
+ } else if (startDot !== -1) {
352
+ // We saw a non-dot and non-path separator before our dot, so we should
353
+ // have a good chance at having a non-empty extension
354
+ preDotState = -1;
355
+ }
356
+ }
357
+ if (startDot === -1 || end === -1 || // We saw a non-dot character immediately before the dot
358
+ preDotState === 0 || // The (right-most) trimmed path component is exactly '..'
359
+ preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
360
+ return "";
361
+ }
362
+ return path.slice(startDot, end);
363
+ }
364
+
365
+ // Copyright 2018-2025 the Deno authors. MIT license.
366
+ // This module is browser compatible.
367
+ function _format(sep, pathObject) {
368
+ const dir = pathObject.dir || pathObject.root;
369
+ const base = pathObject.base || (pathObject.name ?? "") + (pathObject.ext ?? "");
370
+ if (!dir) return base;
371
+ if (base === sep) return dir;
372
+ if (dir === pathObject.root) return dir + base;
373
+ return dir + sep + base;
374
+ }
375
+ function assertArg$1(pathObject) {
376
+ if (pathObject === null || typeof pathObject !== "object") {
377
+ throw new TypeError(`The "pathObject" argument must be of type Object, received type "${typeof pathObject}"`);
378
+ }
379
+ }
380
+
381
+ // Copyright 2018-2025 the Deno authors. MIT license.
382
+ // This module is browser compatible.
383
+ /**
384
+ * Generate a path from `ParsedPath` object.
385
+ *
386
+ * @example Usage
387
+ * ```ts
388
+ * import { format } from "@std/path/windows/format";
389
+ * import { assertEquals } from "@std/assert";
390
+ *
391
+ * const path = format({
392
+ * root: "C:\\",
393
+ * dir: "C:\\path\\dir",
394
+ * base: "file.txt",
395
+ * ext: ".txt",
396
+ * name: "file"
397
+ * });
398
+ * assertEquals(path, "C:\\path\\dir\\file.txt");
399
+ * ```
400
+ *
401
+ * @param pathObject The path object to format.
402
+ * @returns The formatted path.
403
+ */ function format(pathObject) {
404
+ assertArg$1(pathObject);
405
+ return _format("\\", pathObject);
406
+ }
407
+
408
+ // Copyright 2018-2025 the Deno authors. MIT license.
409
+ // This module is browser compatible.
410
+ /**
411
+ * Verifies whether provided path is absolute.
412
+ *
413
+ * @example Usage
414
+ * ```ts
415
+ * import { isAbsolute } from "@std/path/windows/is-absolute";
416
+ * import { assert, assertFalse } from "@std/assert";
417
+ *
418
+ * assert(isAbsolute("C:\\foo\\bar"));
419
+ * assertFalse(isAbsolute("..\\baz"));
420
+ * ```
421
+ *
422
+ * @param path The path to verify.
423
+ * @returns `true` if the path is absolute, `false` otherwise.
424
+ */ function isAbsolute(path) {
425
+ assertPath(path);
426
+ const len = path.length;
427
+ if (len === 0) return false;
428
+ const code = path.charCodeAt(0);
429
+ if (isPathSeparator(code)) {
430
+ return true;
431
+ } else if (isWindowsDeviceRoot(code)) {
432
+ // Possible device root
433
+ if (len > 2 && path.charCodeAt(1) === CHAR_COLON) {
434
+ if (isPathSeparator(path.charCodeAt(2))) return true;
435
+ }
436
+ }
437
+ return false;
438
+ }
439
+
440
+ // Copyright 2018-2025 the Deno authors. MIT license.
441
+ // This module is browser compatible.
442
+ function assertArg(path) {
443
+ assertPath(path);
444
+ if (path.length === 0) return ".";
445
+ }
446
+
447
+ // Copyright 2018-2025 the Deno authors. MIT license.
448
+ // Copyright the Browserify authors. MIT License.
449
+ // Ported from https://github.com/browserify/path-browserify/
450
+ // This module is browser compatible.
451
+ // Resolves . and .. elements in a path with directory names
452
+ function normalizeString(path, allowAboveRoot, separator, isPathSeparator) {
453
+ let res = "";
454
+ let lastSegmentLength = 0;
455
+ let lastSlash = -1;
456
+ let dots = 0;
457
+ let code;
458
+ for(let i = 0; i <= path.length; ++i){
459
+ if (i < path.length) code = path.charCodeAt(i);
460
+ else if (isPathSeparator(code)) break;
461
+ else code = CHAR_FORWARD_SLASH;
462
+ if (isPathSeparator(code)) {
463
+ if (lastSlash === i - 1 || dots === 1) ; else if (lastSlash !== i - 1 && dots === 2) {
464
+ if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== CHAR_DOT || res.charCodeAt(res.length - 2) !== CHAR_DOT) {
465
+ if (res.length > 2) {
466
+ const lastSlashIndex = res.lastIndexOf(separator);
467
+ if (lastSlashIndex === -1) {
468
+ res = "";
469
+ lastSegmentLength = 0;
470
+ } else {
471
+ res = res.slice(0, lastSlashIndex);
472
+ lastSegmentLength = res.length - 1 - res.lastIndexOf(separator);
473
+ }
474
+ lastSlash = i;
475
+ dots = 0;
476
+ continue;
477
+ } else if (res.length === 2 || res.length === 1) {
478
+ res = "";
479
+ lastSegmentLength = 0;
480
+ lastSlash = i;
481
+ dots = 0;
482
+ continue;
483
+ }
484
+ }
485
+ if (allowAboveRoot) {
486
+ if (res.length > 0) res += `${separator}..`;
487
+ else res = "..";
488
+ lastSegmentLength = 2;
489
+ }
490
+ } else {
491
+ if (res.length > 0) res += separator + path.slice(lastSlash + 1, i);
492
+ else res = path.slice(lastSlash + 1, i);
493
+ lastSegmentLength = i - lastSlash - 1;
494
+ }
495
+ lastSlash = i;
496
+ dots = 0;
497
+ } else if (code === CHAR_DOT && dots !== -1) {
498
+ ++dots;
499
+ } else {
500
+ dots = -1;
501
+ }
502
+ }
503
+ return res;
504
+ }
505
+
506
+ // Copyright 2018-2025 the Deno authors. MIT license.
507
+ // This module is browser compatible.
508
+ /**
509
+ * Normalize the `path`, resolving `'..'` and `'.'` segments.
510
+ * Note that resolving these segments does not necessarily mean that all will be eliminated.
511
+ * A `'..'` at the top-level will be preserved, and an empty path is canonically `'.'`.
512
+ *
513
+ * @example Usage
514
+ * ```ts
515
+ * import { normalize } from "@std/path/windows/normalize";
516
+ * import { assertEquals } from "@std/assert";
517
+ *
518
+ * assertEquals(normalize("C:\\foo\\..\\bar"), "C:\\bar");
519
+ * assertEquals(normalize(new URL("file:///C:/foo/../bar")), "C:\\bar");
520
+ * ```
521
+ *
522
+ * @param path The path to normalize
523
+ * @returns The normalized path
524
+ */ function normalize(path) {
525
+ if (path instanceof URL) {
526
+ path = fromFileUrl(path);
527
+ }
528
+ assertArg(path);
529
+ const len = path.length;
530
+ let rootEnd = 0;
531
+ let device;
532
+ let isAbsolute = false;
533
+ const code = path.charCodeAt(0);
534
+ // Try to match a root
535
+ if (len > 1) {
536
+ if (isPathSeparator(code)) {
537
+ // Possible UNC root
538
+ // If we started with a separator, we know we at least have an absolute
539
+ // path of some kind (UNC or otherwise)
540
+ isAbsolute = true;
541
+ if (isPathSeparator(path.charCodeAt(1))) {
542
+ // Matched double path separator at beginning
543
+ let j = 2;
544
+ let last = j;
545
+ // Match 1 or more non-path separators
546
+ for(; j < len; ++j){
547
+ if (isPathSeparator(path.charCodeAt(j))) break;
548
+ }
549
+ if (j < len && j !== last) {
550
+ const firstPart = path.slice(last, j);
551
+ // Matched!
552
+ last = j;
553
+ // Match 1 or more path separators
554
+ for(; j < len; ++j){
555
+ if (!isPathSeparator(path.charCodeAt(j))) break;
556
+ }
557
+ if (j < len && j !== last) {
558
+ // Matched!
559
+ last = j;
560
+ // Match 1 or more non-path separators
561
+ for(; j < len; ++j){
562
+ if (isPathSeparator(path.charCodeAt(j))) break;
563
+ }
564
+ if (j === len) {
565
+ // We matched a UNC root only
566
+ // Return the normalized version of the UNC root since there
567
+ // is nothing left to process
568
+ return `\\\\${firstPart}\\${path.slice(last)}\\`;
569
+ } else if (j !== last) {
570
+ // We matched a UNC root with leftovers
571
+ device = `\\\\${firstPart}\\${path.slice(last, j)}`;
572
+ rootEnd = j;
573
+ }
574
+ }
575
+ }
576
+ } else {
577
+ rootEnd = 1;
578
+ }
579
+ } else if (isWindowsDeviceRoot(code)) {
580
+ // Possible device root
581
+ if (path.charCodeAt(1) === CHAR_COLON) {
582
+ device = path.slice(0, 2);
583
+ rootEnd = 2;
584
+ if (len > 2) {
585
+ if (isPathSeparator(path.charCodeAt(2))) {
586
+ // Treat separator following drive name as an absolute path
587
+ // indicator
588
+ isAbsolute = true;
589
+ rootEnd = 3;
590
+ }
591
+ }
592
+ }
593
+ }
594
+ } else if (isPathSeparator(code)) {
595
+ // `path` contains just a path separator, exit early to avoid unnecessary
596
+ // work
597
+ return "\\";
598
+ }
599
+ let tail;
600
+ if (rootEnd < len) {
601
+ tail = normalizeString(path.slice(rootEnd), !isAbsolute, "\\", isPathSeparator);
602
+ } else {
603
+ tail = "";
604
+ }
605
+ if (tail.length === 0 && !isAbsolute) tail = ".";
606
+ if (tail.length > 0 && isPathSeparator(path.charCodeAt(len - 1))) {
607
+ tail += "\\";
608
+ }
609
+ if (device === undefined) {
610
+ if (isAbsolute) {
611
+ if (tail.length > 0) return `\\${tail}`;
612
+ else return "\\";
613
+ }
614
+ return tail;
615
+ } else if (isAbsolute) {
616
+ if (tail.length > 0) return `${device}\\${tail}`;
617
+ else return `${device}\\`;
618
+ }
619
+ return device + tail;
620
+ }
621
+
622
+ // Copyright 2018-2025 the Deno authors. MIT license.
623
+ // This module is browser compatible.
624
+ /**
625
+ * Join all given a sequence of `paths`,then normalizes the resulting path.
626
+ *
627
+ * @example Usage
628
+ * ```ts
629
+ * import { join } from "@std/path/windows/join";
630
+ * import { assertEquals } from "@std/assert";
631
+ *
632
+ * assertEquals(join("C:\\foo", "bar", "baz\\.."), "C:\\foo\\bar");
633
+ * assertEquals(join(new URL("file:///C:/foo"), "bar", "baz\\.."), "C:\\foo\\bar");
634
+ * ```
635
+ *
636
+ * @param path The path to join. This can be string or file URL.
637
+ * @param paths The paths to join.
638
+ * @returns The joined path.
639
+ */ function join(path, ...paths) {
640
+ if (path instanceof URL) {
641
+ path = fromFileUrl(path);
642
+ }
643
+ paths = path ? [
644
+ path,
645
+ ...paths
646
+ ] : paths;
647
+ paths.forEach((path)=>assertPath(path));
648
+ paths = paths.filter((path)=>path.length > 0);
649
+ if (paths.length === 0) return ".";
650
+ // Make sure that the joined path doesn't start with two slashes, because
651
+ // normalize() will mistake it for an UNC path then.
652
+ //
653
+ // This step is skipped when it is very clear that the user actually
654
+ // intended to point at an UNC path. This is assumed when the first
655
+ // non-empty string arguments starts with exactly two slashes followed by
656
+ // at least one more non-slash character.
657
+ //
658
+ // Note that for normalize() to treat a path as an UNC path it needs to
659
+ // have at least 2 components, so we don't filter for that here.
660
+ // This means that the user can use join to construct UNC paths from
661
+ // a server name and a share name; for example:
662
+ // path.join('//server', 'share') -> '\\\\server\\share\\'
663
+ let needsReplace = true;
664
+ let slashCount = 0;
665
+ const firstPart = paths[0];
666
+ if (isPathSeparator(firstPart.charCodeAt(0))) {
667
+ ++slashCount;
668
+ const firstLen = firstPart.length;
669
+ if (firstLen > 1) {
670
+ if (isPathSeparator(firstPart.charCodeAt(1))) {
671
+ ++slashCount;
672
+ if (firstLen > 2) {
673
+ if (isPathSeparator(firstPart.charCodeAt(2))) ++slashCount;
674
+ else {
675
+ // We matched a UNC path in the first part
676
+ needsReplace = false;
677
+ }
678
+ }
679
+ }
680
+ }
681
+ }
682
+ let joined = paths.join("\\");
683
+ if (needsReplace) {
684
+ // Find any more consecutive slashes we need to replace
685
+ for(; slashCount < joined.length; ++slashCount){
686
+ if (!isPathSeparator(joined.charCodeAt(slashCount))) break;
687
+ }
688
+ // Replace the slashes if needed
689
+ if (slashCount >= 2) joined = `\\${joined.slice(slashCount)}`;
690
+ }
691
+ return normalize(joined);
692
+ }
693
+
694
+ // Copyright 2018-2025 the Deno authors. MIT license.
695
+ // This module is browser compatible.
696
+ /**
697
+ * Return a `ParsedPath` object of the `path`.
698
+ *
699
+ * @example Usage
700
+ * ```ts
701
+ * import { parse } from "@std/path/windows/parse";
702
+ * import { assertEquals } from "@std/assert";
703
+ *
704
+ * const parsed = parse("C:\\foo\\bar\\baz.ext");
705
+ * assertEquals(parsed, {
706
+ * root: "C:\\",
707
+ * dir: "C:\\foo\\bar",
708
+ * base: "baz.ext",
709
+ * ext: ".ext",
710
+ * name: "baz",
711
+ * });
712
+ * ```
713
+ *
714
+ * @param path The path to parse.
715
+ * @returns The `ParsedPath` object.
716
+ */ function parse(path) {
717
+ assertPath(path);
718
+ const ret = {
719
+ root: "",
720
+ dir: "",
721
+ base: "",
722
+ ext: "",
723
+ name: ""
724
+ };
725
+ const len = path.length;
726
+ if (len === 0) return ret;
727
+ let rootEnd = 0;
728
+ let code = path.charCodeAt(0);
729
+ // Try to match a root
730
+ if (len > 1) {
731
+ if (isPathSeparator(code)) {
732
+ // Possible UNC root
733
+ rootEnd = 1;
734
+ if (isPathSeparator(path.charCodeAt(1))) {
735
+ // Matched double path separator at beginning
736
+ let j = 2;
737
+ let last = j;
738
+ // Match 1 or more non-path separators
739
+ for(; j < len; ++j){
740
+ if (isPathSeparator(path.charCodeAt(j))) break;
741
+ }
742
+ if (j < len && j !== last) {
743
+ // Matched!
744
+ last = j;
745
+ // Match 1 or more path separators
746
+ for(; j < len; ++j){
747
+ if (!isPathSeparator(path.charCodeAt(j))) break;
748
+ }
749
+ if (j < len && j !== last) {
750
+ // Matched!
751
+ last = j;
752
+ // Match 1 or more non-path separators
753
+ for(; j < len; ++j){
754
+ if (isPathSeparator(path.charCodeAt(j))) break;
755
+ }
756
+ if (j === len) {
757
+ // We matched a UNC root only
758
+ rootEnd = j;
759
+ } else if (j !== last) {
760
+ // We matched a UNC root with leftovers
761
+ rootEnd = j + 1;
762
+ }
763
+ }
764
+ }
765
+ }
766
+ } else if (isWindowsDeviceRoot(code)) {
767
+ // Possible device root
768
+ if (path.charCodeAt(1) === CHAR_COLON) {
769
+ rootEnd = 2;
770
+ if (len > 2) {
771
+ if (isPathSeparator(path.charCodeAt(2))) {
772
+ if (len === 3) {
773
+ // `path` contains just a drive root, exit early to avoid
774
+ // unnecessary work
775
+ ret.root = ret.dir = path;
776
+ ret.base = "\\";
777
+ return ret;
778
+ }
779
+ rootEnd = 3;
780
+ }
781
+ } else {
782
+ // `path` contains just a relative drive root, exit early to avoid
783
+ // unnecessary work
784
+ ret.root = ret.dir = path;
785
+ return ret;
786
+ }
787
+ }
788
+ }
789
+ } else if (isPathSeparator(code)) {
790
+ // `path` contains just a path separator, exit early to avoid
791
+ // unnecessary work
792
+ ret.root = ret.dir = path;
793
+ ret.base = "\\";
794
+ return ret;
795
+ }
796
+ if (rootEnd > 0) ret.root = path.slice(0, rootEnd);
797
+ let startDot = -1;
798
+ let startPart = rootEnd;
799
+ let end = -1;
800
+ let matchedSlash = true;
801
+ let i = path.length - 1;
802
+ // Track the state of characters (if any) we see before our first dot and
803
+ // after any path separator we find
804
+ let preDotState = 0;
805
+ // Get non-dir info
806
+ for(; i >= rootEnd; --i){
807
+ code = path.charCodeAt(i);
808
+ if (isPathSeparator(code)) {
809
+ // If we reached a path separator that was not part of a set of path
810
+ // separators at the end of the string, stop now
811
+ if (!matchedSlash) {
812
+ startPart = i + 1;
813
+ break;
814
+ }
815
+ continue;
816
+ }
817
+ if (end === -1) {
818
+ // We saw the first non-path separator, mark this as the end of our
819
+ // extension
820
+ matchedSlash = false;
821
+ end = i + 1;
822
+ }
823
+ if (code === CHAR_DOT) {
824
+ // If this is our first dot, mark it as the start of our extension
825
+ if (startDot === -1) startDot = i;
826
+ else if (preDotState !== 1) preDotState = 1;
827
+ } else if (startDot !== -1) {
828
+ // We saw a non-dot and non-path separator before our dot, so we should
829
+ // have a good chance at having a non-empty extension
830
+ preDotState = -1;
831
+ }
832
+ }
833
+ if (startDot === -1 || end === -1 || // We saw a non-dot character immediately before the dot
834
+ preDotState === 0 || // The (right-most) trimmed path component is exactly '..'
835
+ preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
836
+ if (end !== -1) {
837
+ ret.base = ret.name = path.slice(startPart, end);
838
+ }
839
+ } else {
840
+ ret.name = path.slice(startPart, startDot);
841
+ ret.base = path.slice(startPart, end);
842
+ ret.ext = path.slice(startDot, end);
843
+ }
844
+ // Fallback to '\' in case there is no basename
845
+ ret.base = ret.base || "\\";
846
+ // If the directory is the root, use the entire root as the `dir` including
847
+ // the trailing slash if any (`C:\abc` -> `C:\`). Otherwise, strip out the
848
+ // trailing slash (`C:\abc\def` -> `C:\abc`).
849
+ if (startPart > 0 && startPart !== rootEnd) {
850
+ ret.dir = path.slice(0, startPart - 1);
851
+ } else ret.dir = ret.root;
852
+ return ret;
853
+ }
854
+
855
+ // Copyright 2018-2025 the Deno authors. MIT license.
856
+ // This module is browser compatible.
857
+ /**
858
+ * Resolves path segments into a `path`.
859
+ *
860
+ * @example Usage
861
+ * ```ts
862
+ * import { resolve } from "@std/path/windows/resolve";
863
+ * import { assertEquals } from "@std/assert";
864
+ *
865
+ * const resolved = resolve("C:\\foo\\bar", "..\\baz");
866
+ * assertEquals(resolved, "C:\\foo\\baz");
867
+ * ```
868
+ *
869
+ * @param pathSegments The path segments to process to path
870
+ * @returns The resolved path
871
+ */ function resolve(...pathSegments) {
872
+ let resolvedDevice = "";
873
+ let resolvedTail = "";
874
+ let resolvedAbsolute = false;
875
+ for(let i = pathSegments.length - 1; i >= -1; i--){
876
+ let path;
877
+ // deno-lint-ignore no-explicit-any
878
+ const { Deno } = globalThis;
879
+ if (i >= 0) {
880
+ path = pathSegments[i];
881
+ } else if (!resolvedDevice) {
882
+ if (typeof Deno?.cwd !== "function") {
883
+ throw new TypeError("Resolved a drive-letter-less path without a current working directory (CWD)");
884
+ }
885
+ path = Deno.cwd();
886
+ } else {
887
+ if (typeof Deno?.env?.get !== "function" || typeof Deno?.cwd !== "function") {
888
+ throw new TypeError("Resolved a relative path without a current working directory (CWD)");
889
+ }
890
+ path = Deno.cwd();
891
+ // Verify that a cwd was found and that it actually points
892
+ // to our drive. If not, default to the drive's root.
893
+ if (path === undefined || path.slice(0, 3).toLowerCase() !== `${resolvedDevice.toLowerCase()}\\`) {
894
+ path = `${resolvedDevice}\\`;
895
+ }
896
+ }
897
+ assertPath(path);
898
+ const len = path.length;
899
+ // Skip empty entries
900
+ if (len === 0) continue;
901
+ let rootEnd = 0;
902
+ let device = "";
903
+ let isAbsolute = false;
904
+ const code = path.charCodeAt(0);
905
+ // Try to match a root
906
+ if (len > 1) {
907
+ if (isPathSeparator(code)) {
908
+ // Possible UNC root
909
+ // If we started with a separator, we know we at least have an
910
+ // absolute path of some kind (UNC or otherwise)
911
+ isAbsolute = true;
912
+ if (isPathSeparator(path.charCodeAt(1))) {
913
+ // Matched double path separator at beginning
914
+ let j = 2;
915
+ let last = j;
916
+ // Match 1 or more non-path separators
917
+ for(; j < len; ++j){
918
+ if (isPathSeparator(path.charCodeAt(j))) break;
919
+ }
920
+ if (j < len && j !== last) {
921
+ const firstPart = path.slice(last, j);
922
+ // Matched!
923
+ last = j;
924
+ // Match 1 or more path separators
925
+ for(; j < len; ++j){
926
+ if (!isPathSeparator(path.charCodeAt(j))) break;
927
+ }
928
+ if (j < len && j !== last) {
929
+ // Matched!
930
+ last = j;
931
+ // Match 1 or more non-path separators
932
+ for(; j < len; ++j){
933
+ if (isPathSeparator(path.charCodeAt(j))) break;
934
+ }
935
+ if (j === len) {
936
+ // We matched a UNC root only
937
+ device = `\\\\${firstPart}\\${path.slice(last)}`;
938
+ rootEnd = j;
939
+ } else if (j !== last) {
940
+ // We matched a UNC root with leftovers
941
+ device = `\\\\${firstPart}\\${path.slice(last, j)}`;
942
+ rootEnd = j;
943
+ }
944
+ }
945
+ }
946
+ } else {
947
+ rootEnd = 1;
948
+ }
949
+ } else if (isWindowsDeviceRoot(code)) {
950
+ // Possible device root
951
+ if (path.charCodeAt(1) === CHAR_COLON) {
952
+ device = path.slice(0, 2);
953
+ rootEnd = 2;
954
+ if (len > 2) {
955
+ if (isPathSeparator(path.charCodeAt(2))) {
956
+ // Treat separator following drive name as an absolute path
957
+ // indicator
958
+ isAbsolute = true;
959
+ rootEnd = 3;
960
+ }
961
+ }
962
+ }
963
+ }
964
+ } else if (isPathSeparator(code)) {
965
+ // `path` contains just a path separator
966
+ rootEnd = 1;
967
+ isAbsolute = true;
968
+ }
969
+ if (device.length > 0 && resolvedDevice.length > 0 && device.toLowerCase() !== resolvedDevice.toLowerCase()) {
970
+ continue;
971
+ }
972
+ if (resolvedDevice.length === 0 && device.length > 0) {
973
+ resolvedDevice = device;
974
+ }
975
+ if (!resolvedAbsolute) {
976
+ resolvedTail = `${path.slice(rootEnd)}\\${resolvedTail}`;
977
+ resolvedAbsolute = isAbsolute;
978
+ }
979
+ if (resolvedAbsolute && resolvedDevice.length > 0) break;
980
+ }
981
+ // At this point the path should be resolved to a full absolute path,
982
+ // but handle relative paths to be safe (might happen when Deno.cwd()
983
+ // fails)
984
+ // Normalize the tail path
985
+ resolvedTail = normalizeString(resolvedTail, !resolvedAbsolute, "\\", isPathSeparator);
986
+ return resolvedDevice + (resolvedAbsolute ? "\\" : "") + resolvedTail || ".";
987
+ }
988
+
989
+ // Copyright 2018-2025 the Deno authors. MIT license.
990
+ // This module is browser compatible.
991
+ function assertArgs(from, to) {
992
+ assertPath(from);
993
+ assertPath(to);
994
+ if (from === to) return "";
995
+ }
996
+
997
+ // Copyright 2018-2025 the Deno authors. MIT license.
998
+ // This module is browser compatible.
999
+ /**
1000
+ * Return the relative path from `from` to `to` based on current working directory.
1001
+ *
1002
+ * An example in windows, for instance:
1003
+ * from = 'C:\\orandea\\test\\aaa'
1004
+ * to = 'C:\\orandea\\impl\\bbb'
1005
+ * The output of the function should be: '..\\..\\impl\\bbb'
1006
+ *
1007
+ * @example Usage
1008
+ * ```ts
1009
+ * import { relative } from "@std/path/windows/relative";
1010
+ * import { assertEquals } from "@std/assert";
1011
+ *
1012
+ * const relativePath = relative("C:\\foobar\\test\\aaa", "C:\\foobar\\impl\\bbb");
1013
+ * assertEquals(relativePath, "..\\..\\impl\\bbb");
1014
+ * ```
1015
+ *
1016
+ * @param from The path from which to calculate the relative path
1017
+ * @param to The path to which to calculate the relative path
1018
+ * @returns The relative path from `from` to `to`
1019
+ */ function relative(from, to) {
1020
+ assertArgs(from, to);
1021
+ const fromOrig = resolve(from);
1022
+ const toOrig = resolve(to);
1023
+ if (fromOrig === toOrig) return "";
1024
+ from = fromOrig.toLowerCase();
1025
+ to = toOrig.toLowerCase();
1026
+ if (from === to) return "";
1027
+ // Trim any leading backslashes
1028
+ let fromStart = 0;
1029
+ let fromEnd = from.length;
1030
+ for(; fromStart < fromEnd; ++fromStart){
1031
+ if (from.charCodeAt(fromStart) !== CHAR_BACKWARD_SLASH) break;
1032
+ }
1033
+ // Trim trailing backslashes (applicable to UNC paths only)
1034
+ for(; fromEnd - 1 > fromStart; --fromEnd){
1035
+ if (from.charCodeAt(fromEnd - 1) !== CHAR_BACKWARD_SLASH) break;
1036
+ }
1037
+ const fromLen = fromEnd - fromStart;
1038
+ // Trim any leading backslashes
1039
+ let toStart = 0;
1040
+ let toEnd = to.length;
1041
+ for(; toStart < toEnd; ++toStart){
1042
+ if (to.charCodeAt(toStart) !== CHAR_BACKWARD_SLASH) break;
1043
+ }
1044
+ // Trim trailing backslashes (applicable to UNC paths only)
1045
+ for(; toEnd - 1 > toStart; --toEnd){
1046
+ if (to.charCodeAt(toEnd - 1) !== CHAR_BACKWARD_SLASH) break;
1047
+ }
1048
+ const toLen = toEnd - toStart;
1049
+ // Compare paths to find the longest common path from root
1050
+ const length = fromLen < toLen ? fromLen : toLen;
1051
+ let lastCommonSep = -1;
1052
+ let i = 0;
1053
+ for(; i <= length; ++i){
1054
+ if (i === length) {
1055
+ if (toLen > length) {
1056
+ if (to.charCodeAt(toStart + i) === CHAR_BACKWARD_SLASH) {
1057
+ // We get here if `from` is the exact base path for `to`.
1058
+ // For example: from='C:\\foo\\bar'; to='C:\\foo\\bar\\baz'
1059
+ return toOrig.slice(toStart + i + 1);
1060
+ } else if (i === 2) {
1061
+ // We get here if `from` is the device root.
1062
+ // For example: from='C:\\'; to='C:\\foo'
1063
+ return toOrig.slice(toStart + i);
1064
+ }
1065
+ }
1066
+ if (fromLen > length) {
1067
+ if (from.charCodeAt(fromStart + i) === CHAR_BACKWARD_SLASH) {
1068
+ // We get here if `to` is the exact base path for `from`.
1069
+ // For example: from='C:\\foo\\bar'; to='C:\\foo'
1070
+ lastCommonSep = i;
1071
+ } else if (i === 2) {
1072
+ // We get here if `to` is the device root.
1073
+ // For example: from='C:\\foo\\bar'; to='C:\\'
1074
+ lastCommonSep = 3;
1075
+ }
1076
+ }
1077
+ break;
1078
+ }
1079
+ const fromCode = from.charCodeAt(fromStart + i);
1080
+ const toCode = to.charCodeAt(toStart + i);
1081
+ if (fromCode !== toCode) break;
1082
+ else if (fromCode === CHAR_BACKWARD_SLASH) lastCommonSep = i;
1083
+ }
1084
+ // We found a mismatch before the first common path separator was seen, so
1085
+ // return the original `to`.
1086
+ if (i !== length && lastCommonSep === -1) {
1087
+ return toOrig;
1088
+ }
1089
+ let out = "";
1090
+ if (lastCommonSep === -1) lastCommonSep = 0;
1091
+ // Generate the relative path based on the path difference between `to` and
1092
+ // `from`
1093
+ for(i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i){
1094
+ if (i === fromEnd || from.charCodeAt(i) === CHAR_BACKWARD_SLASH) {
1095
+ if (out.length === 0) out += "..";
1096
+ else out += "\\..";
1097
+ }
1098
+ }
1099
+ // Lastly, append the rest of the destination (`to`) path that comes after
1100
+ // the common path parts
1101
+ if (out.length > 0) {
1102
+ return out + toOrig.slice(toStart + lastCommonSep, toEnd);
1103
+ } else {
1104
+ toStart += lastCommonSep;
1105
+ if (toOrig.charCodeAt(toStart) === CHAR_BACKWARD_SLASH) ++toStart;
1106
+ return toOrig.slice(toStart, toEnd);
1107
+ }
1108
+ }
1109
+
1110
+ // Copyright 2018-2025 the Deno authors. MIT license.
1111
+ // This module is browser compatible.
1112
+ const WHITESPACE_ENCODINGS = {
1113
+ "\u0009": "%09",
1114
+ "\u000A": "%0A",
1115
+ "\u000B": "%0B",
1116
+ "\u000C": "%0C",
1117
+ "\u000D": "%0D",
1118
+ "\u0020": "%20"
1119
+ };
1120
+ function encodeWhitespace(string) {
1121
+ return string.replaceAll(/[\s]/g, (c)=>{
1122
+ return WHITESPACE_ENCODINGS[c] ?? c;
1123
+ });
1124
+ }
1125
+
1126
+ // Copyright 2018-2025 the Deno authors. MIT license.
1127
+ // This module is browser compatible.
1128
+ /**
1129
+ * Converts a path string to a file URL.
1130
+ *
1131
+ * @example Usage
1132
+ * ```ts
1133
+ * import { toFileUrl } from "@std/path/windows/to-file-url";
1134
+ * import { assertEquals } from "@std/assert";
1135
+ *
1136
+ * assertEquals(toFileUrl("\\home\\foo"), new URL("file:///home/foo"));
1137
+ * assertEquals(toFileUrl("C:\\Users\\foo"), new URL("file:///C:/Users/foo"));
1138
+ * assertEquals(toFileUrl("\\\\127.0.0.1\\home\\foo"), new URL("file://127.0.0.1/home/foo"));
1139
+ * ```
1140
+ * @param path The path to convert.
1141
+ * @returns The file URL.
1142
+ */ function toFileUrl(path) {
1143
+ if (!isAbsolute(path)) {
1144
+ throw new TypeError(`Path must be absolute: received "${path}"`);
1145
+ }
1146
+ const [, hostname, pathname] = path.match(/^(?:[/\\]{2}([^/\\]+)(?=[/\\](?:[^/\\]|$)))?(.*)/);
1147
+ const url = new URL("file:///");
1148
+ url.pathname = encodeWhitespace(pathname.replace(/%/g, "%25"));
1149
+ if (hostname !== undefined && hostname !== "localhost") {
1150
+ url.hostname = hostname;
1151
+ if (!url.hostname) {
1152
+ throw new TypeError(`Invalid hostname: "${url.hostname}"`);
1153
+ }
1154
+ }
1155
+ return url;
1156
+ }
1157
+
1158
+ // Copyright 2018-2025 the Deno authors. MIT license.
1159
+ // This module is browser compatible.
1160
+ /**
1161
+ * Resolves path to a namespace path
1162
+ *
1163
+ * @example Usage
1164
+ * ```ts
1165
+ * import { toNamespacedPath } from "@std/path/windows/to-namespaced-path";
1166
+ * import { assertEquals } from "@std/assert";
1167
+ *
1168
+ * const namespaced = toNamespacedPath("C:\\foo\\bar");
1169
+ * assertEquals(namespaced, "\\\\?\\C:\\foo\\bar");
1170
+ * ```
1171
+ *
1172
+ * @param path The path to resolve to namespaced path
1173
+ * @returns The resolved namespaced path
1174
+ */ function toNamespacedPath(path) {
1175
+ // Note: this will *probably* throw somewhere.
1176
+ if (typeof path !== "string") return path;
1177
+ if (path.length === 0) return "";
1178
+ const resolvedPath = resolve(path);
1179
+ if (resolvedPath.length >= 3) {
1180
+ if (resolvedPath.charCodeAt(0) === CHAR_BACKWARD_SLASH) {
1181
+ // Possible UNC root
1182
+ if (resolvedPath.charCodeAt(1) === CHAR_BACKWARD_SLASH) {
1183
+ const code = resolvedPath.charCodeAt(2);
1184
+ if (code !== CHAR_QUESTION_MARK && code !== CHAR_DOT) {
1185
+ // Matched non-long UNC root, convert the path to a long UNC path
1186
+ return `\\\\?\\UNC\\${resolvedPath.slice(2)}`;
1187
+ }
1188
+ }
1189
+ } else if (isWindowsDeviceRoot(resolvedPath.charCodeAt(0))) {
1190
+ // Possible device root
1191
+ if (resolvedPath.charCodeAt(1) === CHAR_COLON && resolvedPath.charCodeAt(2) === CHAR_BACKWARD_SLASH) {
1192
+ // Matched device root, convert the path to a long UNC path
1193
+ return `\\\\?\\${resolvedPath}`;
1194
+ }
1195
+ }
1196
+ }
1197
+ return path;
1198
+ }
1199
+
1200
+ // Copyright 2018-2025 the Deno authors. MIT license.
1201
+ // This module is browser compatible.
1202
+ function common$1(paths, sep) {
1203
+ const [first = "", ...remaining] = paths;
1204
+ const parts = first.split(sep);
1205
+ let endOfPrefix = parts.length;
1206
+ let append = "";
1207
+ for (const path of remaining){
1208
+ const compare = path.split(sep);
1209
+ if (compare.length <= endOfPrefix) {
1210
+ endOfPrefix = compare.length;
1211
+ append = "";
1212
+ }
1213
+ for(let i = 0; i < endOfPrefix; i++){
1214
+ if (compare[i] !== parts[i]) {
1215
+ endOfPrefix = i;
1216
+ append = i === 0 ? "" : sep;
1217
+ break;
1218
+ }
1219
+ }
1220
+ }
1221
+ return parts.slice(0, endOfPrefix).join(sep) + append;
1222
+ }
1223
+
1224
+ // Copyright 2018-2025 the Deno authors. MIT license.
1225
+ // This module is browser compatible.
1226
+ /**
1227
+ * Determines the common path from a set of paths for Windows systems.
1228
+ *
1229
+ * @example Usage
1230
+ * ```ts
1231
+ * import { common } from "@std/path/windows/common";
1232
+ * import { assertEquals } from "@std/assert";
1233
+ *
1234
+ * const path = common([
1235
+ * "C:\\foo\\bar",
1236
+ * "C:\\foo\\baz",
1237
+ * ]);
1238
+ * assertEquals(path, "C:\\foo\\");
1239
+ * ```
1240
+ *
1241
+ * @param paths The paths to compare.
1242
+ * @returns The common path.
1243
+ */ function common(paths) {
1244
+ return common$1(paths, SEPARATOR);
1245
+ }
1246
+
1247
+ // Copyright 2018-2025 the Deno authors. MIT license.
1248
+ // This module is browser compatible.
1249
+ /**
1250
+ * Options for {@linkcode globToRegExp}, {@linkcode joinGlobs},
1251
+ * {@linkcode normalizeGlob} and {@linkcode expandGlob}.
1252
+ */ const REG_EXP_ESCAPE_CHARS = [
1253
+ "!",
1254
+ "$",
1255
+ "(",
1256
+ ")",
1257
+ "*",
1258
+ "+",
1259
+ ".",
1260
+ "=",
1261
+ "?",
1262
+ "[",
1263
+ "\\",
1264
+ "^",
1265
+ "{",
1266
+ "|"
1267
+ ];
1268
+ const RANGE_ESCAPE_CHARS = [
1269
+ "-",
1270
+ "\\",
1271
+ "]"
1272
+ ];
1273
+ function _globToRegExp(c, glob, { extended = true, globstar: globstarOption = true, // os = osType,
1274
+ caseInsensitive = false } = {}) {
1275
+ if (glob === "") {
1276
+ return /(?!)/;
1277
+ }
1278
+ // Remove trailing separators.
1279
+ let newLength = glob.length;
1280
+ for(; newLength > 1 && c.seps.includes(glob[newLength - 1]); newLength--);
1281
+ glob = glob.slice(0, newLength);
1282
+ let regExpString = "";
1283
+ // Terminates correctly. Trust that `j` is incremented every iteration.
1284
+ for(let j = 0; j < glob.length;){
1285
+ let segment = "";
1286
+ const groupStack = [];
1287
+ let inRange = false;
1288
+ let inEscape = false;
1289
+ let endsWithSep = false;
1290
+ let i = j;
1291
+ // Terminates with `i` at the non-inclusive end of the current segment.
1292
+ for(; i < glob.length && !(c.seps.includes(glob[i]) && groupStack.length === 0); i++){
1293
+ if (inEscape) {
1294
+ inEscape = false;
1295
+ const escapeChars = inRange ? RANGE_ESCAPE_CHARS : REG_EXP_ESCAPE_CHARS;
1296
+ segment += escapeChars.includes(glob[i]) ? `\\${glob[i]}` : glob[i];
1297
+ continue;
1298
+ }
1299
+ if (glob[i] === c.escapePrefix) {
1300
+ inEscape = true;
1301
+ continue;
1302
+ }
1303
+ if (glob[i] === "[") {
1304
+ if (!inRange) {
1305
+ inRange = true;
1306
+ segment += "[";
1307
+ if (glob[i + 1] === "!") {
1308
+ i++;
1309
+ segment += "^";
1310
+ } else if (glob[i + 1] === "^") {
1311
+ i++;
1312
+ segment += "\\^";
1313
+ }
1314
+ continue;
1315
+ } else if (glob[i + 1] === ":") {
1316
+ let k = i + 1;
1317
+ let value = "";
1318
+ while(glob[k + 1] !== undefined && glob[k + 1] !== ":"){
1319
+ value += glob[k + 1];
1320
+ k++;
1321
+ }
1322
+ if (glob[k + 1] === ":" && glob[k + 2] === "]") {
1323
+ i = k + 2;
1324
+ if (value === "alnum") segment += "\\dA-Za-z";
1325
+ else if (value === "alpha") segment += "A-Za-z";
1326
+ else if (value === "ascii") segment += "\x00-\x7F";
1327
+ else if (value === "blank") segment += "\t ";
1328
+ else if (value === "cntrl") segment += "\x00-\x1F\x7F";
1329
+ else if (value === "digit") segment += "\\d";
1330
+ else if (value === "graph") segment += "\x21-\x7E";
1331
+ else if (value === "lower") segment += "a-z";
1332
+ else if (value === "print") segment += "\x20-\x7E";
1333
+ else if (value === "punct") {
1334
+ segment += "!\"#$%&'()*+,\\-./:;<=>?@[\\\\\\]^_‘{|}~";
1335
+ } else if (value === "space") segment += "\\s\v";
1336
+ else if (value === "upper") segment += "A-Z";
1337
+ else if (value === "word") segment += "\\w";
1338
+ else if (value === "xdigit") segment += "\\dA-Fa-f";
1339
+ continue;
1340
+ }
1341
+ }
1342
+ }
1343
+ if (glob[i] === "]" && inRange) {
1344
+ inRange = false;
1345
+ segment += "]";
1346
+ continue;
1347
+ }
1348
+ if (inRange) {
1349
+ segment += glob[i];
1350
+ continue;
1351
+ }
1352
+ if (glob[i] === ")" && groupStack.length > 0 && groupStack[groupStack.length - 1] !== "BRACE") {
1353
+ segment += ")";
1354
+ const type = groupStack.pop();
1355
+ if (type === "!") {
1356
+ segment += c.wildcard;
1357
+ } else if (type !== "@") {
1358
+ segment += type;
1359
+ }
1360
+ continue;
1361
+ }
1362
+ if (glob[i] === "|" && groupStack.length > 0 && groupStack[groupStack.length - 1] !== "BRACE") {
1363
+ segment += "|";
1364
+ continue;
1365
+ }
1366
+ if (glob[i] === "+" && extended && glob[i + 1] === "(") {
1367
+ i++;
1368
+ groupStack.push("+");
1369
+ segment += "(?:";
1370
+ continue;
1371
+ }
1372
+ if (glob[i] === "@" && extended && glob[i + 1] === "(") {
1373
+ i++;
1374
+ groupStack.push("@");
1375
+ segment += "(?:";
1376
+ continue;
1377
+ }
1378
+ if (glob[i] === "?") {
1379
+ if (extended && glob[i + 1] === "(") {
1380
+ i++;
1381
+ groupStack.push("?");
1382
+ segment += "(?:";
1383
+ } else {
1384
+ segment += ".";
1385
+ }
1386
+ continue;
1387
+ }
1388
+ if (glob[i] === "!" && extended && glob[i + 1] === "(") {
1389
+ i++;
1390
+ groupStack.push("!");
1391
+ segment += "(?!";
1392
+ continue;
1393
+ }
1394
+ if (glob[i] === "{") {
1395
+ groupStack.push("BRACE");
1396
+ segment += "(?:";
1397
+ continue;
1398
+ }
1399
+ if (glob[i] === "}" && groupStack[groupStack.length - 1] === "BRACE") {
1400
+ groupStack.pop();
1401
+ segment += ")";
1402
+ continue;
1403
+ }
1404
+ if (glob[i] === "," && groupStack[groupStack.length - 1] === "BRACE") {
1405
+ segment += "|";
1406
+ continue;
1407
+ }
1408
+ if (glob[i] === "*") {
1409
+ if (extended && glob[i + 1] === "(") {
1410
+ i++;
1411
+ groupStack.push("*");
1412
+ segment += "(?:";
1413
+ } else {
1414
+ const prevChar = glob[i - 1];
1415
+ let numStars = 1;
1416
+ while(glob[i + 1] === "*"){
1417
+ i++;
1418
+ numStars++;
1419
+ }
1420
+ const nextChar = glob[i + 1];
1421
+ if (globstarOption && numStars === 2 && [
1422
+ ...c.seps,
1423
+ undefined
1424
+ ].includes(prevChar) && [
1425
+ ...c.seps,
1426
+ undefined
1427
+ ].includes(nextChar)) {
1428
+ segment += c.globstar;
1429
+ endsWithSep = true;
1430
+ } else {
1431
+ segment += c.wildcard;
1432
+ }
1433
+ }
1434
+ continue;
1435
+ }
1436
+ segment += REG_EXP_ESCAPE_CHARS.includes(glob[i]) ? `\\${glob[i]}` : glob[i];
1437
+ }
1438
+ // Check for unclosed groups or a dangling backslash.
1439
+ if (groupStack.length > 0 || inRange || inEscape) {
1440
+ // Parse failure. Take all characters from this segment literally.
1441
+ segment = "";
1442
+ for (const c of glob.slice(j, i)){
1443
+ segment += REG_EXP_ESCAPE_CHARS.includes(c) ? `\\${c}` : c;
1444
+ endsWithSep = false;
1445
+ }
1446
+ }
1447
+ regExpString += segment;
1448
+ if (!endsWithSep) {
1449
+ regExpString += i < glob.length ? c.sep : c.sepMaybe;
1450
+ endsWithSep = true;
1451
+ }
1452
+ // Terminates with `i` at the start of the next segment.
1453
+ while(c.seps.includes(glob[i]))i++;
1454
+ j = i;
1455
+ }
1456
+ regExpString = `^${regExpString}$`;
1457
+ return new RegExp(regExpString, caseInsensitive ? "i" : "");
1458
+ }
1459
+
1460
+ // Copyright 2018-2025 the Deno authors. MIT license.
1461
+ // This module is browser compatible.
1462
+ const constants = {
1463
+ sep: "(?:\\\\|/)+",
1464
+ sepMaybe: "(?:\\\\|/)*",
1465
+ seps: [
1466
+ "\\",
1467
+ "/"
1468
+ ],
1469
+ globstar: "(?:[^\\\\/]*(?:\\\\|/|$)+)*",
1470
+ wildcard: "[^\\\\/]*",
1471
+ escapePrefix: "`"
1472
+ };
1473
+ /** Convert a glob string to a regular expression.
1474
+ *
1475
+ * Tries to match bash glob expansion as closely as possible.
1476
+ *
1477
+ * Basic glob syntax:
1478
+ * - `*` - Matches everything without leaving the path segment.
1479
+ * - `?` - Matches any single character.
1480
+ * - `{foo,bar}` - Matches `foo` or `bar`.
1481
+ * - `[abcd]` - Matches `a`, `b`, `c` or `d`.
1482
+ * - `[a-d]` - Matches `a`, `b`, `c` or `d`.
1483
+ * - `[!abcd]` - Matches any single character besides `a`, `b`, `c` or `d`.
1484
+ * - `[[:<class>:]]` - Matches any character belonging to `<class>`.
1485
+ * - `[[:alnum:]]` - Matches any digit or letter.
1486
+ * - `[[:digit:]abc]` - Matches any digit, `a`, `b` or `c`.
1487
+ * - See https://facelessuser.github.io/wcmatch/glob/#posix-character-classes
1488
+ * for a complete list of supported character classes.
1489
+ * - `\` - Escapes the next character for an `os` other than `"windows"`.
1490
+ * - \` - Escapes the next character for `os` set to `"windows"`.
1491
+ * - `/` - Path separator.
1492
+ * - `\` - Additional path separator only for `os` set to `"windows"`.
1493
+ *
1494
+ * Extended syntax:
1495
+ * - Requires `{ extended: true }`.
1496
+ * - `?(foo|bar)` - Matches 0 or 1 instance of `{foo,bar}`.
1497
+ * - `@(foo|bar)` - Matches 1 instance of `{foo,bar}`. They behave the same.
1498
+ * - `*(foo|bar)` - Matches _n_ instances of `{foo,bar}`.
1499
+ * - `+(foo|bar)` - Matches _n > 0_ instances of `{foo,bar}`.
1500
+ * - `!(foo|bar)` - Matches anything other than `{foo,bar}`.
1501
+ * - See https://www.linuxjournal.com/content/bash-extended-globbing.
1502
+ *
1503
+ * Globstar syntax:
1504
+ * - Requires `{ globstar: true }`.
1505
+ * - `**` - Matches any number of any path segments.
1506
+ * - Must comprise its entire path segment in the provided glob.
1507
+ * - See https://www.linuxjournal.com/content/globstar-new-bash-globbing-option.
1508
+ *
1509
+ * Note the following properties:
1510
+ * - The generated `RegExp` is anchored at both start and end.
1511
+ * - Repeating and trailing separators are tolerated. Trailing separators in the
1512
+ * provided glob have no meaning and are discarded.
1513
+ * - Absolute globs will only match absolute paths, etc.
1514
+ * - Empty globs will match nothing.
1515
+ * - Any special glob syntax must be contained to one path segment. For example,
1516
+ * `?(foo|bar/baz)` is invalid. The separator will take precedence and the
1517
+ * first segment ends with an unclosed group.
1518
+ * - If a path segment ends with unclosed groups or a dangling escape prefix, a
1519
+ * parse error has occurred. Every character for that segment is taken
1520
+ * literally in this event.
1521
+ *
1522
+ * Limitations:
1523
+ * - A negative group like `!(foo|bar)` will wrongly be converted to a negative
1524
+ * look-ahead followed by a wildcard. This means that `!(foo).js` will wrongly
1525
+ * fail to match `foobar.js`, even though `foobar` is not `foo`. Effectively,
1526
+ * `!(foo|bar)` is treated like `!(@(foo|bar)*)`. This will work correctly if
1527
+ * the group occurs not nested at the end of the segment.
1528
+ *
1529
+ * @example Usage
1530
+ * ```ts
1531
+ * import { globToRegExp } from "@std/path/windows/glob-to-regexp";
1532
+ * import { assertEquals } from "@std/assert";
1533
+ *
1534
+ * assertEquals(globToRegExp("*.js"), /^[^\\/]*\.js(?:\\|\/)*$/);
1535
+ * ```
1536
+ *
1537
+ * @param glob Glob string to convert.
1538
+ * @param options Conversion options.
1539
+ * @returns The regular expression equivalent to the glob.
1540
+ */ function globToRegExp(glob, options = {}) {
1541
+ return _globToRegExp(constants, glob, options);
1542
+ }
1543
+
1544
+ // Copyright 2018-2025 the Deno authors. MIT license.
1545
+ // This module is browser compatible.
1546
+ /**
1547
+ * Test whether the given string is a glob.
1548
+ *
1549
+ * @example Usage
1550
+ * ```ts
1551
+ * import { isGlob } from "@std/path/is-glob";
1552
+ * import { assert } from "@std/assert";
1553
+ *
1554
+ * assert(!isGlob("foo/bar/../baz"));
1555
+ * assert(isGlob("foo/*ar/../baz"));
1556
+ * ```
1557
+ *
1558
+ * @param str String to test.
1559
+ * @returns `true` if the given string is a glob, otherwise `false`
1560
+ */ function isGlob(str) {
1561
+ const chars = {
1562
+ "{": "}",
1563
+ "(": ")",
1564
+ "[": "]"
1565
+ };
1566
+ const regex = /\\(.)|(^!|\*|\?|[\].+)]\?|\[[^[\\\]]+\]|\{[^{\\}]+\}|\(\?[:!=][^\\)]+\)|\([^(|]+\|[^\\)]+\)|@\([^)]+\))/;
1567
+ if (str === "") {
1568
+ return false;
1569
+ }
1570
+ let match;
1571
+ while(match = regex.exec(str)){
1572
+ if (match[2]) return true;
1573
+ let idx = match.index + match[0].length;
1574
+ // if an open bracket/brace/paren is escaped,
1575
+ // set the index to the next closing character
1576
+ const open = match[1];
1577
+ const close = open ? chars[open] : null;
1578
+ if (open && close) {
1579
+ const n = str.indexOf(close, idx);
1580
+ if (n !== -1) {
1581
+ idx = n + 1;
1582
+ }
1583
+ }
1584
+ str = str.slice(idx);
1585
+ }
1586
+ return false;
1587
+ }
1588
+
1589
+ // Copyright 2018-2025 the Deno authors. MIT license.
1590
+ // This module is browser compatible.
1591
+ /**
1592
+ * Like normalize(), but doesn't collapse "**\/.." when `globstar` is true.
1593
+ *
1594
+ * @example Usage
1595
+ * ```ts
1596
+ * import { normalizeGlob } from "@std/path/windows/normalize-glob";
1597
+ * import { assertEquals } from "@std/assert";
1598
+ *
1599
+ * const normalized = normalizeGlob("**\\foo\\..\\bar", { globstar: true });
1600
+ * assertEquals(normalized, "**\\bar");
1601
+ * ```
1602
+ *
1603
+ * @param glob The glob pattern to normalize.
1604
+ * @param options The options for glob pattern.
1605
+ * @returns The normalized glob pattern.
1606
+ */ function normalizeGlob(glob, options = {}) {
1607
+ const { globstar = false } = options;
1608
+ if (glob.match(/\0/g)) {
1609
+ throw new Error(`Glob contains invalid characters: "${glob}"`);
1610
+ }
1611
+ if (!globstar) {
1612
+ return normalize(glob);
1613
+ }
1614
+ const s = SEPARATOR_PATTERN.source;
1615
+ const badParentPattern = new RegExp(`(?<=(${s}|^)\\*\\*${s})\\.\\.(?=${s}|$)`, "g");
1616
+ return normalize(glob.replace(badParentPattern, "\0")).replace(/\0/g, "..");
1617
+ }
1618
+
1619
+ // Copyright 2018-2025 the Deno authors. MIT license.
1620
+ // This module is browser compatible.
1621
+ /**
1622
+ * Like join(), but doesn't collapse "**\/.." when `globstar` is true.
1623
+ *
1624
+ * @example Usage
1625
+ *
1626
+ * ```ts
1627
+ * import { joinGlobs } from "@std/path/windows/join-globs";
1628
+ * import { assertEquals } from "@std/assert";
1629
+ *
1630
+ * const joined = joinGlobs(["foo", "**", "bar"], { globstar: true });
1631
+ * assertEquals(joined, "foo\\**\\bar");
1632
+ * ```
1633
+ *
1634
+ * @param globs The globs to join.
1635
+ * @param options The options for glob pattern.
1636
+ * @returns The joined glob pattern.
1637
+ */ function joinGlobs(globs, options = {}) {
1638
+ const { globstar = false } = options;
1639
+ if (!globstar || globs.length === 0) {
1640
+ return join(...globs);
1641
+ }
1642
+ let joined;
1643
+ for (const glob of globs){
1644
+ const path = glob;
1645
+ if (path.length > 0) {
1646
+ if (!joined) joined = path;
1647
+ else joined += `${SEPARATOR}${path}`;
1648
+ }
1649
+ }
1650
+ if (!joined) return ".";
1651
+ return normalizeGlob(joined, {
1652
+ globstar
1653
+ });
1654
+ }
1655
+
1656
+ export { DELIMITER, SEPARATOR, SEPARATOR_PATTERN, basename, common, dirname, extname, format, fromFileUrl, globToRegExp, isAbsolute, isGlob, join, joinGlobs, normalize, normalizeGlob, parse, relative, resolve, toFileUrl, toNamespacedPath };
server/node_modules/@eslint/config-array/dist/esm/types.d.ts ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @fileoverview Types for the config-array package.
3
+ * @author Nicholas C. Zakas
4
+ */
5
+ export interface ConfigObject {
6
+ /**
7
+ * The base path for files and ignores.
8
+ */
9
+ basePath?: string;
10
+ /**
11
+ * The files to include.
12
+ */
13
+ files?: string[];
14
+ /**
15
+ * The files to exclude.
16
+ */
17
+ ignores?: string[];
18
+ /**
19
+ * The name of the config object.
20
+ */
21
+ name?: string;
22
+ [key: string]: unknown;
23
+ }
server/node_modules/@eslint/config-array/dist/esm/types.ts ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @fileoverview Types for the config-array package.
3
+ * @author Nicholas C. Zakas
4
+ */
5
+
6
+ export interface ConfigObject {
7
+ /**
8
+ * The base path for files and ignores.
9
+ */
10
+ basePath?: string;
11
+
12
+ /**
13
+ * The files to include.
14
+ */
15
+ files?: string[];
16
+
17
+ /**
18
+ * The files to exclude.
19
+ */
20
+ ignores?: string[];
21
+
22
+ /**
23
+ * The name of the config object.
24
+ */
25
+ name?: string;
26
+
27
+ // may also have any number of other properties
28
+ [key: string]: unknown;
29
+ }
server/node_modules/@eslint/config-array/package.json ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@eslint/config-array",
3
+ "version": "0.21.2",
4
+ "description": "General purpose glob-based configuration matching.",
5
+ "author": "Nicholas C. Zakas",
6
+ "type": "module",
7
+ "main": "dist/esm/index.js",
8
+ "types": "dist/esm/index.d.ts",
9
+ "exports": {
10
+ "require": {
11
+ "types": "./dist/cjs/index.d.cts",
12
+ "default": "./dist/cjs/index.cjs"
13
+ },
14
+ "import": {
15
+ "types": "./dist/esm/index.d.ts",
16
+ "default": "./dist/esm/index.js"
17
+ }
18
+ },
19
+ "files": [
20
+ "dist"
21
+ ],
22
+ "publishConfig": {
23
+ "access": "public"
24
+ },
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "git+https://github.com/eslint/rewrite.git",
28
+ "directory": "packages/config-array"
29
+ },
30
+ "bugs": {
31
+ "url": "https://github.com/eslint/rewrite/issues"
32
+ },
33
+ "homepage": "https://github.com/eslint/rewrite/tree/main/packages/config-array#readme",
34
+ "scripts": {
35
+ "build:dedupe-types": "node ../../tools/dedupe-types.js dist/cjs/index.cjs dist/esm/index.js",
36
+ "build:cts": "node ../../tools/build-cts.js dist/esm/index.d.ts dist/cjs/index.d.cts",
37
+ "build:std__path": "rollup -c rollup.std__path-config.js && node fix-std__path-imports",
38
+ "build": "rollup -c && npm run build:dedupe-types && tsc -p tsconfig.esm.json && npm run build:cts && npm run build:std__path",
39
+ "pretest": "npm run build",
40
+ "test": "mocha \"tests/**/*.test.js\"",
41
+ "test:coverage": "c8 npm test",
42
+ "test:jsr": "npx jsr@latest publish --dry-run",
43
+ "test:types": "tsc -p tests/types/tsconfig.json"
44
+ },
45
+ "keywords": [
46
+ "configuration",
47
+ "configarray",
48
+ "config file"
49
+ ],
50
+ "license": "Apache-2.0",
51
+ "dependencies": {
52
+ "@eslint/object-schema": "^2.1.7",
53
+ "debug": "^4.3.1",
54
+ "minimatch": "^3.1.5"
55
+ },
56
+ "devDependencies": {
57
+ "@jsr/std__path": "^1.0.4",
58
+ "@types/minimatch": "^3.0.5",
59
+ "rollup-plugin-copy": "^3.5.0"
60
+ },
61
+ "engines": {
62
+ "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
63
+ }
64
+ }
server/node_modules/@eslint/config-helpers/LICENSE ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
server/node_modules/@eslint/config-helpers/README.md ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # @eslint/config-helpers
2
+
3
+ ## Description
4
+
5
+ Helper utilities for creating ESLint configuration.
6
+
7
+ ## Installation
8
+
9
+ For Node.js and compatible runtimes:
10
+
11
+ ```shell
12
+ npm install @eslint/config-helpers
13
+ # or
14
+ yarn add @eslint/config-helpers
15
+ # or
16
+ pnpm install @eslint/config-helpers
17
+ # or
18
+ bun add @eslint/config-helpers
19
+ ```
20
+
21
+ For Deno:
22
+
23
+ ```shell
24
+ deno add @eslint/config-helpers
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ ### `defineConfig()`
30
+
31
+ The `defineConfig()` function allows you to specify an ESLint configuration with full type checking and additional capabilities, such as `extends`. Here's an example:
32
+
33
+ ```js
34
+ // eslint.config.js
35
+ import { defineConfig } from "@eslint/config-helpers";
36
+ import js from "@eslint/js";
37
+
38
+ export default defineConfig([
39
+ {
40
+ files: ["src/**/*.js"],
41
+ plugins: { js },
42
+ extends: ["js/recommended"],
43
+ rules: {
44
+ semi: "error",
45
+ "prefer-const": "error",
46
+ },
47
+ },
48
+ {
49
+ files: ["test/**/*.js"],
50
+ rules: {
51
+ "no-console": "off",
52
+ },
53
+ },
54
+ ]);
55
+ ```
56
+
57
+ ### `globalIgnores()`
58
+
59
+ The `globalIgnores()` function allows you to specify patterns for files and directories that should be globally ignored by ESLint. This is useful for excluding files that you don't want to lint, such as build directories or third-party libraries. Here's an example:
60
+
61
+ ```js
62
+ // eslint.config.js
63
+ import { defineConfig, globalIgnores } from "@eslint/config-helpers";
64
+
65
+ export default defineConfig([
66
+ {
67
+ files: ["src/**/*.js"],
68
+ rules: {
69
+ semi: "error",
70
+ "prefer-const": "error",
71
+ },
72
+ },
73
+ globalIgnores(["node_modules/", "dist/", "coverage/"]),
74
+ ]);
75
+ ```
76
+
77
+ ## License
78
+
79
+ Apache 2.0
80
+
81
+ <!-- NOTE: This section is autogenerated. Do not manually edit.-->
82
+ <!--sponsorsstart-->
83
+
84
+ ## Sponsors
85
+
86
+ The following companies, organizations, and individuals support ESLint's ongoing maintenance and development. [Become a Sponsor](https://eslint.org/donate)
87
+ to get your logo on our READMEs and [website](https://eslint.org/sponsors).
88
+
89
+ <h3>Platinum Sponsors</h3>
90
+ <p><a href="https://automattic.com"><img src="https://images.opencollective.com/automattic/d0ef3e1/logo.png" alt="Automattic" height="128"></a> <a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/airbnb/d327d66/logo.png" alt="Airbnb" height="128"></a></p><h3>Gold Sponsors</h3>
91
+ <p><a href="https://qlty.sh/"><img src="https://images.opencollective.com/qltysh/33d157d/logo.png" alt="Qlty Software" height="96"></a> <a href="https://trunk.io/"><img src="https://images.opencollective.com/trunkio/fb92d60/avatar.png" alt="trunk.io" height="96"></a> <a href="https://shopify.engineering/"><img src="https://avatars.githubusercontent.com/u/8085" alt="Shopify" height="96"></a></p><h3>Silver Sponsors</h3>
92
+ <p><a href="https://vite.dev/"><img src="https://images.opencollective.com/vite/e6d15e1/logo.png" alt="Vite" height="64"></a> <a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/5c4fa84/logo.png" alt="Liftoff" height="64"></a> <a href="https://americanexpress.io"><img src="https://avatars.githubusercontent.com/u/3853301" alt="American Express" height="64"></a> <a href="https://stackblitz.com"><img src="https://avatars.githubusercontent.com/u/28635252" alt="StackBlitz" height="64"></a></p><h3>Bronze Sponsors</h3>
93
+ <p><a href="https://syntax.fm"><img src="https://github.com/syntaxfm.png" alt="Syntax" height="32"></a> <a href="https://cybozu.co.jp/"><img src="https://images.opencollective.com/cybozu/933e46d/logo.png" alt="Cybozu" height="32"></a> <a href="https://sentry.io"><img src="https://github.com/getsentry.png" alt="Sentry" height="32"></a> <a href="https://icons8.com/"><img src="https://images.opencollective.com/icons8/7fa1641/logo.png" alt="Icons8" height="32"></a> <a href="https://discord.com"><img src="https://images.opencollective.com/discordapp/f9645d9/logo.png" alt="Discord" height="32"></a> <a href="https://www.gitbook.com"><img src="https://avatars.githubusercontent.com/u/7111340" alt="GitBook" height="32"></a> <a href="https://nx.dev"><img src="https://avatars.githubusercontent.com/u/23692104" alt="Nx" height="32"></a> <a href="https://opensource.mercedes-benz.com/"><img src="https://avatars.githubusercontent.com/u/34240465" alt="Mercedes-Benz Group" height="32"></a> <a href="https://herocoders.com"><img src="https://avatars.githubusercontent.com/u/37549774" alt="HeroCoders" height="32"></a> <a href="https://www.lambdatest.com"><img src="https://avatars.githubusercontent.com/u/171592363" alt="LambdaTest" height="32"></a></p>
94
+ <h3>Technology Sponsors</h3>
95
+ Technology sponsors allow us to use their products and services for free as part of a contribution to the open source ecosystem and our work.
96
+ <p><a href="https://netlify.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/netlify-icon.svg" alt="Netlify" height="32"></a> <a href="https://algolia.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/algolia-icon.svg" alt="Algolia" height="32"></a> <a href="https://1password.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/1password-icon.svg" alt="1Password" height="32"></a></p>
97
+ <!--sponsorsend-->
server/node_modules/@eslint/config-helpers/dist/cjs/index.cjs ADDED
@@ -0,0 +1,588 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict';
2
+
3
+ /**
4
+ * @fileoverview defineConfig helper
5
+ * @author Nicholas C. Zakas
6
+ */
7
+
8
+ //-----------------------------------------------------------------------------
9
+ // Type Definitions
10
+ //-----------------------------------------------------------------------------
11
+
12
+ /** @import * as $eslintcore from "@eslint/core"; */
13
+ /** @typedef {$eslintcore.ConfigObject} Config */
14
+ /** @typedef {$eslintcore.LegacyConfigObject} LegacyConfig */
15
+ /** @typedef {$eslintcore.Plugin} Plugin */
16
+ /** @typedef {$eslintcore.RuleConfig} RuleConfig */
17
+ /** @import * as $typests from "./types.ts"; */
18
+ /** @typedef {$typests.ExtendsElement} ExtendsElement */
19
+ /** @typedef {$typests.SimpleExtendsElement} SimpleExtendsElement */
20
+ /** @typedef {$typests.ConfigWithExtends} ConfigWithExtends */
21
+ /** @typedef {$typests.InfiniteArray<Config>} InfiniteConfigArray */
22
+ /** @typedef {$typests.ConfigWithExtendsArray} ConfigWithExtendsArray */
23
+
24
+ //-----------------------------------------------------------------------------
25
+ // Helpers
26
+ //-----------------------------------------------------------------------------
27
+
28
+ const eslintrcKeys = [
29
+ "env",
30
+ "extends",
31
+ "globals",
32
+ "ignorePatterns",
33
+ "noInlineConfig",
34
+ "overrides",
35
+ "parser",
36
+ "parserOptions",
37
+ "reportUnusedDisableDirectives",
38
+ "root",
39
+ ];
40
+
41
+ const allowedGlobalIgnoreKeys = new Set(["basePath", "ignores", "name"]);
42
+
43
+ /**
44
+ * Gets the name of a config object.
45
+ * @param {Config} config The config object.
46
+ * @param {string} indexPath The index path of the config object.
47
+ * @return {string} The name of the config object.
48
+ */
49
+ function getConfigName(config, indexPath) {
50
+ if (config.name) {
51
+ return config.name;
52
+ }
53
+
54
+ return `UserConfig${indexPath}`;
55
+ }
56
+
57
+ /**
58
+ * Gets the name of an extension.
59
+ * @param {SimpleExtendsElement} extension The extension.
60
+ * @param {string} indexPath The index of the extension.
61
+ * @return {string} The name of the extension.
62
+ */
63
+ function getExtensionName(extension, indexPath) {
64
+ if (typeof extension === "string") {
65
+ return extension;
66
+ }
67
+
68
+ if (extension.name) {
69
+ return extension.name;
70
+ }
71
+
72
+ return `ExtendedConfig${indexPath}`;
73
+ }
74
+
75
+ /**
76
+ * Determines if a config object is a legacy config.
77
+ * @param {Config|LegacyConfig} config The config object to check.
78
+ * @return {config is LegacyConfig} `true` if the config object is a legacy config.
79
+ */
80
+ function isLegacyConfig(config) {
81
+ // eslintrc's plugins must be an array; while flat config's must be an object.
82
+ if (Array.isArray(config.plugins)) {
83
+ return true;
84
+ }
85
+
86
+ for (const key of eslintrcKeys) {
87
+ if (key in config) {
88
+ return true;
89
+ }
90
+ }
91
+
92
+ return false;
93
+ }
94
+
95
+ /**
96
+ * Determines if a config object is a global ignores config.
97
+ * @param {Config} config The config object to check.
98
+ * @return {boolean} `true` if the config object is a global ignores config.
99
+ */
100
+ function isGlobalIgnores(config) {
101
+ return Object.keys(config).every(key => allowedGlobalIgnoreKeys.has(key));
102
+ }
103
+
104
+ /**
105
+ * Parses a plugin member ID (rule, processor, etc.) and returns
106
+ * the namespace and member name.
107
+ * @param {string} id The ID to parse.
108
+ * @returns {{namespace:string, name:string}} The namespace and member name.
109
+ */
110
+ function getPluginMember(id) {
111
+ const firstSlashIndex = id.indexOf("/");
112
+
113
+ if (firstSlashIndex === -1) {
114
+ return { namespace: "", name: id };
115
+ }
116
+
117
+ let namespace = id.slice(0, firstSlashIndex);
118
+
119
+ /*
120
+ * Special cases:
121
+ * 1. The namespace is `@`, that means it's referring to the
122
+ * core plugin so `@` is the full namespace.
123
+ * 2. The namespace starts with `@`, that means it's referring to
124
+ * an npm scoped package. That means the namespace is the scope
125
+ * and the package name (i.e., `@eslint/core`).
126
+ */
127
+ if (namespace[0] === "@" && namespace !== "@") {
128
+ const secondSlashIndex = id.indexOf("/", firstSlashIndex + 1);
129
+ if (secondSlashIndex !== -1) {
130
+ namespace = id.slice(0, secondSlashIndex);
131
+ return { namespace, name: id.slice(secondSlashIndex + 1) };
132
+ }
133
+ }
134
+
135
+ const name = id.slice(firstSlashIndex + 1);
136
+
137
+ return { namespace, name };
138
+ }
139
+
140
+ /**
141
+ * Normalizes the plugin config by replacing the namespace with the plugin namespace.
142
+ * @param {string} userNamespace The namespace of the plugin.
143
+ * @param {Plugin} plugin The plugin config object.
144
+ * @param {Config} config The config object to normalize.
145
+ * @return {Config} The normalized config object.
146
+ */
147
+ function normalizePluginConfig(userNamespace, plugin, config) {
148
+ const pluginNamespace = plugin.meta?.namespace;
149
+
150
+ // don't do anything if the plugin doesn't have a namespace or rules
151
+ if (
152
+ !pluginNamespace ||
153
+ pluginNamespace === userNamespace ||
154
+ (!config.rules && !config.processor && !config.language)
155
+ ) {
156
+ return config;
157
+ }
158
+
159
+ const result = { ...config };
160
+
161
+ // update the rules
162
+ if (result.rules) {
163
+ const ruleIds = Object.keys(result.rules);
164
+
165
+ /** @type {Record<string,RuleConfig|undefined>} */
166
+ const newRules = {};
167
+
168
+ for (let i = 0; i < ruleIds.length; i++) {
169
+ const ruleId = ruleIds[i];
170
+ const { namespace: ruleNamespace, name: ruleName } =
171
+ getPluginMember(ruleId);
172
+
173
+ if (ruleNamespace === pluginNamespace) {
174
+ newRules[`${userNamespace}/${ruleName}`] = result.rules[ruleId];
175
+ } else {
176
+ newRules[ruleId] = result.rules[ruleId];
177
+ }
178
+ }
179
+
180
+ result.rules = newRules;
181
+ }
182
+
183
+ // update the processor
184
+
185
+ if (typeof result.processor === "string") {
186
+ const { namespace: processorNamespace, name: processorName } =
187
+ getPluginMember(result.processor);
188
+
189
+ if (processorNamespace) {
190
+ if (processorNamespace === pluginNamespace) {
191
+ result.processor = `${userNamespace}/${processorName}`;
192
+ }
193
+ }
194
+ }
195
+
196
+ // update the language
197
+ if (typeof result.language === "string") {
198
+ const { namespace: languageNamespace, name: languageName } =
199
+ getPluginMember(result.language);
200
+
201
+ if (languageNamespace === pluginNamespace) {
202
+ result.language = `${userNamespace}/${languageName}`;
203
+ }
204
+ }
205
+
206
+ return result;
207
+ }
208
+
209
+ /**
210
+ * Deeply normalizes a plugin config, traversing recursively into an arrays.
211
+ * @param {string} userPluginNamespace The namespace of the plugin.
212
+ * @param {Plugin} plugin The plugin object.
213
+ * @param {Config|LegacyConfig|(Config|LegacyConfig)[]} pluginConfig The plugin config to normalize.
214
+ * @param {string} pluginConfigName The name of the plugin config.
215
+ * @return {InfiniteConfigArray} The normalized plugin config.
216
+ * @throws {TypeError} If the plugin config is a legacy config.
217
+ */
218
+ function deepNormalizePluginConfig(
219
+ userPluginNamespace,
220
+ plugin,
221
+ pluginConfig,
222
+ pluginConfigName,
223
+ ) {
224
+ // if it's an array then it's definitely a new config
225
+ if (Array.isArray(pluginConfig)) {
226
+ return pluginConfig.map(pluginSubConfig =>
227
+ deepNormalizePluginConfig(
228
+ userPluginNamespace,
229
+ plugin,
230
+ pluginSubConfig,
231
+ pluginConfigName,
232
+ ),
233
+ );
234
+ }
235
+
236
+ // if it's a legacy config, throw an error
237
+ if (isLegacyConfig(pluginConfig)) {
238
+ throw new TypeError(
239
+ `Plugin config "${pluginConfigName}" is an eslintrc config and cannot be used in this context.`,
240
+ );
241
+ }
242
+
243
+ return normalizePluginConfig(userPluginNamespace, plugin, pluginConfig);
244
+ }
245
+
246
+ /**
247
+ * Finds a plugin config by name in the given config.
248
+ * @param {Config} config The config object.
249
+ * @param {string} pluginConfigName The name of the plugin config.
250
+ * @return {InfiniteConfigArray} The plugin config.
251
+ * @throws {TypeError} If the plugin config is not found or is a legacy config.
252
+ */
253
+ function findPluginConfig(config, pluginConfigName) {
254
+ const { namespace: userPluginNamespace, name: configName } =
255
+ getPluginMember(pluginConfigName);
256
+ const plugin = config.plugins?.[userPluginNamespace];
257
+
258
+ if (!plugin) {
259
+ throw new TypeError(`Plugin "${userPluginNamespace}" not found.`);
260
+ }
261
+
262
+ const directConfig = plugin.configs?.[configName];
263
+
264
+ // Prefer direct config, but fall back to flat config if available
265
+ if (directConfig) {
266
+ // Arrays are always flat configs, and non-legacy configs can be used directly
267
+ if (Array.isArray(directConfig) || !isLegacyConfig(directConfig)) {
268
+ return deepNormalizePluginConfig(
269
+ userPluginNamespace,
270
+ plugin,
271
+ directConfig,
272
+ pluginConfigName,
273
+ );
274
+ }
275
+ }
276
+
277
+ // If it's a legacy config, or the config does not exist => look for the flat version
278
+ const flatConfig = plugin.configs?.[`flat/${configName}`];
279
+ if (
280
+ flatConfig &&
281
+ (Array.isArray(flatConfig) || !isLegacyConfig(flatConfig))
282
+ ) {
283
+ return deepNormalizePluginConfig(
284
+ userPluginNamespace,
285
+ plugin,
286
+ flatConfig,
287
+ pluginConfigName,
288
+ );
289
+ }
290
+
291
+ // If we get here, then the config was either not found or is a legacy config
292
+ const message =
293
+ directConfig || flatConfig
294
+ ? `Plugin config "${configName}" in plugin "${userPluginNamespace}" is an eslintrc config and cannot be used in this context.`
295
+ : `Plugin config "${configName}" not found in plugin "${userPluginNamespace}".`;
296
+ throw new TypeError(message);
297
+ }
298
+
299
+ /**
300
+ * Flattens an array while keeping track of the index path.
301
+ * @param {any[]} configList The array to traverse.
302
+ * @param {string} indexPath The index path of the value in a multidimensional array.
303
+ * @return {IterableIterator<{indexPath:string, value:any}>} The flattened list of values.
304
+ */
305
+ function* flatTraverse(configList, indexPath = "") {
306
+ for (let i = 0; i < configList.length; i++) {
307
+ const newIndexPath = indexPath ? `${indexPath}[${i}]` : `[${i}]`;
308
+
309
+ // if it's an array then traverse it as well
310
+ if (Array.isArray(configList[i])) {
311
+ yield* flatTraverse(configList[i], newIndexPath);
312
+ continue;
313
+ }
314
+
315
+ yield { indexPath: newIndexPath, value: configList[i] };
316
+ }
317
+ }
318
+
319
+ /**
320
+ * Extends a list of config files by creating every combination of base and extension files.
321
+ * @param {(string|string[])[]} [baseFiles] The base files.
322
+ * @param {(string|string[])[]} [extensionFiles] The extension files.
323
+ * @return {(string|string[])[]} The extended files.
324
+ */
325
+ function extendConfigFiles(baseFiles = [], extensionFiles = []) {
326
+ if (!extensionFiles.length) {
327
+ return baseFiles.concat();
328
+ }
329
+
330
+ if (!baseFiles.length) {
331
+ return extensionFiles.concat();
332
+ }
333
+
334
+ /** @type {(string|string[])[]} */
335
+ const result = [];
336
+
337
+ for (const baseFile of baseFiles) {
338
+ for (const extensionFile of extensionFiles) {
339
+ /*
340
+ * Each entry can be a string or array of strings. The end result
341
+ * needs to be an array of strings, so we need to be sure to include
342
+ * all of the items when there's an array.
343
+ */
344
+
345
+ const entry = [];
346
+
347
+ if (Array.isArray(baseFile)) {
348
+ entry.push(...baseFile);
349
+ } else {
350
+ entry.push(baseFile);
351
+ }
352
+
353
+ if (Array.isArray(extensionFile)) {
354
+ entry.push(...extensionFile);
355
+ } else {
356
+ entry.push(extensionFile);
357
+ }
358
+
359
+ result.push(entry);
360
+ }
361
+ }
362
+
363
+ return result;
364
+ }
365
+
366
+ /**
367
+ * Extends a config object with another config object.
368
+ * @param {Config} baseConfig The base config object.
369
+ * @param {string} baseConfigName The name of the base config object.
370
+ * @param {Config} extension The extension config object.
371
+ * @param {string} extensionName The index of the extension config object.
372
+ * @return {Config} The extended config object.
373
+ */
374
+ function extendConfig(baseConfig, baseConfigName, extension, extensionName) {
375
+ const result = { ...extension };
376
+
377
+ // for global ignores there is no further work to be done, we just keep everything
378
+ if (!isGlobalIgnores(extension)) {
379
+ // for files we need to create every combination of base and extension files
380
+ if (baseConfig.files) {
381
+ result.files = extendConfigFiles(baseConfig.files, extension.files);
382
+ }
383
+
384
+ // for ignores we just concatenation the extension ignores onto the base ignores
385
+ if (baseConfig.ignores) {
386
+ result.ignores = baseConfig.ignores.concat(extension.ignores ?? []);
387
+ }
388
+ }
389
+
390
+ result.name = `${baseConfigName} > ${extensionName}`;
391
+
392
+ // @ts-ignore -- ESLint types aren't updated yet
393
+ if (baseConfig.basePath) {
394
+ // @ts-ignore -- ESLint types aren't updated yet
395
+ result.basePath = baseConfig.basePath;
396
+ }
397
+
398
+ return result;
399
+ }
400
+
401
+ /**
402
+ * Processes a list of extends elements.
403
+ * @param {ConfigWithExtends} config The config object.
404
+ * @param {WeakMap<Config, string>} configNames The map of config objects to their names.
405
+ * @return {Config[]} The flattened list of config objects.
406
+ * @throws {TypeError} If the `extends` property is not an array or if nested `extends` is found.
407
+ */
408
+ function processExtends(config, configNames) {
409
+ if (!config.extends) {
410
+ return [config];
411
+ }
412
+
413
+ if (!Array.isArray(config.extends)) {
414
+ throw new TypeError("The `extends` property must be an array.");
415
+ }
416
+
417
+ const {
418
+ /** @type {Config[]} */
419
+ extends: extendsList,
420
+
421
+ /** @type {Config} */
422
+ ...configObject
423
+ } = config;
424
+
425
+ const extensionNames = new WeakMap();
426
+
427
+ // replace strings with the actual configs
428
+ const objectExtends = extendsList.map(extendsElement => {
429
+ if (typeof extendsElement === "string") {
430
+ const pluginConfig = findPluginConfig(config, extendsElement);
431
+
432
+ // assign names
433
+ if (Array.isArray(pluginConfig)) {
434
+ pluginConfig.forEach((pluginConfigElement, index) => {
435
+ extensionNames.set(
436
+ pluginConfigElement,
437
+ `${extendsElement}[${index}]`,
438
+ );
439
+ });
440
+ } else {
441
+ extensionNames.set(pluginConfig, extendsElement);
442
+ }
443
+
444
+ return pluginConfig;
445
+ }
446
+
447
+ return /** @type {Config} */ (extendsElement);
448
+ });
449
+
450
+ const result = [];
451
+
452
+ for (const { indexPath, value: extendsElement } of flatTraverse(
453
+ objectExtends,
454
+ )) {
455
+ const extension = /** @type {Config} */ (extendsElement);
456
+
457
+ if ("basePath" in extension) {
458
+ throw new TypeError("'basePath' in `extends` is not allowed.");
459
+ }
460
+
461
+ if ("extends" in extension) {
462
+ throw new TypeError("Nested 'extends' is not allowed.");
463
+ }
464
+
465
+ const baseConfigName = /** @type {string} */ (configNames.get(config));
466
+ const extensionName =
467
+ extensionNames.get(extendsElement) ??
468
+ getExtensionName(extendsElement, indexPath);
469
+
470
+ result.push(
471
+ extendConfig(
472
+ configObject,
473
+ baseConfigName,
474
+ extension,
475
+ extensionName,
476
+ ),
477
+ );
478
+ }
479
+
480
+ /*
481
+ * If the base config object has only `ignores` and `extends`, then
482
+ * removing `extends` turns it into a global ignores, which is not what
483
+ * we want. So we need to check if the base config object is a global ignores
484
+ * and if so, we don't add it to the array.
485
+ *
486
+ * (The other option would be to add a `files` entry, but that would result
487
+ * in a config that didn't actually do anything because there are no
488
+ * other keys in the config.)
489
+ */
490
+ if (!isGlobalIgnores(configObject)) {
491
+ result.push(configObject);
492
+ }
493
+
494
+ return result.flat();
495
+ }
496
+
497
+ /**
498
+ * Processes a list of config objects and arrays.
499
+ * @param {ConfigWithExtends[]} configList The list of config objects and arrays.
500
+ * @param {WeakMap<Config, string>} configNames The map of config objects to their names.
501
+ * @return {Config[]} The flattened list of config objects.
502
+ */
503
+ function processConfigList(configList, configNames) {
504
+ return configList.flatMap(config => processExtends(config, configNames));
505
+ }
506
+
507
+ //-----------------------------------------------------------------------------
508
+ // Exports
509
+ //-----------------------------------------------------------------------------
510
+
511
+ /**
512
+ * Helper function to define a config array.
513
+ * @param {ConfigWithExtendsArray} args The arguments to the function.
514
+ * @returns {Config[]} The config array.
515
+ * @throws {TypeError} If no arguments are provided or if an argument is not an object.
516
+ */
517
+ function defineConfig(...args) {
518
+ const configNames = new WeakMap();
519
+ const configs = [];
520
+
521
+ if (args.length === 0) {
522
+ throw new TypeError("Expected one or more arguments.");
523
+ }
524
+
525
+ // first flatten the list of configs and get the names
526
+ for (const { indexPath, value } of flatTraverse(args)) {
527
+ if (typeof value !== "object" || value === null) {
528
+ throw new TypeError(
529
+ `Expected an object but received ${String(value)}.`,
530
+ );
531
+ }
532
+
533
+ const config = /** @type {ConfigWithExtends} */ (value);
534
+
535
+ // save config name for easy reference later
536
+ configNames.set(config, getConfigName(config, indexPath));
537
+ configs.push(config);
538
+ }
539
+
540
+ return processConfigList(configs, configNames);
541
+ }
542
+
543
+ /**
544
+ * @fileoverview Global ignores helper function.
545
+ * @author Nicholas C. Zakas
546
+ */
547
+
548
+ //-----------------------------------------------------------------------------
549
+ // Type Definitions
550
+ //-----------------------------------------------------------------------------
551
+
552
+
553
+ //-----------------------------------------------------------------------------
554
+ // Helpers
555
+ //-----------------------------------------------------------------------------
556
+
557
+ let globalIgnoreCount = 0;
558
+
559
+ //-----------------------------------------------------------------------------
560
+ // Exports
561
+ //-----------------------------------------------------------------------------
562
+
563
+ /**
564
+ * Creates a global ignores config with the given patterns.
565
+ * @param {string[]} ignorePatterns The ignore patterns.
566
+ * @param {string} [name] The name of the global ignores config.
567
+ * @returns {Config} The global ignores config.
568
+ * @throws {TypeError} If ignorePatterns is not an array or if it is empty.
569
+ */
570
+ function globalIgnores(ignorePatterns, name) {
571
+ if (!Array.isArray(ignorePatterns)) {
572
+ throw new TypeError("ignorePatterns must be an array");
573
+ }
574
+
575
+ if (ignorePatterns.length === 0) {
576
+ throw new TypeError("ignorePatterns must contain at least one pattern");
577
+ }
578
+
579
+ const id = globalIgnoreCount++;
580
+
581
+ return {
582
+ name: name || `globalIgnores ${id}`,
583
+ ignores: ignorePatterns,
584
+ };
585
+ }
586
+
587
+ exports.defineConfig = defineConfig;
588
+ exports.globalIgnores = globalIgnores;
server/node_modules/@eslint/config-helpers/dist/cjs/index.d.cts ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export type Config = $eslintcore.ConfigObject;
2
+ export type LegacyConfig = $eslintcore.LegacyConfigObject;
3
+ export type Plugin = $eslintcore.Plugin;
4
+ export type RuleConfig = $eslintcore.RuleConfig;
5
+ export type ExtendsElement = $typests.ExtendsElement;
6
+ export type SimpleExtendsElement = $typests.SimpleExtendsElement;
7
+ export type ConfigWithExtends = $typests.ConfigWithExtends;
8
+ export type InfiniteConfigArray = $typests.InfiniteArray<Config>;
9
+ export type ConfigWithExtendsArray = $typests.ConfigWithExtendsArray;
10
+ /**
11
+ * Helper function to define a config array.
12
+ * @param {ConfigWithExtendsArray} args The arguments to the function.
13
+ * @returns {Config[]} The config array.
14
+ * @throws {TypeError} If no arguments are provided or if an argument is not an object.
15
+ */
16
+ export function defineConfig(...args: ConfigWithExtendsArray): Config[];
17
+ /**
18
+ * Creates a global ignores config with the given patterns.
19
+ * @param {string[]} ignorePatterns The ignore patterns.
20
+ * @param {string} [name] The name of the global ignores config.
21
+ * @returns {Config} The global ignores config.
22
+ * @throws {TypeError} If ignorePatterns is not an array or if it is empty.
23
+ */
24
+ export function globalIgnores(ignorePatterns: string[], name?: string): Config;
25
+ import type * as $eslintcore from "@eslint/core";
26
+ import type * as $typests from "./types.cts";
server/node_modules/@eslint/config-helpers/dist/cjs/types.cts ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @fileoverview Types for this package.
3
+ */
4
+
5
+ import type { ConfigObject } from "@eslint/core";
6
+
7
+ /**
8
+ * Infinite array type.
9
+ */
10
+ export type InfiniteArray<T> = T | InfiniteArray<T>[];
11
+
12
+ /**
13
+ * The type of array element in the `extends` property after flattening.
14
+ */
15
+ export type SimpleExtendsElement = string | ConfigObject;
16
+
17
+ /**
18
+ * The type of array element in the `extends` property before flattening.
19
+ */
20
+ export type ExtendsElement = SimpleExtendsElement | InfiniteArray<ConfigObject>;
21
+
22
+ /**
23
+ * Config with extends. Valid only inside of `defineConfig()`.
24
+ */
25
+ export interface ConfigWithExtends extends ConfigObject {
26
+ extends?: ExtendsElement[];
27
+ }
28
+
29
+ export type ConfigWithExtendsArray = InfiniteArray<ConfigWithExtends>[];
server/node_modules/@eslint/config-helpers/dist/esm/index.d.ts ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export type Config = $eslintcore.ConfigObject;
2
+ export type LegacyConfig = $eslintcore.LegacyConfigObject;
3
+ export type Plugin = $eslintcore.Plugin;
4
+ export type RuleConfig = $eslintcore.RuleConfig;
5
+ export type ExtendsElement = $typests.ExtendsElement;
6
+ export type SimpleExtendsElement = $typests.SimpleExtendsElement;
7
+ export type ConfigWithExtends = $typests.ConfigWithExtends;
8
+ export type InfiniteConfigArray = $typests.InfiniteArray<Config>;
9
+ export type ConfigWithExtendsArray = $typests.ConfigWithExtendsArray;
10
+ /**
11
+ * Helper function to define a config array.
12
+ * @param {ConfigWithExtendsArray} args The arguments to the function.
13
+ * @returns {Config[]} The config array.
14
+ * @throws {TypeError} If no arguments are provided or if an argument is not an object.
15
+ */
16
+ export function defineConfig(...args: ConfigWithExtendsArray): Config[];
17
+ /**
18
+ * Creates a global ignores config with the given patterns.
19
+ * @param {string[]} ignorePatterns The ignore patterns.
20
+ * @param {string} [name] The name of the global ignores config.
21
+ * @returns {Config} The global ignores config.
22
+ * @throws {TypeError} If ignorePatterns is not an array or if it is empty.
23
+ */
24
+ export function globalIgnores(ignorePatterns: string[], name?: string): Config;
25
+ import type * as $eslintcore from "@eslint/core";
26
+ import type * as $typests from "./types.ts";
server/node_modules/@eslint/config-helpers/dist/esm/index.js ADDED
@@ -0,0 +1,586 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-self-types="./index.d.ts"
2
+ /**
3
+ * @fileoverview defineConfig helper
4
+ * @author Nicholas C. Zakas
5
+ */
6
+
7
+ //-----------------------------------------------------------------------------
8
+ // Type Definitions
9
+ //-----------------------------------------------------------------------------
10
+
11
+ /** @import * as $eslintcore from "@eslint/core"; */
12
+ /** @typedef {$eslintcore.ConfigObject} Config */
13
+ /** @typedef {$eslintcore.LegacyConfigObject} LegacyConfig */
14
+ /** @typedef {$eslintcore.Plugin} Plugin */
15
+ /** @typedef {$eslintcore.RuleConfig} RuleConfig */
16
+ /** @import * as $typests from "./types.ts"; */
17
+ /** @typedef {$typests.ExtendsElement} ExtendsElement */
18
+ /** @typedef {$typests.SimpleExtendsElement} SimpleExtendsElement */
19
+ /** @typedef {$typests.ConfigWithExtends} ConfigWithExtends */
20
+ /** @typedef {$typests.InfiniteArray<Config>} InfiniteConfigArray */
21
+ /** @typedef {$typests.ConfigWithExtendsArray} ConfigWithExtendsArray */
22
+
23
+ //-----------------------------------------------------------------------------
24
+ // Helpers
25
+ //-----------------------------------------------------------------------------
26
+
27
+ const eslintrcKeys = [
28
+ "env",
29
+ "extends",
30
+ "globals",
31
+ "ignorePatterns",
32
+ "noInlineConfig",
33
+ "overrides",
34
+ "parser",
35
+ "parserOptions",
36
+ "reportUnusedDisableDirectives",
37
+ "root",
38
+ ];
39
+
40
+ const allowedGlobalIgnoreKeys = new Set(["basePath", "ignores", "name"]);
41
+
42
+ /**
43
+ * Gets the name of a config object.
44
+ * @param {Config} config The config object.
45
+ * @param {string} indexPath The index path of the config object.
46
+ * @return {string} The name of the config object.
47
+ */
48
+ function getConfigName(config, indexPath) {
49
+ if (config.name) {
50
+ return config.name;
51
+ }
52
+
53
+ return `UserConfig${indexPath}`;
54
+ }
55
+
56
+ /**
57
+ * Gets the name of an extension.
58
+ * @param {SimpleExtendsElement} extension The extension.
59
+ * @param {string} indexPath The index of the extension.
60
+ * @return {string} The name of the extension.
61
+ */
62
+ function getExtensionName(extension, indexPath) {
63
+ if (typeof extension === "string") {
64
+ return extension;
65
+ }
66
+
67
+ if (extension.name) {
68
+ return extension.name;
69
+ }
70
+
71
+ return `ExtendedConfig${indexPath}`;
72
+ }
73
+
74
+ /**
75
+ * Determines if a config object is a legacy config.
76
+ * @param {Config|LegacyConfig} config The config object to check.
77
+ * @return {config is LegacyConfig} `true` if the config object is a legacy config.
78
+ */
79
+ function isLegacyConfig(config) {
80
+ // eslintrc's plugins must be an array; while flat config's must be an object.
81
+ if (Array.isArray(config.plugins)) {
82
+ return true;
83
+ }
84
+
85
+ for (const key of eslintrcKeys) {
86
+ if (key in config) {
87
+ return true;
88
+ }
89
+ }
90
+
91
+ return false;
92
+ }
93
+
94
+ /**
95
+ * Determines if a config object is a global ignores config.
96
+ * @param {Config} config The config object to check.
97
+ * @return {boolean} `true` if the config object is a global ignores config.
98
+ */
99
+ function isGlobalIgnores(config) {
100
+ return Object.keys(config).every(key => allowedGlobalIgnoreKeys.has(key));
101
+ }
102
+
103
+ /**
104
+ * Parses a plugin member ID (rule, processor, etc.) and returns
105
+ * the namespace and member name.
106
+ * @param {string} id The ID to parse.
107
+ * @returns {{namespace:string, name:string}} The namespace and member name.
108
+ */
109
+ function getPluginMember(id) {
110
+ const firstSlashIndex = id.indexOf("/");
111
+
112
+ if (firstSlashIndex === -1) {
113
+ return { namespace: "", name: id };
114
+ }
115
+
116
+ let namespace = id.slice(0, firstSlashIndex);
117
+
118
+ /*
119
+ * Special cases:
120
+ * 1. The namespace is `@`, that means it's referring to the
121
+ * core plugin so `@` is the full namespace.
122
+ * 2. The namespace starts with `@`, that means it's referring to
123
+ * an npm scoped package. That means the namespace is the scope
124
+ * and the package name (i.e., `@eslint/core`).
125
+ */
126
+ if (namespace[0] === "@" && namespace !== "@") {
127
+ const secondSlashIndex = id.indexOf("/", firstSlashIndex + 1);
128
+ if (secondSlashIndex !== -1) {
129
+ namespace = id.slice(0, secondSlashIndex);
130
+ return { namespace, name: id.slice(secondSlashIndex + 1) };
131
+ }
132
+ }
133
+
134
+ const name = id.slice(firstSlashIndex + 1);
135
+
136
+ return { namespace, name };
137
+ }
138
+
139
+ /**
140
+ * Normalizes the plugin config by replacing the namespace with the plugin namespace.
141
+ * @param {string} userNamespace The namespace of the plugin.
142
+ * @param {Plugin} plugin The plugin config object.
143
+ * @param {Config} config The config object to normalize.
144
+ * @return {Config} The normalized config object.
145
+ */
146
+ function normalizePluginConfig(userNamespace, plugin, config) {
147
+ const pluginNamespace = plugin.meta?.namespace;
148
+
149
+ // don't do anything if the plugin doesn't have a namespace or rules
150
+ if (
151
+ !pluginNamespace ||
152
+ pluginNamespace === userNamespace ||
153
+ (!config.rules && !config.processor && !config.language)
154
+ ) {
155
+ return config;
156
+ }
157
+
158
+ const result = { ...config };
159
+
160
+ // update the rules
161
+ if (result.rules) {
162
+ const ruleIds = Object.keys(result.rules);
163
+
164
+ /** @type {Record<string,RuleConfig|undefined>} */
165
+ const newRules = {};
166
+
167
+ for (let i = 0; i < ruleIds.length; i++) {
168
+ const ruleId = ruleIds[i];
169
+ const { namespace: ruleNamespace, name: ruleName } =
170
+ getPluginMember(ruleId);
171
+
172
+ if (ruleNamespace === pluginNamespace) {
173
+ newRules[`${userNamespace}/${ruleName}`] = result.rules[ruleId];
174
+ } else {
175
+ newRules[ruleId] = result.rules[ruleId];
176
+ }
177
+ }
178
+
179
+ result.rules = newRules;
180
+ }
181
+
182
+ // update the processor
183
+
184
+ if (typeof result.processor === "string") {
185
+ const { namespace: processorNamespace, name: processorName } =
186
+ getPluginMember(result.processor);
187
+
188
+ if (processorNamespace) {
189
+ if (processorNamespace === pluginNamespace) {
190
+ result.processor = `${userNamespace}/${processorName}`;
191
+ }
192
+ }
193
+ }
194
+
195
+ // update the language
196
+ if (typeof result.language === "string") {
197
+ const { namespace: languageNamespace, name: languageName } =
198
+ getPluginMember(result.language);
199
+
200
+ if (languageNamespace === pluginNamespace) {
201
+ result.language = `${userNamespace}/${languageName}`;
202
+ }
203
+ }
204
+
205
+ return result;
206
+ }
207
+
208
+ /**
209
+ * Deeply normalizes a plugin config, traversing recursively into an arrays.
210
+ * @param {string} userPluginNamespace The namespace of the plugin.
211
+ * @param {Plugin} plugin The plugin object.
212
+ * @param {Config|LegacyConfig|(Config|LegacyConfig)[]} pluginConfig The plugin config to normalize.
213
+ * @param {string} pluginConfigName The name of the plugin config.
214
+ * @return {InfiniteConfigArray} The normalized plugin config.
215
+ * @throws {TypeError} If the plugin config is a legacy config.
216
+ */
217
+ function deepNormalizePluginConfig(
218
+ userPluginNamespace,
219
+ plugin,
220
+ pluginConfig,
221
+ pluginConfigName,
222
+ ) {
223
+ // if it's an array then it's definitely a new config
224
+ if (Array.isArray(pluginConfig)) {
225
+ return pluginConfig.map(pluginSubConfig =>
226
+ deepNormalizePluginConfig(
227
+ userPluginNamespace,
228
+ plugin,
229
+ pluginSubConfig,
230
+ pluginConfigName,
231
+ ),
232
+ );
233
+ }
234
+
235
+ // if it's a legacy config, throw an error
236
+ if (isLegacyConfig(pluginConfig)) {
237
+ throw new TypeError(
238
+ `Plugin config "${pluginConfigName}" is an eslintrc config and cannot be used in this context.`,
239
+ );
240
+ }
241
+
242
+ return normalizePluginConfig(userPluginNamespace, plugin, pluginConfig);
243
+ }
244
+
245
+ /**
246
+ * Finds a plugin config by name in the given config.
247
+ * @param {Config} config The config object.
248
+ * @param {string} pluginConfigName The name of the plugin config.
249
+ * @return {InfiniteConfigArray} The plugin config.
250
+ * @throws {TypeError} If the plugin config is not found or is a legacy config.
251
+ */
252
+ function findPluginConfig(config, pluginConfigName) {
253
+ const { namespace: userPluginNamespace, name: configName } =
254
+ getPluginMember(pluginConfigName);
255
+ const plugin = config.plugins?.[userPluginNamespace];
256
+
257
+ if (!plugin) {
258
+ throw new TypeError(`Plugin "${userPluginNamespace}" not found.`);
259
+ }
260
+
261
+ const directConfig = plugin.configs?.[configName];
262
+
263
+ // Prefer direct config, but fall back to flat config if available
264
+ if (directConfig) {
265
+ // Arrays are always flat configs, and non-legacy configs can be used directly
266
+ if (Array.isArray(directConfig) || !isLegacyConfig(directConfig)) {
267
+ return deepNormalizePluginConfig(
268
+ userPluginNamespace,
269
+ plugin,
270
+ directConfig,
271
+ pluginConfigName,
272
+ );
273
+ }
274
+ }
275
+
276
+ // If it's a legacy config, or the config does not exist => look for the flat version
277
+ const flatConfig = plugin.configs?.[`flat/${configName}`];
278
+ if (
279
+ flatConfig &&
280
+ (Array.isArray(flatConfig) || !isLegacyConfig(flatConfig))
281
+ ) {
282
+ return deepNormalizePluginConfig(
283
+ userPluginNamespace,
284
+ plugin,
285
+ flatConfig,
286
+ pluginConfigName,
287
+ );
288
+ }
289
+
290
+ // If we get here, then the config was either not found or is a legacy config
291
+ const message =
292
+ directConfig || flatConfig
293
+ ? `Plugin config "${configName}" in plugin "${userPluginNamespace}" is an eslintrc config and cannot be used in this context.`
294
+ : `Plugin config "${configName}" not found in plugin "${userPluginNamespace}".`;
295
+ throw new TypeError(message);
296
+ }
297
+
298
+ /**
299
+ * Flattens an array while keeping track of the index path.
300
+ * @param {any[]} configList The array to traverse.
301
+ * @param {string} indexPath The index path of the value in a multidimensional array.
302
+ * @return {IterableIterator<{indexPath:string, value:any}>} The flattened list of values.
303
+ */
304
+ function* flatTraverse(configList, indexPath = "") {
305
+ for (let i = 0; i < configList.length; i++) {
306
+ const newIndexPath = indexPath ? `${indexPath}[${i}]` : `[${i}]`;
307
+
308
+ // if it's an array then traverse it as well
309
+ if (Array.isArray(configList[i])) {
310
+ yield* flatTraverse(configList[i], newIndexPath);
311
+ continue;
312
+ }
313
+
314
+ yield { indexPath: newIndexPath, value: configList[i] };
315
+ }
316
+ }
317
+
318
+ /**
319
+ * Extends a list of config files by creating every combination of base and extension files.
320
+ * @param {(string|string[])[]} [baseFiles] The base files.
321
+ * @param {(string|string[])[]} [extensionFiles] The extension files.
322
+ * @return {(string|string[])[]} The extended files.
323
+ */
324
+ function extendConfigFiles(baseFiles = [], extensionFiles = []) {
325
+ if (!extensionFiles.length) {
326
+ return baseFiles.concat();
327
+ }
328
+
329
+ if (!baseFiles.length) {
330
+ return extensionFiles.concat();
331
+ }
332
+
333
+ /** @type {(string|string[])[]} */
334
+ const result = [];
335
+
336
+ for (const baseFile of baseFiles) {
337
+ for (const extensionFile of extensionFiles) {
338
+ /*
339
+ * Each entry can be a string or array of strings. The end result
340
+ * needs to be an array of strings, so we need to be sure to include
341
+ * all of the items when there's an array.
342
+ */
343
+
344
+ const entry = [];
345
+
346
+ if (Array.isArray(baseFile)) {
347
+ entry.push(...baseFile);
348
+ } else {
349
+ entry.push(baseFile);
350
+ }
351
+
352
+ if (Array.isArray(extensionFile)) {
353
+ entry.push(...extensionFile);
354
+ } else {
355
+ entry.push(extensionFile);
356
+ }
357
+
358
+ result.push(entry);
359
+ }
360
+ }
361
+
362
+ return result;
363
+ }
364
+
365
+ /**
366
+ * Extends a config object with another config object.
367
+ * @param {Config} baseConfig The base config object.
368
+ * @param {string} baseConfigName The name of the base config object.
369
+ * @param {Config} extension The extension config object.
370
+ * @param {string} extensionName The index of the extension config object.
371
+ * @return {Config} The extended config object.
372
+ */
373
+ function extendConfig(baseConfig, baseConfigName, extension, extensionName) {
374
+ const result = { ...extension };
375
+
376
+ // for global ignores there is no further work to be done, we just keep everything
377
+ if (!isGlobalIgnores(extension)) {
378
+ // for files we need to create every combination of base and extension files
379
+ if (baseConfig.files) {
380
+ result.files = extendConfigFiles(baseConfig.files, extension.files);
381
+ }
382
+
383
+ // for ignores we just concatenation the extension ignores onto the base ignores
384
+ if (baseConfig.ignores) {
385
+ result.ignores = baseConfig.ignores.concat(extension.ignores ?? []);
386
+ }
387
+ }
388
+
389
+ result.name = `${baseConfigName} > ${extensionName}`;
390
+
391
+ // @ts-ignore -- ESLint types aren't updated yet
392
+ if (baseConfig.basePath) {
393
+ // @ts-ignore -- ESLint types aren't updated yet
394
+ result.basePath = baseConfig.basePath;
395
+ }
396
+
397
+ return result;
398
+ }
399
+
400
+ /**
401
+ * Processes a list of extends elements.
402
+ * @param {ConfigWithExtends} config The config object.
403
+ * @param {WeakMap<Config, string>} configNames The map of config objects to their names.
404
+ * @return {Config[]} The flattened list of config objects.
405
+ * @throws {TypeError} If the `extends` property is not an array or if nested `extends` is found.
406
+ */
407
+ function processExtends(config, configNames) {
408
+ if (!config.extends) {
409
+ return [config];
410
+ }
411
+
412
+ if (!Array.isArray(config.extends)) {
413
+ throw new TypeError("The `extends` property must be an array.");
414
+ }
415
+
416
+ const {
417
+ /** @type {Config[]} */
418
+ extends: extendsList,
419
+
420
+ /** @type {Config} */
421
+ ...configObject
422
+ } = config;
423
+
424
+ const extensionNames = new WeakMap();
425
+
426
+ // replace strings with the actual configs
427
+ const objectExtends = extendsList.map(extendsElement => {
428
+ if (typeof extendsElement === "string") {
429
+ const pluginConfig = findPluginConfig(config, extendsElement);
430
+
431
+ // assign names
432
+ if (Array.isArray(pluginConfig)) {
433
+ pluginConfig.forEach((pluginConfigElement, index) => {
434
+ extensionNames.set(
435
+ pluginConfigElement,
436
+ `${extendsElement}[${index}]`,
437
+ );
438
+ });
439
+ } else {
440
+ extensionNames.set(pluginConfig, extendsElement);
441
+ }
442
+
443
+ return pluginConfig;
444
+ }
445
+
446
+ return /** @type {Config} */ (extendsElement);
447
+ });
448
+
449
+ const result = [];
450
+
451
+ for (const { indexPath, value: extendsElement } of flatTraverse(
452
+ objectExtends,
453
+ )) {
454
+ const extension = /** @type {Config} */ (extendsElement);
455
+
456
+ if ("basePath" in extension) {
457
+ throw new TypeError("'basePath' in `extends` is not allowed.");
458
+ }
459
+
460
+ if ("extends" in extension) {
461
+ throw new TypeError("Nested 'extends' is not allowed.");
462
+ }
463
+
464
+ const baseConfigName = /** @type {string} */ (configNames.get(config));
465
+ const extensionName =
466
+ extensionNames.get(extendsElement) ??
467
+ getExtensionName(extendsElement, indexPath);
468
+
469
+ result.push(
470
+ extendConfig(
471
+ configObject,
472
+ baseConfigName,
473
+ extension,
474
+ extensionName,
475
+ ),
476
+ );
477
+ }
478
+
479
+ /*
480
+ * If the base config object has only `ignores` and `extends`, then
481
+ * removing `extends` turns it into a global ignores, which is not what
482
+ * we want. So we need to check if the base config object is a global ignores
483
+ * and if so, we don't add it to the array.
484
+ *
485
+ * (The other option would be to add a `files` entry, but that would result
486
+ * in a config that didn't actually do anything because there are no
487
+ * other keys in the config.)
488
+ */
489
+ if (!isGlobalIgnores(configObject)) {
490
+ result.push(configObject);
491
+ }
492
+
493
+ return result.flat();
494
+ }
495
+
496
+ /**
497
+ * Processes a list of config objects and arrays.
498
+ * @param {ConfigWithExtends[]} configList The list of config objects and arrays.
499
+ * @param {WeakMap<Config, string>} configNames The map of config objects to their names.
500
+ * @return {Config[]} The flattened list of config objects.
501
+ */
502
+ function processConfigList(configList, configNames) {
503
+ return configList.flatMap(config => processExtends(config, configNames));
504
+ }
505
+
506
+ //-----------------------------------------------------------------------------
507
+ // Exports
508
+ //-----------------------------------------------------------------------------
509
+
510
+ /**
511
+ * Helper function to define a config array.
512
+ * @param {ConfigWithExtendsArray} args The arguments to the function.
513
+ * @returns {Config[]} The config array.
514
+ * @throws {TypeError} If no arguments are provided or if an argument is not an object.
515
+ */
516
+ function defineConfig(...args) {
517
+ const configNames = new WeakMap();
518
+ const configs = [];
519
+
520
+ if (args.length === 0) {
521
+ throw new TypeError("Expected one or more arguments.");
522
+ }
523
+
524
+ // first flatten the list of configs and get the names
525
+ for (const { indexPath, value } of flatTraverse(args)) {
526
+ if (typeof value !== "object" || value === null) {
527
+ throw new TypeError(
528
+ `Expected an object but received ${String(value)}.`,
529
+ );
530
+ }
531
+
532
+ const config = /** @type {ConfigWithExtends} */ (value);
533
+
534
+ // save config name for easy reference later
535
+ configNames.set(config, getConfigName(config, indexPath));
536
+ configs.push(config);
537
+ }
538
+
539
+ return processConfigList(configs, configNames);
540
+ }
541
+
542
+ /**
543
+ * @fileoverview Global ignores helper function.
544
+ * @author Nicholas C. Zakas
545
+ */
546
+
547
+ //-----------------------------------------------------------------------------
548
+ // Type Definitions
549
+ //-----------------------------------------------------------------------------
550
+
551
+
552
+ //-----------------------------------------------------------------------------
553
+ // Helpers
554
+ //-----------------------------------------------------------------------------
555
+
556
+ let globalIgnoreCount = 0;
557
+
558
+ //-----------------------------------------------------------------------------
559
+ // Exports
560
+ //-----------------------------------------------------------------------------
561
+
562
+ /**
563
+ * Creates a global ignores config with the given patterns.
564
+ * @param {string[]} ignorePatterns The ignore patterns.
565
+ * @param {string} [name] The name of the global ignores config.
566
+ * @returns {Config} The global ignores config.
567
+ * @throws {TypeError} If ignorePatterns is not an array or if it is empty.
568
+ */
569
+ function globalIgnores(ignorePatterns, name) {
570
+ if (!Array.isArray(ignorePatterns)) {
571
+ throw new TypeError("ignorePatterns must be an array");
572
+ }
573
+
574
+ if (ignorePatterns.length === 0) {
575
+ throw new TypeError("ignorePatterns must contain at least one pattern");
576
+ }
577
+
578
+ const id = globalIgnoreCount++;
579
+
580
+ return {
581
+ name: name || `globalIgnores ${id}`,
582
+ ignores: ignorePatterns,
583
+ };
584
+ }
585
+
586
+ export { defineConfig, globalIgnores };
server/node_modules/@eslint/config-helpers/dist/esm/types.d.ts ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @fileoverview Types for this package.
3
+ */
4
+ import type { ConfigObject } from "@eslint/core";
5
+ /**
6
+ * Infinite array type.
7
+ */
8
+ export type InfiniteArray<T> = T | InfiniteArray<T>[];
9
+ /**
10
+ * The type of array element in the `extends` property after flattening.
11
+ */
12
+ export type SimpleExtendsElement = string | ConfigObject;
13
+ /**
14
+ * The type of array element in the `extends` property before flattening.
15
+ */
16
+ export type ExtendsElement = SimpleExtendsElement | InfiniteArray<ConfigObject>;
17
+ /**
18
+ * Config with extends. Valid only inside of `defineConfig()`.
19
+ */
20
+ export interface ConfigWithExtends extends ConfigObject {
21
+ extends?: ExtendsElement[];
22
+ }
23
+ export type ConfigWithExtendsArray = InfiniteArray<ConfigWithExtends>[];
server/node_modules/@eslint/config-helpers/dist/esm/types.ts ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @fileoverview Types for this package.
3
+ */
4
+
5
+ import type { ConfigObject } from "@eslint/core";
6
+
7
+ /**
8
+ * Infinite array type.
9
+ */
10
+ export type InfiniteArray<T> = T | InfiniteArray<T>[];
11
+
12
+ /**
13
+ * The type of array element in the `extends` property after flattening.
14
+ */
15
+ export type SimpleExtendsElement = string | ConfigObject;
16
+
17
+ /**
18
+ * The type of array element in the `extends` property before flattening.
19
+ */
20
+ export type ExtendsElement = SimpleExtendsElement | InfiniteArray<ConfigObject>;
21
+
22
+ /**
23
+ * Config with extends. Valid only inside of `defineConfig()`.
24
+ */
25
+ export interface ConfigWithExtends extends ConfigObject {
26
+ extends?: ExtendsElement[];
27
+ }
28
+
29
+ export type ConfigWithExtendsArray = InfiniteArray<ConfigWithExtends>[];
server/node_modules/@eslint/config-helpers/package.json ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@eslint/config-helpers",
3
+ "version": "0.4.2",
4
+ "description": "Helper utilities for creating ESLint configuration",
5
+ "type": "module",
6
+ "main": "dist/esm/index.js",
7
+ "types": "dist/esm/index.d.ts",
8
+ "exports": {
9
+ "require": {
10
+ "types": "./dist/cjs/index.d.cts",
11
+ "default": "./dist/cjs/index.cjs"
12
+ },
13
+ "import": {
14
+ "types": "./dist/esm/index.d.ts",
15
+ "default": "./dist/esm/index.js"
16
+ }
17
+ },
18
+ "files": [
19
+ "dist"
20
+ ],
21
+ "publishConfig": {
22
+ "access": "public"
23
+ },
24
+ "directories": {
25
+ "test": "tests"
26
+ },
27
+ "scripts": {
28
+ "build:dedupe-types": "node ../../tools/dedupe-types.js dist/cjs/index.cjs dist/esm/index.js",
29
+ "build:cts": "node ../../tools/build-cts.js dist/esm/index.d.ts dist/cjs/index.d.cts",
30
+ "build": "rollup -c && npm run build:dedupe-types && tsc -p tsconfig.esm.json && npm run build:cts",
31
+ "test": "mocha \"tests/**/*.test.js\"",
32
+ "test:coverage": "c8 npm test",
33
+ "test:jsr": "npx jsr@latest publish --dry-run",
34
+ "test:pnpm": "cd tests/pnpm && pnpm install && pnpm exec tsc",
35
+ "test:types": "tsc -p tests/types/tsconfig.json"
36
+ },
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "git+https://github.com/eslint/rewrite.git",
40
+ "directory": "packages/config-helpers"
41
+ },
42
+ "keywords": [
43
+ "eslint"
44
+ ],
45
+ "license": "Apache-2.0",
46
+ "bugs": {
47
+ "url": "https://github.com/eslint/rewrite/issues"
48
+ },
49
+ "homepage": "https://github.com/eslint/rewrite/tree/main/packages/config-helpers#readme",
50
+ "dependencies": {
51
+ "@eslint/core": "^0.17.0"
52
+ },
53
+ "devDependencies": {
54
+ "eslint": "^9.27.0",
55
+ "rollup-plugin-copy": "^3.5.0"
56
+ },
57
+ "engines": {
58
+ "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
59
+ }
60
+ }
server/node_modules/@eslint/core/LICENSE ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
server/node_modules/@eslint/core/README.md ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ESLint Core
2
+
3
+ ## Overview
4
+
5
+ This package is the future home of the rewritten, runtime-agnostic ESLint core.
6
+
7
+ Right now, it exports the core types necessary to implement language plugins.
8
+
9
+ ## License
10
+
11
+ Apache 2.0
12
+
13
+ <!-- NOTE: This section is autogenerated. Do not manually edit.-->
14
+ <!--sponsorsstart-->
15
+
16
+ ## Sponsors
17
+
18
+ The following companies, organizations, and individuals support ESLint's ongoing maintenance and development. [Become a Sponsor](https://eslint.org/donate)
19
+ to get your logo on our READMEs and [website](https://eslint.org/sponsors).
20
+
21
+ <h3>Platinum Sponsors</h3>
22
+ <p><a href="https://automattic.com"><img src="https://images.opencollective.com/automattic/d0ef3e1/logo.png" alt="Automattic" height="128"></a> <a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/airbnb/d327d66/logo.png" alt="Airbnb" height="128"></a></p><h3>Gold Sponsors</h3>
23
+ <p><a href="https://qlty.sh/"><img src="https://images.opencollective.com/qltysh/33d157d/logo.png" alt="Qlty Software" height="96"></a> <a href="https://trunk.io/"><img src="https://images.opencollective.com/trunkio/fb92d60/avatar.png" alt="trunk.io" height="96"></a> <a href="https://shopify.engineering/"><img src="https://avatars.githubusercontent.com/u/8085" alt="Shopify" height="96"></a></p><h3>Silver Sponsors</h3>
24
+ <p><a href="https://vite.dev/"><img src="https://images.opencollective.com/vite/e6d15e1/logo.png" alt="Vite" height="64"></a> <a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/5c4fa84/logo.png" alt="Liftoff" height="64"></a> <a href="https://americanexpress.io"><img src="https://avatars.githubusercontent.com/u/3853301" alt="American Express" height="64"></a> <a href="https://stackblitz.com"><img src="https://avatars.githubusercontent.com/u/28635252" alt="StackBlitz" height="64"></a></p><h3>Bronze Sponsors</h3>
25
+ <p><a href="https://syntax.fm"><img src="https://github.com/syntaxfm.png" alt="Syntax" height="32"></a> <a href="https://cybozu.co.jp/"><img src="https://images.opencollective.com/cybozu/933e46d/logo.png" alt="Cybozu" height="32"></a> <a href="https://sentry.io"><img src="https://github.com/getsentry.png" alt="Sentry" height="32"></a> <a href="https://icons8.com/"><img src="https://images.opencollective.com/icons8/7fa1641/logo.png" alt="Icons8" height="32"></a> <a href="https://discord.com"><img src="https://images.opencollective.com/discordapp/f9645d9/logo.png" alt="Discord" height="32"></a> <a href="https://www.gitbook.com"><img src="https://avatars.githubusercontent.com/u/7111340" alt="GitBook" height="32"></a> <a href="https://nx.dev"><img src="https://avatars.githubusercontent.com/u/23692104" alt="Nx" height="32"></a> <a href="https://opensource.mercedes-benz.com/"><img src="https://avatars.githubusercontent.com/u/34240465" alt="Mercedes-Benz Group" height="32"></a> <a href="https://herocoders.com"><img src="https://avatars.githubusercontent.com/u/37549774" alt="HeroCoders" height="32"></a> <a href="https://www.lambdatest.com"><img src="https://avatars.githubusercontent.com/u/171592363" alt="LambdaTest" height="32"></a></p>
26
+ <h3>Technology Sponsors</h3>
27
+ Technology sponsors allow us to use their products and services for free as part of a contribution to the open source ecosystem and our work.
28
+ <p><a href="https://netlify.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/netlify-icon.svg" alt="Netlify" height="32"></a> <a href="https://algolia.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/algolia-icon.svg" alt="Algolia" height="32"></a> <a href="https://1password.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/1password-icon.svg" alt="1Password" height="32"></a></p>
29
+ <!--sponsorsend-->
server/node_modules/@eslint/core/dist/cjs/types.d.cts ADDED
@@ -0,0 +1,1179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @fileoverview Shared types for ESLint Core.
3
+ */
4
+ import type { JSONSchema4 } from "json-schema";
5
+ /**
6
+ * Represents an error inside of a file.
7
+ */
8
+ export interface FileError {
9
+ message: string;
10
+ line: number;
11
+ column: number;
12
+ endLine?: number;
13
+ endColumn?: number;
14
+ }
15
+ /**
16
+ * Represents a problem found in a file.
17
+ */
18
+ export interface FileProblem {
19
+ ruleId: string | null;
20
+ message: string;
21
+ loc: SourceLocation;
22
+ }
23
+ /**
24
+ * Represents the start and end coordinates of a node inside the source.
25
+ */
26
+ export interface SourceLocation {
27
+ start: Position;
28
+ end: Position;
29
+ }
30
+ /**
31
+ * Represents the start and end coordinates of a node inside the source with an offset.
32
+ */
33
+ export interface SourceLocationWithOffset {
34
+ start: PositionWithOffset;
35
+ end: PositionWithOffset;
36
+ }
37
+ /**
38
+ * Represents a location coordinate inside the source. ESLint-style formats
39
+ * have just `line` and `column` while others may have `offset` as well.
40
+ */
41
+ export interface Position {
42
+ line: number;
43
+ column: number;
44
+ }
45
+ /**
46
+ * Represents a location coordinate inside the source with an offset.
47
+ */
48
+ export interface PositionWithOffset extends Position {
49
+ offset: number;
50
+ }
51
+ /**
52
+ * Represents a range of characters in the source.
53
+ */
54
+ export type SourceRange = [number, number];
55
+ /**
56
+ * What the rule is responsible for finding:
57
+ * - `problem` means the rule has noticed a potential error.
58
+ * - `suggestion` means the rule suggests an alternate or better approach.
59
+ * - `layout` means the rule is looking at spacing, indentation, etc.
60
+ */
61
+ export type RuleType = "problem" | "suggestion" | "layout";
62
+ /**
63
+ * The type of fix the rule can provide:
64
+ * - `code` means the rule can fix syntax.
65
+ * - `whitespace` means the rule can fix spacing and indentation.
66
+ */
67
+ export type RuleFixType = "code" | "whitespace";
68
+ /**
69
+ * An object containing visitor information for a rule. Each method is either the
70
+ * name of a node type or a selector, or is a method that will be called at specific
71
+ * times during the traversal.
72
+ */
73
+ export type RuleVisitor = Record<string, ((...args: any[]) => void) | undefined>;
74
+ /**
75
+ * Rule meta information used for documentation.
76
+ */
77
+ export interface RulesMetaDocs {
78
+ /**
79
+ * A short description of the rule.
80
+ */
81
+ description?: string | undefined;
82
+ /**
83
+ * The URL to the documentation for the rule.
84
+ */
85
+ url?: string | undefined;
86
+ /**
87
+ * The category the rule falls under.
88
+ * @deprecated No longer used.
89
+ */
90
+ category?: string | undefined;
91
+ /**
92
+ * Indicates if the rule is generally recommended for all users.
93
+ *
94
+ * Note - this will always be a boolean for core rules, but may be used in any way by plugins.
95
+ */
96
+ recommended?: unknown;
97
+ /**
98
+ * Indicates if the rule is frozen (no longer accepting feature requests).
99
+ */
100
+ frozen?: boolean | undefined;
101
+ }
102
+ /**
103
+ * Meta information about a rule.
104
+ */
105
+ export interface RulesMeta<MessageIds extends string = string, RuleOptions = unknown[], ExtRuleDocs = unknown> {
106
+ /**
107
+ * Properties that are used when documenting the rule.
108
+ */
109
+ docs?: (RulesMetaDocs & ExtRuleDocs) | undefined;
110
+ /**
111
+ * The type of rule.
112
+ */
113
+ type?: RuleType | undefined;
114
+ /**
115
+ * The schema for the rule options. Required if the rule has options.
116
+ */
117
+ schema?: JSONSchema4 | JSONSchema4[] | false | undefined;
118
+ /**
119
+ * Any default options to be recursively merged on top of any user-provided options.
120
+ */
121
+ defaultOptions?: RuleOptions;
122
+ /**
123
+ * The messages that the rule can report.
124
+ */
125
+ messages?: Record<MessageIds, string>;
126
+ /**
127
+ * Indicates whether the rule has been deprecated or provides additional metadata about the deprecation. Omit if not deprecated.
128
+ */
129
+ deprecated?: boolean | DeprecatedInfo | undefined;
130
+ /**
131
+ * @deprecated Use deprecated.replacedBy instead.
132
+ * The name of the rule(s) this rule was replaced by, if it was deprecated.
133
+ */
134
+ replacedBy?: readonly string[] | undefined;
135
+ /**
136
+ * Indicates if the rule is fixable, and if so, what type of fix it provides.
137
+ */
138
+ fixable?: RuleFixType | undefined;
139
+ /**
140
+ * Indicates if the rule may provide suggestions.
141
+ */
142
+ hasSuggestions?: boolean | undefined;
143
+ /**
144
+ * The language the rule is intended to lint.
145
+ */
146
+ language?: string;
147
+ /**
148
+ * The dialects of `language` that the rule is intended to lint.
149
+ */
150
+ dialects?: string[];
151
+ }
152
+ /**
153
+ * Provides additional metadata about a deprecation.
154
+ */
155
+ export interface DeprecatedInfo {
156
+ /**
157
+ * General message presented to the user, e.g. for the key rule why the rule
158
+ * is deprecated or for info how to replace the rule.
159
+ */
160
+ message?: string;
161
+ /**
162
+ * URL to more information about this deprecation in general.
163
+ */
164
+ url?: string;
165
+ /**
166
+ * An empty array explicitly states that there is no replacement.
167
+ */
168
+ replacedBy?: ReplacedByInfo[];
169
+ /**
170
+ * The package version since when the rule is deprecated (should use full
171
+ * semver without a leading "v").
172
+ */
173
+ deprecatedSince?: string;
174
+ /**
175
+ * The estimated version when the rule is removed (probably the next major
176
+ * version). null means the rule is "frozen" (will be available but will not
177
+ * be changed).
178
+ */
179
+ availableUntil?: string | null;
180
+ }
181
+ /**
182
+ * Provides metadata about a replacement
183
+ */
184
+ export interface ReplacedByInfo {
185
+ /**
186
+ * General message presented to the user, e.g. how to replace the rule
187
+ */
188
+ message?: string;
189
+ /**
190
+ * URL to more information about this replacement in general
191
+ */
192
+ url?: string;
193
+ /**
194
+ * Name should be "eslint" if the replacement is an ESLint core rule. Omit
195
+ * the property if the replacement is in the same plugin.
196
+ */
197
+ plugin?: ExternalSpecifier;
198
+ /**
199
+ * Name and documentation of the replacement rule
200
+ */
201
+ rule?: ExternalSpecifier;
202
+ }
203
+ /**
204
+ * Specifies the name and url of an external resource. At least one property
205
+ * should be set.
206
+ */
207
+ export interface ExternalSpecifier {
208
+ /**
209
+ * Name of the referenced plugin / rule.
210
+ */
211
+ name?: string;
212
+ /**
213
+ * URL pointing to documentation for the plugin / rule.
214
+ */
215
+ url?: string;
216
+ }
217
+ /**
218
+ * Generic type for `RuleContext`.
219
+ */
220
+ export interface RuleContextTypeOptions {
221
+ LangOptions: LanguageOptions;
222
+ Code: SourceCode;
223
+ RuleOptions: unknown[];
224
+ Node: unknown;
225
+ MessageIds: string;
226
+ }
227
+ /**
228
+ * Represents the context object that is passed to a rule. This object contains
229
+ * information about the current state of the linting process and is the rule's
230
+ * view into the outside world.
231
+ */
232
+ export interface RuleContext<Options extends RuleContextTypeOptions = RuleContextTypeOptions> {
233
+ /**
234
+ * The current working directory for the session.
235
+ */
236
+ cwd: string;
237
+ /**
238
+ * Returns the current working directory for the session.
239
+ * @deprecated Use `cwd` instead.
240
+ */
241
+ getCwd(): string;
242
+ /**
243
+ * The filename of the file being linted.
244
+ */
245
+ filename: string;
246
+ /**
247
+ * Returns the filename of the file being linted.
248
+ * @deprecated Use `filename` instead.
249
+ */
250
+ getFilename(): string;
251
+ /**
252
+ * The physical filename of the file being linted.
253
+ */
254
+ physicalFilename: string;
255
+ /**
256
+ * Returns the physical filename of the file being linted.
257
+ * @deprecated Use `physicalFilename` instead.
258
+ */
259
+ getPhysicalFilename(): string;
260
+ /**
261
+ * The source code object that the rule is running on.
262
+ */
263
+ sourceCode: Options["Code"];
264
+ /**
265
+ * Returns the source code object that the rule is running on.
266
+ * @deprecated Use `sourceCode` instead.
267
+ */
268
+ getSourceCode(): Options["Code"];
269
+ /**
270
+ * Shared settings for the configuration.
271
+ */
272
+ settings: SettingsConfig;
273
+ /**
274
+ * Parser-specific options for the configuration.
275
+ * @deprecated Use `languageOptions.parserOptions` instead.
276
+ */
277
+ parserOptions: Record<string, unknown>;
278
+ /**
279
+ * The language options for the configuration.
280
+ */
281
+ languageOptions: Options["LangOptions"];
282
+ /**
283
+ * The CommonJS path to the parser used while parsing this file.
284
+ * @deprecated No longer used.
285
+ */
286
+ parserPath: string | undefined;
287
+ /**
288
+ * The rule ID.
289
+ */
290
+ id: string;
291
+ /**
292
+ * The rule's configured options.
293
+ */
294
+ options: Options["RuleOptions"];
295
+ /**
296
+ * The report function that the rule should use to report problems.
297
+ * @param violation The violation to report.
298
+ */
299
+ report(violation: ViolationReport<Options["Node"], Options["MessageIds"]>): void;
300
+ }
301
+ /**
302
+ * Manager of text edits for a rule fix.
303
+ */
304
+ export interface RuleTextEditor<EditableSyntaxElement = unknown> {
305
+ /**
306
+ * Inserts text after the specified node or token.
307
+ * @param syntaxElement The node or token to insert after.
308
+ * @param text The edit to insert after the node or token.
309
+ */
310
+ insertTextAfter(syntaxElement: EditableSyntaxElement, text: string): RuleTextEdit;
311
+ /**
312
+ * Inserts text after the specified range.
313
+ * @param range The range to insert after.
314
+ * @param text The edit to insert after the range.
315
+ */
316
+ insertTextAfterRange(range: SourceRange, text: string): RuleTextEdit;
317
+ /**
318
+ * Inserts text before the specified node or token.
319
+ * @param syntaxElement A syntax element with location information to insert before.
320
+ * @param text The edit to insert before the node or token.
321
+ */
322
+ insertTextBefore(syntaxElement: EditableSyntaxElement, text: string): RuleTextEdit;
323
+ /**
324
+ * Inserts text before the specified range.
325
+ * @param range The range to insert before.
326
+ * @param text The edit to insert before the range.
327
+ */
328
+ insertTextBeforeRange(range: SourceRange, text: string): RuleTextEdit;
329
+ /**
330
+ * Removes the specified node or token.
331
+ * @param syntaxElement A syntax element with location information to remove.
332
+ * @returns The edit to remove the node or token.
333
+ */
334
+ remove(syntaxElement: EditableSyntaxElement): RuleTextEdit;
335
+ /**
336
+ * Removes the specified range.
337
+ * @param range The range to remove.
338
+ * @returns The edit to remove the range.
339
+ */
340
+ removeRange(range: SourceRange): RuleTextEdit;
341
+ /**
342
+ * Replaces the specified node or token with the given text.
343
+ * @param syntaxElement A syntax element with location information to replace.
344
+ * @param text The text to replace the node or token with.
345
+ * @returns The edit to replace the node or token.
346
+ */
347
+ replaceText(syntaxElement: EditableSyntaxElement, text: string): RuleTextEdit;
348
+ /**
349
+ * Replaces the specified range with the given text.
350
+ * @param range The range to replace.
351
+ * @param text The text to replace the range with.
352
+ * @returns The edit to replace the range.
353
+ */
354
+ replaceTextRange(range: SourceRange, text: string): RuleTextEdit;
355
+ }
356
+ /**
357
+ * Represents a fix for a rule violation implemented as a text edit.
358
+ */
359
+ export interface RuleTextEdit {
360
+ /**
361
+ * The range to replace.
362
+ */
363
+ range: SourceRange;
364
+ /**
365
+ * The text to insert.
366
+ */
367
+ text: string;
368
+ }
369
+ /**
370
+ * Fixes a violation.
371
+ * @param fixer The text editor to apply the fix.
372
+ * @returns The fix(es) for the violation.
373
+ */
374
+ export type RuleFixer = (fixer: RuleTextEditor) => RuleTextEdit | Iterable<RuleTextEdit> | null;
375
+ export interface ViolationReportBase {
376
+ /**
377
+ * The data to insert into the message.
378
+ */
379
+ data?: Record<string, unknown> | undefined;
380
+ /**
381
+ * The fix to be applied for the violation.
382
+ */
383
+ fix?: RuleFixer | null | undefined;
384
+ /**
385
+ * An array of suggested fixes for the problem. These fixes may change the
386
+ * behavior of the code, so they are not applied automatically.
387
+ */
388
+ suggest?: SuggestedEdit[] | null | undefined;
389
+ }
390
+ export type ViolationMessage<MessageIds = string> = {
391
+ message: string;
392
+ } | {
393
+ messageId: MessageIds;
394
+ };
395
+ export type ViolationLocation<Node> = {
396
+ loc: SourceLocation | Position;
397
+ } | {
398
+ node: Node;
399
+ };
400
+ export type ViolationReport<Node = unknown, MessageIds = string> = ViolationReportBase & ViolationMessage<MessageIds> & ViolationLocation<Node>;
401
+ export interface SuggestedEditBase {
402
+ /**
403
+ * The data to insert into the message.
404
+ */
405
+ data?: Record<string, unknown> | undefined;
406
+ /**
407
+ * The fix to be applied for the suggestion.
408
+ */
409
+ fix: RuleFixer;
410
+ }
411
+ export type SuggestionMessage = {
412
+ desc: string;
413
+ } | {
414
+ messageId: string;
415
+ };
416
+ /**
417
+ * A suggested edit for a rule violation.
418
+ */
419
+ export type SuggestedEdit = SuggestedEditBase & SuggestionMessage;
420
+ /**
421
+ * The normalized version of a lint suggestion.
422
+ */
423
+ export interface LintSuggestion {
424
+ /** A short description. */
425
+ desc: string;
426
+ /** Fix result info. */
427
+ fix: RuleTextEdit;
428
+ /** Id referencing a message for the description. */
429
+ messageId?: string | undefined;
430
+ }
431
+ /**
432
+ * The normalized version of a lint violation message.
433
+ */
434
+ export interface LintMessage {
435
+ /** The 1-based column number. */
436
+ column: number;
437
+ /** The 1-based line number. */
438
+ line: number;
439
+ /** The 1-based column number of the end location. */
440
+ endColumn?: number | undefined;
441
+ /** The 1-based line number of the end location. */
442
+ endLine?: number | undefined;
443
+ /** The ID of the rule which makes this message. */
444
+ ruleId: string | null;
445
+ /** The reported message. */
446
+ message: string;
447
+ /** The ID of the message in the rule's meta. */
448
+ messageId?: string | undefined;
449
+ /**
450
+ * Type of node.
451
+ * @deprecated `nodeType` is deprecated and will be removed in the next major version.
452
+ */
453
+ nodeType?: string | undefined;
454
+ /** If `true` then this is a fatal error. */
455
+ fatal?: true | undefined;
456
+ /** The severity of this message. */
457
+ severity: Exclude<SeverityLevel, 0>;
458
+ /** Information for autofix. */
459
+ fix?: RuleTextEdit | undefined;
460
+ /** Information for suggestions. */
461
+ suggestions?: LintSuggestion[] | undefined;
462
+ }
463
+ /**
464
+ * Generic options for the `RuleDefinition` type.
465
+ */
466
+ export interface RuleDefinitionTypeOptions {
467
+ LangOptions: LanguageOptions;
468
+ Code: SourceCode;
469
+ RuleOptions: unknown[];
470
+ Visitor: RuleVisitor;
471
+ Node: unknown;
472
+ MessageIds: string;
473
+ ExtRuleDocs: unknown;
474
+ }
475
+ /**
476
+ * The definition of an ESLint rule.
477
+ */
478
+ export interface RuleDefinition<Options extends RuleDefinitionTypeOptions = RuleDefinitionTypeOptions> {
479
+ /**
480
+ * The meta information for the rule.
481
+ */
482
+ meta?: RulesMeta<Options["MessageIds"], Options["RuleOptions"], Options["ExtRuleDocs"]>;
483
+ /**
484
+ * Creates the visitor that ESLint uses to apply the rule during traversal.
485
+ * @param context The rule context.
486
+ * @returns The rule visitor.
487
+ */
488
+ create(context: RuleContext<{
489
+ LangOptions: Options["LangOptions"];
490
+ Code: Options["Code"];
491
+ RuleOptions: Options["RuleOptions"];
492
+ Node: Options["Node"];
493
+ MessageIds: Options["MessageIds"];
494
+ }>): Options["Visitor"];
495
+ }
496
+ /**
497
+ * Defaults for non-language-related `RuleDefinition` options.
498
+ */
499
+ export interface CustomRuleTypeDefinitions {
500
+ RuleOptions: unknown[];
501
+ MessageIds: string;
502
+ ExtRuleDocs: Record<string, unknown>;
503
+ }
504
+ /**
505
+ * A helper type to define language specific specializations of the `RuleDefinition` type.
506
+ *
507
+ * @example
508
+ * ```ts
509
+ * type YourRuleDefinition<
510
+ * Options extends Partial<CustomRuleTypeDefinitions> = {},
511
+ * > = CustomRuleDefinitionType<
512
+ * {
513
+ * LangOptions: YourLanguageOptions;
514
+ * Code: YourSourceCode;
515
+ * Visitor: YourRuleVisitor;
516
+ * Node: YourNode;
517
+ * },
518
+ * Options
519
+ * >;
520
+ * ```
521
+ */
522
+ export type CustomRuleDefinitionType<LanguageSpecificOptions extends Omit<RuleDefinitionTypeOptions, keyof CustomRuleTypeDefinitions>, Options extends Partial<CustomRuleTypeDefinitions>> = RuleDefinition<LanguageSpecificOptions & Required<Options & Omit<CustomRuleTypeDefinitions, keyof Options>>>;
523
+ /**
524
+ * The human readable severity level used in a configuration.
525
+ */
526
+ export type SeverityName = "off" | "warn" | "error";
527
+ /**
528
+ * The numeric severity level for a rule.
529
+ *
530
+ * - `0` means off.
531
+ * - `1` means warn.
532
+ * - `2` means error.
533
+ */
534
+ export type SeverityLevel = 0 | 1 | 2;
535
+ /**
536
+ * The severity of a rule in a configuration.
537
+ */
538
+ export type Severity = SeverityName | SeverityLevel;
539
+ /**
540
+ * Represents the metadata for an object, such as a plugin or processor.
541
+ */
542
+ export interface ObjectMetaProperties {
543
+ /** @deprecated Use `meta.name` instead. */
544
+ name?: string | undefined;
545
+ /** @deprecated Use `meta.version` instead. */
546
+ version?: string | undefined;
547
+ meta?: {
548
+ name?: string | undefined;
549
+ version?: string | undefined;
550
+ };
551
+ }
552
+ /**
553
+ * Represents the configuration options for the core linter.
554
+ */
555
+ export interface LinterOptionsConfig {
556
+ /**
557
+ * Indicates whether or not inline configuration is evaluated.
558
+ */
559
+ noInlineConfig?: boolean;
560
+ /**
561
+ * Indicates what to do when an unused disable directive is found.
562
+ */
563
+ reportUnusedDisableDirectives?: boolean | Severity;
564
+ /**
565
+ * A severity value indicating if and how unused inline configs should be
566
+ * tracked and reported.
567
+ */
568
+ reportUnusedInlineConfigs?: Severity;
569
+ }
570
+ /**
571
+ * The configuration for a rule.
572
+ */
573
+ export type RuleConfig<RuleOptions extends unknown[] = unknown[]> = Severity | [Severity, ...Partial<RuleOptions>];
574
+ /**
575
+ * A collection of rules and their configurations.
576
+ */
577
+ export interface RulesConfig {
578
+ [key: string]: RuleConfig;
579
+ }
580
+ /**
581
+ * A collection of settings.
582
+ */
583
+ export interface SettingsConfig {
584
+ [key: string]: unknown;
585
+ }
586
+ /**
587
+ * The configuration for a set of files.
588
+ */
589
+ export interface ConfigObject<Rules extends RulesConfig = RulesConfig> {
590
+ /**
591
+ * A string to identify the configuration object. Used in error messages and
592
+ * inspection tools.
593
+ */
594
+ name?: string;
595
+ /**
596
+ * Path to the directory where the configuration object should apply.
597
+ * `files` and `ignores` patterns in the configuration object are
598
+ * interpreted as relative to this path.
599
+ */
600
+ basePath?: string;
601
+ /**
602
+ * An array of glob patterns indicating the files that the configuration
603
+ * object should apply to. If not specified, the configuration object applies
604
+ * to all files
605
+ */
606
+ files?: (string | string[])[];
607
+ /**
608
+ * An array of glob patterns indicating the files that the configuration
609
+ * object should not apply to. If not specified, the configuration object
610
+ * applies to all files matched by files
611
+ */
612
+ ignores?: string[];
613
+ /**
614
+ * The name of the language used for linting. This is used to determine the
615
+ * parser and other language-specific settings.
616
+ * @since 9.7.0
617
+ */
618
+ language?: string;
619
+ /**
620
+ * An object containing settings related to how the language is configured for
621
+ * linting.
622
+ */
623
+ languageOptions?: LanguageOptions;
624
+ /**
625
+ * An object containing settings related to the linting process
626
+ */
627
+ linterOptions?: LinterOptionsConfig;
628
+ /**
629
+ * Either an object containing preprocess() and postprocess() methods or a
630
+ * string indicating the name of a processor inside of a plugin
631
+ * (i.e., "pluginName/processorName").
632
+ */
633
+ processor?: string | Processor;
634
+ /**
635
+ * An object containing a name-value mapping of plugin names to plugin objects.
636
+ * When files is specified, these plugins are only available to the matching files.
637
+ */
638
+ plugins?: Record<string, Plugin>;
639
+ /**
640
+ * An object containing the configured rules. When files or ignores are specified,
641
+ * these rule configurations are only available to the matching files.
642
+ */
643
+ rules?: Partial<Rules>;
644
+ /**
645
+ * An object containing name-value pairs of information that should be
646
+ * available to all rules.
647
+ */
648
+ settings?: Record<string, unknown>;
649
+ }
650
+ /** @deprecated Only supported in legacy eslintrc config format. */
651
+ export type GlobalAccess = boolean | "off" | "readable" | "readonly" | "writable" | "writeable";
652
+ /** @deprecated Only supported in legacy eslintrc config format. */
653
+ export interface GlobalsConfig {
654
+ [name: string]: GlobalAccess;
655
+ }
656
+ /**
657
+ * The ECMAScript version of the code being linted.
658
+ * @deprecated Only supported in legacy eslintrc config format.
659
+ */
660
+ export type EcmaVersion = 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023 | 2024 | 2025 | 2026 | "latest";
661
+ /**
662
+ * The type of JavaScript source code.
663
+ * @deprecated Only supported in legacy eslintrc config format.
664
+ */
665
+ export type JavaScriptSourceType = "script" | "module" | "commonjs";
666
+ /**
667
+ * Parser options.
668
+ * @deprecated Only supported in legacy eslintrc config format.
669
+ * @see [Specifying Parser Options](https://eslint.org/docs/latest/use/configure/language-options#specifying-parser-options)
670
+ */
671
+ export interface JavaScriptParserOptionsConfig {
672
+ /**
673
+ * Allow the use of reserved words as identifiers (if `ecmaVersion` is 3).
674
+ *
675
+ * @default false
676
+ */
677
+ allowReserved?: boolean | undefined;
678
+ /**
679
+ * Accepts any valid ECMAScript version number or `'latest'`:
680
+ *
681
+ * - A version: es3, es5, es6, es7, es8, es9, es10, es11, es12, es13, es14, ..., or
682
+ * - A year: es2015, es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, ..., or
683
+ * - `'latest'`
684
+ *
685
+ * When it's a version or a year, the value must be a number - so do not include the `es` prefix.
686
+ *
687
+ * Specifies the version of ECMAScript syntax you want to use. This is used by the parser to determine how to perform scope analysis, and it affects the default
688
+ *
689
+ * @default 5
690
+ */
691
+ ecmaVersion?: EcmaVersion | undefined;
692
+ /**
693
+ * The type of JavaScript source code. Possible values are "script" for
694
+ * traditional script files, "module" for ECMAScript modules (ESM), and
695
+ * "commonjs" for CommonJS files.
696
+ *
697
+ * @default 'script'
698
+ *
699
+ * @see https://eslint.org/docs/latest/use/configure/language-options-deprecated#specifying-parser-options
700
+ */
701
+ sourceType?: JavaScriptSourceType | undefined;
702
+ /**
703
+ * An object indicating which additional language features you'd like to use.
704
+ *
705
+ * @see https://eslint.org/docs/latest/use/configure/language-options-deprecated#specifying-parser-options
706
+ */
707
+ ecmaFeatures?: {
708
+ globalReturn?: boolean | undefined;
709
+ impliedStrict?: boolean | undefined;
710
+ jsx?: boolean | undefined;
711
+ experimentalObjectRestSpread?: boolean | undefined;
712
+ [key: string]: any;
713
+ } | undefined;
714
+ [key: string]: any;
715
+ }
716
+ /** @deprecated Only supported in legacy eslintrc config format. */
717
+ export interface EnvironmentConfig {
718
+ /** The definition of global variables. */
719
+ globals?: GlobalsConfig | undefined;
720
+ /** The parser options that will be enabled under this environment. */
721
+ parserOptions?: JavaScriptParserOptionsConfig | undefined;
722
+ }
723
+ /**
724
+ * A configuration object that may have a `rules` block.
725
+ */
726
+ export interface HasRules<Rules extends RulesConfig = RulesConfig> {
727
+ rules?: Partial<Rules> | undefined;
728
+ }
729
+ /**
730
+ * ESLint legacy configuration.
731
+ *
732
+ * @see [ESLint Legacy Configuration](https://eslint.org/docs/latest/use/configure/)
733
+ */
734
+ export interface BaseConfig<Rules extends RulesConfig = RulesConfig, OverrideRules extends RulesConfig = Rules> extends HasRules<Rules> {
735
+ $schema?: string | undefined;
736
+ /**
737
+ * An environment provides predefined global variables.
738
+ *
739
+ * @see [Environments](https://eslint.org/docs/latest/use/configure/language-options-deprecated#specifying-environments)
740
+ */
741
+ env?: {
742
+ [name: string]: boolean;
743
+ } | undefined;
744
+ /**
745
+ * Extending configuration files.
746
+ *
747
+ * @see [Extends](https://eslint.org/docs/latest/use/configure/configuration-files-deprecated#extending-configuration-files)
748
+ */
749
+ extends?: string | string[] | undefined;
750
+ /**
751
+ * Specifying globals.
752
+ *
753
+ * @see [Globals](https://eslint.org/docs/latest/use/configure/language-options-deprecated#specifying-globals)
754
+ */
755
+ globals?: GlobalsConfig | undefined;
756
+ /**
757
+ * Disable processing of inline comments.
758
+ *
759
+ * @see [Disabling Inline Comments](https://eslint.org/docs/latest/use/configure/rules-deprecated#disabling-inline-comments)
760
+ */
761
+ noInlineConfig?: boolean | undefined;
762
+ /**
763
+ * Overrides can be used to use a differing configuration for matching sub-directories and files.
764
+ *
765
+ * @see [How do overrides work](https://eslint.org/docs/latest/use/configure/configuration-files-deprecated#how-do-overrides-work)
766
+ */
767
+ overrides?: ConfigOverride<OverrideRules>[] | undefined;
768
+ /**
769
+ * Parser.
770
+ *
771
+ * @see [Working with Custom Parsers](https://eslint.org/docs/latest/extend/custom-parsers)
772
+ * @see [Specifying Parser](https://eslint.org/docs/latest/use/configure/parser-deprecated)
773
+ */
774
+ parser?: string | undefined;
775
+ /**
776
+ * Parser options.
777
+ *
778
+ * @see [Working with Custom Parsers](https://eslint.org/docs/latest/extend/custom-parsers)
779
+ * @see [Specifying Parser Options](https://eslint.org/docs/latest/use/configure/language-options-deprecated#specifying-parser-options)
780
+ */
781
+ parserOptions?: JavaScriptParserOptionsConfig | undefined;
782
+ /**
783
+ * Which third-party plugins define additional rules, environments, configs, etc. for ESLint to use.
784
+ *
785
+ * @see [Configuring Plugins](https://eslint.org/docs/latest/use/configure/plugins-deprecated#configure-plugins)
786
+ */
787
+ plugins?: string[] | undefined;
788
+ /**
789
+ * Specifying processor.
790
+ *
791
+ * @see [processor](https://eslint.org/docs/latest/use/configure/plugins-deprecated#specify-a-processor)
792
+ */
793
+ processor?: string | undefined;
794
+ /**
795
+ * Report unused eslint-disable comments as warning.
796
+ *
797
+ * @see [Report unused eslint-disable comments](https://eslint.org/docs/latest/use/configure/rules-deprecated#report-unused-eslint-disable-comments)
798
+ */
799
+ reportUnusedDisableDirectives?: boolean | undefined;
800
+ /**
801
+ * Settings.
802
+ *
803
+ * @see [Settings](https://eslint.org/docs/latest/use/configure/configuration-files-deprecated#adding-shared-settings)
804
+ */
805
+ settings?: SettingsConfig | undefined;
806
+ }
807
+ /**
808
+ * The overwrites that apply more differing configuration to specific files or directories.
809
+ */
810
+ export interface ConfigOverride<Rules extends RulesConfig = RulesConfig> extends BaseConfig<Rules> {
811
+ /**
812
+ * The glob patterns for excluded files.
813
+ */
814
+ excludedFiles?: string | string[] | undefined;
815
+ /**
816
+ * The glob patterns for target files.
817
+ */
818
+ files: string | string[];
819
+ }
820
+ /**
821
+ * ESLint legacy configuration.
822
+ *
823
+ * @see [ESLint Legacy Configuration](https://eslint.org/docs/latest/use/configure/)
824
+ */
825
+ export interface LegacyConfigObject<Rules extends RulesConfig = RulesConfig, OverrideRules extends RulesConfig = Rules> extends BaseConfig<Rules, OverrideRules> {
826
+ /**
827
+ * Tell ESLint to ignore specific files and directories.
828
+ *
829
+ * @see [Ignore Patterns](https://eslint.org/docs/latest/use/configure/ignore-deprecated#ignorepatterns-in-config-files)
830
+ */
831
+ ignorePatterns?: string | string[] | undefined;
832
+ /**
833
+ * @see [Using Configuration Files](https://eslint.org/docs/latest/use/configure/configuration-files-deprecated#using-configuration-files)
834
+ */
835
+ root?: boolean | undefined;
836
+ }
837
+ /**
838
+ * File information passed to a processor.
839
+ */
840
+ export interface ProcessorFile {
841
+ text: string;
842
+ filename: string;
843
+ }
844
+ /**
845
+ * A processor is an object that can preprocess and postprocess files.
846
+ */
847
+ export interface Processor<T extends string | ProcessorFile = string | ProcessorFile> extends ObjectMetaProperties {
848
+ /** If `true` then it means the processor supports autofix. */
849
+ supportsAutofix?: boolean | undefined;
850
+ /** The function to extract code blocks. */
851
+ preprocess?(text: string, filename: string): T[];
852
+ /** The function to merge messages. */
853
+ postprocess?(messages: LintMessage[][], filename: string): LintMessage[];
854
+ }
855
+ export interface Plugin extends ObjectMetaProperties {
856
+ meta?: ObjectMetaProperties["meta"] & {
857
+ namespace?: string | undefined;
858
+ };
859
+ configs?: Record<string, LegacyConfigObject | ConfigObject | ConfigObject[]> | undefined;
860
+ environments?: Record<string, EnvironmentConfig> | undefined;
861
+ languages?: Record<string, Language> | undefined;
862
+ processors?: Record<string, Processor> | undefined;
863
+ rules?: Record<string, RuleDefinition> | undefined;
864
+ }
865
+ /**
866
+ * Generic options for the `Language` type.
867
+ */
868
+ export interface LanguageTypeOptions {
869
+ LangOptions: LanguageOptions;
870
+ Code: SourceCode;
871
+ RootNode: unknown;
872
+ Node: unknown;
873
+ }
874
+ /**
875
+ * Represents a plugin language.
876
+ */
877
+ export interface Language<Options extends LanguageTypeOptions = {
878
+ LangOptions: LanguageOptions;
879
+ Code: SourceCode;
880
+ RootNode: unknown;
881
+ Node: unknown;
882
+ }> {
883
+ /**
884
+ * Indicates how ESLint should read the file.
885
+ */
886
+ fileType: "text";
887
+ /**
888
+ * First line number returned from the parser (text mode only).
889
+ */
890
+ lineStart: 0 | 1;
891
+ /**
892
+ * First column number returned from the parser (text mode only).
893
+ */
894
+ columnStart: 0 | 1;
895
+ /**
896
+ * The property to read the node type from. Used in selector querying.
897
+ */
898
+ nodeTypeKey: string;
899
+ /**
900
+ * The traversal path that tools should take when evaluating the AST
901
+ */
902
+ visitorKeys?: Record<string, string[]>;
903
+ /**
904
+ * Default language options. User-defined options are merged with this object.
905
+ */
906
+ defaultLanguageOptions?: LanguageOptions;
907
+ /**
908
+ * Validates languageOptions for this language.
909
+ */
910
+ validateLanguageOptions(languageOptions: Options["LangOptions"]): void;
911
+ /**
912
+ * Normalizes languageOptions for this language.
913
+ */
914
+ normalizeLanguageOptions?(languageOptions: Options["LangOptions"]): Options["LangOptions"];
915
+ /**
916
+ * Helper for esquery that allows languages to match nodes against
917
+ * class. esquery currently has classes like `function` that will
918
+ * match all the various function nodes. This method allows languages
919
+ * to implement similar shorthands.
920
+ */
921
+ matchesSelectorClass?(className: string, node: Options["Node"], ancestry: Options["Node"][]): boolean;
922
+ /**
923
+ * Parses the given file input into its component parts. This file should not
924
+ * throws errors for parsing errors but rather should return any parsing
925
+ * errors as parse of the ParseResult object.
926
+ */
927
+ parse(file: File, context: LanguageContext<Options["LangOptions"]>): ParseResult<Options["RootNode"]>;
928
+ /**
929
+ * Creates SourceCode object that ESLint uses to work with a file.
930
+ */
931
+ createSourceCode(file: File, input: OkParseResult<Options["RootNode"]>, context: LanguageContext<Options["LangOptions"]>): Options["Code"];
932
+ }
933
+ /**
934
+ * Plugin-defined options for the language.
935
+ */
936
+ export type LanguageOptions = Record<string, unknown>;
937
+ /**
938
+ * The context object that is passed to the language plugin methods.
939
+ */
940
+ export interface LanguageContext<LangOptions = LanguageOptions> {
941
+ languageOptions: LangOptions;
942
+ }
943
+ /**
944
+ * Represents a file read by ESLint.
945
+ */
946
+ export interface File {
947
+ /**
948
+ * The path that ESLint uses for this file. May be a virtual path
949
+ * if it was returned by a processor.
950
+ */
951
+ path: string;
952
+ /**
953
+ * The path to the file on disk. This always maps directly to a file
954
+ * regardless of whether it was returned from a processor.
955
+ */
956
+ physicalPath: string;
957
+ /**
958
+ * Indicates if the original source contained a byte-order marker.
959
+ * ESLint strips the BOM from the `body`, but this info is needed
960
+ * to correctly apply autofixing.
961
+ */
962
+ bom: boolean;
963
+ /**
964
+ * The body of the file to parse.
965
+ */
966
+ body: string | Uint8Array;
967
+ }
968
+ /**
969
+ * Represents the successful result of parsing a file.
970
+ */
971
+ export interface OkParseResult<RootNode = unknown> {
972
+ /**
973
+ * Indicates if the parse was successful. If true, the parse was successful
974
+ * and ESLint should continue on to create a SourceCode object and run rules;
975
+ * if false, ESLint should just report the error(s) without doing anything
976
+ * else.
977
+ */
978
+ ok: true;
979
+ /**
980
+ * The abstract syntax tree created by the parser. (only when ok: true)
981
+ */
982
+ ast: RootNode;
983
+ /**
984
+ * Any additional data that the parser wants to provide.
985
+ */
986
+ [key: string]: any;
987
+ }
988
+ /**
989
+ * Represents the unsuccessful result of parsing a file.
990
+ */
991
+ export interface NotOkParseResult {
992
+ /**
993
+ * Indicates if the parse was successful. If true, the parse was successful
994
+ * and ESLint should continue on to create a SourceCode object and run rules;
995
+ * if false, ESLint should just report the error(s) without doing anything
996
+ * else.
997
+ */
998
+ ok: false;
999
+ /**
1000
+ * Any parsing errors, whether fatal or not. (only when ok: false)
1001
+ */
1002
+ errors: FileError[];
1003
+ /**
1004
+ * Any additional data that the parser wants to provide.
1005
+ */
1006
+ [key: string]: any;
1007
+ }
1008
+ export type ParseResult<RootNode = unknown> = OkParseResult<RootNode> | NotOkParseResult;
1009
+ /**
1010
+ * Represents inline configuration found in the source code.
1011
+ */
1012
+ interface InlineConfigElement {
1013
+ /**
1014
+ * The location of the inline config element.
1015
+ */
1016
+ loc: SourceLocation;
1017
+ /**
1018
+ * The interpreted configuration from the inline config element.
1019
+ */
1020
+ config: {
1021
+ rules: RulesConfig;
1022
+ };
1023
+ }
1024
+ /**
1025
+ * Generic options for the `SourceCodeBase` type.
1026
+ */
1027
+ export interface SourceCodeBaseTypeOptions {
1028
+ LangOptions: LanguageOptions;
1029
+ RootNode: unknown;
1030
+ SyntaxElementWithLoc: unknown;
1031
+ ConfigNode: unknown;
1032
+ }
1033
+ /**
1034
+ * Represents the basic interface for a source code object.
1035
+ */
1036
+ interface SourceCodeBase<Options extends SourceCodeBaseTypeOptions = {
1037
+ LangOptions: LanguageOptions;
1038
+ RootNode: unknown;
1039
+ SyntaxElementWithLoc: unknown;
1040
+ ConfigNode: unknown;
1041
+ }> {
1042
+ /**
1043
+ * Root of the AST.
1044
+ */
1045
+ ast: Options["RootNode"];
1046
+ /**
1047
+ * The traversal path that tools should take when evaluating the AST.
1048
+ * When present, this overrides the `visitorKeys` on the language for
1049
+ * just this source code object.
1050
+ */
1051
+ visitorKeys?: Record<string, string[]>;
1052
+ /**
1053
+ * Retrieves the equivalent of `loc` for a given node or token.
1054
+ * @param syntaxElement The node or token to get the location for.
1055
+ * @returns The location of the node or token.
1056
+ */
1057
+ getLoc(syntaxElement: Options["SyntaxElementWithLoc"]): SourceLocation;
1058
+ /**
1059
+ * Retrieves the equivalent of `range` for a given node or token.
1060
+ * @param syntaxElement The node or token to get the range for.
1061
+ * @returns The range of the node or token.
1062
+ */
1063
+ getRange(syntaxElement: Options["SyntaxElementWithLoc"]): SourceRange;
1064
+ /**
1065
+ * Traversal of AST.
1066
+ */
1067
+ traverse(): Iterable<TraversalStep>;
1068
+ /**
1069
+ * Applies language options passed in from the ESLint core.
1070
+ */
1071
+ applyLanguageOptions?(languageOptions: Options["LangOptions"]): void;
1072
+ /**
1073
+ * Return all of the inline areas where ESLint should be disabled/enabled
1074
+ * along with any problems found in evaluating the directives.
1075
+ */
1076
+ getDisableDirectives?(): {
1077
+ directives: Directive[];
1078
+ problems: FileProblem[];
1079
+ };
1080
+ /**
1081
+ * Returns an array of all inline configuration nodes found in the
1082
+ * source code.
1083
+ */
1084
+ getInlineConfigNodes?(): Options["ConfigNode"][];
1085
+ /**
1086
+ * Applies configuration found inside of the source code. This method is only
1087
+ * called when ESLint is running with inline configuration allowed.
1088
+ */
1089
+ applyInlineConfig?(): {
1090
+ configs: InlineConfigElement[];
1091
+ problems: FileProblem[];
1092
+ };
1093
+ /**
1094
+ * Called by ESLint core to indicate that it has finished providing
1095
+ * information. We now add in all the missing variables and ensure that
1096
+ * state-changing methods cannot be called by rules.
1097
+ * @returns {void}
1098
+ */
1099
+ finalize?(): void;
1100
+ }
1101
+ /**
1102
+ * Represents the source of a text file being linted.
1103
+ */
1104
+ export interface TextSourceCode<Options extends SourceCodeBaseTypeOptions = {
1105
+ LangOptions: LanguageOptions;
1106
+ RootNode: unknown;
1107
+ SyntaxElementWithLoc: unknown;
1108
+ ConfigNode: unknown;
1109
+ }> extends SourceCodeBase<Options> {
1110
+ /**
1111
+ * The body of the file that you'd like rule developers to access.
1112
+ */
1113
+ text: string;
1114
+ }
1115
+ /**
1116
+ * Represents the source of a binary file being linted.
1117
+ */
1118
+ export interface BinarySourceCode<Options extends SourceCodeBaseTypeOptions = {
1119
+ LangOptions: LanguageOptions;
1120
+ RootNode: unknown;
1121
+ SyntaxElementWithLoc: unknown;
1122
+ ConfigNode: unknown;
1123
+ }> extends SourceCodeBase<Options> {
1124
+ /**
1125
+ * The body of the file that you'd like rule developers to access.
1126
+ */
1127
+ body: Uint8Array;
1128
+ }
1129
+ export type SourceCode<Options extends SourceCodeBaseTypeOptions = {
1130
+ LangOptions: LanguageOptions;
1131
+ RootNode: unknown;
1132
+ SyntaxElementWithLoc: unknown;
1133
+ ConfigNode: unknown;
1134
+ }> = TextSourceCode<Options> | BinarySourceCode<Options>;
1135
+ /**
1136
+ * Represents a traversal step visiting the AST.
1137
+ */
1138
+ export interface VisitTraversalStep {
1139
+ kind: 1;
1140
+ target: unknown;
1141
+ phase: 1 | 2;
1142
+ args: unknown[];
1143
+ }
1144
+ /**
1145
+ * Represents a traversal step calling a function.
1146
+ */
1147
+ export interface CallTraversalStep {
1148
+ kind: 2;
1149
+ target: string;
1150
+ phase?: string;
1151
+ args: unknown[];
1152
+ }
1153
+ export type TraversalStep = VisitTraversalStep | CallTraversalStep;
1154
+ /**
1155
+ * The type of disable directive. This determines how ESLint will disable rules.
1156
+ */
1157
+ export type DirectiveType = "disable" | "enable" | "disable-line" | "disable-next-line";
1158
+ /**
1159
+ * Represents a disable directive.
1160
+ */
1161
+ export interface Directive {
1162
+ /**
1163
+ * The type of directive.
1164
+ */
1165
+ type: DirectiveType;
1166
+ /**
1167
+ * The node of the directive. May be in the AST or a comment/token.
1168
+ */
1169
+ node: unknown;
1170
+ /**
1171
+ * The value of the directive.
1172
+ */
1173
+ value: string;
1174
+ /**
1175
+ * The justification for the directive.
1176
+ */
1177
+ justification?: string;
1178
+ }
1179
+ export {};
server/node_modules/@eslint/core/dist/esm/types.d.ts ADDED
@@ -0,0 +1,1179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @fileoverview Shared types for ESLint Core.
3
+ */
4
+ import type { JSONSchema4 } from "json-schema";
5
+ /**
6
+ * Represents an error inside of a file.
7
+ */
8
+ export interface FileError {
9
+ message: string;
10
+ line: number;
11
+ column: number;
12
+ endLine?: number;
13
+ endColumn?: number;
14
+ }
15
+ /**
16
+ * Represents a problem found in a file.
17
+ */
18
+ export interface FileProblem {
19
+ ruleId: string | null;
20
+ message: string;
21
+ loc: SourceLocation;
22
+ }
23
+ /**
24
+ * Represents the start and end coordinates of a node inside the source.
25
+ */
26
+ export interface SourceLocation {
27
+ start: Position;
28
+ end: Position;
29
+ }
30
+ /**
31
+ * Represents the start and end coordinates of a node inside the source with an offset.
32
+ */
33
+ export interface SourceLocationWithOffset {
34
+ start: PositionWithOffset;
35
+ end: PositionWithOffset;
36
+ }
37
+ /**
38
+ * Represents a location coordinate inside the source. ESLint-style formats
39
+ * have just `line` and `column` while others may have `offset` as well.
40
+ */
41
+ export interface Position {
42
+ line: number;
43
+ column: number;
44
+ }
45
+ /**
46
+ * Represents a location coordinate inside the source with an offset.
47
+ */
48
+ export interface PositionWithOffset extends Position {
49
+ offset: number;
50
+ }
51
+ /**
52
+ * Represents a range of characters in the source.
53
+ */
54
+ export type SourceRange = [number, number];
55
+ /**
56
+ * What the rule is responsible for finding:
57
+ * - `problem` means the rule has noticed a potential error.
58
+ * - `suggestion` means the rule suggests an alternate or better approach.
59
+ * - `layout` means the rule is looking at spacing, indentation, etc.
60
+ */
61
+ export type RuleType = "problem" | "suggestion" | "layout";
62
+ /**
63
+ * The type of fix the rule can provide:
64
+ * - `code` means the rule can fix syntax.
65
+ * - `whitespace` means the rule can fix spacing and indentation.
66
+ */
67
+ export type RuleFixType = "code" | "whitespace";
68
+ /**
69
+ * An object containing visitor information for a rule. Each method is either the
70
+ * name of a node type or a selector, or is a method that will be called at specific
71
+ * times during the traversal.
72
+ */
73
+ export type RuleVisitor = Record<string, ((...args: any[]) => void) | undefined>;
74
+ /**
75
+ * Rule meta information used for documentation.
76
+ */
77
+ export interface RulesMetaDocs {
78
+ /**
79
+ * A short description of the rule.
80
+ */
81
+ description?: string | undefined;
82
+ /**
83
+ * The URL to the documentation for the rule.
84
+ */
85
+ url?: string | undefined;
86
+ /**
87
+ * The category the rule falls under.
88
+ * @deprecated No longer used.
89
+ */
90
+ category?: string | undefined;
91
+ /**
92
+ * Indicates if the rule is generally recommended for all users.
93
+ *
94
+ * Note - this will always be a boolean for core rules, but may be used in any way by plugins.
95
+ */
96
+ recommended?: unknown;
97
+ /**
98
+ * Indicates if the rule is frozen (no longer accepting feature requests).
99
+ */
100
+ frozen?: boolean | undefined;
101
+ }
102
+ /**
103
+ * Meta information about a rule.
104
+ */
105
+ export interface RulesMeta<MessageIds extends string = string, RuleOptions = unknown[], ExtRuleDocs = unknown> {
106
+ /**
107
+ * Properties that are used when documenting the rule.
108
+ */
109
+ docs?: (RulesMetaDocs & ExtRuleDocs) | undefined;
110
+ /**
111
+ * The type of rule.
112
+ */
113
+ type?: RuleType | undefined;
114
+ /**
115
+ * The schema for the rule options. Required if the rule has options.
116
+ */
117
+ schema?: JSONSchema4 | JSONSchema4[] | false | undefined;
118
+ /**
119
+ * Any default options to be recursively merged on top of any user-provided options.
120
+ */
121
+ defaultOptions?: RuleOptions;
122
+ /**
123
+ * The messages that the rule can report.
124
+ */
125
+ messages?: Record<MessageIds, string>;
126
+ /**
127
+ * Indicates whether the rule has been deprecated or provides additional metadata about the deprecation. Omit if not deprecated.
128
+ */
129
+ deprecated?: boolean | DeprecatedInfo | undefined;
130
+ /**
131
+ * @deprecated Use deprecated.replacedBy instead.
132
+ * The name of the rule(s) this rule was replaced by, if it was deprecated.
133
+ */
134
+ replacedBy?: readonly string[] | undefined;
135
+ /**
136
+ * Indicates if the rule is fixable, and if so, what type of fix it provides.
137
+ */
138
+ fixable?: RuleFixType | undefined;
139
+ /**
140
+ * Indicates if the rule may provide suggestions.
141
+ */
142
+ hasSuggestions?: boolean | undefined;
143
+ /**
144
+ * The language the rule is intended to lint.
145
+ */
146
+ language?: string;
147
+ /**
148
+ * The dialects of `language` that the rule is intended to lint.
149
+ */
150
+ dialects?: string[];
151
+ }
152
+ /**
153
+ * Provides additional metadata about a deprecation.
154
+ */
155
+ export interface DeprecatedInfo {
156
+ /**
157
+ * General message presented to the user, e.g. for the key rule why the rule
158
+ * is deprecated or for info how to replace the rule.
159
+ */
160
+ message?: string;
161
+ /**
162
+ * URL to more information about this deprecation in general.
163
+ */
164
+ url?: string;
165
+ /**
166
+ * An empty array explicitly states that there is no replacement.
167
+ */
168
+ replacedBy?: ReplacedByInfo[];
169
+ /**
170
+ * The package version since when the rule is deprecated (should use full
171
+ * semver without a leading "v").
172
+ */
173
+ deprecatedSince?: string;
174
+ /**
175
+ * The estimated version when the rule is removed (probably the next major
176
+ * version). null means the rule is "frozen" (will be available but will not
177
+ * be changed).
178
+ */
179
+ availableUntil?: string | null;
180
+ }
181
+ /**
182
+ * Provides metadata about a replacement
183
+ */
184
+ export interface ReplacedByInfo {
185
+ /**
186
+ * General message presented to the user, e.g. how to replace the rule
187
+ */
188
+ message?: string;
189
+ /**
190
+ * URL to more information about this replacement in general
191
+ */
192
+ url?: string;
193
+ /**
194
+ * Name should be "eslint" if the replacement is an ESLint core rule. Omit
195
+ * the property if the replacement is in the same plugin.
196
+ */
197
+ plugin?: ExternalSpecifier;
198
+ /**
199
+ * Name and documentation of the replacement rule
200
+ */
201
+ rule?: ExternalSpecifier;
202
+ }
203
+ /**
204
+ * Specifies the name and url of an external resource. At least one property
205
+ * should be set.
206
+ */
207
+ export interface ExternalSpecifier {
208
+ /**
209
+ * Name of the referenced plugin / rule.
210
+ */
211
+ name?: string;
212
+ /**
213
+ * URL pointing to documentation for the plugin / rule.
214
+ */
215
+ url?: string;
216
+ }
217
+ /**
218
+ * Generic type for `RuleContext`.
219
+ */
220
+ export interface RuleContextTypeOptions {
221
+ LangOptions: LanguageOptions;
222
+ Code: SourceCode;
223
+ RuleOptions: unknown[];
224
+ Node: unknown;
225
+ MessageIds: string;
226
+ }
227
+ /**
228
+ * Represents the context object that is passed to a rule. This object contains
229
+ * information about the current state of the linting process and is the rule's
230
+ * view into the outside world.
231
+ */
232
+ export interface RuleContext<Options extends RuleContextTypeOptions = RuleContextTypeOptions> {
233
+ /**
234
+ * The current working directory for the session.
235
+ */
236
+ cwd: string;
237
+ /**
238
+ * Returns the current working directory for the session.
239
+ * @deprecated Use `cwd` instead.
240
+ */
241
+ getCwd(): string;
242
+ /**
243
+ * The filename of the file being linted.
244
+ */
245
+ filename: string;
246
+ /**
247
+ * Returns the filename of the file being linted.
248
+ * @deprecated Use `filename` instead.
249
+ */
250
+ getFilename(): string;
251
+ /**
252
+ * The physical filename of the file being linted.
253
+ */
254
+ physicalFilename: string;
255
+ /**
256
+ * Returns the physical filename of the file being linted.
257
+ * @deprecated Use `physicalFilename` instead.
258
+ */
259
+ getPhysicalFilename(): string;
260
+ /**
261
+ * The source code object that the rule is running on.
262
+ */
263
+ sourceCode: Options["Code"];
264
+ /**
265
+ * Returns the source code object that the rule is running on.
266
+ * @deprecated Use `sourceCode` instead.
267
+ */
268
+ getSourceCode(): Options["Code"];
269
+ /**
270
+ * Shared settings for the configuration.
271
+ */
272
+ settings: SettingsConfig;
273
+ /**
274
+ * Parser-specific options for the configuration.
275
+ * @deprecated Use `languageOptions.parserOptions` instead.
276
+ */
277
+ parserOptions: Record<string, unknown>;
278
+ /**
279
+ * The language options for the configuration.
280
+ */
281
+ languageOptions: Options["LangOptions"];
282
+ /**
283
+ * The CommonJS path to the parser used while parsing this file.
284
+ * @deprecated No longer used.
285
+ */
286
+ parserPath: string | undefined;
287
+ /**
288
+ * The rule ID.
289
+ */
290
+ id: string;
291
+ /**
292
+ * The rule's configured options.
293
+ */
294
+ options: Options["RuleOptions"];
295
+ /**
296
+ * The report function that the rule should use to report problems.
297
+ * @param violation The violation to report.
298
+ */
299
+ report(violation: ViolationReport<Options["Node"], Options["MessageIds"]>): void;
300
+ }
301
+ /**
302
+ * Manager of text edits for a rule fix.
303
+ */
304
+ export interface RuleTextEditor<EditableSyntaxElement = unknown> {
305
+ /**
306
+ * Inserts text after the specified node or token.
307
+ * @param syntaxElement The node or token to insert after.
308
+ * @param text The edit to insert after the node or token.
309
+ */
310
+ insertTextAfter(syntaxElement: EditableSyntaxElement, text: string): RuleTextEdit;
311
+ /**
312
+ * Inserts text after the specified range.
313
+ * @param range The range to insert after.
314
+ * @param text The edit to insert after the range.
315
+ */
316
+ insertTextAfterRange(range: SourceRange, text: string): RuleTextEdit;
317
+ /**
318
+ * Inserts text before the specified node or token.
319
+ * @param syntaxElement A syntax element with location information to insert before.
320
+ * @param text The edit to insert before the node or token.
321
+ */
322
+ insertTextBefore(syntaxElement: EditableSyntaxElement, text: string): RuleTextEdit;
323
+ /**
324
+ * Inserts text before the specified range.
325
+ * @param range The range to insert before.
326
+ * @param text The edit to insert before the range.
327
+ */
328
+ insertTextBeforeRange(range: SourceRange, text: string): RuleTextEdit;
329
+ /**
330
+ * Removes the specified node or token.
331
+ * @param syntaxElement A syntax element with location information to remove.
332
+ * @returns The edit to remove the node or token.
333
+ */
334
+ remove(syntaxElement: EditableSyntaxElement): RuleTextEdit;
335
+ /**
336
+ * Removes the specified range.
337
+ * @param range The range to remove.
338
+ * @returns The edit to remove the range.
339
+ */
340
+ removeRange(range: SourceRange): RuleTextEdit;
341
+ /**
342
+ * Replaces the specified node or token with the given text.
343
+ * @param syntaxElement A syntax element with location information to replace.
344
+ * @param text The text to replace the node or token with.
345
+ * @returns The edit to replace the node or token.
346
+ */
347
+ replaceText(syntaxElement: EditableSyntaxElement, text: string): RuleTextEdit;
348
+ /**
349
+ * Replaces the specified range with the given text.
350
+ * @param range The range to replace.
351
+ * @param text The text to replace the range with.
352
+ * @returns The edit to replace the range.
353
+ */
354
+ replaceTextRange(range: SourceRange, text: string): RuleTextEdit;
355
+ }
356
+ /**
357
+ * Represents a fix for a rule violation implemented as a text edit.
358
+ */
359
+ export interface RuleTextEdit {
360
+ /**
361
+ * The range to replace.
362
+ */
363
+ range: SourceRange;
364
+ /**
365
+ * The text to insert.
366
+ */
367
+ text: string;
368
+ }
369
+ /**
370
+ * Fixes a violation.
371
+ * @param fixer The text editor to apply the fix.
372
+ * @returns The fix(es) for the violation.
373
+ */
374
+ export type RuleFixer = (fixer: RuleTextEditor) => RuleTextEdit | Iterable<RuleTextEdit> | null;
375
+ export interface ViolationReportBase {
376
+ /**
377
+ * The data to insert into the message.
378
+ */
379
+ data?: Record<string, unknown> | undefined;
380
+ /**
381
+ * The fix to be applied for the violation.
382
+ */
383
+ fix?: RuleFixer | null | undefined;
384
+ /**
385
+ * An array of suggested fixes for the problem. These fixes may change the
386
+ * behavior of the code, so they are not applied automatically.
387
+ */
388
+ suggest?: SuggestedEdit[] | null | undefined;
389
+ }
390
+ export type ViolationMessage<MessageIds = string> = {
391
+ message: string;
392
+ } | {
393
+ messageId: MessageIds;
394
+ };
395
+ export type ViolationLocation<Node> = {
396
+ loc: SourceLocation | Position;
397
+ } | {
398
+ node: Node;
399
+ };
400
+ export type ViolationReport<Node = unknown, MessageIds = string> = ViolationReportBase & ViolationMessage<MessageIds> & ViolationLocation<Node>;
401
+ export interface SuggestedEditBase {
402
+ /**
403
+ * The data to insert into the message.
404
+ */
405
+ data?: Record<string, unknown> | undefined;
406
+ /**
407
+ * The fix to be applied for the suggestion.
408
+ */
409
+ fix: RuleFixer;
410
+ }
411
+ export type SuggestionMessage = {
412
+ desc: string;
413
+ } | {
414
+ messageId: string;
415
+ };
416
+ /**
417
+ * A suggested edit for a rule violation.
418
+ */
419
+ export type SuggestedEdit = SuggestedEditBase & SuggestionMessage;
420
+ /**
421
+ * The normalized version of a lint suggestion.
422
+ */
423
+ export interface LintSuggestion {
424
+ /** A short description. */
425
+ desc: string;
426
+ /** Fix result info. */
427
+ fix: RuleTextEdit;
428
+ /** Id referencing a message for the description. */
429
+ messageId?: string | undefined;
430
+ }
431
+ /**
432
+ * The normalized version of a lint violation message.
433
+ */
434
+ export interface LintMessage {
435
+ /** The 1-based column number. */
436
+ column: number;
437
+ /** The 1-based line number. */
438
+ line: number;
439
+ /** The 1-based column number of the end location. */
440
+ endColumn?: number | undefined;
441
+ /** The 1-based line number of the end location. */
442
+ endLine?: number | undefined;
443
+ /** The ID of the rule which makes this message. */
444
+ ruleId: string | null;
445
+ /** The reported message. */
446
+ message: string;
447
+ /** The ID of the message in the rule's meta. */
448
+ messageId?: string | undefined;
449
+ /**
450
+ * Type of node.
451
+ * @deprecated `nodeType` is deprecated and will be removed in the next major version.
452
+ */
453
+ nodeType?: string | undefined;
454
+ /** If `true` then this is a fatal error. */
455
+ fatal?: true | undefined;
456
+ /** The severity of this message. */
457
+ severity: Exclude<SeverityLevel, 0>;
458
+ /** Information for autofix. */
459
+ fix?: RuleTextEdit | undefined;
460
+ /** Information for suggestions. */
461
+ suggestions?: LintSuggestion[] | undefined;
462
+ }
463
+ /**
464
+ * Generic options for the `RuleDefinition` type.
465
+ */
466
+ export interface RuleDefinitionTypeOptions {
467
+ LangOptions: LanguageOptions;
468
+ Code: SourceCode;
469
+ RuleOptions: unknown[];
470
+ Visitor: RuleVisitor;
471
+ Node: unknown;
472
+ MessageIds: string;
473
+ ExtRuleDocs: unknown;
474
+ }
475
+ /**
476
+ * The definition of an ESLint rule.
477
+ */
478
+ export interface RuleDefinition<Options extends RuleDefinitionTypeOptions = RuleDefinitionTypeOptions> {
479
+ /**
480
+ * The meta information for the rule.
481
+ */
482
+ meta?: RulesMeta<Options["MessageIds"], Options["RuleOptions"], Options["ExtRuleDocs"]>;
483
+ /**
484
+ * Creates the visitor that ESLint uses to apply the rule during traversal.
485
+ * @param context The rule context.
486
+ * @returns The rule visitor.
487
+ */
488
+ create(context: RuleContext<{
489
+ LangOptions: Options["LangOptions"];
490
+ Code: Options["Code"];
491
+ RuleOptions: Options["RuleOptions"];
492
+ Node: Options["Node"];
493
+ MessageIds: Options["MessageIds"];
494
+ }>): Options["Visitor"];
495
+ }
496
+ /**
497
+ * Defaults for non-language-related `RuleDefinition` options.
498
+ */
499
+ export interface CustomRuleTypeDefinitions {
500
+ RuleOptions: unknown[];
501
+ MessageIds: string;
502
+ ExtRuleDocs: Record<string, unknown>;
503
+ }
504
+ /**
505
+ * A helper type to define language specific specializations of the `RuleDefinition` type.
506
+ *
507
+ * @example
508
+ * ```ts
509
+ * type YourRuleDefinition<
510
+ * Options extends Partial<CustomRuleTypeDefinitions> = {},
511
+ * > = CustomRuleDefinitionType<
512
+ * {
513
+ * LangOptions: YourLanguageOptions;
514
+ * Code: YourSourceCode;
515
+ * Visitor: YourRuleVisitor;
516
+ * Node: YourNode;
517
+ * },
518
+ * Options
519
+ * >;
520
+ * ```
521
+ */
522
+ export type CustomRuleDefinitionType<LanguageSpecificOptions extends Omit<RuleDefinitionTypeOptions, keyof CustomRuleTypeDefinitions>, Options extends Partial<CustomRuleTypeDefinitions>> = RuleDefinition<LanguageSpecificOptions & Required<Options & Omit<CustomRuleTypeDefinitions, keyof Options>>>;
523
+ /**
524
+ * The human readable severity level used in a configuration.
525
+ */
526
+ export type SeverityName = "off" | "warn" | "error";
527
+ /**
528
+ * The numeric severity level for a rule.
529
+ *
530
+ * - `0` means off.
531
+ * - `1` means warn.
532
+ * - `2` means error.
533
+ */
534
+ export type SeverityLevel = 0 | 1 | 2;
535
+ /**
536
+ * The severity of a rule in a configuration.
537
+ */
538
+ export type Severity = SeverityName | SeverityLevel;
539
+ /**
540
+ * Represents the metadata for an object, such as a plugin or processor.
541
+ */
542
+ export interface ObjectMetaProperties {
543
+ /** @deprecated Use `meta.name` instead. */
544
+ name?: string | undefined;
545
+ /** @deprecated Use `meta.version` instead. */
546
+ version?: string | undefined;
547
+ meta?: {
548
+ name?: string | undefined;
549
+ version?: string | undefined;
550
+ };
551
+ }
552
+ /**
553
+ * Represents the configuration options for the core linter.
554
+ */
555
+ export interface LinterOptionsConfig {
556
+ /**
557
+ * Indicates whether or not inline configuration is evaluated.
558
+ */
559
+ noInlineConfig?: boolean;
560
+ /**
561
+ * Indicates what to do when an unused disable directive is found.
562
+ */
563
+ reportUnusedDisableDirectives?: boolean | Severity;
564
+ /**
565
+ * A severity value indicating if and how unused inline configs should be
566
+ * tracked and reported.
567
+ */
568
+ reportUnusedInlineConfigs?: Severity;
569
+ }
570
+ /**
571
+ * The configuration for a rule.
572
+ */
573
+ export type RuleConfig<RuleOptions extends unknown[] = unknown[]> = Severity | [Severity, ...Partial<RuleOptions>];
574
+ /**
575
+ * A collection of rules and their configurations.
576
+ */
577
+ export interface RulesConfig {
578
+ [key: string]: RuleConfig;
579
+ }
580
+ /**
581
+ * A collection of settings.
582
+ */
583
+ export interface SettingsConfig {
584
+ [key: string]: unknown;
585
+ }
586
+ /**
587
+ * The configuration for a set of files.
588
+ */
589
+ export interface ConfigObject<Rules extends RulesConfig = RulesConfig> {
590
+ /**
591
+ * A string to identify the configuration object. Used in error messages and
592
+ * inspection tools.
593
+ */
594
+ name?: string;
595
+ /**
596
+ * Path to the directory where the configuration object should apply.
597
+ * `files` and `ignores` patterns in the configuration object are
598
+ * interpreted as relative to this path.
599
+ */
600
+ basePath?: string;
601
+ /**
602
+ * An array of glob patterns indicating the files that the configuration
603
+ * object should apply to. If not specified, the configuration object applies
604
+ * to all files
605
+ */
606
+ files?: (string | string[])[];
607
+ /**
608
+ * An array of glob patterns indicating the files that the configuration
609
+ * object should not apply to. If not specified, the configuration object
610
+ * applies to all files matched by files
611
+ */
612
+ ignores?: string[];
613
+ /**
614
+ * The name of the language used for linting. This is used to determine the
615
+ * parser and other language-specific settings.
616
+ * @since 9.7.0
617
+ */
618
+ language?: string;
619
+ /**
620
+ * An object containing settings related to how the language is configured for
621
+ * linting.
622
+ */
623
+ languageOptions?: LanguageOptions;
624
+ /**
625
+ * An object containing settings related to the linting process
626
+ */
627
+ linterOptions?: LinterOptionsConfig;
628
+ /**
629
+ * Either an object containing preprocess() and postprocess() methods or a
630
+ * string indicating the name of a processor inside of a plugin
631
+ * (i.e., "pluginName/processorName").
632
+ */
633
+ processor?: string | Processor;
634
+ /**
635
+ * An object containing a name-value mapping of plugin names to plugin objects.
636
+ * When files is specified, these plugins are only available to the matching files.
637
+ */
638
+ plugins?: Record<string, Plugin>;
639
+ /**
640
+ * An object containing the configured rules. When files or ignores are specified,
641
+ * these rule configurations are only available to the matching files.
642
+ */
643
+ rules?: Partial<Rules>;
644
+ /**
645
+ * An object containing name-value pairs of information that should be
646
+ * available to all rules.
647
+ */
648
+ settings?: Record<string, unknown>;
649
+ }
650
+ /** @deprecated Only supported in legacy eslintrc config format. */
651
+ export type GlobalAccess = boolean | "off" | "readable" | "readonly" | "writable" | "writeable";
652
+ /** @deprecated Only supported in legacy eslintrc config format. */
653
+ export interface GlobalsConfig {
654
+ [name: string]: GlobalAccess;
655
+ }
656
+ /**
657
+ * The ECMAScript version of the code being linted.
658
+ * @deprecated Only supported in legacy eslintrc config format.
659
+ */
660
+ export type EcmaVersion = 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023 | 2024 | 2025 | 2026 | "latest";
661
+ /**
662
+ * The type of JavaScript source code.
663
+ * @deprecated Only supported in legacy eslintrc config format.
664
+ */
665
+ export type JavaScriptSourceType = "script" | "module" | "commonjs";
666
+ /**
667
+ * Parser options.
668
+ * @deprecated Only supported in legacy eslintrc config format.
669
+ * @see [Specifying Parser Options](https://eslint.org/docs/latest/use/configure/language-options#specifying-parser-options)
670
+ */
671
+ export interface JavaScriptParserOptionsConfig {
672
+ /**
673
+ * Allow the use of reserved words as identifiers (if `ecmaVersion` is 3).
674
+ *
675
+ * @default false
676
+ */
677
+ allowReserved?: boolean | undefined;
678
+ /**
679
+ * Accepts any valid ECMAScript version number or `'latest'`:
680
+ *
681
+ * - A version: es3, es5, es6, es7, es8, es9, es10, es11, es12, es13, es14, ..., or
682
+ * - A year: es2015, es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, ..., or
683
+ * - `'latest'`
684
+ *
685
+ * When it's a version or a year, the value must be a number - so do not include the `es` prefix.
686
+ *
687
+ * Specifies the version of ECMAScript syntax you want to use. This is used by the parser to determine how to perform scope analysis, and it affects the default
688
+ *
689
+ * @default 5
690
+ */
691
+ ecmaVersion?: EcmaVersion | undefined;
692
+ /**
693
+ * The type of JavaScript source code. Possible values are "script" for
694
+ * traditional script files, "module" for ECMAScript modules (ESM), and
695
+ * "commonjs" for CommonJS files.
696
+ *
697
+ * @default 'script'
698
+ *
699
+ * @see https://eslint.org/docs/latest/use/configure/language-options-deprecated#specifying-parser-options
700
+ */
701
+ sourceType?: JavaScriptSourceType | undefined;
702
+ /**
703
+ * An object indicating which additional language features you'd like to use.
704
+ *
705
+ * @see https://eslint.org/docs/latest/use/configure/language-options-deprecated#specifying-parser-options
706
+ */
707
+ ecmaFeatures?: {
708
+ globalReturn?: boolean | undefined;
709
+ impliedStrict?: boolean | undefined;
710
+ jsx?: boolean | undefined;
711
+ experimentalObjectRestSpread?: boolean | undefined;
712
+ [key: string]: any;
713
+ } | undefined;
714
+ [key: string]: any;
715
+ }
716
+ /** @deprecated Only supported in legacy eslintrc config format. */
717
+ export interface EnvironmentConfig {
718
+ /** The definition of global variables. */
719
+ globals?: GlobalsConfig | undefined;
720
+ /** The parser options that will be enabled under this environment. */
721
+ parserOptions?: JavaScriptParserOptionsConfig | undefined;
722
+ }
723
+ /**
724
+ * A configuration object that may have a `rules` block.
725
+ */
726
+ export interface HasRules<Rules extends RulesConfig = RulesConfig> {
727
+ rules?: Partial<Rules> | undefined;
728
+ }
729
+ /**
730
+ * ESLint legacy configuration.
731
+ *
732
+ * @see [ESLint Legacy Configuration](https://eslint.org/docs/latest/use/configure/)
733
+ */
734
+ export interface BaseConfig<Rules extends RulesConfig = RulesConfig, OverrideRules extends RulesConfig = Rules> extends HasRules<Rules> {
735
+ $schema?: string | undefined;
736
+ /**
737
+ * An environment provides predefined global variables.
738
+ *
739
+ * @see [Environments](https://eslint.org/docs/latest/use/configure/language-options-deprecated#specifying-environments)
740
+ */
741
+ env?: {
742
+ [name: string]: boolean;
743
+ } | undefined;
744
+ /**
745
+ * Extending configuration files.
746
+ *
747
+ * @see [Extends](https://eslint.org/docs/latest/use/configure/configuration-files-deprecated#extending-configuration-files)
748
+ */
749
+ extends?: string | string[] | undefined;
750
+ /**
751
+ * Specifying globals.
752
+ *
753
+ * @see [Globals](https://eslint.org/docs/latest/use/configure/language-options-deprecated#specifying-globals)
754
+ */
755
+ globals?: GlobalsConfig | undefined;
756
+ /**
757
+ * Disable processing of inline comments.
758
+ *
759
+ * @see [Disabling Inline Comments](https://eslint.org/docs/latest/use/configure/rules-deprecated#disabling-inline-comments)
760
+ */
761
+ noInlineConfig?: boolean | undefined;
762
+ /**
763
+ * Overrides can be used to use a differing configuration for matching sub-directories and files.
764
+ *
765
+ * @see [How do overrides work](https://eslint.org/docs/latest/use/configure/configuration-files-deprecated#how-do-overrides-work)
766
+ */
767
+ overrides?: ConfigOverride<OverrideRules>[] | undefined;
768
+ /**
769
+ * Parser.
770
+ *
771
+ * @see [Working with Custom Parsers](https://eslint.org/docs/latest/extend/custom-parsers)
772
+ * @see [Specifying Parser](https://eslint.org/docs/latest/use/configure/parser-deprecated)
773
+ */
774
+ parser?: string | undefined;
775
+ /**
776
+ * Parser options.
777
+ *
778
+ * @see [Working with Custom Parsers](https://eslint.org/docs/latest/extend/custom-parsers)
779
+ * @see [Specifying Parser Options](https://eslint.org/docs/latest/use/configure/language-options-deprecated#specifying-parser-options)
780
+ */
781
+ parserOptions?: JavaScriptParserOptionsConfig | undefined;
782
+ /**
783
+ * Which third-party plugins define additional rules, environments, configs, etc. for ESLint to use.
784
+ *
785
+ * @see [Configuring Plugins](https://eslint.org/docs/latest/use/configure/plugins-deprecated#configure-plugins)
786
+ */
787
+ plugins?: string[] | undefined;
788
+ /**
789
+ * Specifying processor.
790
+ *
791
+ * @see [processor](https://eslint.org/docs/latest/use/configure/plugins-deprecated#specify-a-processor)
792
+ */
793
+ processor?: string | undefined;
794
+ /**
795
+ * Report unused eslint-disable comments as warning.
796
+ *
797
+ * @see [Report unused eslint-disable comments](https://eslint.org/docs/latest/use/configure/rules-deprecated#report-unused-eslint-disable-comments)
798
+ */
799
+ reportUnusedDisableDirectives?: boolean | undefined;
800
+ /**
801
+ * Settings.
802
+ *
803
+ * @see [Settings](https://eslint.org/docs/latest/use/configure/configuration-files-deprecated#adding-shared-settings)
804
+ */
805
+ settings?: SettingsConfig | undefined;
806
+ }
807
+ /**
808
+ * The overwrites that apply more differing configuration to specific files or directories.
809
+ */
810
+ export interface ConfigOverride<Rules extends RulesConfig = RulesConfig> extends BaseConfig<Rules> {
811
+ /**
812
+ * The glob patterns for excluded files.
813
+ */
814
+ excludedFiles?: string | string[] | undefined;
815
+ /**
816
+ * The glob patterns for target files.
817
+ */
818
+ files: string | string[];
819
+ }
820
+ /**
821
+ * ESLint legacy configuration.
822
+ *
823
+ * @see [ESLint Legacy Configuration](https://eslint.org/docs/latest/use/configure/)
824
+ */
825
+ export interface LegacyConfigObject<Rules extends RulesConfig = RulesConfig, OverrideRules extends RulesConfig = Rules> extends BaseConfig<Rules, OverrideRules> {
826
+ /**
827
+ * Tell ESLint to ignore specific files and directories.
828
+ *
829
+ * @see [Ignore Patterns](https://eslint.org/docs/latest/use/configure/ignore-deprecated#ignorepatterns-in-config-files)
830
+ */
831
+ ignorePatterns?: string | string[] | undefined;
832
+ /**
833
+ * @see [Using Configuration Files](https://eslint.org/docs/latest/use/configure/configuration-files-deprecated#using-configuration-files)
834
+ */
835
+ root?: boolean | undefined;
836
+ }
837
+ /**
838
+ * File information passed to a processor.
839
+ */
840
+ export interface ProcessorFile {
841
+ text: string;
842
+ filename: string;
843
+ }
844
+ /**
845
+ * A processor is an object that can preprocess and postprocess files.
846
+ */
847
+ export interface Processor<T extends string | ProcessorFile = string | ProcessorFile> extends ObjectMetaProperties {
848
+ /** If `true` then it means the processor supports autofix. */
849
+ supportsAutofix?: boolean | undefined;
850
+ /** The function to extract code blocks. */
851
+ preprocess?(text: string, filename: string): T[];
852
+ /** The function to merge messages. */
853
+ postprocess?(messages: LintMessage[][], filename: string): LintMessage[];
854
+ }
855
+ export interface Plugin extends ObjectMetaProperties {
856
+ meta?: ObjectMetaProperties["meta"] & {
857
+ namespace?: string | undefined;
858
+ };
859
+ configs?: Record<string, LegacyConfigObject | ConfigObject | ConfigObject[]> | undefined;
860
+ environments?: Record<string, EnvironmentConfig> | undefined;
861
+ languages?: Record<string, Language> | undefined;
862
+ processors?: Record<string, Processor> | undefined;
863
+ rules?: Record<string, RuleDefinition> | undefined;
864
+ }
865
+ /**
866
+ * Generic options for the `Language` type.
867
+ */
868
+ export interface LanguageTypeOptions {
869
+ LangOptions: LanguageOptions;
870
+ Code: SourceCode;
871
+ RootNode: unknown;
872
+ Node: unknown;
873
+ }
874
+ /**
875
+ * Represents a plugin language.
876
+ */
877
+ export interface Language<Options extends LanguageTypeOptions = {
878
+ LangOptions: LanguageOptions;
879
+ Code: SourceCode;
880
+ RootNode: unknown;
881
+ Node: unknown;
882
+ }> {
883
+ /**
884
+ * Indicates how ESLint should read the file.
885
+ */
886
+ fileType: "text";
887
+ /**
888
+ * First line number returned from the parser (text mode only).
889
+ */
890
+ lineStart: 0 | 1;
891
+ /**
892
+ * First column number returned from the parser (text mode only).
893
+ */
894
+ columnStart: 0 | 1;
895
+ /**
896
+ * The property to read the node type from. Used in selector querying.
897
+ */
898
+ nodeTypeKey: string;
899
+ /**
900
+ * The traversal path that tools should take when evaluating the AST
901
+ */
902
+ visitorKeys?: Record<string, string[]>;
903
+ /**
904
+ * Default language options. User-defined options are merged with this object.
905
+ */
906
+ defaultLanguageOptions?: LanguageOptions;
907
+ /**
908
+ * Validates languageOptions for this language.
909
+ */
910
+ validateLanguageOptions(languageOptions: Options["LangOptions"]): void;
911
+ /**
912
+ * Normalizes languageOptions for this language.
913
+ */
914
+ normalizeLanguageOptions?(languageOptions: Options["LangOptions"]): Options["LangOptions"];
915
+ /**
916
+ * Helper for esquery that allows languages to match nodes against
917
+ * class. esquery currently has classes like `function` that will
918
+ * match all the various function nodes. This method allows languages
919
+ * to implement similar shorthands.
920
+ */
921
+ matchesSelectorClass?(className: string, node: Options["Node"], ancestry: Options["Node"][]): boolean;
922
+ /**
923
+ * Parses the given file input into its component parts. This file should not
924
+ * throws errors for parsing errors but rather should return any parsing
925
+ * errors as parse of the ParseResult object.
926
+ */
927
+ parse(file: File, context: LanguageContext<Options["LangOptions"]>): ParseResult<Options["RootNode"]>;
928
+ /**
929
+ * Creates SourceCode object that ESLint uses to work with a file.
930
+ */
931
+ createSourceCode(file: File, input: OkParseResult<Options["RootNode"]>, context: LanguageContext<Options["LangOptions"]>): Options["Code"];
932
+ }
933
+ /**
934
+ * Plugin-defined options for the language.
935
+ */
936
+ export type LanguageOptions = Record<string, unknown>;
937
+ /**
938
+ * The context object that is passed to the language plugin methods.
939
+ */
940
+ export interface LanguageContext<LangOptions = LanguageOptions> {
941
+ languageOptions: LangOptions;
942
+ }
943
+ /**
944
+ * Represents a file read by ESLint.
945
+ */
946
+ export interface File {
947
+ /**
948
+ * The path that ESLint uses for this file. May be a virtual path
949
+ * if it was returned by a processor.
950
+ */
951
+ path: string;
952
+ /**
953
+ * The path to the file on disk. This always maps directly to a file
954
+ * regardless of whether it was returned from a processor.
955
+ */
956
+ physicalPath: string;
957
+ /**
958
+ * Indicates if the original source contained a byte-order marker.
959
+ * ESLint strips the BOM from the `body`, but this info is needed
960
+ * to correctly apply autofixing.
961
+ */
962
+ bom: boolean;
963
+ /**
964
+ * The body of the file to parse.
965
+ */
966
+ body: string | Uint8Array;
967
+ }
968
+ /**
969
+ * Represents the successful result of parsing a file.
970
+ */
971
+ export interface OkParseResult<RootNode = unknown> {
972
+ /**
973
+ * Indicates if the parse was successful. If true, the parse was successful
974
+ * and ESLint should continue on to create a SourceCode object and run rules;
975
+ * if false, ESLint should just report the error(s) without doing anything
976
+ * else.
977
+ */
978
+ ok: true;
979
+ /**
980
+ * The abstract syntax tree created by the parser. (only when ok: true)
981
+ */
982
+ ast: RootNode;
983
+ /**
984
+ * Any additional data that the parser wants to provide.
985
+ */
986
+ [key: string]: any;
987
+ }
988
+ /**
989
+ * Represents the unsuccessful result of parsing a file.
990
+ */
991
+ export interface NotOkParseResult {
992
+ /**
993
+ * Indicates if the parse was successful. If true, the parse was successful
994
+ * and ESLint should continue on to create a SourceCode object and run rules;
995
+ * if false, ESLint should just report the error(s) without doing anything
996
+ * else.
997
+ */
998
+ ok: false;
999
+ /**
1000
+ * Any parsing errors, whether fatal or not. (only when ok: false)
1001
+ */
1002
+ errors: FileError[];
1003
+ /**
1004
+ * Any additional data that the parser wants to provide.
1005
+ */
1006
+ [key: string]: any;
1007
+ }
1008
+ export type ParseResult<RootNode = unknown> = OkParseResult<RootNode> | NotOkParseResult;
1009
+ /**
1010
+ * Represents inline configuration found in the source code.
1011
+ */
1012
+ interface InlineConfigElement {
1013
+ /**
1014
+ * The location of the inline config element.
1015
+ */
1016
+ loc: SourceLocation;
1017
+ /**
1018
+ * The interpreted configuration from the inline config element.
1019
+ */
1020
+ config: {
1021
+ rules: RulesConfig;
1022
+ };
1023
+ }
1024
+ /**
1025
+ * Generic options for the `SourceCodeBase` type.
1026
+ */
1027
+ export interface SourceCodeBaseTypeOptions {
1028
+ LangOptions: LanguageOptions;
1029
+ RootNode: unknown;
1030
+ SyntaxElementWithLoc: unknown;
1031
+ ConfigNode: unknown;
1032
+ }
1033
+ /**
1034
+ * Represents the basic interface for a source code object.
1035
+ */
1036
+ interface SourceCodeBase<Options extends SourceCodeBaseTypeOptions = {
1037
+ LangOptions: LanguageOptions;
1038
+ RootNode: unknown;
1039
+ SyntaxElementWithLoc: unknown;
1040
+ ConfigNode: unknown;
1041
+ }> {
1042
+ /**
1043
+ * Root of the AST.
1044
+ */
1045
+ ast: Options["RootNode"];
1046
+ /**
1047
+ * The traversal path that tools should take when evaluating the AST.
1048
+ * When present, this overrides the `visitorKeys` on the language for
1049
+ * just this source code object.
1050
+ */
1051
+ visitorKeys?: Record<string, string[]>;
1052
+ /**
1053
+ * Retrieves the equivalent of `loc` for a given node or token.
1054
+ * @param syntaxElement The node or token to get the location for.
1055
+ * @returns The location of the node or token.
1056
+ */
1057
+ getLoc(syntaxElement: Options["SyntaxElementWithLoc"]): SourceLocation;
1058
+ /**
1059
+ * Retrieves the equivalent of `range` for a given node or token.
1060
+ * @param syntaxElement The node or token to get the range for.
1061
+ * @returns The range of the node or token.
1062
+ */
1063
+ getRange(syntaxElement: Options["SyntaxElementWithLoc"]): SourceRange;
1064
+ /**
1065
+ * Traversal of AST.
1066
+ */
1067
+ traverse(): Iterable<TraversalStep>;
1068
+ /**
1069
+ * Applies language options passed in from the ESLint core.
1070
+ */
1071
+ applyLanguageOptions?(languageOptions: Options["LangOptions"]): void;
1072
+ /**
1073
+ * Return all of the inline areas where ESLint should be disabled/enabled
1074
+ * along with any problems found in evaluating the directives.
1075
+ */
1076
+ getDisableDirectives?(): {
1077
+ directives: Directive[];
1078
+ problems: FileProblem[];
1079
+ };
1080
+ /**
1081
+ * Returns an array of all inline configuration nodes found in the
1082
+ * source code.
1083
+ */
1084
+ getInlineConfigNodes?(): Options["ConfigNode"][];
1085
+ /**
1086
+ * Applies configuration found inside of the source code. This method is only
1087
+ * called when ESLint is running with inline configuration allowed.
1088
+ */
1089
+ applyInlineConfig?(): {
1090
+ configs: InlineConfigElement[];
1091
+ problems: FileProblem[];
1092
+ };
1093
+ /**
1094
+ * Called by ESLint core to indicate that it has finished providing
1095
+ * information. We now add in all the missing variables and ensure that
1096
+ * state-changing methods cannot be called by rules.
1097
+ * @returns {void}
1098
+ */
1099
+ finalize?(): void;
1100
+ }
1101
+ /**
1102
+ * Represents the source of a text file being linted.
1103
+ */
1104
+ export interface TextSourceCode<Options extends SourceCodeBaseTypeOptions = {
1105
+ LangOptions: LanguageOptions;
1106
+ RootNode: unknown;
1107
+ SyntaxElementWithLoc: unknown;
1108
+ ConfigNode: unknown;
1109
+ }> extends SourceCodeBase<Options> {
1110
+ /**
1111
+ * The body of the file that you'd like rule developers to access.
1112
+ */
1113
+ text: string;
1114
+ }
1115
+ /**
1116
+ * Represents the source of a binary file being linted.
1117
+ */
1118
+ export interface BinarySourceCode<Options extends SourceCodeBaseTypeOptions = {
1119
+ LangOptions: LanguageOptions;
1120
+ RootNode: unknown;
1121
+ SyntaxElementWithLoc: unknown;
1122
+ ConfigNode: unknown;
1123
+ }> extends SourceCodeBase<Options> {
1124
+ /**
1125
+ * The body of the file that you'd like rule developers to access.
1126
+ */
1127
+ body: Uint8Array;
1128
+ }
1129
+ export type SourceCode<Options extends SourceCodeBaseTypeOptions = {
1130
+ LangOptions: LanguageOptions;
1131
+ RootNode: unknown;
1132
+ SyntaxElementWithLoc: unknown;
1133
+ ConfigNode: unknown;
1134
+ }> = TextSourceCode<Options> | BinarySourceCode<Options>;
1135
+ /**
1136
+ * Represents a traversal step visiting the AST.
1137
+ */
1138
+ export interface VisitTraversalStep {
1139
+ kind: 1;
1140
+ target: unknown;
1141
+ phase: 1 | 2;
1142
+ args: unknown[];
1143
+ }
1144
+ /**
1145
+ * Represents a traversal step calling a function.
1146
+ */
1147
+ export interface CallTraversalStep {
1148
+ kind: 2;
1149
+ target: string;
1150
+ phase?: string;
1151
+ args: unknown[];
1152
+ }
1153
+ export type TraversalStep = VisitTraversalStep | CallTraversalStep;
1154
+ /**
1155
+ * The type of disable directive. This determines how ESLint will disable rules.
1156
+ */
1157
+ export type DirectiveType = "disable" | "enable" | "disable-line" | "disable-next-line";
1158
+ /**
1159
+ * Represents a disable directive.
1160
+ */
1161
+ export interface Directive {
1162
+ /**
1163
+ * The type of directive.
1164
+ */
1165
+ type: DirectiveType;
1166
+ /**
1167
+ * The node of the directive. May be in the AST or a comment/token.
1168
+ */
1169
+ node: unknown;
1170
+ /**
1171
+ * The value of the directive.
1172
+ */
1173
+ value: string;
1174
+ /**
1175
+ * The justification for the directive.
1176
+ */
1177
+ justification?: string;
1178
+ }
1179
+ export {};
server/node_modules/@eslint/core/package.json ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@eslint/core",
3
+ "version": "0.17.0",
4
+ "description": "Runtime-agnostic core of ESLint",
5
+ "type": "module",
6
+ "types": "./dist/esm/types.d.ts",
7
+ "exports": {
8
+ "types": {
9
+ "import": "./dist/esm/types.d.ts",
10
+ "require": "./dist/cjs/types.d.cts"
11
+ }
12
+ },
13
+ "files": [
14
+ "dist"
15
+ ],
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
19
+ "scripts": {
20
+ "build:cts": "node -e \"fs.cpSync('dist/esm/types.d.ts', 'dist/cjs/types.d.cts')\"",
21
+ "build": "tsc && npm run build:cts",
22
+ "test:jsr": "npx jsr@latest publish --dry-run",
23
+ "test:types": "tsc -p tests/types/tsconfig.json"
24
+ },
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "git+https://github.com/eslint/rewrite.git",
28
+ "directory": "packages/core"
29
+ },
30
+ "keywords": [
31
+ "eslint",
32
+ "core"
33
+ ],
34
+ "author": "Nicholas C. Zakas",
35
+ "license": "Apache-2.0",
36
+ "bugs": {
37
+ "url": "https://github.com/eslint/rewrite/issues"
38
+ },
39
+ "homepage": "https://github.com/eslint/rewrite/tree/main/packages/core#readme",
40
+ "dependencies": {
41
+ "@types/json-schema": "^7.0.15"
42
+ },
43
+ "devDependencies": {
44
+ "json-schema": "^0.4.0"
45
+ },
46
+ "engines": {
47
+ "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
48
+ }
49
+ }
server/node_modules/@eslint/object-schema/LICENSE ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
server/node_modules/@eslint/object-schema/README.md ADDED
@@ -0,0 +1,242 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ObjectSchema Package
2
+
3
+ ## Overview
4
+
5
+ A JavaScript object merge/validation utility where you can define a different merge and validation strategy for each key. This is helpful when you need to validate complex data structures and then merge them in a way that is more complex than `Object.assign()`. This is used in the [`@eslint/config-array`](https://npmjs.com/package/@eslint/config-array) package but can also be used on its own.
6
+
7
+ ## Installation
8
+
9
+ For Node.js and compatible runtimes:
10
+
11
+ ```shell
12
+ npm install @eslint/object-schema
13
+ # or
14
+ yarn add @eslint/object-schema
15
+ # or
16
+ pnpm install @eslint/object-schema
17
+ # or
18
+ bun add @eslint/object-schema
19
+ ```
20
+
21
+ For Deno:
22
+
23
+ ```shell
24
+ deno add @eslint/object-schema
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ Import the `ObjectSchema` constructor:
30
+
31
+ ```js
32
+ // using ESM
33
+ import { ObjectSchema } from "@eslint/object-schema";
34
+
35
+ // using CommonJS
36
+ const { ObjectSchema } = require("@eslint/object-schema");
37
+
38
+ const schema = new ObjectSchema({
39
+ // define a definition for the "downloads" key
40
+ downloads: {
41
+ required: true,
42
+ merge(value1, value2) {
43
+ return value1 + value2;
44
+ },
45
+ validate(value) {
46
+ if (typeof value !== "number") {
47
+ throw new Error("Expected downloads to be a number.");
48
+ }
49
+ },
50
+ },
51
+
52
+ // define a strategy for the "versions" key
53
+ version: {
54
+ required: true,
55
+ merge(value1, value2) {
56
+ return value1.concat(value2);
57
+ },
58
+ validate(value) {
59
+ if (!Array.isArray(value)) {
60
+ throw new Error("Expected versions to be an array.");
61
+ }
62
+ },
63
+ },
64
+ });
65
+
66
+ const record1 = {
67
+ downloads: 25,
68
+ versions: ["v1.0.0", "v1.1.0", "v1.2.0"],
69
+ };
70
+
71
+ const record2 = {
72
+ downloads: 125,
73
+ versions: ["v2.0.0", "v2.1.0", "v3.0.0"],
74
+ };
75
+
76
+ // make sure the records are valid
77
+ schema.validate(record1);
78
+ schema.validate(record2);
79
+
80
+ // merge together (schema.merge() accepts any number of objects)
81
+ const result = schema.merge(record1, record2);
82
+
83
+ // result looks like this:
84
+
85
+ const result = {
86
+ downloads: 75,
87
+ versions: ["v1.0.0", "v1.1.0", "v1.2.0", "v2.0.0", "v2.1.0", "v3.0.0"],
88
+ };
89
+ ```
90
+
91
+ ## Tips and Tricks
92
+
93
+ ### Named merge strategies
94
+
95
+ Instead of specifying a `merge()` method, you can specify one of the following strings to use a default merge strategy:
96
+
97
+ - `"assign"` - use `Object.assign()` to merge the two values into one object.
98
+ - `"overwrite"` - the second value always replaces the first.
99
+ - `"replace"` - the second value replaces the first if the second is not `undefined`.
100
+
101
+ For example:
102
+
103
+ ```js
104
+ const schema = new ObjectSchema({
105
+ name: {
106
+ merge: "replace",
107
+ validate() {},
108
+ },
109
+ });
110
+ ```
111
+
112
+ ### Named validation strategies
113
+
114
+ Instead of specifying a `validate()` method, you can specify one of the following strings to use a default validation strategy:
115
+
116
+ - `"array"` - value must be an array.
117
+ - `"boolean"` - value must be a boolean.
118
+ - `"number"` - value must be a number.
119
+ - `"object"` - value must be an object.
120
+ - `"object?"` - value must be an object or null.
121
+ - `"string"` - value must be a string.
122
+ - `"string!"` - value must be a non-empty string.
123
+
124
+ For example:
125
+
126
+ ```js
127
+ const schema = new ObjectSchema({
128
+ name: {
129
+ merge: "replace",
130
+ validate: "string",
131
+ },
132
+ });
133
+ ```
134
+
135
+ ### Subschemas
136
+
137
+ If you are defining a key that is, itself, an object, you can simplify the process by using a subschema. Instead of defining `merge()` and `validate()`, assign a `schema` key that contains a schema definition, like this:
138
+
139
+ ```js
140
+ const schema = new ObjectSchema({
141
+ name: {
142
+ schema: {
143
+ first: {
144
+ merge: "replace",
145
+ validate: "string",
146
+ },
147
+ last: {
148
+ merge: "replace",
149
+ validate: "string",
150
+ },
151
+ },
152
+ },
153
+ });
154
+
155
+ schema.validate({
156
+ name: {
157
+ first: "n",
158
+ last: "z",
159
+ },
160
+ });
161
+ ```
162
+
163
+ ### Remove Keys During Merge
164
+
165
+ If the merge strategy for a key returns `undefined`, then the key will not appear in the final object. For example:
166
+
167
+ ```js
168
+ const schema = new ObjectSchema({
169
+ date: {
170
+ merge() {
171
+ return undefined;
172
+ },
173
+ validate(value) {
174
+ Date.parse(value); // throws an error when invalid
175
+ },
176
+ },
177
+ });
178
+
179
+ const object1 = { date: "5/5/2005" };
180
+ const object2 = { date: "6/6/2006" };
181
+
182
+ const result = schema.merge(object1, object2);
183
+
184
+ console.log("date" in result); // false
185
+ ```
186
+
187
+ ### Requiring Another Key Be Present
188
+
189
+ If you'd like the presence of one key to require the presence of another key, you can use the `requires` property to specify an array of other properties that any key requires. For example:
190
+
191
+ ```js
192
+ const schema = new ObjectSchema();
193
+
194
+ const schema = new ObjectSchema({
195
+ date: {
196
+ merge() {
197
+ return undefined;
198
+ },
199
+ validate(value) {
200
+ Date.parse(value); // throws an error when invalid
201
+ },
202
+ },
203
+ time: {
204
+ requires: ["date"],
205
+ merge(first, second) {
206
+ return second;
207
+ },
208
+ validate(value) {
209
+ // ...
210
+ },
211
+ },
212
+ });
213
+
214
+ // throws error: Key "time" requires keys "date"
215
+ schema.validate({
216
+ time: "13:45",
217
+ });
218
+ ```
219
+
220
+ In this example, even though `date` is an optional key, it is required to be present whenever `time` is present.
221
+
222
+ ## License
223
+
224
+ Apache 2.0
225
+
226
+ <!-- NOTE: This section is autogenerated. Do not manually edit.-->
227
+ <!--sponsorsstart-->
228
+
229
+ ## Sponsors
230
+
231
+ The following companies, organizations, and individuals support ESLint's ongoing maintenance and development. [Become a Sponsor](https://eslint.org/donate)
232
+ to get your logo on our READMEs and [website](https://eslint.org/sponsors).
233
+
234
+ <h3>Platinum Sponsors</h3>
235
+ <p><a href="https://automattic.com"><img src="https://images.opencollective.com/automattic/d0ef3e1/logo.png" alt="Automattic" height="128"></a> <a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/airbnb/d327d66/logo.png" alt="Airbnb" height="128"></a></p><h3>Gold Sponsors</h3>
236
+ <p><a href="https://qlty.sh/"><img src="https://images.opencollective.com/qltysh/33d157d/logo.png" alt="Qlty Software" height="96"></a> <a href="https://trunk.io/"><img src="https://images.opencollective.com/trunkio/fb92d60/avatar.png" alt="trunk.io" height="96"></a> <a href="https://shopify.engineering/"><img src="https://avatars.githubusercontent.com/u/8085" alt="Shopify" height="96"></a></p><h3>Silver Sponsors</h3>
237
+ <p><a href="https://vite.dev/"><img src="https://images.opencollective.com/vite/e6d15e1/logo.png" alt="Vite" height="64"></a> <a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/5c4fa84/logo.png" alt="Liftoff" height="64"></a> <a href="https://americanexpress.io"><img src="https://avatars.githubusercontent.com/u/3853301" alt="American Express" height="64"></a> <a href="https://stackblitz.com"><img src="https://avatars.githubusercontent.com/u/28635252" alt="StackBlitz" height="64"></a></p><h3>Bronze Sponsors</h3>
238
+ <p><a href="https://syntax.fm"><img src="https://github.com/syntaxfm.png" alt="Syntax" height="32"></a> <a href="https://cybozu.co.jp/"><img src="https://images.opencollective.com/cybozu/933e46d/logo.png" alt="Cybozu" height="32"></a> <a href="https://sentry.io"><img src="https://github.com/getsentry.png" alt="Sentry" height="32"></a> <a href="https://discord.com"><img src="https://images.opencollective.com/discordapp/f9645d9/logo.png" alt="Discord" height="32"></a> <a href="https://www.gitbook.com"><img src="https://avatars.githubusercontent.com/u/7111340" alt="GitBook" height="32"></a> <a href="https://nx.dev"><img src="https://avatars.githubusercontent.com/u/23692104" alt="Nx" height="32"></a> <a href="https://opensource.mercedes-benz.com/"><img src="https://avatars.githubusercontent.com/u/34240465" alt="Mercedes-Benz Group" height="32"></a> <a href="https://herocoders.com"><img src="https://avatars.githubusercontent.com/u/37549774" alt="HeroCoders" height="32"></a> <a href="https://www.lambdatest.com"><img src="https://avatars.githubusercontent.com/u/171592363" alt="LambdaTest" height="32"></a></p>
239
+ <h3>Technology Sponsors</h3>
240
+ Technology sponsors allow us to use their products and services for free as part of a contribution to the open source ecosystem and our work.
241
+ <p><a href="https://netlify.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/netlify-icon.svg" alt="Netlify" height="32"></a> <a href="https://algolia.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/algolia-icon.svg" alt="Algolia" height="32"></a> <a href="https://1password.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/1password-icon.svg" alt="1Password" height="32"></a></p>
242
+ <!--sponsorsend-->
server/node_modules/@eslint/object-schema/dist/cjs/index.cjs ADDED
@@ -0,0 +1,457 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict';
2
+
3
+ /**
4
+ * @fileoverview Merge Strategy
5
+ */
6
+
7
+ //-----------------------------------------------------------------------------
8
+ // Class
9
+ //-----------------------------------------------------------------------------
10
+
11
+ /**
12
+ * Container class for several different merge strategies.
13
+ */
14
+ class MergeStrategy {
15
+ /**
16
+ * Merges two keys by overwriting the first with the second.
17
+ * @param {*} value1 The value from the first object key.
18
+ * @param {*} value2 The value from the second object key.
19
+ * @returns {*} The second value.
20
+ */
21
+ static overwrite(value1, value2) {
22
+ return value2;
23
+ }
24
+
25
+ /**
26
+ * Merges two keys by replacing the first with the second only if the
27
+ * second is defined.
28
+ * @param {*} value1 The value from the first object key.
29
+ * @param {*} value2 The value from the second object key.
30
+ * @returns {*} The second value if it is defined.
31
+ */
32
+ static replace(value1, value2) {
33
+ if (typeof value2 !== "undefined") {
34
+ return value2;
35
+ }
36
+
37
+ return value1;
38
+ }
39
+
40
+ /**
41
+ * Merges two properties by assigning properties from the second to the first.
42
+ * @param {*} value1 The value from the first object key.
43
+ * @param {*} value2 The value from the second object key.
44
+ * @returns {*} A new object containing properties from both value1 and
45
+ * value2.
46
+ */
47
+ static assign(value1, value2) {
48
+ return Object.assign({}, value1, value2);
49
+ }
50
+ }
51
+
52
+ /**
53
+ * @fileoverview Validation Strategy
54
+ */
55
+
56
+ //-----------------------------------------------------------------------------
57
+ // Class
58
+ //-----------------------------------------------------------------------------
59
+
60
+ /**
61
+ * Container class for several different validation strategies.
62
+ */
63
+ class ValidationStrategy {
64
+ /**
65
+ * Validates that a value is an array.
66
+ * @param {*} value The value to validate.
67
+ * @returns {void}
68
+ * @throws {TypeError} If the value is invalid.
69
+ */
70
+ static array(value) {
71
+ if (!Array.isArray(value)) {
72
+ throw new TypeError("Expected an array.");
73
+ }
74
+ }
75
+
76
+ /**
77
+ * Validates that a value is a boolean.
78
+ * @param {*} value The value to validate.
79
+ * @returns {void}
80
+ * @throws {TypeError} If the value is invalid.
81
+ */
82
+ static boolean(value) {
83
+ if (typeof value !== "boolean") {
84
+ throw new TypeError("Expected a Boolean.");
85
+ }
86
+ }
87
+
88
+ /**
89
+ * Validates that a value is a number.
90
+ * @param {*} value The value to validate.
91
+ * @returns {void}
92
+ * @throws {TypeError} If the value is invalid.
93
+ */
94
+ static number(value) {
95
+ if (typeof value !== "number") {
96
+ throw new TypeError("Expected a number.");
97
+ }
98
+ }
99
+
100
+ /**
101
+ * Validates that a value is a object.
102
+ * @param {*} value The value to validate.
103
+ * @returns {void}
104
+ * @throws {TypeError} If the value is invalid.
105
+ */
106
+ static object(value) {
107
+ if (!value || typeof value !== "object") {
108
+ throw new TypeError("Expected an object.");
109
+ }
110
+ }
111
+
112
+ /**
113
+ * Validates that a value is a object or null.
114
+ * @param {*} value The value to validate.
115
+ * @returns {void}
116
+ * @throws {TypeError} If the value is invalid.
117
+ */
118
+ static "object?"(value) {
119
+ if (typeof value !== "object") {
120
+ throw new TypeError("Expected an object or null.");
121
+ }
122
+ }
123
+
124
+ /**
125
+ * Validates that a value is a string.
126
+ * @param {*} value The value to validate.
127
+ * @returns {void}
128
+ * @throws {TypeError} If the value is invalid.
129
+ */
130
+ static string(value) {
131
+ if (typeof value !== "string") {
132
+ throw new TypeError("Expected a string.");
133
+ }
134
+ }
135
+
136
+ /**
137
+ * Validates that a value is a non-empty string.
138
+ * @param {*} value The value to validate.
139
+ * @returns {void}
140
+ * @throws {TypeError} If the value is invalid.
141
+ */
142
+ static "string!"(value) {
143
+ if (typeof value !== "string" || value.length === 0) {
144
+ throw new TypeError("Expected a non-empty string.");
145
+ }
146
+ }
147
+ }
148
+
149
+ /**
150
+ * @fileoverview Object Schema
151
+ */
152
+
153
+
154
+ //-----------------------------------------------------------------------------
155
+ // Types
156
+ //-----------------------------------------------------------------------------
157
+
158
+ /** @import * as $typests from "./types.ts"; */
159
+ /** @typedef {$typests.ObjectDefinition} ObjectDefinition */
160
+ /** @typedef {$typests.PropertyDefinition} PropertyDefinition */
161
+
162
+ //-----------------------------------------------------------------------------
163
+ // Private
164
+ //-----------------------------------------------------------------------------
165
+
166
+ /**
167
+ * Validates a schema strategy.
168
+ * @param {string} name The name of the key this strategy is for.
169
+ * @param {PropertyDefinition} definition The strategy for the object key.
170
+ * @returns {void}
171
+ * @throws {TypeError} When the strategy is missing a name.
172
+ * @throws {TypeError} When the strategy is missing a merge() method.
173
+ * @throws {TypeError} When the strategy is missing a validate() method.
174
+ */
175
+ function validateDefinition(name, definition) {
176
+ let hasSchema = false;
177
+ if (definition.schema) {
178
+ if (typeof definition.schema === "object") {
179
+ hasSchema = true;
180
+ } else {
181
+ throw new TypeError("Schema must be an object.");
182
+ }
183
+ }
184
+
185
+ if (typeof definition.merge === "string") {
186
+ if (!(definition.merge in MergeStrategy)) {
187
+ throw new TypeError(
188
+ `Definition for key "${name}" missing valid merge strategy.`,
189
+ );
190
+ }
191
+ } else if (!hasSchema && typeof definition.merge !== "function") {
192
+ throw new TypeError(
193
+ `Definition for key "${name}" must have a merge property.`,
194
+ );
195
+ }
196
+
197
+ if (typeof definition.validate === "string") {
198
+ if (!(definition.validate in ValidationStrategy)) {
199
+ throw new TypeError(
200
+ `Definition for key "${name}" missing valid validation strategy.`,
201
+ );
202
+ }
203
+ } else if (!hasSchema && typeof definition.validate !== "function") {
204
+ throw new TypeError(
205
+ `Definition for key "${name}" must have a validate() method.`,
206
+ );
207
+ }
208
+ }
209
+
210
+ //-----------------------------------------------------------------------------
211
+ // Errors
212
+ //-----------------------------------------------------------------------------
213
+
214
+ /**
215
+ * Error when an unexpected key is found.
216
+ */
217
+ class UnexpectedKeyError extends Error {
218
+ /**
219
+ * Creates a new instance.
220
+ * @param {string} key The key that was unexpected.
221
+ */
222
+ constructor(key) {
223
+ super(`Unexpected key "${key}" found.`);
224
+ }
225
+ }
226
+
227
+ /**
228
+ * Error when a required key is missing.
229
+ */
230
+ class MissingKeyError extends Error {
231
+ /**
232
+ * Creates a new instance.
233
+ * @param {string} key The key that was missing.
234
+ */
235
+ constructor(key) {
236
+ super(`Missing required key "${key}".`);
237
+ }
238
+ }
239
+
240
+ /**
241
+ * Error when a key requires other keys that are missing.
242
+ */
243
+ class MissingDependentKeysError extends Error {
244
+ /**
245
+ * Creates a new instance.
246
+ * @param {string} key The key that was unexpected.
247
+ * @param {Array<string>} requiredKeys The keys that are required.
248
+ */
249
+ constructor(key, requiredKeys) {
250
+ super(`Key "${key}" requires keys "${requiredKeys.join('", "')}".`);
251
+ }
252
+ }
253
+
254
+ /**
255
+ * Wrapper error for errors occuring during a merge or validate operation.
256
+ */
257
+ class WrapperError extends Error {
258
+ /**
259
+ * Creates a new instance.
260
+ * @param {string} key The object key causing the error.
261
+ * @param {Error} source The source error.
262
+ */
263
+ constructor(key, source) {
264
+ super(`Key "${key}": ${source.message}`, { cause: source });
265
+
266
+ // copy over custom properties that aren't represented
267
+ for (const sourceKey of Object.keys(source)) {
268
+ if (!(sourceKey in this)) {
269
+ this[sourceKey] = source[sourceKey];
270
+ }
271
+ }
272
+ }
273
+ }
274
+
275
+ //-----------------------------------------------------------------------------
276
+ // Main
277
+ //-----------------------------------------------------------------------------
278
+
279
+ /**
280
+ * Represents an object validation/merging schema.
281
+ */
282
+ class ObjectSchema {
283
+ /**
284
+ * Track all definitions in the schema by key.
285
+ * @type {Map<string, PropertyDefinition>}
286
+ */
287
+ #definitions = new Map();
288
+
289
+ /**
290
+ * Separately track any keys that are required for faster validtion.
291
+ * @type {Map<string, PropertyDefinition>}
292
+ */
293
+ #requiredKeys = new Map();
294
+
295
+ /**
296
+ * Creates a new instance.
297
+ * @param {ObjectDefinition} definitions The schema definitions.
298
+ * @throws {Error} When the definitions are missing or invalid.
299
+ */
300
+ constructor(definitions) {
301
+ if (!definitions) {
302
+ throw new Error("Schema definitions missing.");
303
+ }
304
+
305
+ // add in all strategies
306
+ for (const key of Object.keys(definitions)) {
307
+ validateDefinition(key, definitions[key]);
308
+
309
+ // normalize merge and validate methods if subschema is present
310
+ if (typeof definitions[key].schema === "object") {
311
+ const schema = new ObjectSchema(definitions[key].schema);
312
+ definitions[key] = {
313
+ ...definitions[key],
314
+ merge(first = {}, second = {}) {
315
+ return schema.merge(first, second);
316
+ },
317
+ validate(value) {
318
+ ValidationStrategy.object(value);
319
+ schema.validate(value);
320
+ },
321
+ };
322
+ }
323
+
324
+ // normalize the merge method in case there's a string
325
+ if (typeof definitions[key].merge === "string") {
326
+ definitions[key] = {
327
+ ...definitions[key],
328
+ merge: MergeStrategy[
329
+ /** @type {string} */ (definitions[key].merge)
330
+ ],
331
+ };
332
+ }
333
+
334
+ // normalize the validate method in case there's a string
335
+ if (typeof definitions[key].validate === "string") {
336
+ definitions[key] = {
337
+ ...definitions[key],
338
+ validate:
339
+ ValidationStrategy[
340
+ /** @type {string} */ (definitions[key].validate)
341
+ ],
342
+ };
343
+ }
344
+
345
+ this.#definitions.set(key, definitions[key]);
346
+
347
+ if (definitions[key].required) {
348
+ this.#requiredKeys.set(key, definitions[key]);
349
+ }
350
+ }
351
+ }
352
+
353
+ /**
354
+ * Determines if a strategy has been registered for the given object key.
355
+ * @param {string} key The object key to find a strategy for.
356
+ * @returns {boolean} True if the key has a strategy registered, false if not.
357
+ */
358
+ hasKey(key) {
359
+ return this.#definitions.has(key);
360
+ }
361
+
362
+ /**
363
+ * Merges objects together to create a new object comprised of the keys
364
+ * of the all objects. Keys are merged based on the each key's merge
365
+ * strategy.
366
+ * @param {...Object} objects The objects to merge.
367
+ * @returns {Object} A new object with a mix of all objects' keys.
368
+ * @throws {TypeError} If any object is invalid.
369
+ */
370
+ merge(...objects) {
371
+ // double check arguments
372
+ if (objects.length < 2) {
373
+ throw new TypeError("merge() requires at least two arguments.");
374
+ }
375
+
376
+ if (
377
+ objects.some(
378
+ object => object === null || typeof object !== "object",
379
+ )
380
+ ) {
381
+ throw new TypeError("All arguments must be objects.");
382
+ }
383
+
384
+ return objects.reduce((result, object) => {
385
+ this.validate(object);
386
+
387
+ for (const [key, strategy] of this.#definitions) {
388
+ try {
389
+ if (key in result || key in object) {
390
+ const merge = /** @type {Function} */ (strategy.merge);
391
+ const value = merge.call(
392
+ this,
393
+ result[key],
394
+ object[key],
395
+ );
396
+ if (value !== undefined) {
397
+ result[key] = value;
398
+ }
399
+ }
400
+ } catch (ex) {
401
+ throw new WrapperError(key, ex);
402
+ }
403
+ }
404
+ return result;
405
+ }, {});
406
+ }
407
+
408
+ /**
409
+ * Validates an object's keys based on the validate strategy for each key.
410
+ * @param {Object} object The object to validate.
411
+ * @returns {void}
412
+ * @throws {Error} When the object is invalid.
413
+ */
414
+ validate(object) {
415
+ // check existing keys first
416
+ for (const key of Object.keys(object)) {
417
+ // check to see if the key is defined
418
+ if (!this.hasKey(key)) {
419
+ throw new UnexpectedKeyError(key);
420
+ }
421
+
422
+ // validate existing keys
423
+ const definition = this.#definitions.get(key);
424
+
425
+ // first check to see if any other keys are required
426
+ if (Array.isArray(definition.requires)) {
427
+ if (
428
+ !definition.requires.every(otherKey => otherKey in object)
429
+ ) {
430
+ throw new MissingDependentKeysError(
431
+ key,
432
+ definition.requires,
433
+ );
434
+ }
435
+ }
436
+
437
+ // now apply remaining validation strategy
438
+ try {
439
+ const validate = /** @type {Function} */ (definition.validate);
440
+ validate.call(definition, object[key]);
441
+ } catch (ex) {
442
+ throw new WrapperError(key, ex);
443
+ }
444
+ }
445
+
446
+ // ensure required keys aren't missing
447
+ for (const [key] of this.#requiredKeys) {
448
+ if (!(key in object)) {
449
+ throw new MissingKeyError(key);
450
+ }
451
+ }
452
+ }
453
+ }
454
+
455
+ exports.MergeStrategy = MergeStrategy;
456
+ exports.ObjectSchema = ObjectSchema;
457
+ exports.ValidationStrategy = ValidationStrategy;
server/node_modules/@eslint/object-schema/dist/cjs/index.d.cts ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export type ObjectDefinition = $typests.ObjectDefinition;
2
+ export type PropertyDefinition = $typests.PropertyDefinition;
3
+ /**
4
+ * @fileoverview Merge Strategy
5
+ */
6
+ /**
7
+ * Container class for several different merge strategies.
8
+ */
9
+ export class MergeStrategy {
10
+ /**
11
+ * Merges two keys by overwriting the first with the second.
12
+ * @param {*} value1 The value from the first object key.
13
+ * @param {*} value2 The value from the second object key.
14
+ * @returns {*} The second value.
15
+ */
16
+ static overwrite(value1: any, value2: any): any;
17
+ /**
18
+ * Merges two keys by replacing the first with the second only if the
19
+ * second is defined.
20
+ * @param {*} value1 The value from the first object key.
21
+ * @param {*} value2 The value from the second object key.
22
+ * @returns {*} The second value if it is defined.
23
+ */
24
+ static replace(value1: any, value2: any): any;
25
+ /**
26
+ * Merges two properties by assigning properties from the second to the first.
27
+ * @param {*} value1 The value from the first object key.
28
+ * @param {*} value2 The value from the second object key.
29
+ * @returns {*} A new object containing properties from both value1 and
30
+ * value2.
31
+ */
32
+ static assign(value1: any, value2: any): any;
33
+ }
34
+ /**
35
+ * Represents an object validation/merging schema.
36
+ */
37
+ export class ObjectSchema {
38
+ /**
39
+ * Creates a new instance.
40
+ * @param {ObjectDefinition} definitions The schema definitions.
41
+ * @throws {Error} When the definitions are missing or invalid.
42
+ */
43
+ constructor(definitions: ObjectDefinition);
44
+ /**
45
+ * Determines if a strategy has been registered for the given object key.
46
+ * @param {string} key The object key to find a strategy for.
47
+ * @returns {boolean} True if the key has a strategy registered, false if not.
48
+ */
49
+ hasKey(key: string): boolean;
50
+ /**
51
+ * Merges objects together to create a new object comprised of the keys
52
+ * of the all objects. Keys are merged based on the each key's merge
53
+ * strategy.
54
+ * @param {...Object} objects The objects to merge.
55
+ * @returns {Object} A new object with a mix of all objects' keys.
56
+ * @throws {TypeError} If any object is invalid.
57
+ */
58
+ merge(...objects: any[]): any;
59
+ /**
60
+ * Validates an object's keys based on the validate strategy for each key.
61
+ * @param {Object} object The object to validate.
62
+ * @returns {void}
63
+ * @throws {Error} When the object is invalid.
64
+ */
65
+ validate(object: any): void;
66
+ #private;
67
+ }
68
+ /**
69
+ * @fileoverview Validation Strategy
70
+ */
71
+ /**
72
+ * Container class for several different validation strategies.
73
+ */
74
+ export class ValidationStrategy {
75
+ /**
76
+ * Validates that a value is an array.
77
+ * @param {*} value The value to validate.
78
+ * @returns {void}
79
+ * @throws {TypeError} If the value is invalid.
80
+ */
81
+ static array(value: any): void;
82
+ /**
83
+ * Validates that a value is a boolean.
84
+ * @param {*} value The value to validate.
85
+ * @returns {void}
86
+ * @throws {TypeError} If the value is invalid.
87
+ */
88
+ static boolean(value: any): void;
89
+ /**
90
+ * Validates that a value is a number.
91
+ * @param {*} value The value to validate.
92
+ * @returns {void}
93
+ * @throws {TypeError} If the value is invalid.
94
+ */
95
+ static number(value: any): void;
96
+ /**
97
+ * Validates that a value is a object.
98
+ * @param {*} value The value to validate.
99
+ * @returns {void}
100
+ * @throws {TypeError} If the value is invalid.
101
+ */
102
+ static object(value: any): void;
103
+ /**
104
+ * Validates that a value is a object or null.
105
+ * @param {*} value The value to validate.
106
+ * @returns {void}
107
+ * @throws {TypeError} If the value is invalid.
108
+ */
109
+ static "object?"(value: any): void;
110
+ /**
111
+ * Validates that a value is a string.
112
+ * @param {*} value The value to validate.
113
+ * @returns {void}
114
+ * @throws {TypeError} If the value is invalid.
115
+ */
116
+ static string(value: any): void;
117
+ /**
118
+ * Validates that a value is a non-empty string.
119
+ * @param {*} value The value to validate.
120
+ * @returns {void}
121
+ * @throws {TypeError} If the value is invalid.
122
+ */
123
+ static "string!"(value: any): void;
124
+ }
125
+ import type * as $typests from "./types.cts";
server/node_modules/@eslint/object-schema/dist/cjs/types.cts ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @fileoverview Types for object-schema package.
3
+ */
4
+
5
+ /**
6
+ * Built-in validation strategies.
7
+ */
8
+ export type BuiltInValidationStrategy =
9
+ | "array"
10
+ | "boolean"
11
+ | "number"
12
+ | "object"
13
+ | "object?"
14
+ | "string"
15
+ | "string!";
16
+
17
+ /**
18
+ * Built-in merge strategies.
19
+ */
20
+ export type BuiltInMergeStrategy = "assign" | "overwrite" | "replace";
21
+
22
+ /**
23
+ * Property definition.
24
+ */
25
+ export interface PropertyDefinition {
26
+ /**
27
+ * Indicates if the property is required.
28
+ */
29
+ required: boolean;
30
+
31
+ /**
32
+ * The other properties that must be present when this property is used.
33
+ */
34
+ requires?: string[];
35
+
36
+ /**
37
+ * The strategy to merge the property.
38
+ */
39
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/eslint/rewrite/pull/90#discussion_r1687206213
40
+ merge: BuiltInMergeStrategy | ((target: any, source: any) => any);
41
+
42
+ /**
43
+ * The strategy to validate the property.
44
+ */
45
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/eslint/rewrite/pull/90#discussion_r1687206213
46
+ validate: BuiltInValidationStrategy | ((value: any) => void);
47
+
48
+ /**
49
+ * The schema for the object value of this property.
50
+ */
51
+ schema?: ObjectDefinition;
52
+ }
53
+
54
+ /**
55
+ * Object definition.
56
+ */
57
+ export type ObjectDefinition = Record<string, PropertyDefinition>;
server/node_modules/@eslint/object-schema/dist/esm/index.d.ts ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export type ObjectDefinition = $typests.ObjectDefinition;
2
+ export type PropertyDefinition = $typests.PropertyDefinition;
3
+ /**
4
+ * @fileoverview Merge Strategy
5
+ */
6
+ /**
7
+ * Container class for several different merge strategies.
8
+ */
9
+ export class MergeStrategy {
10
+ /**
11
+ * Merges two keys by overwriting the first with the second.
12
+ * @param {*} value1 The value from the first object key.
13
+ * @param {*} value2 The value from the second object key.
14
+ * @returns {*} The second value.
15
+ */
16
+ static overwrite(value1: any, value2: any): any;
17
+ /**
18
+ * Merges two keys by replacing the first with the second only if the
19
+ * second is defined.
20
+ * @param {*} value1 The value from the first object key.
21
+ * @param {*} value2 The value from the second object key.
22
+ * @returns {*} The second value if it is defined.
23
+ */
24
+ static replace(value1: any, value2: any): any;
25
+ /**
26
+ * Merges two properties by assigning properties from the second to the first.
27
+ * @param {*} value1 The value from the first object key.
28
+ * @param {*} value2 The value from the second object key.
29
+ * @returns {*} A new object containing properties from both value1 and
30
+ * value2.
31
+ */
32
+ static assign(value1: any, value2: any): any;
33
+ }
34
+ /**
35
+ * Represents an object validation/merging schema.
36
+ */
37
+ export class ObjectSchema {
38
+ /**
39
+ * Creates a new instance.
40
+ * @param {ObjectDefinition} definitions The schema definitions.
41
+ * @throws {Error} When the definitions are missing or invalid.
42
+ */
43
+ constructor(definitions: ObjectDefinition);
44
+ /**
45
+ * Determines if a strategy has been registered for the given object key.
46
+ * @param {string} key The object key to find a strategy for.
47
+ * @returns {boolean} True if the key has a strategy registered, false if not.
48
+ */
49
+ hasKey(key: string): boolean;
50
+ /**
51
+ * Merges objects together to create a new object comprised of the keys
52
+ * of the all objects. Keys are merged based on the each key's merge
53
+ * strategy.
54
+ * @param {...Object} objects The objects to merge.
55
+ * @returns {Object} A new object with a mix of all objects' keys.
56
+ * @throws {TypeError} If any object is invalid.
57
+ */
58
+ merge(...objects: any[]): any;
59
+ /**
60
+ * Validates an object's keys based on the validate strategy for each key.
61
+ * @param {Object} object The object to validate.
62
+ * @returns {void}
63
+ * @throws {Error} When the object is invalid.
64
+ */
65
+ validate(object: any): void;
66
+ #private;
67
+ }
68
+ /**
69
+ * @fileoverview Validation Strategy
70
+ */
71
+ /**
72
+ * Container class for several different validation strategies.
73
+ */
74
+ export class ValidationStrategy {
75
+ /**
76
+ * Validates that a value is an array.
77
+ * @param {*} value The value to validate.
78
+ * @returns {void}
79
+ * @throws {TypeError} If the value is invalid.
80
+ */
81
+ static array(value: any): void;
82
+ /**
83
+ * Validates that a value is a boolean.
84
+ * @param {*} value The value to validate.
85
+ * @returns {void}
86
+ * @throws {TypeError} If the value is invalid.
87
+ */
88
+ static boolean(value: any): void;
89
+ /**
90
+ * Validates that a value is a number.
91
+ * @param {*} value The value to validate.
92
+ * @returns {void}
93
+ * @throws {TypeError} If the value is invalid.
94
+ */
95
+ static number(value: any): void;
96
+ /**
97
+ * Validates that a value is a object.
98
+ * @param {*} value The value to validate.
99
+ * @returns {void}
100
+ * @throws {TypeError} If the value is invalid.
101
+ */
102
+ static object(value: any): void;
103
+ /**
104
+ * Validates that a value is a object or null.
105
+ * @param {*} value The value to validate.
106
+ * @returns {void}
107
+ * @throws {TypeError} If the value is invalid.
108
+ */
109
+ static "object?"(value: any): void;
110
+ /**
111
+ * Validates that a value is a string.
112
+ * @param {*} value The value to validate.
113
+ * @returns {void}
114
+ * @throws {TypeError} If the value is invalid.
115
+ */
116
+ static string(value: any): void;
117
+ /**
118
+ * Validates that a value is a non-empty string.
119
+ * @param {*} value The value to validate.
120
+ * @returns {void}
121
+ * @throws {TypeError} If the value is invalid.
122
+ */
123
+ static "string!"(value: any): void;
124
+ }
125
+ import type * as $typests from "./types.ts";