@eslint-sh/eslint-plugin 0.2.0 → 0.4.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 (39) hide show
  1. package/README.md +12 -4
  2. package/dist/eslint-plugin.d.ts +95 -57
  3. package/dist/index.d.ts +12 -12
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +10 -12
  6. package/dist/index.js.map +1 -1
  7. package/dist/language/selector-classes.d.ts +6 -10
  8. package/dist/language/selector-classes.d.ts.map +1 -1
  9. package/dist/language/selector-classes.js +6 -9
  10. package/dist/language/selector-classes.js.map +1 -1
  11. package/dist/language/shell-language-options.d.ts +9 -11
  12. package/dist/language/shell-language-options.d.ts.map +1 -1
  13. package/dist/language/shell-language-options.js +7 -11
  14. package/dist/language/shell-language-options.js.map +1 -1
  15. package/dist/language/shell-language.d.ts +10 -12
  16. package/dist/language/shell-language.d.ts.map +1 -1
  17. package/dist/language/shell-language.js +45 -79
  18. package/dist/language/shell-language.js.map +1 -1
  19. package/dist/language/shell-source-code.d.ts +10 -19
  20. package/dist/language/shell-source-code.d.ts.map +1 -1
  21. package/dist/language/shell-source-code.js +165 -62
  22. package/dist/language/shell-source-code.js.map +1 -1
  23. package/dist/language/source-coordinates.d.ts +23 -0
  24. package/dist/language/source-coordinates.d.ts.map +1 -0
  25. package/dist/language/source-coordinates.js +58 -0
  26. package/dist/language/source-coordinates.js.map +1 -0
  27. package/dist/language/syntax-view.d.ts +60 -0
  28. package/dist/language/syntax-view.d.ts.map +1 -0
  29. package/dist/language/syntax-view.js +164 -0
  30. package/dist/language/syntax-view.js.map +1 -0
  31. package/dist/language/word-resolution.d.ts +11 -0
  32. package/dist/language/word-resolution.d.ts.map +1 -0
  33. package/dist/language/word-resolution.js +18 -0
  34. package/dist/language/word-resolution.js.map +1 -0
  35. package/docs/custom-rule-tutorial.md +23 -12
  36. package/docs/examples/eslint.config.mjs +1 -1
  37. package/docs/examples/{no-rm-rf-rule.js → no-rm-rf-rule.mjs} +9 -4
  38. package/docs/selectors.md +9 -0
  39. package/package.json +9 -3
@@ -1,5 +1,5 @@
1
1
  import { ConfigCommentParser, Directive, TextSourceCodeBase, VisitNodeStep, } from '@eslint/plugin-kit';
2
- import { visitorKeys as shellVisitorKeys, walk } from 'sh-ast';
2
+ import { isShellComment, isShellNode, shellVisitorKeys, walkShell } from './syntax-view.js';
3
3
  /**
4
4
  * Shared instance — `ConfigCommentParser` is stateless (see
5
5
  * `@eslint/plugin-kit`'s implementation), so every `ShellSourceCode`
@@ -47,28 +47,158 @@ function getCommentText(comment) {
47
47
  return typeof text === 'string' ? text : '';
48
48
  }
49
49
  /**
50
- * Narrows an unknown field value to a normalized `ShNode` — used while
51
- * traversing (see `ShellSourceCode.traverse()` below) to tell an actual
52
- * child node apart from a scalar field (e.g. `Lit.value: string`) or
53
- * `undefined`.
54
- * Deliberately duck-typed (checks only `type`, matching
55
- * `ShellLanguage.nodeTypeKey`) rather than re-validating the full `ShNode`
56
- * shape — every value reachable through a `visitorKeys` field on a bridge
57
- * AST is either a normalized node or absent, by construction of
58
- * `sh-ast`'s `normalize()`.
50
+ * Length of the line terminator starting at `text[index]` — `2` for `\r\n`,
51
+ * `1` for a lone `\n` or a lone `\r` (classic-Mac style), `0` if `index`
52
+ * isn't the start of a line terminator at all (including end of string).
53
+ * Shared by both the forward-widening check and the preceding-line
54
+ * continuation check in {@link computeUnusedDirectiveFixRange} so both
55
+ * agree on what counts as "a newline" regardless of the file's line-ending
56
+ * convention.
59
57
  */
60
- function isShNode(value) {
61
- return (typeof value === 'object' &&
62
- value !== null &&
63
- typeof value.type === 'string');
58
+ function newlineLengthAt(text, index) {
59
+ if (text[index] === '\n')
60
+ return 1;
61
+ if (text[index] === '\r')
62
+ return text[index + 1] === '\n' ? 2 : 1;
63
+ return 0;
64
+ }
65
+ /**
66
+ * Computes the `.range` to hand `@eslint/plugin-kit`'s `Directive` as its
67
+ * backing `node` (see {@link ShellSourceCode.getDisableDirectives}) so that
68
+ * ESLint core's unused-directive `--fix` (issue #64, criterion 7) removes a
69
+ * whole-line directive comment cleanly instead of leaving a stray
70
+ * whitespace-only line, in the cases where that can be done **without
71
+ * risking a change to the fixed script's behavior**.
72
+ *
73
+ * ESLint core's `apply-disable-directives.js` (`createDirectiveRemoval`)
74
+ * always replaces whatever range `sourceCode.getRange(directive.node)`
75
+ * reports with a single literal `" "` — this is hardcoded, not something a
76
+ * `Language`/`SourceCode` can override. Reporting the comment's own bare
77
+ * range (`[start, end)`, spanning only the `#...` text) therefore autofixes
78
+ * `"echo hi\n# eslint-disable-next-line sh/foo -- x\necho bye\n"` into
79
+ * `"echo hi\n \necho bye\n"`: the forced space lands where the comment was,
80
+ * and the newlines on both sides of it are untouched, leaving a line that
81
+ * contains nothing but that one space.
82
+ *
83
+ * Widening the reported range forward to also swallow the newline
84
+ * *immediately following* the comment turns that same forced single-space
85
+ * insertion into a harmless leading space on the next real line instead of
86
+ * a line of its own — shell ignores leading whitespace before a command, so
87
+ * this has no effect on the fixed script's behavior. This is the **only**
88
+ * direction ever widened, and only when every one of the following holds:
89
+ *
90
+ * - The comment is genuinely alone on its source line (nothing but leading
91
+ * whitespace precedes it — mvdan/sh's `#` comments always run to end of
92
+ * line, so nothing but the line terminator can follow it). A directive
93
+ * trailing real code on the same line (e.g.
94
+ * `echo hi # eslint-disable-line sh/foo -- x`) keeps the bare range: the
95
+ * existing "single space where the comment was, code stays on the line"
96
+ * behavior is already correct there, and widening would eat into the
97
+ * following line's content instead.
98
+ * - A line terminator (`\n`, `\r\n`, or a lone `\r`) immediately follows the
99
+ * comment, *and* real content follows that terminator. A directive on the
100
+ * file's last line with a trailing terminator but nothing after it (e.g.
101
+ * `"echo hi\n# directive\n"`, EOF right after) has nothing for the forced
102
+ * space to attach to as a leading space — widening there would only move
103
+ * the stray-whitespace problem from a line of its own to a trailing space
104
+ * with no line terminator at all, which is no better.
105
+ * - The physical line immediately preceding the comment's own line does
106
+ * **not** end in an unescaped (odd count of trailing `\`) line-
107
+ * continuation backslash. If it does, the comment's line is not a fresh
108
+ * statement — it's a continuation of the previous logical line — and the
109
+ * terminator right after the comment is what finally closes that still-
110
+ * open logical line. Swallowing it would splice whatever follows into
111
+ * that statement instead of starting a new one (reproduced: a `printf`
112
+ * command continued with `\` onto a line holding only the directive
113
+ * comment, followed by `echo bye`, autofixes from printing `<hi>` then
114
+ * `bye` to printing `<hi>`, `<echo>`, `<bye>` — `echo` and `bye` become
115
+ * extra `printf` arguments instead of a separate command).
116
+ *
117
+ * Backward widening (attaching the forced space as a *trailing* space on
118
+ * the *previous* line, for a directive on the file's last line with no
119
+ * trailing terminator at all) is deliberately never attempted, even though
120
+ * it would close that one remaining gap: joining the directive's line into
121
+ * whatever precedes it is not generally safe to do from text alone. A
122
+ * heredoc terminator line immediately before the directive is the sharpest
123
+ * counterexample — `"cat <<EOF\nbody\nEOF\n# eslint-disable-next-line ...".`
124
+ * (no trailing newline) would widen back across the newline that terminates
125
+ * the `EOF` line, and the forced single-space replacement respells the
126
+ * terminator as `"EOF "`, which no longer matches `<<EOF` (bash requires the
127
+ * terminator alone on its line); the next lint pass reports "unclosed
128
+ * here-document" and bash itself would read the following content as more
129
+ * heredoc body. An escaped continuation ending the previous line has the
130
+ * same problem in the backward direction. Detecting "the previous line is a
131
+ * heredoc terminator" reliably from text alone isn't tractable here (it
132
+ * depends on quoting/tab-stripping rules this function has no access to);
133
+ * fully safe removal in this one last-line/no-trailing-newline case would
134
+ * need an upstream ESLint core mechanism (e.g. a fixer that can express
135
+ * "remove and also delete one adjacent newline") rather than range
136
+ * manipulation, so this function leaves the bare (non-widened) range there
137
+ * — the pre-existing, but never behavior-changing, whitespace-only-line
138
+ * outcome — rather than risk corrupting the script.
139
+ */
140
+ function computeUnusedDirectiveFixRange(comment, text) {
141
+ const [start, end] = comment.range;
142
+ const lineStart = text.lastIndexOf('\n', start - 1) + 1;
143
+ const textBeforeOnLine = text.slice(lineStart, start);
144
+ if (!/^[ \t]*$/u.test(textBeforeOnLine)) {
145
+ return comment.range;
146
+ }
147
+ const newlineLength = newlineLengthAt(text, end);
148
+ if (newlineLength === 0) {
149
+ // Last line, no trailing terminator at all — nothing safe to widen into
150
+ // (see the doc comment's "Backward widening" section).
151
+ return comment.range;
152
+ }
153
+ if (end + newlineLength >= text.length) {
154
+ // A trailing terminator, but nothing follows it — no next line to
155
+ // attach the forced space to as harmless leading whitespace.
156
+ return comment.range;
157
+ }
158
+ if (lineStart > 0) {
159
+ // Find where the *previous* physical line's real content ends (i.e.
160
+ // strip that line's own terminator, which sits directly before
161
+ // `lineStart`) so trailing-backslash counting only looks at content,
162
+ // never at `\n`/`\r`.
163
+ let previousLineContentEnd = lineStart - 1;
164
+ if (text[previousLineContentEnd] === '\n' && text[previousLineContentEnd - 1] === '\r') {
165
+ previousLineContentEnd -= 1;
166
+ }
167
+ let backslashRun = 0;
168
+ let cursor = previousLineContentEnd - 1;
169
+ while (cursor >= 0 && text[cursor] === '\\') {
170
+ backslashRun += 1;
171
+ cursor -= 1;
172
+ }
173
+ if (backslashRun % 2 === 1) {
174
+ // The previous line ends in an unescaped continuation backslash —
175
+ // this comment's line isn't a fresh statement (see the doc comment's
176
+ // continuation bullet).
177
+ return comment.range;
178
+ }
179
+ }
180
+ return [start, end + newlineLength];
181
+ }
182
+ /**
183
+ * Wraps `comment` in a shallow copy whose `.range` is
184
+ * {@link computeUnusedDirectiveFixRange}'s (possibly widened) range, while
185
+ * every other property — critically `.loc`, which ESLint core also reads
186
+ * off this same object to compute both the "unused directive" warning's
187
+ * reported location and a `disable-next-line` directive's target line — is
188
+ * byte-for-byte `comment`'s own. Widening only `.range` therefore changes
189
+ * what the unused-directive autofix removes without changing where
190
+ * anything is *reported*.
191
+ */
192
+ function withUnusedDirectiveFixRange(comment, text) {
193
+ const range = computeUnusedDirectiveFixRange(comment, text);
194
+ return range === comment.range ? comment : { ...comment, range };
64
195
  }
65
196
  /**
66
197
  * `ShellSourceCode` — the `SourceCode` object ESLint uses to work with a
67
- * parsed shell file (design/ARCHITECTURE.md, "SourceCode and Language
68
- * objects"). Extends `@eslint/plugin-kit`'s `TextSourceCodeBase`, which
198
+ * parsed shell file. Extends `@eslint/plugin-kit`'s `TextSourceCodeBase`, which
69
199
  * already implements `getLoc`/`getRange`/`getText`/`lines` (both by reading
70
200
  * the normalized node's own `loc`/`range` fields — see
71
- * `sh-ast`'s "Normalized node shape"), `getLocFromIndex`, and
201
+ * the consumer's source-view contract), `getLocFromIndex`, and
72
202
  * `getIndexFromLoc`; this class adds the two members the base class
73
203
  * deliberately leaves unimplemented: `traverse()` (base throws "Not
74
204
  * implemented") and `getParent()` (base throws "Not implemented", and
@@ -80,7 +210,7 @@ function isShNode(value) {
80
210
  * (`<prefix>-disable`, `<prefix>-enable`, `<prefix>-disable-line`,
81
211
  * `<prefix>-disable-next-line`) plus whole-file inline rule config
82
212
  * (bare `<prefix> <rule-config>`), sourced from `Comment` nodes gathered via
83
- * `sh-ast`'s structural `walk()` and parsed with
213
+ * the consumer's `walkShell()` and parsed with
84
214
  * `@eslint/plugin-kit`'s `ConfigCommentParser` — the same building blocks
85
215
  * `@eslint/json`'s `JSONSourceCode` uses, generalized so the `<prefix>` is
86
216
  * configurable (default `"eslint"`; see `ShellLanguageOptions.directivePrefix`)
@@ -101,8 +231,8 @@ export class ShellSourceCode extends TextSourceCodeBase {
101
231
  */
102
232
  #parents = new WeakMap();
103
233
  /**
104
- * Cached traversal steps — the AST never mutates after `parse()` returns
105
- * it, so `traverse()` only needs to compute this once (mirroring
234
+ * Cached traversal steps — the lint view is a snapshot independent of later
235
+ * raw syntax edits, so `traverse()` only needs to compute this once (mirroring
106
236
  * `@eslint/json`'s `JSONSourceCode`).
107
237
  */
108
238
  #steps;
@@ -124,15 +254,9 @@ export class ShellSourceCode extends TextSourceCodeBase {
124
254
  */
125
255
  #inlineConfigPattern;
126
256
  /**
127
- * Every `Comment` node in the AST, gathered once (cached) via
128
- * `sh-ast`'s `walk()` — deliberately *not* derived from
129
- * `traverse()`/`visitorKeys` even though, verified against a real parse,
130
- * `comments` and `last` already appear in the generated `visitorKeys`
131
- * table (so `traverse()` does visit `Comment` nodes today too). `walk()`
132
- * discovers children structurally rather than through that table (see its
133
- * own doc comment: the hand-written table once missed a field and
134
- * silently under-walked), so comment collection keeps working even if a
135
- * future `visitorKeys` regeneration omits a comment-bearing field.
257
+ * Comments gathered through the consumer's child graph. Source-order sorting
258
+ * is required for repeated inline configuration; schema field order does not
259
+ * encode physical source order. The lint view is a stable parse snapshot.
136
260
  */
137
261
  #comments;
138
262
  /**
@@ -161,17 +285,9 @@ export class ShellSourceCode extends TextSourceCodeBase {
161
285
  return this.#parents.get(node);
162
286
  }
163
287
  /**
164
- * Traverses the AST pre-order, yielding a `VisitNodeStep` on node enter
165
- * (`phase: 1`) and another on node exit (`phase: 2`) for every node —
166
- * exactly the two-phase shape `@eslint/json`/`@eslint/css` produce, which
167
- * is what lets rule listeners use `NodeType` and `NodeType:exit` esquery
168
- * selectors. Children are discovered via `sh-ast`'s generated,
169
- * frozen `visitorKeys` table (per node `type`) — **not** structurally
170
- * (contrast `sh-ast`'s own `walk()`, which deliberately walks
171
- * structurally so its correctness never depends on that table) — because
172
- * ESLint's traversal contract is defined in terms of a language's
173
- * declared `visitorKeys`, and this class's whole job is to honor that
174
- * contract for shell ASTs.
288
+ * Produces the enter/exit steps ESLint uses for selectors and ancestor lookup.
289
+ * Child keys describe the consumer view, including its auxiliary records.
290
+ * This callback protocol is ESLint's, independent of upstream syntax.Walk.
175
291
  */
176
292
  traverse() {
177
293
  if (this.#steps) {
@@ -189,12 +305,12 @@ export class ShellSourceCode extends TextSourceCodeBase {
189
305
  const value = node[key];
190
306
  if (Array.isArray(value)) {
191
307
  for (const child of value) {
192
- if (isShNode(child)) {
308
+ if (isShellNode(child)) {
193
309
  visit(child, node);
194
310
  }
195
311
  }
196
312
  }
197
- else if (isShNode(value)) {
313
+ else if (isShellNode(value)) {
198
314
  visit(value, node);
199
315
  }
200
316
  }
@@ -204,28 +320,15 @@ export class ShellSourceCode extends TextSourceCodeBase {
204
320
  return steps.values();
205
321
  }
206
322
  /**
207
- * Returns every `Comment` node in the AST, in source order, gathering them
208
- * (once, cached) via `sh-ast`'s structural `walk()` rather than
209
- * `traverse()` — see `#comments`'s doc comment for why.
210
- *
211
- * `walk()` discovers children in AST field/insertion order (e.g.
212
- * `Stmt.comments` before descending into `Stmt.cmd`'s own nested
213
- * comments), which is not guaranteed to match *source* order — a comment
214
- * trailing an early statement can be visited after a comment buried
215
- * inside a later command substitution's own sub-tree, depending on field
216
- * layout. `getDisableDirectives()`'s `disable`/`enable` ranges happen to
217
- * be safe regardless (ESLint core re-sorts directives by location
218
- * internally), but `applyInlineConfig()`'s "last inline-config comment
219
- * wins" semantics for a repeated whole-file rule config, and any external
220
- * caller of `getInlineConfigNodes()`, both depend on source order. Sorting
221
- * once here — rather than requiring every consumer to re-sort — is the
222
- * fix that's correct regardless of how `walk()` happens to traverse.
323
+ * Returns retained comments in source order. Reflection-field order can place
324
+ * a later enclosing comment before an earlier nested comment, so sort by the
325
+ * exact derived source span before directive and inline-config processing.
223
326
  */
224
327
  #getComments() {
225
328
  if (!this.#comments) {
226
329
  const comments = [];
227
- walk(this.ast, (node) => {
228
- if (node.type === 'Comment') {
330
+ walkShell(this.ast, (node) => {
331
+ if (isShellComment(node)) {
229
332
  comments.push(node);
230
333
  }
231
334
  });
@@ -275,7 +378,7 @@ export class ShellSourceCode extends TextSourceCodeBase {
275
378
  if (directiveType) {
276
379
  directives.push(new Directive({
277
380
  type: directiveType,
278
- node: comment,
381
+ node: withUnusedDirectiveFixRange(comment, this.text),
279
382
  value: parsed.value,
280
383
  justification: parsed.justification,
281
384
  }));
@@ -293,7 +396,7 @@ export class ShellSourceCode extends TextSourceCodeBase {
293
396
  * calling this method — and `getDisableDirectives`, together, since both
294
397
  * are gated by the same flag in `eslint`'s own `linter.js` — and instead
295
398
  * calls `getInlineConfigNodes` to emit a "has no effect" warning per
296
- * comment; see design/ARCHITECTURE.md, "SourceCode and Language objects").
399
+ * comment).
297
400
  */
298
401
  applyInlineConfig() {
299
402
  const problems = [];
@@ -1 +1 @@
1
- {"version":3,"file":"shell-source-code.js","sourceRoot":"","sources":["../../src/language/shell-source-code.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,SAAS,EACT,kBAAkB,EAClB,aAAa,GACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,WAAW,IAAI,gBAAgB,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAY/D;;;;GAIG;AACH,MAAM,aAAa,GAAG,IAAI,mBAAmB,EAAE,CAAC;AAEhD;;;;;;;;GAQG;AACH,SAAS,wBAAwB,CAAC,eAAuB;IACvD,MAAM,aAAa,GAAG,eAAe,CAAC,OAAO,CAAC,sBAAsB,EAAE,MAAM,CAAC,CAAC;IAC9E,OAAO,IAAI,MAAM,CAAC,QAAQ,aAAa,oDAAoD,EAAE,GAAG,CAAC,CAAC;AACpG,CAAC;AAED;;;;;GAKG;AACH,SAAS,oBAAoB,CAAC,eAAuB;IACnD,OAAO,IAAI,GAAG,CAAwB;QACpC,CAAC,GAAG,eAAe,UAAU,EAAE,SAAS,CAAC;QACzC,CAAC,GAAG,eAAe,SAAS,EAAE,QAAQ,CAAC;QACvC,CAAC,GAAG,eAAe,oBAAoB,EAAE,mBAAmB,CAAC;QAC7D,CAAC,GAAG,eAAe,eAAe,EAAE,cAAc,CAAC;KACpD,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,cAAc,CAAC,OAAe;IACrC,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;IACzB,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;AAC9C,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,CACL,OAAO,KAA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AAC;QAE9E,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,oBAAoB,EAAE,EAAE,CAAC;YAClD,MAAM,MAAM,GAAG,aAAa,CAAC,cAAc,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;YACrE,IAAI,MAAM,EAAE,KAAK,KAAK,IAAI,CAAC,gBAAgB,EAAE,CAAC;gBAC5C,SAAS;YACX,CAAC;YAED,MAAM,WAAW,GAAG,aAAa,CAAC,mBAAmB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACpE,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YACjC,IAAI,WAAW,CAAC,EAAE,EAAE,CAAC;gBACnB,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;YAC/D,CAAC;iBAAM,CAAC;gBACN,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC;YAC3E,CAAC;QACH,CAAC;QAED,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;IAC/B,CAAC;CACF"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Coordinates belong to the exact source string ESLint indexes. Upstream positions
3
+ * count bytes; this adapter derives UTF-16 indices and columns without replacing or
4
+ * mutating the raw syntax position. Display widths, graphemes, and tab expansion
5
+ * are deliberately outside this contract.
6
+ */
7
+ /** A source boundary expressed in JavaScript indexing and ESLint's one-based location convention. @internal */
8
+ export interface ISourceCoordinate {
9
+ readonly index: number;
10
+ readonly line: number;
11
+ readonly column: number;
12
+ }
13
+ /** Source-bound conversion shared by tree projection and diagnostic adaptation. @internal */
14
+ export declare class SourceCoordinates {
15
+ #private;
16
+ /** Build one reusable coordinate index for the exact source passed to the parser. @internal */
17
+ constructor(source: string);
18
+ /** Reject mismatched/out-of-source/interior-byte positions rather than inventing a fix boundary. @internal */
19
+ fromByteOffset(offset: number): ISourceCoordinate;
20
+ /** Derive a one-based location from a known JavaScript source index. @internal */
21
+ atIndex(index: number): ISourceCoordinate;
22
+ }
23
+ //# sourceMappingURL=source-coordinates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source-coordinates.d.ts","sourceRoot":"","sources":["../../src/language/source-coordinates.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,+GAA+G;AAC/G,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,6FAA6F;AAC7F,qBAAa,iBAAiB;;IAQ5B,+FAA+F;gBACnF,MAAM,EAAE,MAAM;IAgB1B,8GAA8G;IAC9G,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB;IAQjD,kFAAkF;IAClF,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,iBAAiB;CAgB1C"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Coordinates belong to the exact source string ESLint indexes. Upstream positions
3
+ * count bytes; this adapter derives UTF-16 indices and columns without replacing or
4
+ * mutating the raw syntax position. Display widths, graphemes, and tab expansion
5
+ * are deliberately outside this contract.
6
+ */
7
+ /** Source-bound conversion shared by tree projection and diagnostic adaptation. @internal */
8
+ export class SourceCoordinates {
9
+ /** Only complete UTF-8 character boundaries have meaningful JavaScript counterparts. */
10
+ #byteIndices = new Map();
11
+ /** UTF-16 start indices of lines; CRLF becomes one line break at its LF. */
12
+ #lineStarts = [0];
13
+ /** The source extent constrains all derived ranges, including empty-file fallback. */
14
+ #length;
15
+ /** Build one reusable coordinate index for the exact source passed to the parser. @internal */
16
+ constructor(source) {
17
+ this.#length = source.length;
18
+ let bytes = 0;
19
+ let index = 0;
20
+ this.#byteIndices.set(0, 0);
21
+ const encoder = new TextEncoder();
22
+ for (const character of source) {
23
+ bytes += encoder.encode(character).length;
24
+ index += character.length;
25
+ this.#byteIndices.set(bytes, index);
26
+ if (character === '\n') {
27
+ this.#lineStarts.push(index);
28
+ }
29
+ }
30
+ }
31
+ /** Reject mismatched/out-of-source/interior-byte positions rather than inventing a fix boundary. @internal */
32
+ fromByteOffset(offset) {
33
+ const index = this.#byteIndices.get(offset);
34
+ if (!Number.isInteger(offset) || index === undefined) {
35
+ throw new RangeError(`byte offset ${String(offset)} is not a boundary in this source`);
36
+ }
37
+ return this.atIndex(index);
38
+ }
39
+ /** Derive a one-based location from a known JavaScript source index. @internal */
40
+ atIndex(index) {
41
+ if (!Number.isInteger(index) || index < 0 || index > this.#length) {
42
+ throw new RangeError(`UTF-16 index ${String(index)} is outside this source`);
43
+ }
44
+ let low = 0;
45
+ let high = this.#lineStarts.length;
46
+ while (low + 1 < high) {
47
+ const middle = Math.floor((low + high) / 2);
48
+ if (this.#lineStarts[middle] <= index) {
49
+ low = middle;
50
+ }
51
+ else {
52
+ high = middle;
53
+ }
54
+ }
55
+ return { index, line: low + 1, column: index - this.#lineStarts[low] + 1 };
56
+ }
57
+ }
58
+ //# sourceMappingURL=source-coordinates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source-coordinates.js","sourceRoot":"","sources":["../../src/language/source-coordinates.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH,6FAA6F;AAC7F,MAAM,OAAO,iBAAiB;IAC5B,wFAAwF;IAC/E,YAAY,GAAG,IAAI,GAAG,EAAkB,CAAC;IAClD,4EAA4E;IACnE,WAAW,GAAa,CAAC,CAAC,CAAC,CAAC;IACrC,sFAAsF;IAC7E,OAAO,CAAS;IAEzB,+FAA+F;IAC/F,YAAY,MAAc;QACxB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC;QAC7B,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,IA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AC,MAAM,CAAC;QACnC,OAAO,GAAG,GAAG,CAAC,GAAG,IAAI,EAAE,CAAC;YACtB,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;YAC5C,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;gBACtC,GAAG,GAAG,MAAM,CAAC;YACf,CAAC;iBAAM,CAAC;gBACN,IAAI,GAAG,MAAM,CAAC;YAChB,CAAC;QACH,CAAC;QACD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,GAAG,CAAC,EAAE,MAAM,EAAE,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;IAC7E,CAAC;CACF"}
@@ -0,0 +1,60 @@
1
+ import type { File, Node as SyntaxNode, PositionSnapshot } from 'sh-ast';
2
+ /** An ESLint location counts UTF-16 units, with both line and column starting at one. @public */
3
+ export interface ShellPosition {
4
+ /** One-based source line, with CRLF treated as one line break. */
5
+ readonly line: number;
6
+ /** One-based UTF-16 column; tabs and grapheme widths are not expanded. */
7
+ readonly column: number;
8
+ }
9
+ /**
10
+ * A node in the consumer's lint view. Scalar/child fields use lowercase upstream
11
+ * spellings; syntax fidelity belongs to the associated upstream tree. Auxiliary
12
+ * view nodes may have spans derived from children and are not upstream Nodes.
13
+ * @public
14
+ */
15
+ export interface ShellNode {
16
+ /** Original syntax kind retained as the discriminator for lint selectors. */
17
+ readonly type: string;
18
+ /** Half-open UTF-16 span used to slice source and place fixes. */
19
+ readonly range: readonly [number, number];
20
+ /** Source-derived endpoints for ESLint diagnostics. */
21
+ readonly loc: {
22
+ readonly start: ShellPosition;
23
+ readonly end: ShellPosition;
24
+ };
25
+ /** Lowercase syntax fields containing consumer children or decoded scalar values. */
26
+ readonly [field: string]: unknown;
27
+ }
28
+ /** The lint root has a statement collection even when upstream represents it as nil. @public */
29
+ export interface ShellFile extends ShellNode {
30
+ /** Root discriminator retained for selectors. */
31
+ readonly type: 'File';
32
+ /** Top-level statements in source order; nil upstream slices become an empty view. */
33
+ readonly stmts: readonly ShellNode[];
34
+ }
35
+ /** Directive processing uses the comment text without its leading shell hash. @public */
36
+ export interface ShellComment extends ShellNode {
37
+ /** Comment discriminator used by directive collection. */
38
+ readonly type: 'Comment';
39
+ /** Decoded comment content after the leading hash, preserving its whitespace. */
40
+ readonly text: string;
41
+ }
42
+ /** ESLint child relationships follow the consumer projection, including auxiliary views; not upstream Walk ordering. @internal */
43
+ export declare const shellVisitorKeys: Readonly<Record<string, readonly string[]>>;
44
+ /** Identifies projected children without confusing raw position records or byte strings with nodes. @internal */
45
+ export declare function isShellNode(value: unknown): value is ShellNode;
46
+ /** Directive processing requires both the comment kind and its decoded text. @internal */
47
+ export declare function isShellComment(node: ShellNode): node is ShellComment;
48
+ /** Returns the actual parser node, or undefined for consumer-created/synthetic views. @internal */
49
+ export declare function syntaxForNode(node: ShellNode): SyntaxNode | undefined;
50
+ /**
51
+ * Builds a source-bound view immediately from one parse's File and Positions.
52
+ * Snapshot bounds describe that original parse, never subsequent syntax edits.
53
+ * A missing observation indicates a mismatched/incomplete snapshot and cannot be
54
+ * repaired by querying live syntax without reintroducing repeated subtree work.
55
+ * @internal
56
+ */
57
+ export declare function adaptSyntaxFile(file: File, source: string, positions: PositionSnapshot): ShellFile;
58
+ /** Consumer traversal visits each projected child, including auxiliary views, without claiming upstream Walk control semantics. @internal */
59
+ export declare function walkShell(root: ShellNode, visit: (node: ShellNode) => void): void;
60
+ //# sourceMappingURL=syntax-view.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"syntax-view.d.ts","sourceRoot":"","sources":["../../src/language/syntax-view.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,IAAI,EAAE,IAAI,IAAI,UAAU,EAAE,gBAAgB,EAAa,MAAM,QAAQ,CAAC;AAIpF,iGAAiG;AACjG,M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