@eslint-sh/eslint-plugin 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/README.md +23 -29
  2. package/dist/api.d.ts +4 -4
  3. package/dist/command-harvest/builtins/bats.d.ts +1 -1
  4. package/dist/command-harvest/harvest-commands.d.ts +18 -7
  5. package/dist/command-harvest/harvest-commands.js +11 -10
  6. package/dist/command-harvest/wrapper-table.d.ts +1 -1
  7. package/dist/command-harvest/wrapper-table.js +1 -1
  8. package/dist/eslint-plugin-api.d.ts +65 -55
  9. package/dist/language/command-resolution.d.ts +44 -10
  10. package/dist/language/command-resolution.js +39 -13
  11. package/dist/language/shell-source-code.d.ts +25 -42
  12. package/dist/language/shell-source-code.js +27 -44
  13. package/dist/language/syntax-view.d.ts +1 -1
  14. package/dist/language/word-resolution.d.ts +2 -2
  15. package/dist/language/word-resolution.js +2 -2
  16. package/dist/rules/compat/declaration-options.js +2 -2
  17. package/dist/rules/compat/no-brace-sequence-padding-step.js +1 -1
  18. package/dist/rules/compat/no-mapfile.js +2 -2
  19. package/dist/rules/compat/no-negative-array-index.js +2 -2
  20. package/dist/rules/compat/no-printf-time-format.js +2 -2
  21. package/dist/rules/compat/no-test-v.js +2 -2
  22. package/dist/rules/compat/no-wait-n.js +2 -2
  23. package/dist/rules/compat/posix-absent-command.js +2 -2
  24. package/dist/rules/compat/shopt-options.js +2 -2
  25. package/dist/rules/create-wrapper-rule.d.ts +3 -3
  26. package/dist/rules/create-wrapper-rule.js +8 -4
  27. package/dist/rules/no-dynamic-invocation.d.ts +1 -1
  28. package/dist/rules/no-dynamic-invocation.js +12 -4
  29. package/dist/rules/no-eval.js +6 -2
  30. package/dist/rules/no-masked-exit-status.js +1 -1
  31. package/dist/rules/no-secret-env-reads.js +1 -1
  32. package/dist/rules/no-unchecked-cd.js +1 -1
  33. package/dist/rules/no-undeclared-commands.js +2 -1
  34. package/dist/rules/no-unused-declarations.js +7 -2
  35. package/dist/rules/quote-expansions.js +1 -1
  36. package/dist/rules/require-network-wrapper.d.ts +1 -1
  37. package/dist/rules/require-network-wrapper.js +10 -4
  38. package/dist/rules/require-tty-guard.js +1 -1
  39. package/dist/rules/resolve-network-wrapper.d.ts +2 -2
  40. package/dist/rules/resolve-network-wrapper.js +6 -6
  41. package/dist/rules/resolve-transparent-wrappers.d.ts +1 -1
  42. package/dist/rules/resolve-transparent-wrappers.js +2 -2
  43. package/dist/rules/transparent-wrappers.d.ts +3 -3
  44. package/dist/rules/transparent-wrappers.js +1 -1
  45. package/docs/custom-rule-tutorial.md +35 -35
  46. package/docs/error-codes.md +6 -5
  47. package/docs/examples/no-backticks-rule.mjs +1 -1
  48. package/docs/examples/no-curl-in-functions-rule.mjs +2 -2
  49. package/docs/examples/no-listed-commands-rule.ts +1 -1
  50. package/docs/examples/no-rm-rf-rule.mjs +1 -1
  51. package/docs/rules/no-dynamic-invocation.md +5 -0
  52. package/docs/rules/no-undeclared-commands.md +4 -0
  53. package/docs/rules/no-unused-declarations.md +4 -0
  54. package/docs/rules/require-network-wrapper.md +1 -1
  55. package/docs/selectors.md +1 -1
  56. package/docs/wrapper-rules.md +1 -1
  57. package/package.json +9 -20
  58. package/dist/eslint-plugin-syntax-analyze.d.ts +0 -23
  59. package/dist/eslint-plugin-syntax.d.ts +0 -30
  60. package/dist/syntax/analyze.d.ts +0 -19
  61. package/dist/syntax/analyze.js +0 -21
  62. package/dist/syntax/index.d.ts +0 -26
  63. package/dist/syntax/index.js +0 -28
@@ -1,4 +1,5 @@
1
- import type { Argv0Resolution, CallExpr, CommandContext, CommandSite, ResolveArgv0Options, WordResolution } from 'sh-ast/analyze';
1
+ import type { Argv0Resolution, CommandUncertainty, CommandContext, CommandSite, ResolveArgv0Options, WordResolution } from 'sh-analysis';
2
+ import type { CallExpr } from 'sh-ast';
2
3
  import type { ShellFile, ShellNode, ShellNodeOf } from './syntax-view.js';
3
4
  /**
4
5
  * Every command site in one parsed file, from a single `enumerateCommands`
@@ -10,19 +11,21 @@ import type { ShellFile, ShellNode, ShellNodeOf } from './syntax-view.js';
10
11
  */
11
12
  export interface CommandSiteIndex {
12
13
  readonly sites: readonly CommandSite[];
14
+ /** Opaque execution boundaries retained alongside represented commands. */
15
+ readonly uncertainties: readonly CommandUncertainty[];
13
16
  readonly byNode: ReadonlyMap<CallExpr, CommandSite>;
14
17
  }
15
18
  /**
16
19
  * One command invocation in a linted shell file, in lint-view terms: an
17
- * `sh-ast/analyze` `CommandSite` whose `node` is the `CallExpr` view node
20
+ * `sh-analysis` `CommandSite` whose `node` is the `CallExpr` view node
18
21
  * ESLint passes to rule visitors, so a rule can `context.report()` on it.
19
22
  *
20
- * The data comes from `sh-ast/analyze`'s `enumerateCommands` and is facts
23
+ * The data comes from `sh-analysis`'s `enumerateCommands` and is facts
21
24
  * only: how the command is reached and what its words resolve to, never a
22
25
  * verdict on whether running it is safe. A dynamic (`static: false`) `argv0`
23
26
  * is a normal result.
24
27
  *
25
- * Read one through `ShellSourceCode.getCommandSites()`.
28
+ * Read one through `ShellSourceCode.getCommandInventory().commands`.
26
29
  *
27
30
  * Every rule linting a file sees the same sites, so each one is deeply
28
31
  * frozen: the entry, its `context` array and every frame in it, its `argv`
@@ -43,7 +46,7 @@ export interface ShellCommandSite {
43
46
  readonly node: ShellNodeOf<'CallExpr'>;
44
47
  /**
45
48
  * The path from the file root to this command, outermost frame first,
46
- * exactly as `sh-ast/analyze` reports it. For example, `date` in
49
+ * exactly as `sh-analysis` reports it. For example, `date` in
47
50
  * `f() { echo "$(date)"; }` has
48
51
  * `[{ kind: 'function', name: 'f' }, { kind: 'cmdSubst' }]`.
49
52
  */
@@ -58,23 +61,47 @@ export interface ShellCommandSite {
58
61
  readonly argv: readonly WordResolution[];
59
62
  /**
60
63
  * Follows this command's argv0 through transparent wrappers (`env`, `sudo`,
61
- * `nohup`, `exec`, …) and returns `sh-ast/analyze`'s `resolveArgv0`
64
+ * `nohup`, `exec`, …) and returns `sh-analysis`'s `resolveArgv0`
62
65
  * result. Same answer as
63
66
  * `ShellSourceCode.resolveInvokedCommand(node, options)`; both read the
64
67
  * same per-file index.
65
68
  *
66
69
  * @param options - Forwarded to `resolveArgv0` unchanged.
67
- * `transparentWrappers` replaces `sh-ast/analyze`'s
70
+ * `transparentWrappers` replaces `sh-analysis`'s
68
71
  * `DEFAULT_TRANSPARENT_WRAPPERS`; spread the defaults into the array to
69
72
  * extend them instead.
70
73
  * @returns A new result on every call. Its `chain` and `chainIndices`
71
74
  * arrays belong to the caller. `chainIndices` gives each chain entry's
72
75
  * position in this site's `argv`.
73
- * @throws `ShAnalyzeInvalidWrapperSpecError` (`SH_AST_ANALYZE_INVALID_WRAPPER_SPEC`, from `sh-ast/analyze`) when
76
+ * @throws `ShAnalyzeInvalidWrapperSpecError` (`SH_ANALYSIS_INVALID_WRAPPER_SPEC`, from `sh-analysis`) when
74
77
  * `options.transparentWrappers` contains a malformed entry.
75
78
  */
76
79
  resolveInvokedCommand(options?: ResolveArgv0Options): Argv0Resolution;
77
80
  }
81
+ /**
82
+ * An opaque executable construct projected onto the original ESLint view.
83
+ * Its presence limits inventory completeness; it does not assert a hidden command.
84
+ * @public
85
+ */
86
+ export interface ShellCommandUncertainty {
87
+ /** The analysis observation, without a lint-policy interpretation. */
88
+ readonly reason: CommandUncertainty['reason'];
89
+ /** Original projected construct, with this file's UTF-16 range and location. */
90
+ readonly node: ShellNode;
91
+ /** Context reaching the opaque construct, outermost frame first. */
92
+ readonly context: readonly CommandContext[];
93
+ }
94
+ /**
95
+ * Represented commands and opaque execution boundaries in one linted file.
96
+ * Consumers requiring complete execution knowledge must consider uncertainties.
97
+ * @public
98
+ */
99
+ export interface ShellCommandInventory {
100
+ /** Known represented command sites, in source order. */
101
+ readonly commands: readonly ShellCommandSite[];
102
+ /** Opaque constructs whose executable contents cannot be enumerated. */
103
+ readonly uncertainties: readonly ShellCommandUncertainty[];
104
+ }
78
105
  /**
79
106
  * Builds the {@link CommandSiteIndex} for a whole parsed file with a single
80
107
  * `enumerateCommands` call over the file's original syntax. Each site's
@@ -86,13 +113,13 @@ export interface ShellCommandSite {
86
113
  * this bridge exists to prevent.
87
114
  *
88
115
  * The index is shared by every rule linting the file, and its data reaches
89
- * rules: `getCommandSites` exposes each site's `context`, `argv0` and `argv`.
116
+ * rules: `getCommandInventory` exposes each site's `context`, `argv0` and `argv`.
90
117
  * Analysis also shares one `context` array and its frames between
91
118
  * sibling commands. So every site is frozen in place here, before any rule
92
119
  * can see it (see {@link freezeCommandSite}).
93
120
  *
94
121
  * @throws TypeError with `ESLINT_SH_FILE_NODE` when `file` has no associated parsed syntax.
95
- * @throws `ShAnalyzeMaxDepthError` (`SH_AST_ANALYZE_MAX_DEPTH`, from `sh-ast/analyze`) when the file's
122
+ * @throws `ShAnalyzeMaxDepthError` (`SH_ANALYSIS_MAX_DEPTH`, from `sh-analysis`) when the file's
96
123
  * nesting exceeds analysis's recursion guard. It propagates unchanged: a
97
124
  * partial index would silently omit real commands, so callers fail closed.
98
125
  * @internal
@@ -114,6 +141,13 @@ export declare function buildCommandSiteIndex(file: ShellFile): CommandSiteIndex
114
141
  * @internal
115
142
  */
116
143
  export declare function viewCommandSites(file: ShellFile, index: CommandSiteIndex): readonly ShellCommandSite[];
144
+ /**
145
+ * Projects inventory limits by original syntax identity, using the same associations
146
+ * as command sites. A missing association is an adapter invariant failure, never
147
+ * permission to silently discard uncertainty or reinterpret shell source text.
148
+ * @internal
149
+ */
150
+ export declare function viewCommandInventory(file: ShellFile, index: CommandSiteIndex): ShellCommandInventory;
117
151
  /**
118
152
  * Returns the parser's own `CallExpr` behind a lint `CallExpr`.
119
153
  *
@@ -1,14 +1,14 @@
1
1
  /**
2
- * Bridges command-level questions from ESLint view identity back to faithful
3
- * syntax. `sh-ast/analyze` owns what a command invocation is and which command
4
- * it runs; this module only builds the per-file index of the `CommandSite`s
5
- * analysis reports, maps a lint `CallExpr` to its raw syntax node, and maps
6
- * each site's raw `CallExpr` forward to its lint view node, so every rule gets
7
- * the analysis answer rather than a local reinterpretation.
2
+ * Maps reusable command observations onto ESLint source identity. sh-analysis owns
3
+ * represented command sites, their context and opaque execution boundaries; this
4
+ * adapter indexes the original syntax nodes and maps every observation to its
5
+ * original lint view without interpreting source text or choosing lint policy.
8
6
  *
9
- * ESLINT_SH_FILE_NODE and ESLINT_SH_CALL_NODE reject missing syntax associations. ESLINT_SH_COMMAND_SITE_VIEW rejects a site from a different file; analysis resource and wrapper failures propagate unchanged.
7
+ * Missing source associations are invariant failures. Commands and uncertainties
8
+ * must never disappear during projection; analysis resource/configuration errors
9
+ * propagate unchanged instead of becoming partial inventories or parser errors.
10
10
  */
11
- import { enumerateCommands, resolveArgv0 } from 'sh-ast/analyze';
11
+ import { enumerateCommands, resolveArgv0 } from 'sh-analysis';
12
12
  import { syntaxForNode, viewForSyntax, withoutCrlfCarriageReturn } from './syntax-view.js';
13
13
  /**
14
14
  * Builds the {@link CommandSiteIndex} for a whole parsed file with a single
@@ -21,13 +21,13 @@ import { syntaxForNode, viewForSyntax, withoutCrlfCarriageReturn } from './synta
21
21
  * this bridge exists to prevent.
22
22
  *
23
23
  * The index is shared by every rule linting the file, and its data reaches
24
- * rules: `getCommandSites` exposes each site's `context`, `argv0` and `argv`.
24
+ * rules: `getCommandInventory` exposes each site's `context`, `argv0` and `argv`.
25
25
  * Analysis also shares one `context` array and its frames between
26
26
  * sibling commands. So every site is frozen in place here, before any rule
27
27
  * can see it (see {@link freezeCommandSite}).
28
28
  *
29
29
  * @throws TypeError with `ESLINT_SH_FILE_NODE` when `file` has no associated parsed syntax.
30
- * @throws `ShAnalyzeMaxDepthError` (`SH_AST_ANALYZE_MAX_DEPTH`, from `sh-ast/analyze`) when the file's
30
+ * @throws `ShAnalyzeMaxDepthError` (`SH_ANALYSIS_MAX_DEPTH`, from `sh-analysis`) when the file's
31
31
  * nesting exceeds analysis's recursion guard. It propagates unchanged: a
32
32
  * partial index would silently omit real commands, so callers fail closed.
33
33
  * @internal
@@ -39,8 +39,16 @@ export function buildCommandSiteIndex(file) {
39
39
  code: 'ESLINT_SH_FILE_NODE',
40
40
  });
41
41
  }
42
- const sites = Object.freeze(enumerateCommands(syntax).map((site) => freezeCommandSite(withLfArgv(site))));
43
- return { sites, byNode: new Map(sites.map((site) => [site.node, site])) };
42
+ const inventory = enumerateCommands(syntax);
43
+ const sites = Object.freeze(inventory.commands.map((site) => freezeCommandSite(withLfArgv(site))));
44
+ const uncertainties = Object.freeze(inventory.uncertainties.map((uncertainty) => {
45
+ for (const frame of uncertainty.context) {
46
+ Object.freeze(frame);
47
+ }
48
+ Object.freeze(uncertainty.context);
49
+ return Object.freeze(uncertainty);
50
+ }));
51
+ return { sites, uncertainties, byNode: new Map(sites.map((site) => [site.node, site])) };
44
52
  }
45
53
  /**
46
54
  * `site` with each argv word resolved as its LF equivalent (see
@@ -64,7 +72,7 @@ function withLfArgv(site) {
64
72
  *
65
73
  * Freezing in place, instead of copying, keeps every value identical to what
66
74
  * analysis returned. That is safe because `enumerateCommands` builds these
67
- * objects fresh on each call, and nothing in `sh-ast/analyze` writes to them
75
+ * objects fresh on each call, and nothing in `sh-analysis` writes to them
68
76
  * after it returns: `resolveArgv0` only reads a site. A frame's fields are
69
77
  * primitives or source text, so freezing each frame shallowly is complete.
70
78
  */
@@ -108,6 +116,24 @@ export function viewCommandSites(file, index) {
108
116
  });
109
117
  }));
110
118
  }
119
+ /**
120
+ * Projects inventory limits by original syntax identity, using the same associations
121
+ * as command sites. A missing association is an adapter invariant failure, never
122
+ * permission to silently discard uncertainty or reinterpret shell source text.
123
+ * @internal
124
+ */
125
+ export function viewCommandInventory(file, index) {
126
+ const uncertainties = Object.freeze(index.uncertainties.map((uncertainty) => {
127
+ const node = viewForSyntax(file, uncertainty.node);
128
+ if (node === undefined) {
129
+ throw Object.assign(new Error('command uncertainty has no node in the lint view of this file'), {
130
+ code: 'ESLINT_SH_COMMAND_UNCERTAINTY_VIEW',
131
+ });
132
+ }
133
+ return Object.freeze({ reason: uncertainty.reason, node, context: uncertainty.context });
134
+ }));
135
+ return Object.freeze({ commands: viewCommandSites(file, index), uncertainties });
136
+ }
111
137
  /**
112
138
  * Returns the parser's own `CallExpr` behind a lint `CallExpr`.
113
139
  *
@@ -10,9 +10,9 @@ import { TextSourceCodeBase } from '@eslint/plugin-kit';
10
10
  import type { ShellFile as ShFile, ShellNode as ShNode, ShellNodeOf, ShellComment } from './syntax-view.js';
11
11
  import type { Directive as IDirective, FileProblem, RulesConfig, SourceLocation, TraversalStep } from '@eslint/core';
12
12
  import type { Node as SyntaxNode, PrintOptions, SyntaxPos } from 'sh-ast';
13
- import type { Argv0Resolution, ResolveArgv0Options, ResolveWordOptions, WordResolution } from 'sh-ast/analyze';
13
+ import type { Argv0Resolution, ResolveArgv0Options, ResolveWordOptions, WordResolution } from 'sh-analysis';
14
14
  import type { ShellDialect, ShellLanguageOptions } from './shell-language-options.js';
15
- import type { ShellCommandSite } from './command-resolution.js';
15
+ import type { ShellCommandInventory } from './command-resolution.js';
16
16
  /**
17
17
  * `ShellSourceCode` — the `SourceCode` object ESLint uses to work with a
18
18
  * parsed shell file. Extends `@eslint/plugin-kit`'s `TextSourceCodeBase`, which
@@ -44,10 +44,10 @@ import type { ShellCommandSite } from './command-resolution.js';
44
44
  * from `context.sourceCode`; its constructor is internal language plumbing.
45
45
  *
46
46
  * Rule-author helpers (`resolveWord`, `resolveWordText`, `getCommandName`,
47
- * `resolveInvokedCommand`, `getCommandSites`) answer "is this word statically
47
+ * `resolveInvokedCommand`, `getCommandInventory`) answer "is this word statically
48
48
  * the string `jq`?", "which command does this invocation run?", and "which
49
49
  * commands does this file run, and where?" by delegating to
50
- * `sh-ast/analyze`. They never reinterpret words themselves, so every rule
50
+ * `sh-analysis`. They never reinterpret words themselves, so every rule
51
51
  * gets the same answer for the same syntax. `dialect` and `minBashVersion`
52
52
  * expose the file's normalized language options.
53
53
  *
@@ -123,7 +123,7 @@ export declare class ShellSourceCode extends TextSourceCodeBase<{
123
123
  }): number;
124
124
  /**
125
125
  * Resolves a lint-view word using its original syntax and grammar position.
126
- * `sh-ast/analyze` owns static-word interpretation and dynamic reasons; this
126
+ * `sh-analysis` owns static-word interpretation and dynamic reasons; this
127
127
  * method supplies the lint tree's position-based policy, without executing shell.
128
128
  *
129
129
  * Without explicit options, `CallExpr.args` use command-argument context, so
@@ -141,7 +141,7 @@ export declare class ShellSourceCode extends TextSourceCodeBase<{
141
141
  /**
142
142
  * The text-only form of {@link ShellSourceCode.resolveWord}: returns its text
143
143
  * exactly when static, otherwise `null`. Both methods share one policy path
144
- * through `sh-ast/analyze`.
144
+ * through `sh-analysis`.
145
145
  *
146
146
  * @param word - A parsed Word from the lint view.
147
147
  * @param options - Explicit analysis policy overriding grammar defaults.
@@ -157,7 +157,7 @@ export declare class ShellSourceCode extends TextSourceCodeBase<{
157
157
  * {@link ShellSourceCode.resolveInvokedCommand} for the command a wrapper
158
158
  * chain actually runs.
159
159
  *
160
- * Delegates to `sh-ast/analyze`: the answer is the `argv0` resolution of the
160
+ * Delegates to `sh-analysis`: the answer is the `argv0` resolution of the
161
161
  * `CommandSite` that `enumerateCommands` reports for this `CallExpr` in this
162
162
  * file. Leading `VAR=val` assignments are not part of argv, so
163
163
  * `FOO=1 jq .` yields `"jq"`. An assignment-only statement (`FOO=1`) has no
@@ -166,14 +166,14 @@ export declare class ShellSourceCode extends TextSourceCodeBase<{
166
166
  * @param callExpr - A parsed `CallExpr` node from this file's lint tree.
167
167
  * @returns The command word's static text, or `null`.
168
168
  * @throws TypeError with `ESLINT_SH_CALL_NODE` when `callExpr` is not a parsed shell `CallExpr`.
169
- * @throws `ShAnalyzeMaxDepthError` (`SH_AST_ANALYZE_MAX_DEPTH`, from `sh-ast/analyze`) when this file's
169
+ * @throws `ShAnalyzeMaxDepthError` (`SH_ANALYSIS_MAX_DEPTH`, from `sh-analysis`) when this file's
170
170
  * nesting exceeds analysis's recursion guard; see
171
171
  * {@link ShellSourceCode.resolveInvokedCommand}.
172
172
  */
173
173
  getCommandName(callExpr: ShellNodeOf<'CallExpr'>): string | null;
174
174
  /**
175
175
  * Follows `callExpr`'s argv0 through transparent wrappers (`env`, `sudo`,
176
- * `nohup`, `exec`, …) and returns `sh-ast/analyze`'s full `resolveArgv0`
176
+ * `nohup`, `exec`, …) and returns `sh-analysis`'s full `resolveArgv0`
177
177
  * result, or `null` for a `CallExpr` that has no `CommandSite` (an
178
178
  * assignment-only statement such as `FOO=1`).
179
179
  *
@@ -187,7 +187,7 @@ export declare class ShellSourceCode extends TextSourceCodeBase<{
187
187
  * `embedded-command`; `chain`
188
188
  * lists every word resolved along the way, outermost wrapper first, and
189
189
  * `chainIndices` gives each entry's position in the command's `argv` (as
190
- * {@link ShellSourceCode.getCommandSites} reports it). When `effective` is
190
+ * {@link ShellSourceCode.getCommandInventory} reports it). When `effective` is
191
191
  * static, the effective command's arguments are
192
192
  * `argv.slice(chainIndices.at(-1)! + 1)`: every entry after the effective
193
193
  * command's own index. For an interpreter command string the final chain
@@ -205,49 +205,32 @@ export declare class ShellSourceCode extends TextSourceCodeBase<{
205
205
  *
206
206
  * @param callExpr - A parsed `CallExpr` node from this file's lint tree.
207
207
  * @param options - Forwarded to `resolveArgv0` unchanged.
208
- * `transparentWrappers` replaces `sh-ast/analyze`'s
208
+ * `transparentWrappers` replaces `sh-analysis`'s
209
209
  * `DEFAULT_TRANSPARENT_WRAPPERS`; spread the defaults into the array to
210
210
  * extend them instead.
211
211
  * @returns The resolution, or `null` when `callExpr` invokes no command.
212
212
  * @throws TypeError with `ESLINT_SH_CALL_NODE` when `callExpr` is not a parsed shell `CallExpr`.
213
- * @throws `ShAnalyzeMaxDepthError` (`SH_AST_ANALYZE_MAX_DEPTH`, from `sh-ast/analyze`) when this file's
213
+ * @throws `ShAnalyzeMaxDepthError` (`SH_ANALYSIS_MAX_DEPTH`, from `sh-analysis`) when this file's
214
214
  * nesting exceeds analysis's recursion guard.
215
- * @throws `ShAnalyzeInvalidWrapperSpecError` (`SH_AST_ANALYZE_INVALID_WRAPPER_SPEC`, from `sh-ast/analyze`) when
215
+ * @throws `ShAnalyzeInvalidWrapperSpecError` (`SH_ANALYSIS_INVALID_WRAPPER_SPEC`, from `sh-analysis`) when
216
216
  * `options.transparentWrappers` contains a malformed entry.
217
217
  */
218
218
  resolveInvokedCommand(callExpr: ShellNodeOf<'CallExpr'>, options?: ResolveArgv0Options): Argv0Resolution | null;
219
219
  /**
220
- * Returns every command invocation in this file, one entry per
221
- * `sh-ast/analyze` `CommandSite`, in source order. Use it when a rule needs
222
- * the whole file's commands with their structural context, such as every
223
- * command inside a function or inside `$(…)`, instead of visiting
224
- * `CallExpr` nodes one by one.
220
+ * Returns represented command sites and explicit opaque execution boundaries.
221
+ * Both retain original node identity in this file's UTF-16 ESLint view. This
222
+ * adapter maps sh-analysis observations without parsing text or choosing policy.
225
223
  *
226
- * The data comes from `sh-ast/analyze`'s `enumerateCommands`: facts about
227
- * how each command is reached and what its words resolve to, never a
228
- * verdict. Each entry's `context`, `argv0`, and `argv` are analysis's own
229
- * values, unchanged; `context` lists frames outermost first, as in sh-ast.
230
- * Each entry's `node` is the `CallExpr` view node (`===` the node ESLint
231
- * passes to a `CallExpr` visitor), so it can be passed to
232
- * `context.report()`.
224
+ * The inventory and observation data are frozen and shared across rules; view
225
+ * nodes retain ESLint's ordinary mutable-node contract. Enumeration runs once,
226
+ * lazily, shared with getCommandName and resolveInvokedCommand. Analysis errors
227
+ * propagate unchanged rather than returning a partial inventory.
233
228
  *
234
- * An assignment-only statement (`FOO=1`) runs no command and has no entry,
235
- * although a command substitution in its value (`FOO=$(date)`) does.
236
- *
237
- * Enumeration runs at most once per file, shared with
238
- * {@link ShellSourceCode.getCommandName} and
239
- * {@link ShellSourceCode.resolveInvokedCommand}, and every call returns the
240
- * same array. Because every rule shares it, the array and everything in each
241
- * entry except `node` are deeply frozen (see `ShellCommandSite`): no rule can
242
- * change what another rule reads. If the file's nesting exceeds `enumerateCommands`'s
243
- * recursion guard, its `ShAnalyzeMaxDepthError` propagates unchanged, as it
244
- * does for those helpers: a partial list would silently omit real commands.
245
- *
246
- * @returns This file's command sites, in source order.
247
- * @throws `ShAnalyzeMaxDepthError` (`SH_AST_ANALYZE_MAX_DEPTH`, from `sh-ast/analyze`) when this file's
248
- * nesting exceeds analysis's recursion guard.
229
+ * A known-command policy may inspect `commands`; any assertion of execution
230
+ * completeness must also account for `uncertainties` and its own dynamic-code
231
+ * assumptions. Empty commands with nonempty uncertainties never proves no execution.
249
232
  */
250
- getCommandSites(): readonly ShellCommandSite[];
233
+ getCommandInventory(): ShellCommandInventory;
251
234
  /**
252
235
  * Returns the sh-ast record `node` was projected from: this file's original
253
236
  * parse of `node`, with every field the lint view leaves out, including
@@ -255,7 +238,7 @@ export declare class ShellSourceCode extends TextSourceCodeBase<{
255
238
  * `Redirect.OpPos`. Pass those positions to
256
239
  * {@link ShellSourceCode.getIndexFromSyntaxPos} or
257
240
  * {@link ShellSourceCode.getLocFromSyntaxPos} to report on them, or pass the
258
- * record to an `sh-ast/analyze` function.
241
+ * record to an `sh-analysis` function.
259
242
  *
260
243
  * The returned record is read-only by contract. It is the language's
261
244
  * original parse, shared by every rule and helper linting this file, and
@@ -10,8 +10,8 @@ import { ConfigCommentParser, Directive, TextSourceCodeBase, VisitNodeStep, } fr
10
10
  import { childNodes, isShellComment, projectedComments, projectedCoordinates, syntaxForNode, viewForSyntax, walkShell, } from './syntax-view.js';
11
11
  import { SourceCoordinates } from './source-coordinates.js';
12
12
  import { SYNTAX_INTERFACES, printSync } from 'sh-ast';
13
- import { resolveArgv0 } from 'sh-ast/analyze';
14
- import { buildCommandSiteIndex, rawCallExprFor, viewCommandSites } from './command-resolution.js';
13
+ import { resolveArgv0 } from 'sh-analysis';
14
+ import { buildCommandSiteIndex, rawCallExprFor, viewCommandInventory, } from './command-resolution.js';
15
15
  import { resolveWord } from './word-resolution.js';
16
16
  /**
17
17
  * Refuses edited syntax whose string or byte values the upstream printer treats as layout.
@@ -339,10 +339,10 @@ function withUnusedDirectiveFixRange(comment, text) {
339
339
  * from `context.sourceCode`; its constructor is internal language plumbing.
340
340
  *
341
341
  * Rule-author helpers (`resolveWord`, `resolveWordText`, `getCommandName`,
342
- * `resolveInvokedCommand`, `getCommandSites`) answer "is this word statically
342
+ * `resolveInvokedCommand`, `getCommandInventory`) answer "is this word statically
343
343
  * the string `jq`?", "which command does this invocation run?", and "which
344
344
  * commands does this file run, and where?" by delegating to
345
- * `sh-ast/analyze`. They never reinterpret words themselves, so every rule
345
+ * `sh-analysis`. They never reinterpret words themselves, so every rule
346
346
  * gets the same answer for the same syntax. `dialect` and `minBashVersion`
347
347
  * expose the file's normalized language options.
348
348
  *
@@ -415,7 +415,7 @@ export class ShellSourceCode extends TextSourceCodeBase {
415
415
  */
416
416
  #commandSites;
417
417
  /**
418
- * {@link ShellSourceCode.getCommandSites}'s answer: the index's sites in
418
+ * {@link ShellSourceCode.getCommandInventory}'s answer: the index's sites in
419
419
  * view terms, built once from `#commandSites` so every caller shares one
420
420
  * frozen array.
421
421
  */
@@ -501,7 +501,7 @@ export class ShellSourceCode extends TextSourceCodeBase {
501
501
  }
502
502
  /**
503
503
  * Resolves a lint-view word using its original syntax and grammar position.
504
- * `sh-ast/analyze` owns static-word interpretation and dynamic reasons; this
504
+ * `sh-analysis` owns static-word interpretation and dynamic reasons; this
505
505
  * method supplies the lint tree's position-based policy, without executing shell.
506
506
  *
507
507
  * Without explicit options, `CallExpr.args` use command-argument context, so
@@ -521,7 +521,7 @@ export class ShellSourceCode extends TextSourceCodeBase {
521
521
  /**
522
522
  * The text-only form of {@link ShellSourceCode.resolveWord}: returns its text
523
523
  * exactly when static, otherwise `null`. Both methods share one policy path
524
- * through `sh-ast/analyze`.
524
+ * through `sh-analysis`.
525
525
  *
526
526
  * @param word - A parsed Word from the lint view.
527
527
  * @param options - Explicit analysis policy overriding grammar defaults.
@@ -550,7 +550,7 @@ export class ShellSourceCode extends TextSourceCodeBase {
550
550
  * {@link ShellSourceCode.resolveInvokedCommand} for the command a wrapper
551
551
  * chain actually runs.
552
552
  *
553
- * Delegates to `sh-ast/analyze`: the answer is the `argv0` resolution of the
553
+ * Delegates to `sh-analysis`: the answer is the `argv0` resolution of the
554
554
  * `CommandSite` that `enumerateCommands` reports for this `CallExpr` in this
555
555
  * file. Leading `VAR=val` assignments are not part of argv, so
556
556
  * `FOO=1 jq .` yields `"jq"`. An assignment-only statement (`FOO=1`) has no
@@ -559,7 +559,7 @@ export class ShellSourceCode extends TextSourceCodeBase {
559
559
  * @param callExpr - A parsed `CallExpr` node from this file's lint tree.
560
560
  * @returns The command word's static text, or `null`.
561
561
  * @throws TypeError with `ESLINT_SH_CALL_NODE` when `callExpr` is not a parsed shell `CallExpr`.
562
- * @throws `ShAnalyzeMaxDepthError` (`SH_AST_ANALYZE_MAX_DEPTH`, from `sh-ast/analyze`) when this file's
562
+ * @throws `ShAnalyzeMaxDepthError` (`SH_ANALYSIS_MAX_DEPTH`, from `sh-analysis`) when this file's
563
563
  * nesting exceeds analysis's recursion guard; see
564
564
  * {@link ShellSourceCode.resolveInvokedCommand}.
565
565
  */
@@ -569,7 +569,7 @@ export class ShellSourceCode extends TextSourceCodeBase {
569
569
  }
570
570
  /**
571
571
  * Follows `callExpr`'s argv0 through transparent wrappers (`env`, `sudo`,
572
- * `nohup`, `exec`, …) and returns `sh-ast/analyze`'s full `resolveArgv0`
572
+ * `nohup`, `exec`, …) and returns `sh-analysis`'s full `resolveArgv0`
573
573
  * result, or `null` for a `CallExpr` that has no `CommandSite` (an
574
574
  * assignment-only statement such as `FOO=1`).
575
575
  *
@@ -583,7 +583,7 @@ export class ShellSourceCode extends TextSourceCodeBase {
583
583
  * `embedded-command`; `chain`
584
584
  * lists every word resolved along the way, outermost wrapper first, and
585
585
  * `chainIndices` gives each entry's position in the command's `argv` (as
586
- * {@link ShellSourceCode.getCommandSites} reports it). When `effective` is
586
+ * {@link ShellSourceCode.getCommandInventory} reports it). When `effective` is
587
587
  * static, the effective command's arguments are
588
588
  * `argv.slice(chainIndices.at(-1)! + 1)`: every entry after the effective
589
589
  * command's own index. For an interpreter command string the final chain
@@ -601,14 +601,14 @@ export class ShellSourceCode extends TextSourceCodeBase {
601
601
  *
602
602
  * @param callExpr - A parsed `CallExpr` node from this file's lint tree.
603
603
  * @param options - Forwarded to `resolveArgv0` unchanged.
604
- * `transparentWrappers` replaces `sh-ast/analyze`'s
604
+ * `transparentWrappers` replaces `sh-analysis`'s
605
605
  * `DEFAULT_TRANSPARENT_WRAPPERS`; spread the defaults into the array to
606
606
  * extend them instead.
607
607
  * @returns The resolution, or `null` when `callExpr` invokes no command.
608
608
  * @throws TypeError with `ESLINT_SH_CALL_NODE` when `callExpr` is not a parsed shell `CallExpr`.
609
- * @throws `ShAnalyzeMaxDepthError` (`SH_AST_ANALYZE_MAX_DEPTH`, from `sh-ast/analyze`) when this file's
609
+ * @throws `ShAnalyzeMaxDepthError` (`SH_ANALYSIS_MAX_DEPTH`, from `sh-analysis`) when this file's
610
610
  * nesting exceeds analysis's recursion guard.
611
- * @throws `ShAnalyzeInvalidWrapperSpecError` (`SH_AST_ANALYZE_INVALID_WRAPPER_SPEC`, from `sh-ast/analyze`) when
611
+ * @throws `ShAnalyzeInvalidWrapperSpecError` (`SH_ANALYSIS_INVALID_WRAPPER_SPEC`, from `sh-analysis`) when
612
612
  * `options.transparentWrappers` contains a malformed entry.
613
613
  */
614
614
  resolveInvokedCommand(callExpr, options) {
@@ -616,38 +616,21 @@ export class ShellSourceCode extends TextSourceCodeBase {
616
616
  return site ? resolveArgv0(site, options) : null;
617
617
  }
618
618
  /**
619
- * Returns every command invocation in this file, one entry per
620
- * `sh-ast/analyze` `CommandSite`, in source order. Use it when a rule needs
621
- * the whole file's commands with their structural context, such as every
622
- * command inside a function or inside `$(…)`, instead of visiting
623
- * `CallExpr` nodes one by one.
619
+ * Returns represented command sites and explicit opaque execution boundaries.
620
+ * Both retain original node identity in this file's UTF-16 ESLint view. This
621
+ * adapter maps sh-analysis observations without parsing text or choosing policy.
624
622
  *
625
- * The data comes from `sh-ast/analyze`'s `enumerateCommands`: facts about
626
- * how each command is reached and what its words resolve to, never a
627
- * verdict. Each entry's `context`, `argv0`, and `argv` are analysis's own
628
- * values, unchanged; `context` lists frames outermost first, as in sh-ast.
629
- * Each entry's `node` is the `CallExpr` view node (`===` the node ESLint
630
- * passes to a `CallExpr` visitor), so it can be passed to
631
- * `context.report()`.
623
+ * The inventory and observation data are frozen and shared across rules; view
624
+ * nodes retain ESLint's ordinary mutable-node contract. Enumeration runs once,
625
+ * lazily, shared with getCommandName and resolveInvokedCommand. Analysis errors
626
+ * propagate unchanged rather than returning a partial inventory.
632
627
  *
633
- * An assignment-only statement (`FOO=1`) runs no command and has no entry,
634
- * although a command substitution in its value (`FOO=$(date)`) does.
635
- *
636
- * Enumeration runs at most once per file, shared with
637
- * {@link ShellSourceCode.getCommandName} and
638
- * {@link ShellSourceCode.resolveInvokedCommand}, and every call returns the
639
- * same array. Because every rule shares it, the array and everything in each
640
- * entry except `node` are deeply frozen (see `ShellCommandSite`): no rule can
641
- * change what another rule reads. If the file's nesting exceeds `enumerateCommands`'s
642
- * recursion guard, its `ShAnalyzeMaxDepthError` propagates unchanged, as it
643
- * does for those helpers: a partial list would silently omit real commands.
644
- *
645
- * @returns This file's command sites, in source order.
646
- * @throws `ShAnalyzeMaxDepthError` (`SH_AST_ANALYZE_MAX_DEPTH`, from `sh-ast/analyze`) when this file's
647
- * nesting exceeds analysis's recursion guard.
628
+ * A known-command policy may inspect `commands`; any assertion of execution
629
+ * completeness must also account for `uncertainties` and its own dynamic-code
630
+ * assumptions. Empty commands with nonempty uncertainties never proves no execution.
648
631
  */
649
- getCommandSites() {
650
- this.#commandSiteViews ??= viewCommandSites(this.ast, this.#getCommandSiteIndex());
632
+ getCommandInventory() {
633
+ this.#commandSiteViews ??= viewCommandInventory(this.ast, this.#getCommandSiteIndex());
651
634
  return this.#commandSiteViews;
652
635
  }
653
636
  /**
@@ -657,7 +640,7 @@ export class ShellSourceCode extends TextSourceCodeBase {
657
640
  * `Redirect.OpPos`. Pass those positions to
658
641
  * {@link ShellSourceCode.getIndexFromSyntaxPos} or
659
642
  * {@link ShellSourceCode.getLocFromSyntaxPos} to report on them, or pass the
660
- * record to an `sh-ast/analyze` function.
643
+ * record to an `sh-analysis` function.
661
644
  *
662
645
  * The returned record is read-only by contract. It is the language's
663
646
  * original parse, shared by every rule and helper linting this file, and
@@ -1,5 +1,5 @@
1
1
  import type { File, Node as SyntaxNode, PositionSnapshot } from 'sh-ast';
2
- import type { WordResolution } from 'sh-ast/analyze';
2
+ import type { WordResolution } from 'sh-analysis';
3
3
  import type { ShellNodeMap, ShellNodeOf, ShellNodeType } from './lint-view-types.js';
4
4
  import { SourceCoordinates } from './source-coordinates.js';
5
5
  /**
@@ -1,8 +1,8 @@
1
- import type { ResolveWordOptions, WordResolution } from 'sh-ast/analyze';
1
+ import type { ResolveWordOptions, WordResolution } from 'sh-analysis';
2
2
  import type { ShellNodeOf } from './syntax-view.js';
3
3
  /**
4
4
  * Resolves a parsed lint Word using the upstream-shaped syntax associated with it.
5
- * The view supplies locations and selector fields; sh-ast/analyze owns the word
5
+ * The view supplies locations and selector fields; sh-analysis owns the word
6
6
  * interpretation. Fabricated or synthetic view nodes have no source syntax and
7
7
  * are rejected instead of being treated as known or unknown shell values.
8
8
  * A static word that ends a line of a CRLF file resolves without the line
@@ -3,11 +3,11 @@
3
3
  * ESLINT_SH_WORD_NODE rejects a missing source association; dynamic words
4
4
  * remain ordinary analysis results rather than errors.
5
5
  */
6
- import { resolveWord as resolveSyntaxWord } from 'sh-ast/analyze';
6
+ import { resolveWord as resolveSyntaxWord } from 'sh-analysis';
7
7
  import { syntaxForNode, withoutCrlfCarriageReturn } from './syntax-view.js';
8
8
  /**
9
9
  * Resolves a parsed lint Word using the upstream-shaped syntax associated with it.
10
- * The view supplies locations and selector fields; sh-ast/analyze owns the word
10
+ * The view supplies locations and selector fields; sh-analysis owns the word
11
11
  * interpretation. Fabricated or synthetic view nodes have no source syntax and
12
12
  * are rejected instead of being treated as known or unknown shell values.
13
13
  * A static word that ends a line of a CRLF file resolves without the line
@@ -13,7 +13,7 @@
13
13
  * gating an option `local` shares (`-n`, `-l`, `-u`) adds `local` with
14
14
  * {@link DECLARATION_AND_LOCAL_COMMANDS}.
15
15
  */
16
- import { DEFAULT_TRANSPARENT_WRAPPERS } from 'sh-ast/analyze';
16
+ import { DEFAULT_TRANSPARENT_WRAPPERS } from 'sh-analysis';
17
17
  import { resolveTransparentWrappers } from '../resolve-transparent-wrappers.js';
18
18
  import { BUILTIN_WRAPPER } from '../transparent-wrappers.js';
19
19
  /** The declaration commands that take option clusters. */
@@ -32,7 +32,7 @@ export const DECLARATION_AND_LOCAL_COMMANDS = new Set([
32
32
  ]);
33
33
  /**
34
34
  * The wrappers followed to find a declaration command written as an ordinary
35
- * command: `sh-ast/analyze`'s defaults (which include `command`) plus Bash's
35
+ * command: `sh-analysis`'s defaults (which include `command`) plus Bash's
36
36
  * `builtin`.
37
37
  */
38
38
  const TRANSPARENT_WRAPPERS = [
@@ -72,7 +72,7 @@
72
72
  * the whole word, once per word.
73
73
  */
74
74
  import { createCompatRule } from './create-compat-rule.js';
75
- import { DashHdoc, DplIn, DplOut, Hdoc, WordHdoc } from 'sh-ast/analyze';
75
+ import { DashHdoc, DplIn, DplOut, Hdoc, WordHdoc } from 'sh-ast';
76
76
  /** The sequence between braces: two endpoints and an optional step. */
77
77
  const SEQUENCE = /^([+-]?\d+|[A-Za-z])\.\.([+-]?\d+|[A-Za-z])(?:\.\.([+-]?\d+))?$/u;
78
78
  /**
@@ -27,7 +27,7 @@
27
27
  * `-t`, which keeps each newline) and POSIX files, which have no arrays at
28
28
  * all, get the report without a suggestion.
29
29
  */
30
- import { DEFAULT_TRANSPARENT_WRAPPERS } from 'sh-ast/analyze';
30
+ import { DEFAULT_TRANSPARENT_WRAPPERS } from 'sh-analysis';
31
31
  import { resolveTransparentWrappers } from '../resolve-transparent-wrappers.js';
32
32
  import { BUILTIN_WRAPPER } from '../transparent-wrappers.js';
33
33
  import { createCompatRule } from './create-compat-rule.js';
@@ -39,7 +39,7 @@ const DEFAULT_ARRAY = 'MAPFILE';
39
39
  const IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_]*$/u;
40
40
  /**
41
41
  * The wrappers followed to find the command an invocation runs:
42
- * `sh-ast/analyze`'s defaults (which include `command`) plus Bash's
42
+ * `sh-analysis`'s defaults (which include `command`) plus Bash's
43
43
  * `builtin`.
44
44
  */
45
45
  const TRANSPARENT_WRAPPERS = [
@@ -28,14 +28,14 @@
28
28
  * ordinary word; option words (`-v`) never match an element name.
29
29
  */
30
30
  import { Minus } from 'sh-ast';
31
- import { DEFAULT_TRANSPARENT_WRAPPERS } from 'sh-ast/analyze';
31
+ import { DEFAULT_TRANSPARENT_WRAPPERS } from 'sh-analysis';
32
32
  import { resolveTransparentWrappers } from '../resolve-transparent-wrappers.js';
33
33
  import { BUILTIN_WRAPPER } from '../transparent-wrappers.js';
34
34
  import { createCompatRule } from './create-compat-rule.js';
35
35
  /** A bare negative-subscript read, the only shape the suggestion rewrites. */
36
36
  const BARE_READ = /^\$\{([A-Za-z_][A-Za-z0-9_]*)\[\s*-\s*(\d+)\s*\]\}$/u;
37
37
  /**
38
- * The wrappers followed to find an `unset` command: `sh-ast/analyze`'s
38
+ * The wrappers followed to find an `unset` command: `sh-analysis`'s
39
39
  * defaults (which include `command`) plus Bash's `builtin`.
40
40
  */
41
41
  const TRANSPARENT_WRAPPERS = [