@eslint-sh/eslint-plugin 0.8.0 → 0.9.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 (91) hide show
  1. package/README.md +41 -34
  2. package/dist/api.d.ts +92 -0
  3. package/dist/api.js +83 -0
  4. package/dist/command-harvest/harvest-commands.d.ts +2 -2
  5. package/dist/command-harvest/harvest-commands.js +2 -2
  6. package/dist/configs/posix-portable.d.ts +6 -10
  7. package/dist/configs/posix-portable.js +4 -6
  8. package/dist/configuration-message.d.ts +14 -0
  9. package/dist/configuration-message.js +33 -0
  10. package/dist/declaration-conventions/get-declared-commands.d.ts +41 -0
  11. package/dist/declaration-conventions/{read-declared-commands.js → get-declared-commands.js} +43 -43
  12. package/dist/eslint-plugin-api.d.ts +1506 -0
  13. package/dist/eslint-plugin-syntax-analyze.d.ts +3 -3
  14. package/dist/eslint-plugin-syntax.d.ts +3 -4
  15. package/dist/eslint-plugin.d.ts +16 -1560
  16. package/dist/index.d.ts +14 -81
  17. package/dist/index.js +22 -76
  18. package/dist/language/command-resolution.d.ts +5 -5
  19. package/dist/language/command-resolution.js +11 -7
  20. package/dist/language/selector-classes.d.ts +7 -3
  21. package/dist/language/selector-classes.js +13 -4
  22. package/dist/language/shell-language-options.d.ts +3 -3
  23. package/dist/language/shell-language-options.js +12 -17
  24. package/dist/language/shell-language.d.ts +3 -1
  25. package/dist/language/shell-language.js +6 -11
  26. package/dist/language/shell-source-code.d.ts +59 -42
  27. package/dist/language/shell-source-code.js +86 -60
  28. package/dist/language/source-coordinates.d.ts +2 -0
  29. package/dist/language/source-coordinates.js +8 -4
  30. package/dist/language/syntax-view.js +19 -7
  31. package/dist/language/word-resolution.d.ts +2 -1
  32. package/dist/language/word-resolution.js +8 -3
  33. package/dist/rules/create-wrapper-rule.d.ts +1 -1
  34. package/dist/rules/create-wrapper-rule.js +11 -9
  35. package/dist/rules/define-shell-rule.js +1 -1
  36. package/dist/rules/no-masked-exit-status.d.ts +4 -3
  37. package/dist/rules/no-masked-exit-status.js +3 -2
  38. package/dist/rules/no-secret-env-reads.d.ts +2 -0
  39. package/dist/rules/no-secret-env-reads.js +13 -2
  40. package/dist/rules/no-secret-flags.d.ts +2 -0
  41. package/dist/rules/no-secret-flags.js +14 -3
  42. package/dist/rules/no-unchecked-cd.js +3 -2
  43. package/dist/rules/no-undeclared-commands.js +8 -3
  44. package/dist/rules/no-unused-declarations.js +6 -2
  45. package/dist/rules/prefer-local.d.ts +3 -2
  46. package/dist/rules/prefer-local.js +4 -2
  47. package/dist/rules/require-network-wrapper.d.ts +1 -1
  48. package/dist/rules/require-network-wrapper.js +11 -7
  49. package/dist/rules/require-strict-mode.d.ts +5 -46
  50. package/dist/rules/require-strict-mode.js +17 -107
  51. package/dist/rules/require-tty-guard.d.ts +2 -0
  52. package/dist/rules/require-tty-guard.js +8 -1
  53. package/dist/rules/resolve-declaration-convention.d.ts +9 -88
  54. package/dist/rules/resolve-declaration-convention.js +19 -71
  55. package/dist/rules/resolve-network-wrapper.d.ts +1 -2
  56. package/dist/rules/resolve-network-wrapper.js +18 -14
  57. package/dist/rules/resolve-transparent-wrappers.d.ts +2 -7
  58. package/dist/rules/resolve-transparent-wrappers.js +19 -9
  59. package/dist/rules/set-options.d.ts +1 -1
  60. package/dist/rules/set-options.js +1 -1
  61. package/dist/rules/strict-mode-prologue.d.ts +43 -0
  62. package/dist/rules/strict-mode-prologue.js +91 -0
  63. package/dist/rules/user-pattern.d.ts +4 -3
  64. package/dist/rules/user-pattern.js +10 -8
  65. package/dist/shell-dialect.d.ts +8 -0
  66. package/dist/shell-dialect.js +22 -0
  67. package/dist/syntax/analyze.d.ts +3 -3
  68. package/dist/syntax/analyze.js +3 -3
  69. package/dist/syntax/index.d.ts +3 -4
  70. package/dist/syntax/index.js +3 -4
  71. package/dist/version.js +2 -1
  72. package/docs/compat.md +5 -6
  73. package/docs/custom-rule-tutorial.md +22 -18
  74. package/docs/declaration-conventions.md +20 -23
  75. package/docs/error-codes.md +93 -0
  76. package/docs/examples/no-rm-rf-rule.mjs +8 -10
  77. package/docs/examples/sorted-declarations-rule.mjs +6 -9
  78. package/docs/examples/tsconfig.json +10 -0
  79. package/docs/rules/README.md +12 -4
  80. package/docs/rules/compat/no-nounset-empty-array.md +1 -1
  81. package/docs/rules/no-masked-exit-status.md +2 -2
  82. package/docs/rules/no-secret-env-reads.md +13 -3
  83. package/docs/rules/no-secret-flags.md +14 -5
  84. package/docs/rules/no-unchecked-cd.md +15 -2
  85. package/docs/rules/require-network-wrapper.md +5 -5
  86. package/docs/rules/require-strict-mode.md +25 -23
  87. package/docs/rules/require-tty-guard.md +12 -3
  88. package/docs/selectors.md +7 -2
  89. package/docs/wrapper-rules.md +2 -0
  90. package/package.json +3 -3
  91. package/dist/declaration-conventions/read-declared-commands.d.ts +0 -70
@@ -1,8 +1,16 @@
1
+ /**
2
+ * ESLint's per-file shell view: source coordinates, grammar-aware analysis and
3
+ * checked syntax edits for rules. The language pipeline owns construction;
4
+ * consumers receive this instance through their rule context.
5
+ * Guard codes distinguish malformed argument shapes, foreign views, inexact
6
+ * ranges and printer content loss. Dependency analysis/printing errors retain
7
+ * their classes, codes and causes.
8
+ */
1
9
  import { TextSourceCodeBase } from '@eslint/plugin-kit';
2
10
  import type { ShellFile as ShFile, ShellNode as ShNode, ShellNodeOf, ShellComment } from './syntax-view.js';
3
11
  import type { Directive as IDirective, FileProblem, RulesConfig, SourceLocation, TraversalStep } from '@eslint/core';
4
12
  import type { Node as SyntaxNode, PrintOptions, SyntaxPos } from 'sh-ast';
5
- import type { Argv0Resolution, ResolveArgv0Options, ResolveWordOptions } from 'sh-ast/analyze';
13
+ import type { Argv0Resolution, ResolveArgv0Options, ResolveWordOptions, WordResolution } from 'sh-ast/analyze';
6
14
  import type { ShellDialect, ShellLanguageOptions } from './shell-language-options.js';
7
15
  import type { ShellCommandSite } from './command-resolution.js';
8
16
  /**
@@ -32,7 +40,10 @@ import type { ShellCommandSite } from './command-resolution.js';
32
40
  * classes) is implemented on `ShellLanguage` — see `shell-language.ts` and
33
41
  * `selector-classes.ts`.
34
42
  *
35
- * Rule-author helpers (`resolveWordText`, `getCommandName`,
43
+ * Exported from the package root as a type only. Rules receive the instance
44
+ * from `context.sourceCode`; its constructor is internal language plumbing.
45
+ *
46
+ * Rule-author helpers (`resolveWord`, `resolveWordText`, `getCommandName`,
36
47
  * `resolveInvokedCommand`, `getCommandSites`) answer "is this word statically
37
48
  * the string `jq`?", "which command does this invocation run?", and "which
38
49
  * commands does this file run, and where?" by delegating to
@@ -89,8 +100,8 @@ export declare class ShellSourceCode extends TextSourceCodeBase<{
89
100
  * file's root starts at its first statement or comment, so the base answer
90
101
  * was shifted by any leading blank lines or indentation.
91
102
  *
92
- * @throws TypeError when `index` is not a number.
93
- * @throws RangeError when `index` is not an integer from 0 to `text.length`.
103
+ * @throws TypeError with `ESLINT_SH_SOURCE_INDEX` when `index` is not a number.
104
+ * @throws RangeError with `ESLINT_SH_SOURCE_RANGE` when `index` is not an integer from 0 to `text.length`.
94
105
  */
95
106
  getLocFromIndex(index: number): {
96
107
  line: number;
@@ -103,35 +114,40 @@ export declare class ShellSourceCode extends TextSourceCodeBase<{
103
114
  *
104
115
  * Overrides the base class for the same reason as `getLocFromIndex`.
105
116
  *
106
- * @throws TypeError when `loc` is not an object with numeric `line` and `column`.
107
- * @throws RangeError when `loc` is not inside the text.
117
+ * @throws TypeError with `ESLINT_SH_SOURCE_LOCATION` when `loc` is not an object with numeric `line` and `column`.
118
+ * @throws RangeError with `ESLINT_SH_SOURCE_RANGE` when `loc` is not inside the text.
108
119
  */
109
120
  getIndexFromLoc(loc: {
110
121
  line: number;
111
122
  column: number;
112
123
  }): number;
113
124
  /**
114
- * Returns the literal text of `word` when `sh-ast/analyze`'s `resolveWord`
115
- * reports it static, or `null` otherwise.
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
127
+ * method supplies the lint tree's position-based policy, without executing shell.
116
128
  *
117
- * Delegates to `resolveWord` (through this package's `resolveWord` export),
118
- * which alone defines what "static" means: a word is static iff
119
- * `resolveWord` reports `static: true`. Its non-static reasons are
120
- * `expansion`, `tilde`, `glob`, `brace`, `locale`, and `unsupported`.
121
- * Call the root `resolveWord` export instead when the reason matters.
129
+ * Without explicit options, `CallExpr.args` use command-argument context, so
130
+ * `PATH=a:~/bin` is literal there. Other positions retain the analyzer's
131
+ * conservative default, including tilde expansion after an unquoted colon.
132
+ * Explicit options are forwarded unchanged, even when empty.
122
133
  *
123
- * `options` is forwarded to `resolveWord` unchanged. When it is omitted, the
124
- * word's grammar position picks the tilde context: a word in a `CallExpr`'s
125
- * `args` uses `{ context: 'command-argument' }`, the context
126
- * `enumerateCommands` uses for argv, so `resolveWordText(callExpr.args[0])`
127
- * equals `getCommandName(callExpr)`. Any other word uses `resolveWord`'s
128
- * conservative default, which also treats a `~` after an unquoted `:` as a
129
- * tilde expansion, as assignment values do.
134
+ * @param word - A parsed Word from the lint view.
135
+ * @param options - Explicit analysis policy overriding grammar defaults.
136
+ * @returns Static text or the analyzer's reason the word is dynamic.
137
+ * @throws TypeError with `ESLINT_SH_WORD_NODE` when the word has no associated parsed shell syntax.
138
+ * @public
139
+ */
140
+ resolveWord(word: ShellNodeOf<'Word'>, options?: ResolveWordOptions): WordResolution;
141
+ /**
142
+ * The text-only form of {@link ShellSourceCode.resolveWord}: returns its text
143
+ * exactly when static, otherwise `null`. Both methods share one policy path
144
+ * through `sh-ast/analyze`.
130
145
  *
131
- * @param word - A parsed `Word` node from this file's lint tree.
132
- * @param options - Forwarded to `resolveWord` unchanged when supplied.
146
+ * @param word - A parsed Word from the lint view.
147
+ * @param options - Explicit analysis policy overriding grammar defaults.
133
148
  * @returns The resolved text, or `null` when the word is not static.
134
- * @throws TypeError when `word` is not a parsed shell `Word`.
149
+ * @throws TypeError with `ESLINT_SH_WORD_NODE` when `word` is not a parsed shell `Word`.
150
+ * @public
135
151
  */
136
152
  resolveWordText(word: ShellNodeOf<'Word'>, options?: ResolveWordOptions): string | null;
137
153
  /**
@@ -149,8 +165,8 @@ export declare class ShellSourceCode extends TextSourceCodeBase<{
149
165
  *
150
166
  * @param callExpr - A parsed `CallExpr` node from this file's lint tree.
151
167
  * @returns The command word's static text, or `null`.
152
- * @throws TypeError when `callExpr` is not a parsed shell `CallExpr`.
153
- * @throws `ShAnalyzeMaxDepthError` (from `sh-ast/analyze`) when this file's
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
154
170
  * nesting exceeds analysis's recursion guard; see
155
171
  * {@link ShellSourceCode.resolveInvokedCommand}.
156
172
  */
@@ -193,10 +209,10 @@ export declare class ShellSourceCode extends TextSourceCodeBase<{
193
209
  * `DEFAULT_TRANSPARENT_WRAPPERS`; spread the defaults into the array to
194
210
  * extend them instead.
195
211
  * @returns The resolution, or `null` when `callExpr` invokes no command.
196
- * @throws TypeError when `callExpr` is not a parsed shell `CallExpr`.
197
- * @throws `ShAnalyzeMaxDepthError` (from `sh-ast/analyze`) when this file's
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
198
214
  * nesting exceeds analysis's recursion guard.
199
- * @throws `ShAnalyzeInvalidWrapperSpecError` (from `sh-ast/analyze`) when
215
+ * @throws `ShAnalyzeInvalidWrapperSpecError` (`SH_AST_ANALYZE_INVALID_WRAPPER_SPEC`, from `sh-ast/analyze`) when
200
216
  * `options.transparentWrappers` contains a malformed entry.
201
217
  */
202
218
  resolveInvokedCommand(callExpr: ShellNodeOf<'CallExpr'>, options?: ResolveArgv0Options): Argv0Resolution | null;
@@ -228,7 +244,7 @@ export declare class ShellSourceCode extends TextSourceCodeBase<{
228
244
  * does for those helpers: a partial list would silently omit real commands.
229
245
  *
230
246
  * @returns This file's command sites, in source order.
231
- * @throws `ShAnalyzeMaxDepthError` (from `sh-ast/analyze`) when this file's
247
+ * @throws `ShAnalyzeMaxDepthError` (`SH_AST_ANALYZE_MAX_DEPTH`, from `sh-ast/analyze`) when this file's
232
248
  * nesting exceeds analysis's recursion guard.
233
249
  */
234
250
  getCommandSites(): readonly ShellCommandSite[];
@@ -287,7 +303,7 @@ export declare class ShellSourceCode extends TextSourceCodeBase<{
287
303
  * printing"), so no second parse is involved. The copy owns its records,
288
304
  * arrays, positions and byte buffers. Editing it leaves this file's original
289
305
  * syntax, its lint view, its cached traversal and the answers of view-aware
290
- * helpers such as `resolveWord` and
306
+ * helpers such as {@link ShellSourceCode.resolveWord} and
291
307
  * {@link ShellSourceCode.resolveWordText} unchanged. Each call returns a new
292
308
  * copy.
293
309
  *
@@ -299,7 +315,7 @@ export declare class ShellSourceCode extends TextSourceCodeBase<{
299
315
  *
300
316
  * @param node - A view node from this file's lint tree.
301
317
  * @returns A deep copy of `node`'s original sh-ast record.
302
- * @throws TypeError when `node` has no original record in this file: an
318
+ * @throws TypeError with `ESLINT_SH_FOREIGN_VIEW_NODE` when `node` has no original record in this file: an
303
319
  * auxiliary view (such as the `Slice` of `${x:1:2}`), a view node of another
304
320
  * file, or an object that did not come from the parser.
305
321
  */
@@ -337,13 +353,14 @@ export declare class ShellSourceCode extends TextSourceCodeBase<{
337
353
  * `Command` or `WordPart`.
338
354
  * @param options - Forwarded to `printSync` unchanged.
339
355
  * @returns The range to replace and the printed text to put there.
340
- * @throws TypeError when `node` has no original record in this file (see
356
+ * @throws TypeError with `ESLINT_SH_FOREIGN_VIEW_NODE` when `node` has no original record in this file (see
341
357
  * {@link ShellSourceCode.getEditableSyntax}), when `edited` is not a
342
- * printable root (the message names its type), or when the printer's output
343
- * is not valid UTF-8, or the edited syntax contains literal vertical tabs or
344
- * form feeds that the printer cannot preserve. Non-UTF-8 output comes back
358
+ * printable root (`ESLINT_SH_PRINT_ROOT`; the message names its type), or when the printer's output
359
+ * is not valid UTF-8 (`ESLINT_SH_PRINT_ENCODING`), or the edited syntax contains literal vertical tabs or
360
+ * form feeds that the printer cannot preserve (`ESLINT_SH_PRINT_UNSAFE_TEXT`). Non-UTF-8 output comes back
345
361
  * from `printSync` as a `Uint8Array` and is never decoded lossily into a fix.
346
- * @throws `PrintError` or `PrintPanicError` (from sh-ast) when upstream's
362
+ * @throws `PrintError` (`SH_AST_SYNTAX_PRINT`), `PrintPanicError` (`SH_AST_SYNTAX_PRINT_PANIC`),
363
+ * or `InputError` (`SH_AST_SYNTAX_INPUT`), passed through unchanged from sh-ast, when upstream's
347
364
  * printer fails for `edited` or `options`.
348
365
  */
349
366
  getPrintedReplacement(node: ShNode, edited: SyntaxNode, options?: PrintOptions): {
@@ -364,12 +381,12 @@ export declare class ShellSourceCode extends TextSourceCodeBase<{
364
381
  *
365
382
  * @param pos - A `SyntaxPos` from one of this file's original records.
366
383
  * @returns The UTF-16 index of `pos` in this file's text.
367
- * @throws RangeError when `pos` is invalid (`IsValid === false`), recovered
384
+ * @throws RangeError with `ESLINT_SH_SOURCE_RANGE` when `pos` is invalid (`IsValid === false`), recovered
368
385
  * (`IsRecovered === true`), or overflowed (`OffsetOverflow === true`), or
369
386
  * when its offset is not a UTF-8 character boundary of this source. Such a
370
387
  * position is never rounded to a nearby boundary.
371
- * @throws TypeError when `pos` is not a `SyntaxPos`, or when this source
372
- * code's tree was not built by this language's parser.
388
+ * @throws TypeError with `ESLINT_SH_SYNTAX_POSITION` when `pos` is not a `SyntaxPos`, or when this source
389
+ * code's tree was not built by this language's parser (`ESLINT_SH_FILE_NODE`).
373
390
  */
374
391
  getIndexFromSyntaxPos(pos: SyntaxPos): number;
375
392
  /**
@@ -380,10 +397,10 @@ export declare class ShellSourceCode extends TextSourceCodeBase<{
380
397
  *
381
398
  * @param pos - A `SyntaxPos` from one of this file's original records.
382
399
  * @returns The one-based line and UTF-16 column of `pos`.
383
- * @throws RangeError when `pos` is invalid, recovered, or overflowed, or
400
+ * @throws RangeError with `ESLINT_SH_SOURCE_RANGE` when `pos` is invalid, recovered, or overflowed, or
384
401
  * when its offset is not a UTF-8 character boundary of this source.
385
- * @throws TypeError when `pos` is not a `SyntaxPos`, or when this source
386
- * code's tree was not built by this language's parser.
402
+ * @throws TypeError with `ESLINT_SH_SYNTAX_POSITION` when `pos` is not a `SyntaxPos`, or when this source
403
+ * code's tree was not built by this language's parser (`ESLINT_SH_FILE_NODE`).
387
404
  */
388
405
  getLocFromSyntaxPos(pos: SyntaxPos): {
389
406
  line: number;
@@ -1,3 +1,11 @@
1
+ /**
2
+ * ESLint's per-file shell view: source coordinates, grammar-aware analysis and
3
+ * checked syntax edits for rules. The language pipeline owns construction;
4
+ * consumers receive this instance through their rule context.
5
+ * Guard codes distinguish malformed argument shapes, foreign views, inexact
6
+ * ranges and printer content loss. Dependency analysis/printing errors retain
7
+ * their classes, codes and causes.
8
+ */
1
9
  import { ConfigCommentParser, Directive, TextSourceCodeBase, VisitNodeStep, } from '@eslint/plugin-kit';
2
10
  import { childNodes, isShellComment, projectedComments, projectedCoordinates, syntaxForNode, viewForSyntax, walkShell, } from './syntax-view.js';
3
11
  import { SourceCoordinates } from './source-coordinates.js';
@@ -21,8 +29,8 @@ function refusePrinterControlCharacters(root) {
21
29
  const unsafe = (typeof current === 'string' && /[\v\f]/u.test(current)) ||
22
30
  (current instanceof Uint8Array && current.some((byte) => byte === 0x0b || byte === 0x0c));
23
31
  if (unsafe) {
24
- throw new TypeError('cannot print a text fix containing literal vertical tabs and form feeds: ' +
25
- 'the printer changes their value');
32
+ throw Object.assign(new TypeError('cannot print a text fix containing literal vertical tabs and form feeds: ' +
33
+ 'the printer changes their value'), { code: 'ESLINT_SH_PRINT_UNSAFE_TEXT' });
26
34
  }
27
35
  // A checked byte-valued string is a leaf; its individual numbers are not syntax children.
28
36
  if (current instanceof Uint8Array) {
@@ -220,8 +228,8 @@ function computeUnusedDirectiveFixRange(comment, text) {
220
228
  * converting them would place a report or fix somewhere the parser never
221
229
  * pointed. They are rejected rather than rounded to a nearby boundary.
222
230
  *
223
- * @throws TypeError when `pos` is not shaped like an sh-ast `SyntaxPos`.
224
- * @throws RangeError when `pos` is invalid, recovered, or overflowed.
231
+ * @throws TypeError with `ESLINT_SH_SYNTAX_POSITION` when `pos` is not shaped like an sh-ast `SyntaxPos`.
232
+ * @throws RangeError with `ESLINT_SH_SOURCE_RANGE` when `pos` is invalid, recovered, or overflowed.
225
233
  */
226
234
  function exactByteOffset(pos) {
227
235
  const candidate = pos;
@@ -231,11 +239,13 @@ function exactByteOffset(pos) {
231
239
  typeof pos.IsValid !== 'boolean' ||
232
240
  typeof pos.IsRecovered !== 'boolean' ||
233
241
  typeof pos.OffsetOverflow !== 'boolean') {
234
- throw new TypeError('expected an sh-ast SyntaxPos');
242
+ throw Object.assign(new TypeError('expected an sh-ast SyntaxPos'), {
243
+ code: 'ESLINT_SH_SYNTAX_POSITION',
244
+ });
235
245
  }
236
246
  if (!pos.IsValid || pos.IsRecovered || pos.OffsetOverflow) {
237
- throw new RangeError(`syntax position has no exact source offset (IsValid: ${String(pos.IsValid)}, ` +
238
- `IsRecovered: ${String(pos.IsRecovered)}, OffsetOverflow: ${String(pos.OffsetOverflow)})`);
247
+ throw Object.assign(new RangeError(`syntax position has no exact source offset (IsValid: ${String(pos.IsValid)}, ` +
248
+ `IsRecovered: ${String(pos.IsRecovered)}, OffsetOverflow: ${String(pos.OffsetOverflow)})`), { code: 'ESLINT_SH_SOURCE_RANGE' });
239
249
  }
240
250
  return pos.Offset;
241
251
  }
@@ -265,11 +275,13 @@ function printableRootType(edited) {
265
275
  candidate === null ||
266
276
  !('Type' in candidate) ||
267
277
  typeof candidate.Type !== 'string') {
268
- throw new TypeError('expected an sh-ast syntax record to print');
278
+ throw Object.assign(new TypeError('expected an sh-ast syntax record to print'), {
279
+ code: 'ESLINT_SH_PRINT_ROOT',
280
+ });
269
281
  }
270
282
  if (!printableRootTypes.has(candidate.Type)) {
271
- throw new TypeError(`cannot print a ${candidate.Type} as a fix: printSync accepts File, Stmt, Word, Assign, ` +
272
- 'Command and WordPart roots');
283
+ throw Object.assign(new TypeError(`cannot print a ${candidate.Type} as a fix: printSync accepts File, Stmt, Word, Assign, ` +
284
+ 'Command and WordPart roots'), { code: 'ESLINT_SH_PRINT_ROOT' });
273
285
  }
274
286
  return candidate.Type;
275
287
  }
@@ -323,7 +335,10 @@ function withUnusedDirectiveFixRange(comment, text) {
323
335
  * classes) is implemented on `ShellLanguage` — see `shell-language.ts` and
324
336
  * `selector-classes.ts`.
325
337
  *
326
- * Rule-author helpers (`resolveWordText`, `getCommandName`,
338
+ * Exported from the package root as a type only. Rules receive the instance
339
+ * from `context.sourceCode`; its constructor is internal language plumbing.
340
+ *
341
+ * Rule-author helpers (`resolveWord`, `resolveWordText`, `getCommandName`,
327
342
  * `resolveInvokedCommand`, `getCommandSites`) answer "is this word statically
328
343
  * the string `jq`?", "which command does this invocation run?", and "which
329
344
  * commands does this file run, and where?" by delegating to
@@ -443,12 +458,15 @@ export class ShellSourceCode extends TextSourceCodeBase {
443
458
  * file's root starts at its first statement or comment, so the base answer
444
459
  * was shifted by any leading blank lines or indentation.
445
460
  *
446
- * @throws TypeError when `index` is not a number.
447
- * @throws RangeError when `index` is not an integer from 0 to `text.length`.
461
+ * @throws TypeError with `ESLINT_SH_SOURCE_INDEX` when `index` is not a number.
462
+ * @throws RangeError with `ESLINT_SH_SOURCE_RANGE` when `index` is not an integer from 0 to `text.length`.
448
463
  */
449
464
  getLocFromIndex(index) {
450
- if (typeof index !== 'number')
451
- throw new TypeError('Expected `index` to be a number.');
465
+ if (typeof index !== 'number') {
466
+ throw Object.assign(new TypeError('Expected `index` to be a number.'), {
467
+ code: 'ESLINT_SH_SOURCE_INDEX',
468
+ });
469
+ }
452
470
  const { line, column } = this.#textCoordinates().atIndex(index);
453
471
  return { line, column };
454
472
  }
@@ -459,8 +477,8 @@ export class ShellSourceCode extends TextSourceCodeBase {
459
477
  *
460
478
  * Overrides the base class for the same reason as `getLocFromIndex`.
461
479
  *
462
- * @throws TypeError when `loc` is not an object with numeric `line` and `column`.
463
- * @throws RangeError when `loc` is not inside the text.
480
+ * @throws TypeError with `ESLINT_SH_SOURCE_LOCATION` when `loc` is not an object with numeric `line` and `column`.
481
+ * @throws RangeError with `ESLINT_SH_SOURCE_RANGE` when `loc` is not inside the text.
464
482
  */
465
483
  getIndexFromLoc(loc) {
466
484
  if (typeof loc !== 'object' ||
@@ -468,7 +486,7 @@ export class ShellSourceCode extends TextSourceCodeBase {
468
486
  loc === null ||
469
487
  typeof loc.line !== 'number' ||
470
488
  typeof loc.column !== 'number') {
471
- throw new TypeError('Expected `loc` to be an object with numeric `line` and `column` properties.');
489
+ throw Object.assign(new TypeError('Expected `loc` to be an object with numeric `line` and `column` properties.'), { code: 'ESLINT_SH_SOURCE_LOCATION' });
472
490
  }
473
491
  return this.#textCoordinates().indexAt(loc.line, loc.column);
474
492
  }
@@ -482,30 +500,37 @@ export class ShellSourceCode extends TextSourceCodeBase {
482
500
  return this.#ownCoordinates;
483
501
  }
484
502
  /**
485
- * Returns the literal text of `word` when `sh-ast/analyze`'s `resolveWord`
486
- * reports it static, or `null` otherwise.
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
505
+ * method supplies the lint tree's position-based policy, without executing shell.
487
506
  *
488
- * Delegates to `resolveWord` (through this package's `resolveWord` export),
489
- * which alone defines what "static" means: a word is static iff
490
- * `resolveWord` reports `static: true`. Its non-static reasons are
491
- * `expansion`, `tilde`, `glob`, `brace`, `locale`, and `unsupported`.
492
- * Call the root `resolveWord` export instead when the reason matters.
507
+ * Without explicit options, `CallExpr.args` use command-argument context, so
508
+ * `PATH=a:~/bin` is literal there. Other positions retain the analyzer's
509
+ * conservative default, including tilde expansion after an unquoted colon.
510
+ * Explicit options are forwarded unchanged, even when empty.
493
511
  *
494
- * `options` is forwarded to `resolveWord` unchanged. When it is omitted, the
495
- * word's grammar position picks the tilde context: a word in a `CallExpr`'s
496
- * `args` uses `{ context: 'command-argument' }`, the context
497
- * `enumerateCommands` uses for argv, so `resolveWordText(callExpr.args[0])`
498
- * equals `getCommandName(callExpr)`. Any other word uses `resolveWord`'s
499
- * conservative default, which also treats a `~` after an unquoted `:` as a
500
- * tilde expansion, as assignment values do.
512
+ * @param word - A parsed Word from the lint view.
513
+ * @param options - Explicit analysis policy overriding grammar defaults.
514
+ * @returns Static text or the analyzer's reason the word is dynamic.
515
+ * @throws TypeError with `ESLINT_SH_WORD_NODE` when the word has no associated parsed shell syntax.
516
+ * @public
517
+ */
518
+ resolveWord(word, options) {
519
+ return resolveWord(word, options ?? this.#defaultWordOptions(word));
520
+ }
521
+ /**
522
+ * The text-only form of {@link ShellSourceCode.resolveWord}: returns its text
523
+ * exactly when static, otherwise `null`. Both methods share one policy path
524
+ * through `sh-ast/analyze`.
501
525
  *
502
- * @param word - A parsed `Word` node from this file's lint tree.
503
- * @param options - Forwarded to `resolveWord` unchanged when supplied.
526
+ * @param word - A parsed Word from the lint view.
527
+ * @param options - Explicit analysis policy overriding grammar defaults.
504
528
  * @returns The resolved text, or `null` when the word is not static.
505
- * @throws TypeError when `word` is not a parsed shell `Word`.
529
+ * @throws TypeError with `ESLINT_SH_WORD_NODE` when `word` is not a parsed shell `Word`.
530
+ * @public
506
531
  */
507
532
  resolveWordText(word, options) {
508
- const resolution = resolveWord(word, options ?? this.#defaultWordOptions(word));
533
+ const resolution = this.resolveWord(word, options);
509
534
  return resolution.static ? resolution.text : null;
510
535
  }
511
536
  /**
@@ -533,8 +558,8 @@ export class ShellSourceCode extends TextSourceCodeBase {
533
558
  *
534
559
  * @param callExpr - A parsed `CallExpr` node from this file's lint tree.
535
560
  * @returns The command word's static text, or `null`.
536
- * @throws TypeError when `callExpr` is not a parsed shell `CallExpr`.
537
- * @throws `ShAnalyzeMaxDepthError` (from `sh-ast/analyze`) when this file's
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
538
563
  * nesting exceeds analysis's recursion guard; see
539
564
  * {@link ShellSourceCode.resolveInvokedCommand}.
540
565
  */
@@ -580,10 +605,10 @@ export class ShellSourceCode extends TextSourceCodeBase {
580
605
  * `DEFAULT_TRANSPARENT_WRAPPERS`; spread the defaults into the array to
581
606
  * extend them instead.
582
607
  * @returns The resolution, or `null` when `callExpr` invokes no command.
583
- * @throws TypeError when `callExpr` is not a parsed shell `CallExpr`.
584
- * @throws `ShAnalyzeMaxDepthError` (from `sh-ast/analyze`) when this file's
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
585
610
  * nesting exceeds analysis's recursion guard.
586
- * @throws `ShAnalyzeInvalidWrapperSpecError` (from `sh-ast/analyze`) when
611
+ * @throws `ShAnalyzeInvalidWrapperSpecError` (`SH_AST_ANALYZE_INVALID_WRAPPER_SPEC`, from `sh-ast/analyze`) when
587
612
  * `options.transparentWrappers` contains a malformed entry.
588
613
  */
589
614
  resolveInvokedCommand(callExpr, options) {
@@ -618,7 +643,7 @@ export class ShellSourceCode extends TextSourceCodeBase {
618
643
  * does for those helpers: a partial list would silently omit real commands.
619
644
  *
620
645
  * @returns This file's command sites, in source order.
621
- * @throws `ShAnalyzeMaxDepthError` (from `sh-ast/analyze`) when this file's
646
+ * @throws `ShAnalyzeMaxDepthError` (`SH_AST_ANALYZE_MAX_DEPTH`, from `sh-ast/analyze`) when this file's
622
647
  * nesting exceeds analysis's recursion guard.
623
648
  */
624
649
  getCommandSites() {
@@ -686,7 +711,7 @@ export class ShellSourceCode extends TextSourceCodeBase {
686
711
  * printing"), so no second parse is involved. The copy owns its records,
687
712
  * arrays, positions and byte buffers. Editing it leaves this file's original
688
713
  * syntax, its lint view, its cached traversal and the answers of view-aware
689
- * helpers such as `resolveWord` and
714
+ * helpers such as {@link ShellSourceCode.resolveWord} and
690
715
  * {@link ShellSourceCode.resolveWordText} unchanged. Each call returns a new
691
716
  * copy.
692
717
  *
@@ -698,7 +723,7 @@ export class ShellSourceCode extends TextSourceCodeBase {
698
723
  *
699
724
  * @param node - A view node from this file's lint tree.
700
725
  * @returns A deep copy of `node`'s original sh-ast record.
701
- * @throws TypeError when `node` has no original record in this file: an
726
+ * @throws TypeError with `ESLINT_SH_FOREIGN_VIEW_NODE` when `node` has no original record in this file: an
702
727
  * auxiliary view (such as the `Slice` of `${x:1:2}`), a view node of another
703
728
  * file, or an object that did not come from the parser.
704
729
  */
@@ -738,13 +763,14 @@ export class ShellSourceCode extends TextSourceCodeBase {
738
763
  * `Command` or `WordPart`.
739
764
  * @param options - Forwarded to `printSync` unchanged.
740
765
  * @returns The range to replace and the printed text to put there.
741
- * @throws TypeError when `node` has no original record in this file (see
766
+ * @throws TypeError with `ESLINT_SH_FOREIGN_VIEW_NODE` when `node` has no original record in this file (see
742
767
  * {@link ShellSourceCode.getEditableSyntax}), when `edited` is not a
743
- * printable root (the message names its type), or when the printer's output
744
- * is not valid UTF-8, or the edited syntax contains literal vertical tabs or
745
- * form feeds that the printer cannot preserve. Non-UTF-8 output comes back
768
+ * printable root (`ESLINT_SH_PRINT_ROOT`; the message names its type), or when the printer's output
769
+ * is not valid UTF-8 (`ESLINT_SH_PRINT_ENCODING`), or the edited syntax contains literal vertical tabs or
770
+ * form feeds that the printer cannot preserve (`ESLINT_SH_PRINT_UNSAFE_TEXT`). Non-UTF-8 output comes back
746
771
  * from `printSync` as a `Uint8Array` and is never decoded lossily into a fix.
747
- * @throws `PrintError` or `PrintPanicError` (from sh-ast) when upstream's
772
+ * @throws `PrintError` (`SH_AST_SYNTAX_PRINT`), `PrintPanicError` (`SH_AST_SYNTAX_PRINT_PANIC`),
773
+ * or `InputError` (`SH_AST_SYNTAX_INPUT`), passed through unchanged from sh-ast, when upstream's
748
774
  * printer fails for `edited` or `options`.
749
775
  */
750
776
  getPrintedReplacement(node, edited, options) {
@@ -754,8 +780,8 @@ export class ShellSourceCode extends TextSourceCodeBase {
754
780
  refusePrinterControlCharacters(root);
755
781
  const printed = printSync(root, options);
756
782
  if (typeof printed !== 'string') {
757
- throw new TypeError('printSync produced output that is not valid UTF-8; a text fix cannot hold it without ' +
758
- 'lossy decoding');
783
+ throw Object.assign(new TypeError('printSync produced output that is not valid UTF-8; a text fix cannot hold it without ' +
784
+ 'lossy decoding'), { code: 'ESLINT_SH_PRINT_ENCODING' });
759
785
  }
760
786
  if (rootType === 'File') {
761
787
  return { range: [0, this.text.length], text: printed };
@@ -777,8 +803,8 @@ export class ShellSourceCode extends TextSourceCodeBase {
777
803
  #originalSyntaxFor(node) {
778
804
  const syntax = this.getSyntax(node);
779
805
  if (syntax === undefined) {
780
- throw new TypeError('expected a view node parsed from this file; auxiliary views, view nodes of other ' +
781
- 'files and objects that did not come from the parser have no original syntax');
806
+ throw Object.assign(new TypeError('expected a view node parsed from this file; auxiliary views, view nodes of other ' +
807
+ 'files and objects that did not come from the parser have no original syntax'), { code: 'ESLINT_SH_FOREIGN_VIEW_NODE' });
782
808
  }
783
809
  return syntax;
784
810
  }
@@ -796,12 +822,12 @@ export class ShellSourceCode extends TextSourceCodeBase {
796
822
  *
797
823
  * @param pos - A `SyntaxPos` from one of this file's original records.
798
824
  * @returns The UTF-16 index of `pos` in this file's text.
799
- * @throws RangeError when `pos` is invalid (`IsValid === false`), recovered
825
+ * @throws RangeError with `ESLINT_SH_SOURCE_RANGE` when `pos` is invalid (`IsValid === false`), recovered
800
826
  * (`IsRecovered === true`), or overflowed (`OffsetOverflow === true`), or
801
827
  * when its offset is not a UTF-8 character boundary of this source. Such a
802
828
  * position is never rounded to a nearby boundary.
803
- * @throws TypeError when `pos` is not a `SyntaxPos`, or when this source
804
- * code's tree was not built by this language's parser.
829
+ * @throws TypeError with `ESLINT_SH_SYNTAX_POSITION` when `pos` is not a `SyntaxPos`, or when this source
830
+ * code's tree was not built by this language's parser (`ESLINT_SH_FILE_NODE`).
805
831
  */
806
832
  getIndexFromSyntaxPos(pos) {
807
833
  return this.#coordinateAt(pos).index;
@@ -814,10 +840,10 @@ export class ShellSourceCode extends TextSourceCodeBase {
814
840
  *
815
841
  * @param pos - A `SyntaxPos` from one of this file's original records.
816
842
  * @returns The one-based line and UTF-16 column of `pos`.
817
- * @throws RangeError when `pos` is invalid, recovered, or overflowed, or
843
+ * @throws RangeError with `ESLINT_SH_SOURCE_RANGE` when `pos` is invalid, recovered, or overflowed, or
818
844
  * when its offset is not a UTF-8 character boundary of this source.
819
- * @throws TypeError when `pos` is not a `SyntaxPos`, or when this source
820
- * code's tree was not built by this language's parser.
845
+ * @throws TypeError with `ESLINT_SH_SYNTAX_POSITION` when `pos` is not a `SyntaxPos`, or when this source
846
+ * code's tree was not built by this language's parser (`ESLINT_SH_FILE_NODE`).
821
847
  */
822
848
  getLocFromSyntaxPos(pos) {
823
849
  const { line, column } = this.#coordinateAt(pos);
@@ -831,7 +857,7 @@ export class ShellSourceCode extends TextSourceCodeBase {
831
857
  #coordinateAt(pos) {
832
858
  const coordinates = projectedCoordinates(this.ast);
833
859
  if (coordinates === undefined) {
834
- throw new TypeError('expected a parsed shell File from this language adapter');
860
+ throw Object.assign(new TypeError('expected a parsed shell File from this language adapter'), { code: 'ESLINT_SH_FILE_NODE' });
835
861
  }
836
862
  return coordinates.fromByteOffset(exactByteOffset(pos));
837
863
  }
@@ -3,6 +3,8 @@
3
3
  * count bytes; this adapter derives UTF-16 indices and columns without replacing or
4
4
  * mutating the raw syntax position. Display widths, graphemes, and tab expansion
5
5
  * are deliberately outside this contract.
6
+ *
7
+ * ESLINT_SH_SOURCE_RANGE rejects an inexact or out-of-source boundary instead of inventing a location or edit range.
6
8
  */
7
9
  /** A source boundary expressed in JavaScript indexing and ESLint's one-based location convention. @internal */
8
10
  export interface ISourceCoordinate {
@@ -3,6 +3,8 @@
3
3
  * count bytes; this adapter derives UTF-16 indices and columns without replacing or
4
4
  * mutating the raw syntax position. Display widths, graphemes, and tab expansion
5
5
  * are deliberately outside this contract.
6
+ *
7
+ * ESLINT_SH_SOURCE_RANGE rejects an inexact or out-of-source boundary instead of inventing a location or edit range.
6
8
  */
7
9
  /**
8
10
  * Sentinel in the byte table for an offset that falls inside a multi-byte
@@ -69,14 +71,16 @@ export class SourceCoordinates {
69
71
  ? this.#byteIndices[offset]
70
72
  : INTERIOR_BYTE;
71
73
  if (index === INTERIOR_BYTE) {
72
- throw new RangeError(`byte offset ${String(offset)} is not a boundary in this source`);
74
+ throw Object.assign(new RangeError(`byte offset ${String(offset)} is not a boundary in this source`), { code: 'ESLINT_SH_SOURCE_RANGE' });
73
75
  }
74
76
  return this.atIndex(index);
75
77
  }
76
78
  /** Derive a one-based location from a known JavaScript source index. @internal */
77
79
  atIndex(index) {
78
80
  if (!Number.isInteger(index) || index < 0 || index > this.#length) {
79
- throw new RangeError(`UTF-16 index ${String(index)} is outside this source`);
81
+ throw Object.assign(new RangeError(`UTF-16 index ${String(index)} is outside this source`), {
82
+ code: 'ESLINT_SH_SOURCE_RANGE',
83
+ });
80
84
  }
81
85
  let low = 0;
82
86
  let high = this.#lineStarts.length;
@@ -100,12 +104,12 @@ export class SourceCoordinates {
100
104
  */
101
105
  indexAt(line, column) {
102
106
  if (!Number.isInteger(line) || line < 1 || line > this.#lineStarts.length) {
103
- throw new RangeError(`line ${String(line)} is outside this source (lines 1-${String(this.#lineStarts.length)})`);
107
+ throw Object.assign(new RangeError(`line ${String(line)} is outside this source (lines 1-${String(this.#lineStarts.length)})`), { code: 'ESLINT_SH_SOURCE_RANGE' });
104
108
  }
105
109
  const start = this.#lineStarts[line - 1];
106
110
  const last = line === this.#lineStarts.length ? this.#length : this.#lineStarts[line] - 1;
107
111
  if (!Number.isInteger(column) || column < 1 || start + column - 1 > last) {
108
- throw new RangeError(`column ${String(column)} is outside line ${String(line)} (columns 1-${String(last - start + 1)})`);
112
+ throw Object.assign(new RangeError(`column ${String(column)} is outside line ${String(line)} (columns 1-${String(last - start + 1)})`), { code: 'ESLINT_SH_SOURCE_RANGE' });
109
113
  }
110
114
  return start + column - 1;
111
115
  }
@@ -4,6 +4,8 @@
4
4
  * are consumer conventions; the original syntax remains untouched and associated
5
5
  * by identity. Bounds are observations of the original parse, tied to this exact
6
6
  * source. This is neither upstream Walk nor a replacement syntax model.
7
+ *
8
+ * ESLINT_SH_SYNTAX_VIEW identifies a record/snapshot invariant that prevents a faithful lint view; it never denotes invalid shell grammar.
7
9
  */
8
10
  import { SYNTAX_INTERFACES, SYNTAX_SCHEMA } from 'sh-ast';
9
11
  import { SourceCoordinates } from './source-coordinates.js';
@@ -122,7 +124,9 @@ function sourceText(value) {
122
124
  if (value instanceof Uint8Array) {
123
125
  return textDecoder.decode(value);
124
126
  }
125
- throw new TypeError('shell text view expected a Go string');
127
+ throw Object.assign(new TypeError('shell text view expected a Go string'), {
128
+ code: 'ESLINT_SH_SYNTAX_VIEW',
129
+ });
126
130
  }
127
131
  /**
128
132
  * Parser nodes whose view span was shortened by {@link endsBeforeCrlfNewline}.
@@ -177,7 +181,9 @@ export function withoutCrlfCarriageReturn(word, resolution) {
177
181
  */
178
182
  export function adaptSyntaxFile(file, source, positions) {
179
183
  if (!isRecord(positions) || typeof positions.get !== 'function') {
180
- throw new TypeError('shell view requires a source position snapshot');
184
+ throw Object.assign(new TypeError('shell view requires a source position snapshot'), {
185
+ code: 'ESLINT_SH_SYNTAX_VIEW',
186
+ });
181
187
  }
182
188
  const coordinates = new SourceCoordinates(source);
183
189
  const views = new WeakMap();
@@ -189,11 +195,15 @@ export function adaptSyntaxFile(file, source, positions) {
189
195
  /** Each projected record owns its derived fields, while real syntax nodes retain their original identity. */
190
196
  const project = (raw, fallback) => {
191
197
  if (!isRecord(raw) || typeof raw.Type !== 'string') {
192
- throw new TypeError('shell view expected a known upstream syntax record');
198
+ throw Object.assign(new TypeError('shell view expected a known upstream syntax record'), {
199
+ code: 'ESLINT_SH_SYNTAX_VIEW',
200
+ });
193
201
  }
194
202
  const plan = projectionPlans.get(raw.Type);
195
203
  if (plan === undefined) {
196
- throw new TypeError('shell view expected a known upstream syntax record');
204
+ throw Object.assign(new TypeError('shell view expected a known upstream syntax record'), {
205
+ code: 'ESLINT_SH_SYNTAX_VIEW',
206
+ });
197
207
  }
198
208
  const realNode = isSyntaxNode(raw);
199
209
  // eslint-disable-next-line @api-extractor-tools/forgotten-export -- This span belongs only to the private projection closure, not the exported signature.
@@ -203,7 +213,7 @@ export function adaptSyntaxFile(file, source, positions) {
203
213
  if (realNode) {
204
214
  const observed = positions.get(raw);
205
215
  if (observed === undefined) {
206
- throw new TypeError(`shell position snapshot has no observation for ${raw.Type}`);
216
+ throw Object.assign(new TypeError(`shell position snapshot has no observation for ${raw.Type}`), { code: 'ESLINT_SH_SYNTAX_VIEW' });
207
217
  }
208
218
  span = {
209
219
  start: position(observed.Pos, fallback.start),
@@ -235,7 +245,7 @@ export function adaptSyntaxFile(file, source, positions) {
235
245
  if (field.slice) {
236
246
  const items = value === null ? [] : value;
237
247
  if (!Array.isArray(items)) {
238
- throw new TypeError(`shell view expected ${raw.Type}.${field.name} to be a slice`);
248
+ throw Object.assign(new TypeError(`shell view expected ${raw.Type}.${field.name} to be a slice`), { code: 'ESLINT_SH_SYNTAX_VIEW' });
239
249
  }
240
250
  const projected = [];
241
251
  for (const item of items) {
@@ -278,7 +288,9 @@ export function adaptSyntaxFile(file, source, positions) {
278
288
  };
279
289
  const root = project(file, wholeSource);
280
290
  if (!isShellFile(root)) {
281
- throw new TypeError('shell view expected a File with statements');
291
+ throw Object.assign(new TypeError('shell view expected a File with statements'), {
292
+ code: 'ESLINT_SH_SYNTAX_VIEW',
293
+ });
282
294
  }
283
295
  projectedViews.set(root, views);
284
296
  projectedCommentsByRoot.set(root, comments);