@eslint-sh/eslint-plugin 0.8.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +58 -57
- package/dist/api.d.ts +92 -0
- package/dist/api.js +83 -0
- 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/configs/posix-portable.d.ts +6 -10
- package/dist/configs/posix-portable.js +4 -6
- package/dist/configuration-message.d.ts +14 -0
- package/dist/configuration-message.js +33 -0
- package/dist/declaration-conventions/get-declared-commands.d.ts +41 -0
- package/dist/declaration-conventions/{read-declared-commands.js → get-declared-commands.js} +43 -43
- package/dist/eslint-plugin-api.d.ts +1516 -0
- package/dist/eslint-plugin.d.ts +16 -1560
- package/dist/index.d.ts +14 -81
- package/dist/index.js +22 -76
- package/dist/language/command-resolution.d.ts +47 -13
- package/dist/language/command-resolution.js +48 -18
- package/dist/language/selector-classes.d.ts +7 -3
- package/dist/language/selector-classes.js +13 -4
- package/dist/language/shell-language-options.d.ts +3 -3
- package/dist/language/shell-language-options.js +12 -17
- package/dist/language/shell-language.d.ts +3 -1
- package/dist/language/shell-language.js +6 -11
- package/dist/language/shell-source-code.d.ts +77 -77
- package/dist/language/shell-source-code.js +107 -98
- package/dist/language/source-coordinates.d.ts +2 -0
- package/dist/language/source-coordinates.js +8 -4
- package/dist/language/syntax-view.d.ts +1 -1
- package/dist/language/syntax-view.js +19 -7
- package/dist/language/word-resolution.d.ts +4 -3
- package/dist/language/word-resolution.js +10 -5
- 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 +2 -2
- package/dist/rules/compat/no-wait-n.js +2 -2
- 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 +4 -4
- package/dist/rules/create-wrapper-rule.js +19 -13
- package/dist/rules/define-shell-rule.js +1 -1
- 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 +4 -3
- package/dist/rules/no-masked-exit-status.js +4 -3
- package/dist/rules/no-secret-env-reads.d.ts +2 -0
- package/dist/rules/no-secret-env-reads.js +14 -3
- package/dist/rules/no-secret-flags.d.ts +2 -0
- package/dist/rules/no-secret-flags.js +14 -3
- package/dist/rules/no-unchecked-cd.js +4 -3
- package/dist/rules/no-undeclared-commands.js +10 -4
- package/dist/rules/no-unused-declarations.js +13 -4
- package/dist/rules/prefer-local.d.ts +3 -2
- package/dist/rules/prefer-local.js +4 -2
- package/dist/rules/quote-expansions.js +1 -1
- package/dist/rules/require-network-wrapper.d.ts +2 -2
- package/dist/rules/require-network-wrapper.js +21 -11
- package/dist/rules/require-strict-mode.d.ts +5 -46
- package/dist/rules/require-strict-mode.js +17 -107
- package/dist/rules/require-tty-guard.d.ts +2 -0
- package/dist/rules/require-tty-guard.js +9 -2
- package/dist/rules/resolve-declaration-convention.d.ts +9 -88
- package/dist/rules/resolve-declaration-convention.js +19 -71
- package/dist/rules/resolve-network-wrapper.d.ts +3 -4
- package/dist/rules/resolve-network-wrapper.js +23 -19
- package/dist/rules/resolve-transparent-wrappers.d.ts +3 -8
- package/dist/rules/resolve-transparent-wrappers.js +21 -11
- package/dist/rules/set-options.d.ts +1 -1
- package/dist/rules/set-options.js +1 -1
- package/dist/rules/strict-mode-prologue.d.ts +43 -0
- package/dist/rules/strict-mode-prologue.js +91 -0
- package/dist/rules/transparent-wrappers.d.ts +3 -3
- package/dist/rules/transparent-wrappers.js +1 -1
- package/dist/rules/user-pattern.d.ts +4 -3
- package/dist/rules/user-pattern.js +10 -8
- package/dist/shell-dialect.d.ts +8 -0
- package/dist/shell-dialect.js +22 -0
- package/dist/version.js +2 -1
- package/docs/compat.md +5 -6
- package/docs/custom-rule-tutorial.md +55 -51
- package/docs/declaration-conventions.md +20 -23
- package/docs/error-codes.md +94 -0
- 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 +8 -10
- package/docs/examples/sorted-declarations-rule.mjs +6 -9
- package/docs/examples/tsconfig.json +10 -0
- package/docs/rules/README.md +12 -4
- package/docs/rules/compat/no-nounset-empty-array.md +1 -1
- package/docs/rules/no-dynamic-invocation.md +5 -0
- package/docs/rules/no-masked-exit-status.md +2 -2
- package/docs/rules/no-secret-env-reads.md +13 -3
- package/docs/rules/no-secret-flags.md +14 -5
- package/docs/rules/no-unchecked-cd.md +15 -2
- 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 +6 -6
- package/docs/rules/require-strict-mode.md +25 -23
- package/docs/rules/require-tty-guard.md +12 -3
- package/docs/selectors.md +7 -2
- package/docs/wrapper-rules.md +3 -1
- package/package.json +9 -20
- package/dist/declaration-conventions/read-declared-commands.d.ts +0 -70
- package/dist/eslint-plugin-syntax-analyze.d.ts +0 -23
- package/dist/eslint-plugin-syntax.d.ts +0 -31
- package/dist/syntax/analyze.d.ts +0 -19
- package/dist/syntax/analyze.js +0 -21
- package/dist/syntax/index.d.ts +0 -27
- package/dist/syntax/index.js +0 -29
|
@@ -69,8 +69,8 @@ The rule matches parameter expansions only. These reads are not reported:
|
|
|
69
69
|
|
|
70
70
|
## Options
|
|
71
71
|
|
|
72
|
-
- `patterns` (`string[]
|
|
73
|
-
variable's name. They **replace** the default list. Sources use `u` (Unicode, case-sensitive):
|
|
72
|
+
- `patterns` (`string[]`). Regular-expression sources tested against each
|
|
73
|
+
variable's name. They **replace** the default list; an empty list removes all defaults. Sources use `u` (Unicode, case-sensitive):
|
|
74
74
|
`patterns: ['token']` does not catch `$GITHUB_TOKEN`, while `patterns: ['TOKEN']` does.
|
|
75
75
|
Lowercase names such as `$sort_key` do not match the uppercase default patterns.
|
|
76
76
|
See [regular-expression options](./README.md#regular-expression-options) for compilation and
|
|
@@ -78,6 +78,10 @@ The rule matches parameter expansions only. These reads are not reported:
|
|
|
78
78
|
|
|
79
79
|
Default: `["(_TOKEN|_SECRET|_PASSWORD|_KEY)$"]`.
|
|
80
80
|
|
|
81
|
+
- `additionalPatterns` (`string[]`, default `[]`). Sources added to `patterns`, or to the
|
|
82
|
+
defaults when `patterns` is omitted. These also compile with `u` and match exact case.
|
|
83
|
+
An empty addition changes nothing; overlapping patterns report each read only once.
|
|
84
|
+
|
|
81
85
|
- `allowedSinks` (`string[]`). Command names whose own arguments may read a secret-shaped variable. Wrapper-owned
|
|
82
86
|
operands are not exempt.
|
|
83
87
|
|
|
@@ -89,12 +93,18 @@ The rule matches parameter expansions only. These reads are not reported:
|
|
|
89
93
|
rules: {
|
|
90
94
|
'sh/no-secret-env-reads': [
|
|
91
95
|
'error',
|
|
92
|
-
{ allowedSinks: ['vault', 'gh'],
|
|
96
|
+
{ allowedSinks: ['vault', 'gh'], additionalPatterns: ['_PAT$'] },
|
|
93
97
|
],
|
|
94
98
|
},
|
|
95
99
|
}
|
|
96
100
|
```
|
|
97
101
|
|
|
102
|
+
With this configuration, both `echo "$GITHUB_TOKEN"` and `echo "$ACCESS_PAT"` report;
|
|
103
|
+
`echo "$access_pat"` stays clean. `{ patterns: ['^PIN$'], additionalPatterns: ['_PAT$'] }`
|
|
104
|
+
reports `$PIN` and `$ACCESS_PAT`, and leaves `$GITHUB_TOKEN` alone. `{ patterns: [] }` checks no names;
|
|
105
|
+
adding `additionalPatterns` to it checks only those added patterns. A lowercase addition
|
|
106
|
+
`['token']` does not catch `$GITHUB_TOKEN`; flag patterns use different case semantics.
|
|
107
|
+
|
|
98
108
|
Regex syntax errors fail when this rule first runs on a file, naming the rule, option and
|
|
99
109
|
pattern. `--print-config` will not catch any regex syntax errors. See the
|
|
100
110
|
[shared compilation contract](./README.md#regular-expression-options).
|
|
@@ -51,35 +51,44 @@ digit (`--password2`, `--token1`) or by another `-segment` (`--secret-key`,
|
|
|
51
51
|
|
|
52
52
|
Other qualifiers aren't matched, so `--my-token` is not reported. A general prefix would also
|
|
53
53
|
match negations such as `--no-password`, which take no value. Add a project's own flag names
|
|
54
|
-
with the `
|
|
54
|
+
with the `additionalPatterns` option.
|
|
55
55
|
|
|
56
56
|
Expect some false positives: a name such as `--token-type` still matches. Suppress a single false
|
|
57
57
|
positive with a disable comment that says why, or narrow the `patterns` option for your project.
|
|
58
58
|
|
|
59
59
|
## Options
|
|
60
60
|
|
|
61
|
-
- `patterns` (`string[]
|
|
61
|
+
- `patterns` (`string[]`). Regular-expression sources tested against each flag's
|
|
62
62
|
name, without `=` or the value. They **replace** the default list. Each source is compiled
|
|
63
|
-
with `iu` (Unicode, case-insensitive), like the default. For example, `patterns: ['token']`
|
|
63
|
+
with `iu` (Unicode, case-insensitive), like the default. An empty list removes all defaults. For example, `patterns: ['token']`
|
|
64
64
|
catches `cli --TOKEN=abc`; capitals in a custom pattern also match lowercase flag names.
|
|
65
65
|
See [regular-expression options](./README.md#regular-expression-options) for compilation and
|
|
66
66
|
configuration errors, which name the rule, option index and source.
|
|
67
67
|
|
|
68
68
|
Default: `["^(?!.*-(?:stdin|file)$)--?(?:access-|auth-?)?(?:password|passwd|token|secret|api-?key|auth(?:key|orization)?)(?![a-z])"]`.
|
|
69
69
|
|
|
70
|
+
- `additionalPatterns` (`string[]`, default `[]`). Sources added to `patterns`, or to the
|
|
71
|
+
defaults when `patterns` is omitted. These also compile with `iu`. An empty addition changes
|
|
72
|
+
nothing; overlapping patterns report each flag only once.
|
|
73
|
+
|
|
70
74
|
```js
|
|
71
75
|
// eslint.config.js
|
|
72
76
|
{
|
|
73
77
|
rules: {
|
|
74
78
|
'sh/no-secret-flags': [
|
|
75
79
|
'error',
|
|
76
|
-
//
|
|
77
|
-
{
|
|
80
|
+
// Keep the defaults and also catch --vault-pin (in any case).
|
|
81
|
+
{ additionalPatterns: ['^--vault-pin$'] },
|
|
78
82
|
],
|
|
79
83
|
},
|
|
80
84
|
}
|
|
81
85
|
```
|
|
82
86
|
|
|
87
|
+
With this configuration, both `cli --token=abc` and `cli --VAULT-PIN=1234` report.
|
|
88
|
+
For a narrower base, `{ patterns: ['^--pin$'], additionalPatterns: ['^--vault-pin$'] }`
|
|
89
|
+
reports `--pin` and `--vault-pin`, and leaves `--token` alone. `{ patterns: [] }` checks no names;
|
|
90
|
+
adding `additionalPatterns` to it checks only those added patterns.
|
|
91
|
+
|
|
83
92
|
Regex syntax errors fail when this rule first runs on a file, naming the rule, option and
|
|
84
93
|
pattern. `--print-config` will not catch any regex syntax errors. See the
|
|
85
94
|
[shared compilation contract](./README.md#regular-expression-options).
|
|
@@ -35,8 +35,21 @@ read as `cd`.
|
|
|
35
35
|
by itself, so the rule is quiet there. "Prologue" is read exactly as
|
|
36
36
|
[`require-strict-mode`](./require-strict-mode.md) reads it: the first five top-level statements,
|
|
37
37
|
tracked in order, so a later `set +e` undoes an earlier `set -e`, and a `set -e` outside that
|
|
38
|
-
window does not count.
|
|
39
|
-
|
|
38
|
+
window does not count. Those are the defaults. Both rules read the shared project definition:
|
|
39
|
+
|
|
40
|
+
```js
|
|
41
|
+
{
|
|
42
|
+
settings: { sh: { strictModePrologue: { allowShebangOnly: true, withinStatements: 10 } } },
|
|
43
|
+
rules: { 'sh/no-unchecked-cd': 'error' },
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
With this definition, `#!/bin/bash -e` counts and a `set -e` at statement six counts for both
|
|
48
|
+
rules. The defaults are `allowShebangOnly: false` (shebang flags are bypassed by
|
|
49
|
+
`bash script.sh`) and `withinStatements: 5`. Invalid explicit values throw a named shared-setting
|
|
50
|
+
configuration error; the fields are not per-rule options. See
|
|
51
|
+
[the shared prologue definition](./require-strict-mode.md#shared-prologue-definition).
|
|
52
|
+
Set `ignoreWhenErrexit` to `false` to report anyway.
|
|
40
53
|
|
|
41
54
|
**Files run by bats.** With `languageOptions.dialect` set to `"bats"`, a bare `cd` (or `pushd` or
|
|
42
55
|
`popd`) written directly in the body of a `@test` block, or of a top-level `setup`, `teardown`,
|
|
@@ -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,18 +69,18 @@ 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
|
-
wherever it is listed.
|
|
76
|
-
- `
|
|
77
|
-
to its default).
|
|
75
|
+
wherever it is listed. An empty list removes all built-in commands.
|
|
76
|
+
- `additionalCommands` (`string[]`, default `[]`): more commands to check, added to `commands` (or
|
|
77
|
+
to its default). An empty addition changes nothing; overlapping names report only once.
|
|
78
78
|
|
|
79
79
|
```js
|
|
80
80
|
// eslint.config.js
|
|
81
81
|
{
|
|
82
82
|
rules: {
|
|
83
|
-
'sh/require-network-wrapper': ['error', { wrapper: 'retry',
|
|
83
|
+
'sh/require-network-wrapper': ['error', { wrapper: 'retry', additionalCommands: ['aws'] }],
|
|
84
84
|
},
|
|
85
85
|
}
|
|
86
86
|
```
|
|
@@ -164,7 +164,7 @@ wget() { :; }; wget x # a function the file defines, not the clie
|
|
|
164
164
|
Leave the rule off if your project has no single wrapper for network calls, or if network
|
|
165
165
|
resilience is handled outside your scripts (for example by a proxy or by the CI runner). For a
|
|
166
166
|
policy about commands other than network clients, define your own rule with
|
|
167
|
-
[`createWrapperRule`](../wrapper-rules.md) rather than overloading `
|
|
167
|
+
[`createWrapperRule`](../wrapper-rules.md) rather than overloading `additionalCommands`.
|
|
168
168
|
|
|
169
169
|
## Relationship to shellcheck
|
|
170
170
|
|
|
@@ -5,7 +5,7 @@ Require a script to turn on its strict-mode shell options (`set -euo pipefail` b
|
|
|
5
5
|
|
|
6
6
|
| Configs | Fixable | Languages |
|
|
7
7
|
| ------- | ------- | --------- |
|
|
8
|
-
| `recommended`, `agent-authored
|
|
8
|
+
| `recommended`, `agent-authored` | autofix | `sh/sh` |
|
|
9
9
|
|
|
10
10
|
## Rule details
|
|
11
11
|
|
|
@@ -70,7 +70,7 @@ again. Decide what that `set +e` is for, then edit the file by hand.
|
|
|
70
70
|
|
|
71
71
|
### Dialects
|
|
72
72
|
|
|
73
|
-
When `
|
|
73
|
+
When `requiredOptions` is not configured, the required prologue depends on `languageOptions.dialect`:
|
|
74
74
|
|
|
75
75
|
| `dialect` | Default prologue |
|
|
76
76
|
| -------------------------------------------- | ------------------- |
|
|
@@ -82,7 +82,7 @@ still reject `set -o pipefail`. An autofix that inserted it would break a workin
|
|
|
82
82
|
on those shells, so under `posix` the default requires and inserts only `set -eu`. A `posix` file
|
|
83
83
|
may still turn `pipefail` on; the rule just doesn't require it.
|
|
84
84
|
|
|
85
|
-
|
|
85
|
+
Configured `requiredOptions` always win, whatever the dialect. To require `pipefail` in POSIX scripts too,
|
|
86
86
|
configure it (see below).
|
|
87
87
|
|
|
88
88
|
The dialect comes from `languageOptions`, not from the shebang. A `#!/bin/sh` file linted under the
|
|
@@ -94,20 +94,14 @@ shebang by [`sh/shebang-matches-dialect`](./shebang-matches-dialect.md); set
|
|
|
94
94
|
|
|
95
95
|
This rule takes one options object:
|
|
96
96
|
|
|
97
|
-
- `
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
list. Options with a one-letter flag go into one cluster in list order. The first option with no
|
|
106
|
-
letter is attached to that cluster with `o`, and any others follow as `-o <name>`. So
|
|
107
|
-
`["errexit", "nounset", "pipefail"]` inserts `set -euo pipefail` and `["errexit", "nounset"]`
|
|
108
|
-
inserts `set -eu`.
|
|
109
|
-
|
|
110
|
-
<!-- transform: {"kind": "fix", "options": {"mode": ["errexit", "nounset", "pipefail"]}} -->
|
|
97
|
+
- `requiredOptions` (`string[]`, dialect-aware default above): a nonempty list of unique
|
|
98
|
+
long option names from the supported `set -o` domain (`errexit`, `nounset`, `pipefail`,
|
|
99
|
+
`noclobber`, …). ESLint rejects strings, empty lists, duplicates, unknown names and short
|
|
100
|
+
aliases as configuration errors. The autofix always builds a `set` command from this list:
|
|
101
|
+
options with a one-letter flag go into one cluster in list order, the first long-only option
|
|
102
|
+
follows that cluster with `o`, and any others follow as `-o <name>`.
|
|
103
|
+
|
|
104
|
+
<!-- transform: {"kind": "fix", "options": {"requiredOptions": ["errexit", "nounset", "pipefail"]}} -->
|
|
111
105
|
|
|
112
106
|
```sh
|
|
113
107
|
echo hi
|
|
@@ -116,7 +110,7 @@ This rule takes one options object:
|
|
|
116
110
|
echo hi
|
|
117
111
|
```
|
|
118
112
|
|
|
119
|
-
<!-- transform: {"kind": "fix", "options": {"
|
|
113
|
+
<!-- transform: {"kind": "fix", "options": {"requiredOptions": ["errexit", "nounset"]}} -->
|
|
120
114
|
|
|
121
115
|
```sh
|
|
122
116
|
echo hi
|
|
@@ -124,6 +118,15 @@ This rule takes one options object:
|
|
|
124
118
|
set -eu
|
|
125
119
|
echo hi
|
|
126
120
|
```
|
|
121
|
+
|
|
122
|
+
### Shared prologue definition
|
|
123
|
+
|
|
124
|
+
Both this rule and [`sh/no-unchecked-cd`](./no-unchecked-cd.md) read
|
|
125
|
+
`settings: { sh: { strictModePrologue: { allowShebangOnly: false, withinStatements: 5 } } }`.
|
|
126
|
+
These fields are shared settings, not rule options. Only an absent value uses defaults;
|
|
127
|
+
malformed objects, unknown fields, non-boolean flags and non-positive or non-integer windows
|
|
128
|
+
throw a configuration error naming the shared binding when either rule loads for a file.
|
|
129
|
+
|
|
127
130
|
- `withinStatements` (integer ≥ 1, default `5`): how many top-level statements from the top of the
|
|
128
131
|
file the prologue may take to appear.
|
|
129
132
|
- `allowShebangOnly` (`boolean`, default `false`): when `true`, options passed to the shell on the
|
|
@@ -151,11 +154,10 @@ option. Use an absolute env path and `-S` for both systems.
|
|
|
151
154
|
```js
|
|
152
155
|
// eslint.config.js
|
|
153
156
|
{
|
|
157
|
+
settings: { sh: { strictModePrologue: { allowShebangOnly: false, withinStatements: 5 } } },
|
|
154
158
|
rules: {
|
|
155
159
|
'sh/require-strict-mode': ['error', {
|
|
156
|
-
|
|
157
|
-
withinStatements: 5,
|
|
158
|
-
allowShebangOnly: false,
|
|
160
|
+
requiredOptions: ['errexit', 'nounset', 'pipefail'],
|
|
159
161
|
}],
|
|
160
162
|
},
|
|
161
163
|
}
|
|
@@ -169,7 +171,7 @@ For POSIX `sh` scripts that only run on shells with `pipefail` support, and shou
|
|
|
169
171
|
files: ['**/*.sh'],
|
|
170
172
|
languageOptions: { dialect: 'posix' },
|
|
171
173
|
rules: {
|
|
172
|
-
'sh/require-strict-mode': ['error', {
|
|
174
|
+
'sh/require-strict-mode': ['error', { requiredOptions: ['errexit', 'nounset', 'pipefail'] }],
|
|
173
175
|
},
|
|
174
176
|
}
|
|
175
177
|
```
|
|
@@ -236,7 +238,7 @@ set -e
|
|
|
236
238
|
<!-- example: {"dialect": "posix"} -->
|
|
237
239
|
```sh
|
|
238
240
|
#!/bin/sh
|
|
239
|
-
# with languageOptions: { dialect: 'posix' } and no configured
|
|
241
|
+
# with languageOptions: { dialect: 'posix' } and no configured requiredOptions
|
|
240
242
|
set -eu
|
|
241
243
|
```
|
|
242
244
|
|
|
@@ -11,7 +11,7 @@ have their input supplied explicitly.
|
|
|
11
11
|
|
|
12
12
|
A prompt that waits on the terminal hangs forever when a script runs without one: in CI, from
|
|
13
13
|
cron, or from an agent's tool call. In automation it also reads whatever happens to be on stdin.
|
|
14
|
-
This rule reports `read` and `select` (and any command you add with `
|
|
14
|
+
This rule reports `read` and `select` (and any command you add with `additionalCommands`) that are not
|
|
15
15
|
guarded.
|
|
16
16
|
|
|
17
17
|
The check is **purely syntactic**. The rule never follows data or control flow, so what it treats
|
|
@@ -55,18 +55,27 @@ The rule is honest about what it cannot see:
|
|
|
55
55
|
|
|
56
56
|
- `commands` (`string[]`, default `['read', 'select']`): the interactive commands to check. A
|
|
57
57
|
configured list **replaces** the default, as with `sh/require-network-wrapper`; include `read`
|
|
58
|
-
and `select` to keep them. `select` is parsed as a loop, not a command, and is checked whenever
|
|
58
|
+
and `select` to keep them. An empty list removes all defaults. `select` is parsed as a loop, not a command, and is checked whenever
|
|
59
59
|
the list contains `select`.
|
|
60
60
|
|
|
61
|
+
- `additionalCommands` (`string[]`, default `[]`): commands added to `commands`, or to
|
|
62
|
+
`read` and `select` when `commands` is omitted. An empty addition changes nothing;
|
|
63
|
+
overlapping names report only once.
|
|
64
|
+
|
|
61
65
|
```js
|
|
62
66
|
// eslint.config.js
|
|
63
67
|
{
|
|
64
68
|
rules: {
|
|
65
|
-
'sh/require-tty-guard': ['error', {
|
|
69
|
+
'sh/require-tty-guard': ['error', { additionalCommands: ['confirm'] }],
|
|
66
70
|
},
|
|
67
71
|
}
|
|
68
72
|
```
|
|
69
73
|
|
|
74
|
+
This configuration checks `read`, `select` and `confirm`.
|
|
75
|
+
`{ commands: ['ask'], additionalCommands: ['confirm'] }` checks `ask` and `confirm`,
|
|
76
|
+
leaving `read` and `select` alone. `{ commands: [], additionalCommands: ['confirm'] }`
|
|
77
|
+
checks only `confirm`.
|
|
78
|
+
|
|
70
79
|
## Suggestion
|
|
71
80
|
|
|
72
81
|
The rule offers one suggestion per report: wrap the statement in `if [ -t 0 ]; then … fi`:
|
package/docs/selectors.md
CHANGED
|
@@ -16,13 +16,18 @@ Looking for a complete, runnable `create()` that uses one of these selectors —
|
|
|
16
16
|
|
|
17
17
|
| Class | Matches |
|
|
18
18
|
| -------------- | ---------------------------------------------------- |
|
|
19
|
-
| `:command` | `CallExpr`
|
|
19
|
+
| `:command` | `CallExpr` with a command word (nonempty `args`) |
|
|
20
20
|
| `:loop` | `ForClause`, `WhileClause` |
|
|
21
21
|
| `:conditional` | `IfClause`, `CaseClause` |
|
|
22
22
|
| `:expansion` | `ParamExp`, `CmdSubst`, `ArithmExp`, `ProcSubst` |
|
|
23
23
|
| `:quoted` | `SglQuoted`, `DblQuoted` |
|
|
24
24
|
| `:function` | `FuncDecl` |
|
|
25
25
|
|
|
26
|
+
`:command` matches exactly the calls with an entry in `sourceCode.getCommandInventory().commands`.
|
|
27
|
+
An assignment-only statement such as `FOO=1` has no command site and does not match.
|
|
28
|
+
`FOO=1 jq .`, `true`, `:`, and dynamic invocations such as `"$tool" file` do match.
|
|
29
|
+
Select `CallExpr` directly when you want every call node, including assignment-only calls.
|
|
30
|
+
|
|
26
31
|
`:loop` deliberately does **not** include `CStyleLoop` — that node is `ForClause.loop`'s nested
|
|
27
32
|
C-style arithmetic header (`init`/`cond`/`post`), not a loop statement in its own right. A
|
|
28
33
|
`for ((i=0;i<3;i++))` loop's outer node is still `ForClause`, so `:loop` already reaches it.
|
|
@@ -54,7 +59,7 @@ behind rules like "forbid calling `curl` directly, use the wrapped helper instea
|
|
|
54
59
|
:function :command
|
|
55
60
|
```
|
|
56
61
|
|
|
57
|
-
A descendant combinator: any
|
|
62
|
+
A descendant combinator: any command site that has a `FuncDecl` ancestor. Useful for rules that only
|
|
58
63
|
apply to commands run from within a shell function (e.g. "functions must not shell out to `sudo`").
|
|
59
64
|
|
|
60
65
|
### Match every command nested inside a conditional
|
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
|
|
@@ -213,3 +213,5 @@ A `WrapperSpec` may set `shellBuiltin: true` for a wrapper that runs inside the
|
|
|
213
213
|
Such entries match exact names: an executable such as `/tmp/command` is not the `command`
|
|
214
214
|
builtin and its argument words remain opaque. Omitted or false retains utility-wrapper path
|
|
215
215
|
matching. The same boolean field is accepted in the network-wrapper option and setting.
|
|
216
|
+
|
|
217
|
+
See [error codes](error-codes.md) for stable configuration and helper failure identities.
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
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.0",
|
|
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
13
|
"eslint": "^10.7.0"
|
|
@@ -15,20 +16,12 @@
|
|
|
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": "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
|
|
71
|
+
"check:api-report": "api-extractor run",
|
|
83
72
|
"check:lint-ts": "eslint .",
|
|
84
73
|
"check:typecheck": "tsc --noEmit",
|
|
85
74
|
"clean": "rimraf --glob dist \"temp/*\" \"*.tsbuildinfo\"",
|
|
86
|
-
"fix:api-report": "api-extractor run --local
|
|
75
|
+
"fix:api-report": "api-extractor run --local",
|
|
87
76
|
"fix:lint-ts": "eslint . --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,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The one path by which a rule reads a bound convention's declarations for
|
|
3
|
-
* the file it is linting. The built-in consumers (`sh/no-undeclared-commands`,
|
|
4
|
-
* `sh/no-unused-declarations`) and a pack's own rules all call
|
|
5
|
-
* {@link readDeclaredCommands}, so they hand the convention the same
|
|
6
|
-
* {@link LintedFile} and trust only declarations that passed the same checks.
|
|
7
|
-
*
|
|
8
|
-
* The checks exist because a declaration's kind decides where a report goes
|
|
9
|
-
* and whether a fix is offered. A declaration of an unknown kind, one missing
|
|
10
|
-
* its kind's fields, or a script range outside the text would otherwise be
|
|
11
|
-
* reported at a made-up location, crash deep inside a rule, or be silently
|
|
12
|
-
* accepted by a rule that only reads names. Failing with the declaration and
|
|
13
|
-
* the setting in the message makes the convention's bug the thing the user
|
|
14
|
-
* sees.
|
|
15
|
-
*/
|
|
16
|
-
import type { ShellSourceCode } from '../language/shell-source-code.js';
|
|
17
|
-
import type { DeclarationConvention, DeclaredCommand, LintedFile } from './declaration-convention.js';
|
|
18
|
-
/**
|
|
19
|
-
* What {@link readDeclaredCommands} reads from a rule's context: the linted
|
|
20
|
-
* file and its source code. Any shell rule's `context` satisfies it.
|
|
21
|
-
*
|
|
22
|
-
* @public
|
|
23
|
-
*/
|
|
24
|
-
export interface DeclarationReadContext extends LintedFile {
|
|
25
|
-
/** The source code of the file being linted. */
|
|
26
|
-
readonly sourceCode: ShellSourceCode;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* The only view of the linted file a convention's hooks receive: `filename`,
|
|
30
|
-
* `physicalFilename` and `cwd`, frozen. A rule's `context` must never reach a
|
|
31
|
-
* hook, because it would let a convention report, read options or reach other
|
|
32
|
-
* rule state.
|
|
33
|
-
*
|
|
34
|
-
* @internal
|
|
35
|
-
*/
|
|
36
|
-
export declare function toLintedFile(context: LintedFile): LintedFile;
|
|
37
|
-
/**
|
|
38
|
-
* Returns the declarations `convention` makes for the file `context` is
|
|
39
|
-
* linting, after checking each one against its kind. Call it from a rule's
|
|
40
|
-
* listener with the convention `resolveDeclarationConvention` returned and
|
|
41
|
-
* the rule's own `context`.
|
|
42
|
-
*
|
|
43
|
-
* The convention receives a frozen {@link LintedFile} holding only
|
|
44
|
-
* `filename`, `physicalFilename` and `cwd`, never the whole context, so it
|
|
45
|
-
* sees which file it is reading and nothing it could report through.
|
|
46
|
-
*
|
|
47
|
-
* Throws an `Error` naming the declaration-convention setting and showing the
|
|
48
|
-
* offending value when
|
|
49
|
-
* `declaredCommands` does not return an array, or returns a declaration with
|
|
50
|
-
* a missing or unknown `kind`, without its kind's fields, or with a `range`
|
|
51
|
-
* outside the linted text.
|
|
52
|
-
*
|
|
53
|
-
* @example
|
|
54
|
-
* ```ts
|
|
55
|
-
* const convention = resolveDeclarationConvention(context);
|
|
56
|
-
* if (convention === null) return {};
|
|
57
|
-
* return {
|
|
58
|
-
* File() {
|
|
59
|
-
* for (const declared of readDeclaredCommands(convention, context)) {
|
|
60
|
-
* if (declared.kind === 'script') {
|
|
61
|
-
* // declared.range is an offset pair into context.sourceCode.text
|
|
62
|
-
* }
|
|
63
|
-
* }
|
|
64
|
-
* },
|
|
65
|
-
* };
|
|
66
|
-
* ```
|
|
67
|
-
*
|
|
68
|
-
* @public
|
|
69
|
-
*/
|
|
70
|
-
export declare function readDeclaredCommands(convention: DeclarationConvention, context: DeclarationReadContext): DeclaredCommand[];
|
|
@@ -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`. The plugin root's `resolveWord` takes a lint-view
|
|
11
|
-
* `ShellNode` instead; the two share a name but not an input contract, so this subpath is kept
|
|
12
|
-
* separate from the root.
|
|
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,31 +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. The plugin root (`@eslint-sh/eslint-plugin`) keeps the view-aware helpers such
|
|
17
|
-
* as `resolveWord(ShellNode)`, which differ from the raw helpers of the same name in
|
|
18
|
-
* `@eslint-sh/eslint-plugin/syntax/analyze`. That is why these names live on their own subpath
|
|
19
|
-
* and are not merged into the root.
|
|
20
|
-
*
|
|
21
|
-
* The low-level `printSync` keeps upstream behavior, including changes to literal vertical tabs
|
|
22
|
-
* and form feeds. It does not apply the high-level content refusal used by `format` and
|
|
23
|
-
* `ShellSourceCode.getPrintedReplacement`; callers printing directly must account for that loss.
|
|
24
|
-
*
|
|
25
|
-
* @packageDocumentation
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
export * from "sh-ast";
|
|
30
|
-
|
|
31
|
-
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`. The plugin root's `resolveWord` takes a lint-view
|
|
11
|
-
* `ShellNode` instead; the two share a name but not an input contract, so this subpath is kept
|
|
12
|
-
* separate from the root.
|
|
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`. The plugin root's `resolveWord` takes a lint-view
|
|
13
|
-
* `ShellNode` instead; the two share a name but not an input contract, so this subpath is kept
|
|
14
|
-
* separate from the root.
|
|
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,27 +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. The plugin root (`@eslint-sh/eslint-plugin`) keeps the view-aware helpers such
|
|
17
|
-
* as `resolveWord(ShellNode)`, which differ from the raw helpers of the same name in
|
|
18
|
-
* `@eslint-sh/eslint-plugin/syntax/analyze`. That is why these names live on their own subpath
|
|
19
|
-
* and are not merged into the root.
|
|
20
|
-
*
|
|
21
|
-
* The low-level `printSync` keeps upstream behavior, including changes to literal vertical tabs
|
|
22
|
-
* and form feeds. It does not apply the high-level content refusal used by `format` and
|
|
23
|
-
* `ShellSourceCode.getPrintedReplacement`; callers printing directly must account for that loss.
|
|
24
|
-
*
|
|
25
|
-
* @packageDocumentation
|
|
26
|
-
*/
|
|
27
|
-
export * from 'sh-ast';
|