@eslint-sh/eslint-plugin 0.9.0 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -29
- package/dist/api.d.ts +4 -4
- package/dist/command-harvest/builtins/bats.d.ts +1 -1
- package/dist/command-harvest/harvest-commands.d.ts +18 -7
- package/dist/command-harvest/harvest-commands.js +11 -10
- package/dist/command-harvest/wrapper-table.d.ts +1 -1
- package/dist/command-harvest/wrapper-table.js +1 -1
- package/dist/eslint-plugin-api.d.ts +71 -60
- package/dist/language/command-resolution.d.ts +44 -10
- package/dist/language/command-resolution.js +39 -13
- package/dist/language/shell-source-code.d.ts +31 -47
- package/dist/language/shell-source-code.js +47 -62
- package/dist/language/syntax-clone.d.ts +29 -0
- package/dist/language/syntax-clone.js +76 -0
- package/dist/language/syntax-view.d.ts +23 -2
- package/dist/language/syntax-view.js +166 -33
- package/dist/language/word-resolution.d.ts +2 -2
- package/dist/language/word-resolution.js +2 -2
- package/dist/rules/compat/declaration-options.js +2 -2
- package/dist/rules/compat/no-brace-sequence-padding-step.js +1 -1
- package/dist/rules/compat/no-mapfile.js +2 -2
- package/dist/rules/compat/no-negative-array-index.js +2 -2
- package/dist/rules/compat/no-printf-time-format.js +2 -2
- package/dist/rules/compat/no-test-v.js +5 -3
- package/dist/rules/compat/no-wait-n.js +2 -2
- package/dist/rules/compat/nounset-array-proof.js +16 -9
- package/dist/rules/compat/posix-absent-command.js +2 -2
- package/dist/rules/compat/shopt-options.js +2 -2
- package/dist/rules/create-wrapper-rule.d.ts +3 -3
- package/dist/rules/create-wrapper-rule.js +8 -4
- package/dist/rules/no-dynamic-invocation.d.ts +1 -1
- package/dist/rules/no-dynamic-invocation.js +12 -4
- package/dist/rules/no-eval.js +6 -2
- package/dist/rules/no-masked-exit-status.d.ts +12 -0
- package/dist/rules/no-masked-exit-status.js +27 -17
- package/dist/rules/no-secret-env-reads.js +1 -1
- package/dist/rules/no-unchecked-cd.js +28 -21
- package/dist/rules/no-undeclared-commands.js +2 -1
- package/dist/rules/no-unused-declarations.js +7 -2
- package/dist/rules/prefer-local.js +10 -8
- package/dist/rules/quote-expansions.js +1 -1
- package/dist/rules/require-network-wrapper.d.ts +1 -1
- package/dist/rules/require-network-wrapper.js +10 -4
- package/dist/rules/require-tty-guard.js +1 -1
- package/dist/rules/resolve-network-wrapper.d.ts +2 -2
- package/dist/rules/resolve-network-wrapper.js +6 -6
- package/dist/rules/resolve-transparent-wrappers.d.ts +1 -1
- package/dist/rules/resolve-transparent-wrappers.js +2 -2
- package/dist/rules/transparent-wrappers.d.ts +3 -3
- package/dist/rules/transparent-wrappers.js +1 -1
- package/docs/custom-rule-tutorial.md +35 -35
- package/docs/error-codes.md +6 -5
- package/docs/examples/no-backticks-rule.mjs +1 -1
- package/docs/examples/no-curl-in-functions-rule.mjs +2 -2
- package/docs/examples/no-listed-commands-rule.ts +1 -1
- package/docs/examples/no-rm-rf-rule.mjs +1 -1
- package/docs/rules/no-dynamic-invocation.md +5 -0
- package/docs/rules/no-undeclared-commands.md +4 -0
- package/docs/rules/no-unused-declarations.md +4 -0
- package/docs/rules/require-network-wrapper.md +1 -1
- package/docs/selectors.md +1 -1
- package/docs/wrapper-rules.md +1 -1
- package/package.json +12 -23
- package/dist/eslint-plugin-syntax-analyze.d.ts +0 -23
- package/dist/eslint-plugin-syntax.d.ts +0 -30
- package/dist/syntax/analyze.d.ts +0 -19
- package/dist/syntax/analyze.js +0 -21
- package/dist/syntax/index.d.ts +0 -26
- package/dist/syntax/index.js +0 -28
|
@@ -24,7 +24,7 @@ project's `"type"` field.
|
|
|
24
24
|
## 1. Pick a selector from the cookbook
|
|
25
25
|
|
|
26
26
|
The cookbook's `:command` [launch class](./selectors.md#the-six-launch-classes) matches
|
|
27
|
-
`CallExpr` nodes with a command word, exactly the calls in `sourceCode.
|
|
27
|
+
`CallExpr` nodes with a command word, exactly the calls in `sourceCode.getCommandInventory().commands`.
|
|
28
28
|
An assignment-only statement such as `FOO=1` does not match; `FOO=1 jq .`, `true`, `:`, and
|
|
29
29
|
dynamic invocations such as `"$tool" file` do. Select `CallExpr` directly to include
|
|
30
30
|
assignment-only calls. This tutorial's rule listens on `:command`; `create()` then narrows further
|
|
@@ -57,7 +57,7 @@ selector-first ESLint rule.
|
|
|
57
57
|
* domain-specific check).
|
|
58
58
|
*
|
|
59
59
|
* Flag words are resolved with `context.sourceCode.resolveWord`
|
|
60
|
-
* (backed by `sh-
|
|
60
|
+
* (backed by `sh-analysis`) rather than a
|
|
61
61
|
* hand-rolled scan: a word is only treated as a short-option cluster
|
|
62
62
|
* when it is *statically* that string (bare or
|
|
63
63
|
* quoted literal concatenations). Recursive (`r`/`R`) and force (`f`)
|
|
@@ -222,8 +222,9 @@ this package's test suite against a real `eslint` `Linter.verify()` run (not a h
|
|
|
222
222
|
|
|
223
223
|
The `:command` listener above sees one `CallExpr` at a time. Some rules need every command in the
|
|
224
224
|
file together with how each one is reached: inside which function, inside `$(…)`, in which
|
|
225
|
-
pipeline stage. `context.sourceCode.
|
|
226
|
-
source order, from `enumerateCommands` (in
|
|
225
|
+
pipeline stage. `context.sourceCode.getCommandInventory().commands` returns that list, one entry per command in
|
|
226
|
+
source order, from `enumerateCommands` (in `sh-analysis`). This is the represented-command collection,
|
|
227
|
+
not a completeness claim; inspect `getCommandInventory().uncertainties` for opaque boundaries. Each
|
|
227
228
|
entry has:
|
|
228
229
|
|
|
229
230
|
- `node`: the `CallExpr` node, the same object a `CallExpr` listener receives, so you can report
|
|
@@ -251,7 +252,7 @@ An assignment-only statement such as `FOO=1` runs no command and has no entry.
|
|
|
251
252
|
* It reports `curl` run anywhere inside a shell function, including through a
|
|
252
253
|
* wrapper (`sudo curl …`) or inside a command substitution in that function.
|
|
253
254
|
* Instead of tracking "am I inside a function?" while visiting nodes, it reads
|
|
254
|
-
* every command once from `context.sourceCode.
|
|
255
|
+
* every command once from `context.sourceCode.getCommandInventory().commands`, whose
|
|
255
256
|
* `context` frames (outermost first) already say how each command is reached.
|
|
256
257
|
*
|
|
257
258
|
* @see ../custom-rule-tutorial.md — the tutorial this rule backs
|
|
@@ -272,7 +273,7 @@ const noCurlInFunctions = defineShellRule({
|
|
|
272
273
|
create(context) {
|
|
273
274
|
return {
|
|
274
275
|
File() {
|
|
275
|
-
for (const site of context.sourceCode.
|
|
276
|
+
for (const site of context.sourceCode.getCommandInventory().commands) {
|
|
276
277
|
const { effective } = site.resolveInvokedCommand();
|
|
277
278
|
if (!effective.static || effective.text !== 'curl') {
|
|
278
279
|
continue;
|
|
@@ -404,29 +405,28 @@ it reports once, on line 1 from column 13 to column 15: exactly the `&&`. A plai
|
|
|
404
405
|
|
|
405
406
|
## 7. Using sh-ast's own operations and types
|
|
406
407
|
|
|
407
|
-
The records `getSyntax` returns
|
|
408
|
-
types
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
`getPrintedReplacement`, which refuses these values with `TypeError`.
|
|
408
|
+
The records `getSyntax` returns belong to `sh-ast`. Install and import raw parser operations,
|
|
409
|
+
syntax types and constants from `sh-ast`; import reusable analysis from `sh-analysis`:
|
|
410
|
+
|
|
411
|
+
```ts
|
|
412
|
+
import { walk, printSync, type Node, type PrintOptions } from 'sh-ast';
|
|
413
|
+
import { enumerateCommands, resolveArgv0, type CommandInventory } from 'sh-analysis';
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
The supported dependency ranges are `sh-ast@^0.11.0` and `sh-analysis@^0.1.0`.
|
|
417
|
+
There are no plugin or umbrella syntax forwarding subpaths. Keep using source helpers when you
|
|
418
|
+
need ESLint nodes, UTF-16 locations or fixes: they map the original syntax by identity.
|
|
419
|
+
|
|
420
|
+
`getCommandInventory()` exposes both `commands` and `uncertainties`. The examples here
|
|
421
|
+
report only named, represented commands. They do not establish that a file runs no other code.
|
|
422
|
+
An uncertainty such as `opaque-zsh-subscript` retains the original `FlagsArithm` view and its
|
|
423
|
+
context; raw text is not reparsed as another shell grammar. A security policy requiring all
|
|
424
|
+
execution to be reviewable must handle those boundaries. The built-in
|
|
425
|
+
`no-dynamic-invocation` reports them even in an allowed dispatcher function, and
|
|
426
|
+
`no-unused-declarations` declines deletion whenever they exist.
|
|
427
|
+
|
|
428
|
+
Raw `printSync` preserves the selected Go printer's behavior. Prefer
|
|
429
|
+
`getPrintedReplacement` for checked source edits, including its text-content safeguards.
|
|
430
430
|
|
|
431
431
|
## 8. Printed fixes
|
|
432
432
|
|
|
@@ -463,7 +463,7 @@ into an ESLint fix:
|
|
|
463
463
|
* new text with `getPrintedReplacement`. The original syntax every other rule
|
|
464
464
|
* reads stays unchanged.
|
|
465
465
|
*
|
|
466
|
-
* @import { PrintOptions } from '
|
|
466
|
+
* @import { PrintOptions } from 'sh-ast'
|
|
467
467
|
* @see ../custom-rule-tutorial.md — the tutorial this rule backs
|
|
468
468
|
*/
|
|
469
469
|
import { defineShellRule } from '@eslint-sh/eslint-plugin';
|
|
@@ -550,12 +550,12 @@ out the statement's own leading and trailing comments, which lie outside its ran
|
|
|
550
550
|
hand-formatted construct, step 9's position-based text edit is the better tool.
|
|
551
551
|
|
|
552
552
|
`PrintOptions`, `Node` and the record types (`CmdSubst`, `Word`, …) are the types of
|
|
553
|
-
|
|
553
|
+
`sh-ast` (step 7), and so is `printSync`, if you want to print a record
|
|
554
554
|
yourself, for example to compare it with the source before reporting:
|
|
555
555
|
|
|
556
556
|
```ts
|
|
557
|
-
import { printSync } from '
|
|
558
|
-
import type { Node, PrintOptions } from '
|
|
557
|
+
import { printSync } from 'sh-ast';
|
|
558
|
+
import type { Node, PrintOptions } from 'sh-ast';
|
|
559
559
|
```
|
|
560
560
|
|
|
561
561
|
## 9. Position-based text edits
|
|
@@ -686,7 +686,7 @@ TypeScript rule needs no `@eslint/core` import and no rule types of its own:
|
|
|
686
686
|
- `defineShellRule<Options, MessageIds>(…)` takes the options tuple and message ids as type
|
|
687
687
|
arguments, or infers the message ids from `meta.messages` when you leave them out. Either way,
|
|
688
688
|
`context.options` has your options' type, and `context.report` accepts only declared message ids.
|
|
689
|
-
- `context.sourceCode` is `ShellSourceCode`, so `
|
|
689
|
+
- `context.sourceCode` is `ShellSourceCode`, so `getCommandInventory().commands`, `getSyntax()` and the other
|
|
690
690
|
helpers are typed without a cast, and a listener keyed by a node type (`CallExpr`, `Word:exit`)
|
|
691
691
|
receives that node type, so its fields (`args`, `parts`, `cmd`, …) are typed; other selectors
|
|
692
692
|
receive `ShellNode`, which you narrow on `type`. See [Reading nodes](./reading-nodes.md).
|
|
@@ -755,7 +755,7 @@ const noListedCommands = defineShellRule<Options, 'listed'>({
|
|
|
755
755
|
const listed = new Set(context.options[0]?.commands ?? []);
|
|
756
756
|
return {
|
|
757
757
|
File() {
|
|
758
|
-
for (const site of context.sourceCode.
|
|
758
|
+
for (const site of context.sourceCode.getCommandInventory().commands) {
|
|
759
759
|
reportIfListed(context, site, listed);
|
|
760
760
|
}
|
|
761
761
|
},
|
package/docs/error-codes.md
CHANGED
|
@@ -43,6 +43,7 @@ try {
|
|
|
43
43
|
| `ESLINT_SH_CALL_NODE` | `TypeError` | A command helper requires a parsed `CallExpr` view. |
|
|
44
44
|
| `ESLINT_SH_WORD_NODE` | `TypeError` | A word helper requires a parsed `Word` view. A dynamic word is a normal resolution result. |
|
|
45
45
|
| `ESLINT_SH_COMMAND_SITE_VIEW` | `Error` | An analyzed command site has no corresponding view in the supplied file. |
|
|
46
|
+
| `ESLINT_SH_COMMAND_UNCERTAINTY_VIEW` | `Error` | An analysis uncertainty has no original lint view in this file; inventory mapping fails rather than dropping it. |
|
|
46
47
|
| `ESLINT_SH_FOREIGN_VIEW_NODE` | `TypeError` | A printed-fix helper received a view with no original syntax in this file. |
|
|
47
48
|
| `ESLINT_SH_SYNTAX_POSITION` | `TypeError` | A position argument does not have the required `SyntaxPos` shape. |
|
|
48
49
|
| `ESLINT_SH_SOURCE_INDEX` | `TypeError` | A source index is not numeric. |
|
|
@@ -60,8 +61,7 @@ Formatting/editor failures are documented by the independently maintained
|
|
|
60
61
|
|
|
61
62
|
## Dependency boundaries
|
|
62
63
|
|
|
63
|
-
|
|
64
|
-
`sh-ast/analyze`. They retain upstream errors and codes without aliases. The
|
|
64
|
+
Direct `sh-ast` and `sh-analysis` imports retain their own errors and codes without aliases. The
|
|
65
65
|
plugin's source helpers also preserve analysis resource/invalid-wrapper failures,
|
|
66
66
|
and printed replacements preserve upstream printer errors. Returning a partial
|
|
67
67
|
command inventory on a depth refusal would silently omit real commands.
|
|
@@ -74,9 +74,10 @@ command inventory on a depth refusal would silently omit real commands.
|
|
|
74
74
|
| `SH_AST_SYNTAX_PRINT` | Printer request cannot be honored. |
|
|
75
75
|
| `SH_AST_SYNTAX_PRINT_PANIC` | Upstream printer failure. |
|
|
76
76
|
| `SH_AST_WALK_PANIC` | Upstream syntax traversal failure. |
|
|
77
|
-
| `SH_AST_PARSE_MAX_DEPTH` | Parser resource limit; no partial tree is returned. |
|
|
78
|
-
| `
|
|
79
|
-
| `
|
|
77
|
+
| `SH_AST_PARSE_MAX_DEPTH` | Parser resource limit; no partial tree or formatted output is returned. |
|
|
78
|
+
| `SH_ANALYSIS_MAX_DEPTH` | Analysis resource limit; no partial inventory is returned. |
|
|
79
|
+
| `SH_ANALYSIS_RESOURCE` | Analysis-owned brace-observation copying exceeded the host stack. The error retains operation `brace-observation-copy` and its original `RangeError` cause; source helpers propagate it unchanged. |
|
|
80
|
+
| `SH_ANALYSIS_INVALID_WRAPPER_SPEC` | A raw analysis wrapper table or model is invalid, including non-object entries and missing array elements. Shared settings also have their own project configuration validation. |
|
|
80
81
|
| `SH_AST_INTERNAL` | Upstream bridge/internal failure. |
|
|
81
82
|
|
|
82
83
|
ESLint wraps errors from language-option validation in its own `TypeError`.
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* new text with `getPrintedReplacement`. The original syntax every other rule
|
|
12
12
|
* reads stays unchanged.
|
|
13
13
|
*
|
|
14
|
-
* @import { PrintOptions } from '
|
|
14
|
+
* @import { PrintOptions } from 'sh-ast'
|
|
15
15
|
* @see ../custom-rule-tutorial.md — the tutorial this rule backs
|
|
16
16
|
*/
|
|
17
17
|
import { defineShellRule } from '@eslint-sh/eslint-plugin';
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* It reports `curl` run anywhere inside a shell function, including through a
|
|
8
8
|
* wrapper (`sudo curl …`) or inside a command substitution in that function.
|
|
9
9
|
* Instead of tracking "am I inside a function?" while visiting nodes, it reads
|
|
10
|
-
* every command once from `context.sourceCode.
|
|
10
|
+
* every command once from `context.sourceCode.getCommandInventory().commands`, whose
|
|
11
11
|
* `context` frames (outermost first) already say how each command is reached.
|
|
12
12
|
*
|
|
13
13
|
* @see ../custom-rule-tutorial.md — the tutorial this rule backs
|
|
@@ -28,7 +28,7 @@ const noCurlInFunctions = defineShellRule({
|
|
|
28
28
|
create(context) {
|
|
29
29
|
return {
|
|
30
30
|
File() {
|
|
31
|
-
for (const site of context.sourceCode.
|
|
31
|
+
for (const site of context.sourceCode.getCommandInventory().commands) {
|
|
32
32
|
const { effective } = site.resolveInvokedCommand();
|
|
33
33
|
if (!effective.static || effective.text !== 'curl') {
|
|
34
34
|
continue;
|
|
@@ -52,7 +52,7 @@ const noListedCommands = defineShellRule<Options, 'listed'>({
|
|
|
52
52
|
const listed = new Set(context.options[0]?.commands ?? []);
|
|
53
53
|
return {
|
|
54
54
|
File() {
|
|
55
|
-
for (const site of context.sourceCode.
|
|
55
|
+
for (const site of context.sourceCode.getCommandInventory().commands) {
|
|
56
56
|
reportIfListed(context, site, listed);
|
|
57
57
|
}
|
|
58
58
|
},
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* domain-specific check).
|
|
19
19
|
*
|
|
20
20
|
* Flag words are resolved with `context.sourceCode.resolveWord`
|
|
21
|
-
* (backed by `sh-
|
|
21
|
+
* (backed by `sh-analysis`) rather than a
|
|
22
22
|
* hand-rolled scan: a word is only treated as a short-option cluster
|
|
23
23
|
* when it is *statically* that string (bare or
|
|
24
24
|
* quoted literal concatenations). Recursive (`r`/`R`) and force (`f`)
|
|
@@ -142,3 +142,8 @@ shellcheck has no equivalent. It treats a dynamic command word as legitimate she
|
|
|
142
142
|
warns about how it is written, such as unquoted expansions (SC2086) or a string used where an
|
|
143
143
|
array belongs (SC2089/SC2090). It can't express the policy that every command must be
|
|
144
144
|
statically enumerable, which is what makes a script reviewable as a whole.
|
|
145
|
+
|
|
146
|
+
Opaque executable syntax is exposed separately in the source command inventory.
|
|
147
|
+
This rule reports `opaqueExecutable` at the original opaque construct, including
|
|
148
|
+
inside `allowInFunctions` dispatcher scopes. That exemption permits computed
|
|
149
|
+
command words; embedded executable text still requires review.
|
|
@@ -140,3 +140,7 @@ shellcheck has no equivalent. It checks how a script uses commands, not which co
|
|
|
140
140
|
script may depend on, and it has no notion of a project's declaration convention to compare
|
|
141
141
|
against. A dependency manifest is project policy, which is the kind of rule shellcheck cannot be
|
|
142
142
|
configured to express.
|
|
143
|
+
|
|
144
|
+
Opaque executable syntax is exposed separately in the source command inventory.
|
|
145
|
+
This rule reports known undeclared dependencies even when opaque syntax prevents
|
|
146
|
+
an exhaustive inventory; absence of reports does not prove dependency completeness.
|
|
@@ -211,3 +211,7 @@ shellcheck has no equivalent. It checks how a script uses commands, not which co
|
|
|
211
211
|
script says it depends on, and it has no notion of a project's declaration convention to compare
|
|
212
212
|
against. Keeping a dependency manifest honest is project policy, which is the kind of rule
|
|
213
213
|
shellcheck cannot be configured to express.
|
|
214
|
+
|
|
215
|
+
Opaque executable syntax is exposed separately in the source command inventory.
|
|
216
|
+
Any uncertainty suppresses unused-declaration reports and fixes for the file,
|
|
217
|
+
because the opaque code could use a declared command.
|
|
@@ -69,7 +69,7 @@ It does not depend on `languageOptions`.
|
|
|
69
69
|
`{ names: ['retry'], argFlags: ['-n'] }` makes `retry -n 3 curl x` wrapped. Its fields are
|
|
70
70
|
`names` (required; any of them counts as the wrapper), `noArgFlags`, `argFlags`,
|
|
71
71
|
`stopsChainFlags`, `unresolvableFlags`, `positionalOperandsBeforeCommand`, and
|
|
72
|
-
`assignmentOperands`, as in `sh-
|
|
72
|
+
`assignmentOperands`, as in `sh-analysis`'s `WrapperSpec`.
|
|
73
73
|
- `commands` (`string[]`, default `["curl", "wget", "nc", "ssh", "scp", "rsync", "git"]`): the
|
|
74
74
|
network commands. Setting it replaces the default list. `git` keeps its subcommand restriction
|
|
75
75
|
wherever it is listed. An empty list removes all built-in commands.
|
package/docs/selectors.md
CHANGED
|
@@ -23,7 +23,7 @@ Looking for a complete, runnable `create()` that uses one of these selectors —
|
|
|
23
23
|
| `:quoted` | `SglQuoted`, `DblQuoted` |
|
|
24
24
|
| `:function` | `FuncDecl` |
|
|
25
25
|
|
|
26
|
-
`:command` matches exactly the calls with an entry in `sourceCode.
|
|
26
|
+
`:command` matches exactly the calls with an entry in `sourceCode.getCommandInventory().commands`.
|
|
27
27
|
An assignment-only statement such as `FOO=1` has no command site and does not match.
|
|
28
28
|
`FOO=1 jq .`, `true`, `:`, and dynamic invocations such as `"$tool" file` do match.
|
|
29
29
|
Select `CallExpr` directly when you want every call node, including assignment-only calls.
|
package/docs/wrapper-rules.md
CHANGED
|
@@ -136,7 +136,7 @@ chain, outermost first: `retry sudo curl x` runs `retry`, then `sudo`, then `cur
|
|
|
136
136
|
### Declaring the wrapper's options
|
|
137
137
|
|
|
138
138
|
A wrapper given as a string is assumed to take no options of its own, so the word after it is
|
|
139
|
-
the command it runs. When your wrapper has options, give a `WrapperSpec` (from `sh-
|
|
139
|
+
the command it runs. When your wrapper has options, give a `WrapperSpec` (from `sh-analysis`,
|
|
140
140
|
re-exported by this package) that declares them:
|
|
141
141
|
|
|
142
142
|
```js
|
package/package.json
CHANGED
|
@@ -1,34 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-sh/eslint-plugin",
|
|
3
3
|
"description": "Shell script linting for ESLint, with built-in policy rules, shared presets, and custom rules over a typed shell AST",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.10.1",
|
|
5
5
|
"author": "Mike North <michael.l.north@gmail.com>",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@eslint/core": "^1.2.1",
|
|
8
8
|
"@eslint/plugin-kit": "^0.7.2",
|
|
9
|
-
"sh-ast": "^0.
|
|
9
|
+
"sh-ast": "^0.11.0",
|
|
10
|
+
"sh-analysis": "^0.1.0"
|
|
10
11
|
},
|
|
11
12
|
"devDependencies": {
|
|
12
|
-
"eslint": "^10.
|
|
13
|
+
"eslint": "^10.14.0"
|
|
13
14
|
},
|
|
14
15
|
"peerDependencies": {
|
|
15
16
|
"eslint": "^10.2.0"
|
|
16
17
|
},
|
|
17
18
|
"engines": {
|
|
18
|
-
"node": "^22.
|
|
19
|
+
"node": "^22.14.0 || >=24"
|
|
19
20
|
},
|
|
20
21
|
"exports": {
|
|
21
22
|
".": {
|
|
22
23
|
"types": "./dist/eslint-plugin.d.ts",
|
|
23
24
|
"default": "./dist/index.js"
|
|
24
|
-
},
|
|
25
|
-
"./syntax": {
|
|
26
|
-
"types": "./dist/eslint-plugin-syntax.d.ts",
|
|
27
|
-
"default": "./dist/syntax/index.js"
|
|
28
|
-
},
|
|
29
|
-
"./syntax/analyze": {
|
|
30
|
-
"types": "./dist/eslint-plugin-syntax-analyze.d.ts",
|
|
31
|
-
"default": "./dist/syntax/analyze.js"
|
|
32
25
|
}
|
|
33
26
|
},
|
|
34
27
|
"files": [
|
|
@@ -57,11 +50,7 @@
|
|
|
57
50
|
],
|
|
58
51
|
"outputs": [
|
|
59
52
|
"{workspaceRoot}/api-report-combined/eslint-plugin.api.md",
|
|
60
|
-
"{workspaceRoot}/api-docs-temp/eslint-plugin.api.json"
|
|
61
|
-
"{workspaceRoot}/api-report-combined/eslint-plugin-syntax.api.md",
|
|
62
|
-
"{workspaceRoot}/api-docs-temp/eslint-plugin-syntax.api.json",
|
|
63
|
-
"{workspaceRoot}/api-report-combined/eslint-plugin-syntax-analyze.api.md",
|
|
64
|
-
"{workspaceRoot}/api-docs-temp/eslint-plugin-syntax-analyze.api.json"
|
|
53
|
+
"{workspaceRoot}/api-docs-temp/eslint-plugin.api.json"
|
|
65
54
|
]
|
|
66
55
|
}
|
|
67
56
|
}
|
|
@@ -77,16 +66,16 @@
|
|
|
77
66
|
"directory": "packages/eslint-plugin"
|
|
78
67
|
},
|
|
79
68
|
"scripts": {
|
|
80
|
-
"build": "node ../../scripts/materialize-shared-source.mjs && tsc -p tsconfig.json && node ../../scripts/rollup-declarations.mjs api-extractor.json
|
|
69
|
+
"build": "node ../../scripts/materialize-shared-source.mjs && tsc -p tsconfig.json && node ../../scripts/rollup-declarations.mjs api-extractor.json && cp types/eslint-plugin.d.ts dist/eslint-plugin.d.ts",
|
|
81
70
|
"check": "concurrently -n lint,types,api-report \"pnpm run check:lint-ts\" \"pnpm run check:typecheck\" \"pnpm run check:api-report\"",
|
|
82
|
-
"check:api-report": "api-extractor run
|
|
83
|
-
"check:lint-ts": "eslint .",
|
|
71
|
+
"check:api-report": "api-extractor run",
|
|
72
|
+
"check:lint-ts": "cd ../.. && eslint --config eslint.config.js packages/eslint-plugin",
|
|
84
73
|
"check:typecheck": "tsc --noEmit",
|
|
85
74
|
"clean": "rimraf --glob dist \"temp/*\" \"*.tsbuildinfo\"",
|
|
86
|
-
"fix:api-report": "api-extractor run --local
|
|
87
|
-
"fix:lint-ts": "eslint . --fix",
|
|
75
|
+
"fix:api-report": "api-extractor run --local",
|
|
76
|
+
"fix:lint-ts": "cd ../.. && eslint --config eslint.config.js packages/eslint-plugin --fix",
|
|
88
77
|
"test": "vitest run",
|
|
89
|
-
"uplevel-api-reports": "mkdir -p ../../api-report-combined ../../api-docs-temp && cp api-report/eslint-plugin.api.md
|
|
78
|
+
"uplevel-api-reports": "mkdir -p ../../api-report-combined ../../api-docs-temp && cp api-report/eslint-plugin.api.md ../../api-report-combined/ && cp temp/eslint-plugin.api.json ../../api-docs-temp/",
|
|
90
79
|
"test:candidate": "node --experimental-strip-types test/candidate/run.mjs"
|
|
91
80
|
}
|
|
92
81
|
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The faithful shell analysis surface (`@eslint-sh/eslint-plugin/syntax/analyze`): the complete
|
|
3
|
-
* public surface of `sh-ast/analyze`, re-exported unchanged from the very `sh-ast` instance this
|
|
4
|
-
* plugin's language parses with.
|
|
5
|
-
*
|
|
6
|
-
* It provides `enumerateCommands`, `resolveArgv0` (whose `chainIndices` locate a resolved command's
|
|
7
|
-
* arguments in its site's `argv`), `DEFAULT_TRANSPARENT_WRAPPERS`, `WrapperSpec`, the raw
|
|
8
|
-
* `resolveWord(Node)`, and the named operator constants with `rawOperator` for comparing and
|
|
9
|
-
* constructing the operator values those records carry. All of it works on the faithful records
|
|
10
|
-
* from `@eslint-sh/eslint-plugin/syntax`. For lint-view Word nodes, rules use
|
|
11
|
-
* `context.sourceCode.resolveWord(word)`, whose default policy comes from grammar position.
|
|
12
|
-
* This raw analyzer retains upstream defaults and never infers lint-view context.
|
|
13
|
-
*
|
|
14
|
-
* Like `@eslint-sh/eslint-plugin/syntax`, it tracks the plugin's pinned `sh-ast` minor and never
|
|
15
|
-
* wraps or renames anything.
|
|
16
|
-
*
|
|
17
|
-
* @packageDocumentation
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export * from "sh-ast/analyze";
|
|
22
|
-
|
|
23
|
-
export { }
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The faithful shell syntax surface (`@eslint-sh/eslint-plugin/syntax`): the complete public
|
|
3
|
-
* surface of `sh-ast`'s root entry point, re-exported unchanged from the very `sh-ast` instance
|
|
4
|
-
* this plugin's language parses with.
|
|
5
|
-
*
|
|
6
|
-
* Use it when a custom rule edits or analyzes the parser's own records rather than the plugin's
|
|
7
|
-
* lint view: `walk`, `parseSync`, `printSync` and `PrintOptions`, the record types (`Node`,
|
|
8
|
-
* `Word`, `CallExpr`, `SyntaxPos`, `GoString`, …), and the operator and language constants.
|
|
9
|
-
* Importing them from here, instead of installing `sh-ast` separately, means a rule always gets
|
|
10
|
-
* the same `sh-ast` version and module instance as the language that produced its syntax. Under
|
|
11
|
-
* 0.x a different `sh-ast` minor is a breaking change, and records from one copy are not
|
|
12
|
-
* guaranteed to be accepted by another.
|
|
13
|
-
*
|
|
14
|
-
* This entry point tracks the plugin's pinned `sh-ast` minor, so an `sh-ast` 0.x minor bump is a
|
|
15
|
-
* minor release of this plugin. It never wraps or renames anything: every name has `sh-ast`'s
|
|
16
|
-
* own contract. Rules analyze lint-view words through `context.sourceCode.resolveWord(word)`,
|
|
17
|
-
* which supplies the word's grammar context. Raw syntax analysis lives in
|
|
18
|
-
* `@eslint-sh/eslint-plugin/syntax/analyze`, separate from the lint view.
|
|
19
|
-
*
|
|
20
|
-
* The low-level `printSync` keeps upstream behavior, including changes to literal vertical tabs
|
|
21
|
-
* and form feeds. It does not apply the high-level content refusal used by `format` and
|
|
22
|
-
* `ShellSourceCode.getPrintedReplacement`; callers printing directly must account for that loss.
|
|
23
|
-
*
|
|
24
|
-
* @packageDocumentation
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
export * from "sh-ast";
|
|
29
|
-
|
|
30
|
-
export { }
|
package/dist/syntax/analyze.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The faithful shell analysis surface (`@eslint-sh/eslint-plugin/syntax/analyze`): the complete
|
|
3
|
-
* public surface of `sh-ast/analyze`, re-exported unchanged from the very `sh-ast` instance this
|
|
4
|
-
* plugin's language parses with.
|
|
5
|
-
*
|
|
6
|
-
* It provides `enumerateCommands`, `resolveArgv0` (whose `chainIndices` locate a resolved command's
|
|
7
|
-
* arguments in its site's `argv`), `DEFAULT_TRANSPARENT_WRAPPERS`, `WrapperSpec`, the raw
|
|
8
|
-
* `resolveWord(Node)`, and the named operator constants with `rawOperator` for comparing and
|
|
9
|
-
* constructing the operator values those records carry. All of it works on the faithful records
|
|
10
|
-
* from `@eslint-sh/eslint-plugin/syntax`. For lint-view Word nodes, rules use
|
|
11
|
-
* `context.sourceCode.resolveWord(word)`, whose default policy comes from grammar position.
|
|
12
|
-
* This raw analyzer retains upstream defaults and never infers lint-view context.
|
|
13
|
-
*
|
|
14
|
-
* Like `@eslint-sh/eslint-plugin/syntax`, it tracks the plugin's pinned `sh-ast` minor and never
|
|
15
|
-
* wraps or renames anything.
|
|
16
|
-
*
|
|
17
|
-
* @packageDocumentation
|
|
18
|
-
*/
|
|
19
|
-
export * from 'sh-ast/analyze';
|
package/dist/syntax/analyze.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @api-extractor-tools/package-documentation -- this file is the barrel of the
|
|
2
|
-
`./syntax/analyze` entry point (package.json `exports`); the rule only recognizes the root barrel. */
|
|
3
|
-
/**
|
|
4
|
-
* The faithful shell analysis surface (`@eslint-sh/eslint-plugin/syntax/analyze`): the complete
|
|
5
|
-
* public surface of `sh-ast/analyze`, re-exported unchanged from the very `sh-ast` instance this
|
|
6
|
-
* plugin's language parses with.
|
|
7
|
-
*
|
|
8
|
-
* It provides `enumerateCommands`, `resolveArgv0` (whose `chainIndices` locate a resolved command's
|
|
9
|
-
* arguments in its site's `argv`), `DEFAULT_TRANSPARENT_WRAPPERS`, `WrapperSpec`, the raw
|
|
10
|
-
* `resolveWord(Node)`, and the named operator constants with `rawOperator` for comparing and
|
|
11
|
-
* constructing the operator values those records carry. All of it works on the faithful records
|
|
12
|
-
* from `@eslint-sh/eslint-plugin/syntax`. For lint-view Word nodes, rules use
|
|
13
|
-
* `context.sourceCode.resolveWord(word)`, whose default policy comes from grammar position.
|
|
14
|
-
* This raw analyzer retains upstream defaults and never infers lint-view context.
|
|
15
|
-
*
|
|
16
|
-
* Like `@eslint-sh/eslint-plugin/syntax`, it tracks the plugin's pinned `sh-ast` minor and never
|
|
17
|
-
* wraps or renames anything.
|
|
18
|
-
*
|
|
19
|
-
* @packageDocumentation
|
|
20
|
-
*/
|
|
21
|
-
export * from 'sh-ast/analyze';
|
package/dist/syntax/index.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The faithful shell syntax surface (`@eslint-sh/eslint-plugin/syntax`): the complete public
|
|
3
|
-
* surface of `sh-ast`'s root entry point, re-exported unchanged from the very `sh-ast` instance
|
|
4
|
-
* this plugin's language parses with.
|
|
5
|
-
*
|
|
6
|
-
* Use it when a custom rule edits or analyzes the parser's own records rather than the plugin's
|
|
7
|
-
* lint view: `walk`, `parseSync`, `printSync` and `PrintOptions`, the record types (`Node`,
|
|
8
|
-
* `Word`, `CallExpr`, `SyntaxPos`, `GoString`, …), and the operator and language constants.
|
|
9
|
-
* Importing them from here, instead of installing `sh-ast` separately, means a rule always gets
|
|
10
|
-
* the same `sh-ast` version and module instance as the language that produced its syntax. Under
|
|
11
|
-
* 0.x a different `sh-ast` minor is a breaking change, and records from one copy are not
|
|
12
|
-
* guaranteed to be accepted by another.
|
|
13
|
-
*
|
|
14
|
-
* This entry point tracks the plugin's pinned `sh-ast` minor, so an `sh-ast` 0.x minor bump is a
|
|
15
|
-
* minor release of this plugin. It never wraps or renames anything: every name has `sh-ast`'s
|
|
16
|
-
* own contract. Rules analyze lint-view words through `context.sourceCode.resolveWord(word)`,
|
|
17
|
-
* which supplies the word's grammar context. Raw syntax analysis lives in
|
|
18
|
-
* `@eslint-sh/eslint-plugin/syntax/analyze`, separate from the lint view.
|
|
19
|
-
*
|
|
20
|
-
* The low-level `printSync` keeps upstream behavior, including changes to literal vertical tabs
|
|
21
|
-
* and form feeds. It does not apply the high-level content refusal used by `format` and
|
|
22
|
-
* `ShellSourceCode.getPrintedReplacement`; callers printing directly must account for that loss.
|
|
23
|
-
*
|
|
24
|
-
* @packageDocumentation
|
|
25
|
-
*/
|
|
26
|
-
export * from 'sh-ast';
|
package/dist/syntax/index.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @api-extractor-tools/package-documentation -- this file is the barrel of the
|
|
2
|
-
`./syntax` entry point (package.json `exports`); the rule only recognizes the root barrel. */
|
|
3
|
-
/**
|
|
4
|
-
* The faithful shell syntax surface (`@eslint-sh/eslint-plugin/syntax`): the complete public
|
|
5
|
-
* surface of `sh-ast`'s root entry point, re-exported unchanged from the very `sh-ast` instance
|
|
6
|
-
* this plugin's language parses with.
|
|
7
|
-
*
|
|
8
|
-
* Use it when a custom rule edits or analyzes the parser's own records rather than the plugin's
|
|
9
|
-
* lint view: `walk`, `parseSync`, `printSync` and `PrintOptions`, the record types (`Node`,
|
|
10
|
-
* `Word`, `CallExpr`, `SyntaxPos`, `GoString`, …), and the operator and language constants.
|
|
11
|
-
* Importing them from here, instead of installing `sh-ast` separately, means a rule always gets
|
|
12
|
-
* the same `sh-ast` version and module instance as the language that produced its syntax. Under
|
|
13
|
-
* 0.x a different `sh-ast` minor is a breaking change, and records from one copy are not
|
|
14
|
-
* guaranteed to be accepted by another.
|
|
15
|
-
*
|
|
16
|
-
* This entry point tracks the plugin's pinned `sh-ast` minor, so an `sh-ast` 0.x minor bump is a
|
|
17
|
-
* minor release of this plugin. It never wraps or renames anything: every name has `sh-ast`'s
|
|
18
|
-
* own contract. Rules analyze lint-view words through `context.sourceCode.resolveWord(word)`,
|
|
19
|
-
* which supplies the word's grammar context. Raw syntax analysis lives in
|
|
20
|
-
* `@eslint-sh/eslint-plugin/syntax/analyze`, separate from the lint view.
|
|
21
|
-
*
|
|
22
|
-
* The low-level `printSync` keeps upstream behavior, including changes to literal vertical tabs
|
|
23
|
-
* and form feeds. It does not apply the high-level content refusal used by `format` and
|
|
24
|
-
* `ShellSourceCode.getPrintedReplacement`; callers printing directly must account for that loss.
|
|
25
|
-
*
|
|
26
|
-
* @packageDocumentation
|
|
27
|
-
*/
|
|
28
|
-
export * from 'sh-ast';
|