@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
package/README.md
CHANGED
|
@@ -46,16 +46,22 @@ directory it runs in.
|
|
|
46
46
|
## CommonJS config
|
|
47
47
|
|
|
48
48
|
In a package without `"type": "module"` (the ESLint default), `eslint.config.js` is CommonJS, as
|
|
49
|
-
is `eslint.config.cjs` in any package.
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
is `eslint.config.cjs` in any package. `require('@eslint-sh/eslint-plugin')` returns the plugin object
|
|
50
|
+
directly. Named helpers such as `commentPragma` are properties of that same object;
|
|
51
|
+
`require('@eslint-sh/eslint-plugin').default` also returns it. These helper/default properties are
|
|
52
|
+
non-enumerable, so they do not change ESLint's plugin or config serialization.
|
|
53
|
+
Both packages remain ESM-only and use Node's synchronous `require(ESM)` support
|
|
54
|
+
(Node 22.14+ on the 22.x line, or Node 24+). ESM default and named imports are unchanged.
|
|
55
|
+
|
|
56
|
+
For TypeScript CommonJS consumers, use `import sh = require('@eslint-sh/eslint-plugin')` with
|
|
57
|
+
`module: "node20"` and `moduleResolution: "node16"`, or `module: "nodenext"` and
|
|
58
|
+
`moduleResolution: "nodenext"`. `module: "node16"` models Node without `require(ESM)`
|
|
59
|
+
and rejects this ESM-only package; `skipLibCheck` is not a remedy.
|
|
54
60
|
|
|
55
61
|
```js
|
|
56
62
|
// eslint.config.js (CommonJS package) or eslint.config.cjs
|
|
57
63
|
const { defineConfig } = require('eslint/config');
|
|
58
|
-
const sh = require('@eslint-sh/eslint-plugin')
|
|
64
|
+
const sh = require('@eslint-sh/eslint-plugin');
|
|
59
65
|
// Named exports need no `.default`.
|
|
60
66
|
const { commentPragma } = require('@eslint-sh/eslint-plugin');
|
|
61
67
|
|
|
@@ -71,24 +77,32 @@ module.exports = defineConfig([
|
|
|
71
77
|
|
|
72
78
|
## Public API
|
|
73
79
|
|
|
80
|
+
- `module.exports` — Node's quoted interop export makes plain `require()` return the plugin
|
|
81
|
+
with its hidden default and named helpers. ESM consumers use the ordinary exports below.
|
|
82
|
+
|
|
74
83
|
- `plugin` (default export) — `{ meta: { name, version, namespace: "sh" }, languages: { sh:
|
|
75
84
|
ShellLanguage }, rules, configs: { recommended, 'agent-authored', 'bash-3.2', 'posix-portable' } }`. `meta.version` always
|
|
76
85
|
matches this package's `package.json`. Each config is a single config object with no `files`
|
|
77
86
|
key (`bash-3.2` and `posix-portable` also set `languageOptions`); extend it under your own `files`:
|
|
78
87
|
`defineConfig({ files: ['**/*.sh'], extends: [sh.configs.recommended] })`.
|
|
79
|
-
- `ShellLanguage` —
|
|
88
|
+
- `ShellLanguage` — type-only annotation for `plugin.languages.sh`, the registered runtime
|
|
89
|
+
language. Select it through `language: 'sh/sh'`; construction is internal. The `@eslint/core`
|
|
90
|
+
`Language` implementation has `fileType: "text"`,
|
|
80
91
|
`lineStart`/`columnStart: 1`, `nodeTypeKey: "type"`, the consumer's schema-derived `visitorKeys`,
|
|
81
92
|
`validateLanguageOptions`/`normalizeLanguageOptions` for the
|
|
82
93
|
`{dialect, minBashVersion, directivePrefix}` schema, `parse`/`createSourceCode`, and
|
|
83
94
|
`matchesSelectorClass` for the six launch esquery selector classes (`:command`, `:loop`,
|
|
84
95
|
`:conditional`, `:expansion`, `:quoted`, `:function` — see the
|
|
85
96
|
[selector cookbook](./docs/selectors.md)).
|
|
86
|
-
- `ShellSourceCode` —
|
|
97
|
+
- `ShellSourceCode` — type-only annotation for the instance ESLint supplies as
|
|
98
|
+
`context.sourceCode`; construction belongs to the language pipeline. It extends `@eslint/plugin-kit`'s `TextSourceCodeBase`; implements `traverse()`
|
|
87
99
|
(driven by the consumer's `visitorKeys`, yielding two-phase `VisitNodeStep`s), `getParent()`, and
|
|
88
100
|
the disable-directive surface (`getDisableDirectives()`, `getInlineConfigNodes()`,
|
|
89
|
-
`applyInlineConfig()`). Rule authors get helpers that delegate to `sh-
|
|
90
|
-
gets the same answer: `
|
|
91
|
-
`
|
|
101
|
+
`applyInlineConfig()`). Rule authors get helpers that delegate to `sh-analysis`, so every rule
|
|
102
|
+
gets the same answer: `resolveWord(word, options?)` (the full `WordResolution`) and
|
|
103
|
+
`resolveWordText(word, options?)` (exactly its static text, or `null`). Both use grammar-position
|
|
104
|
+
defaults: command-argument context for `CallExpr.args`, conservative tilde handling elsewhere;
|
|
105
|
+
explicit options override those defaults. Helpers also include `getCommandName(callExpr)` (the static command word,
|
|
92
106
|
without following wrappers), and `resolveInvokedCommand(callExpr, { transparentWrappers? })` (the
|
|
93
107
|
full `Argv0Resolution` once wrappers such as `env`, `sudo`, and `exec` are followed, including the
|
|
94
108
|
wrapper `chain` and the `effective` command or the reason it is unknowable). The `dialect` and
|
|
@@ -109,14 +123,17 @@ ShellLanguage }, rules, configs: { recommended, 'agent-authored', 'bash-3.2', 'p
|
|
|
109
123
|
`ShellNodeMap` maps one to the other. They are computed from `sh-ast`'s generated typings, so
|
|
110
124
|
they follow the pinned mvdan/sh version. `ShellNodeField<T>` is the type of one node field
|
|
111
125
|
(`ShellNodeField<ShellNodeOf<'Stmt'>['cmd']>`), for a helper that takes or returns field values.
|
|
112
|
-
- `
|
|
126
|
+
- `ShellCommandInventory` / `ShellCommandUncertainty` — represented commands and explicit
|
|
127
|
+
opaque execution boundaries from `getCommandInventory()`. Each uncertainty carries its reason,
|
|
128
|
+
original view node, and structural context. The inventory is frozen and cached per file.
|
|
129
|
+
- `ShellCommandSite` / `CommandContext` / `ResolveArgv0Options` — one command in a file as `getCommandInventory().commands` reports it:
|
|
113
130
|
its `CallExpr` node (`node`), the `context` path of enclosing constructs from the file root
|
|
114
131
|
(each frame a `CommandContext`, discriminated by `kind`: `and`, `or`, `pipeline`, `subshell`,
|
|
115
132
|
`cmdSubst`, …), its `argv0` and `argv` as `WordResolution`s, and `resolveInvokedCommand()`,
|
|
116
133
|
which follows wrappers. `ResolveArgv0Options` is that method's option bag (and
|
|
117
134
|
`ShellSourceCode.resolveInvokedCommand`'s): `transparentWrappers` replaces the wrapper table
|
|
118
135
|
followed.
|
|
119
|
-
- `WordResolution` — what `resolveWord` and a site's `argv` words report: `{ static: true, text }`
|
|
136
|
+
- `WordResolution` — what `ShellSourceCode.resolveWord` and a site's `argv` words report: `{ static: true, text }`
|
|
120
137
|
when the word's value is known without running the script, or `{ static: false, reason }` when
|
|
121
138
|
it is not (`reason` is `'expansion'`, `'tilde'`, `'glob'`, `'brace'`, `'locale'` or
|
|
122
139
|
`'unsupported'`; a new reason can appear in a minor release, so keep a `default` branch). Check
|
|
@@ -124,11 +141,7 @@ ShellLanguage }, rules, configs: { recommended, 'agent-authored', 'bash-3.2', 'p
|
|
|
124
141
|
- `ShellDialect` — the `dialect` language option's values: `'bash'`, `'posix'`, `'mksh'`,
|
|
125
142
|
`'bats'` and `'zsh'`.
|
|
126
143
|
- `Argv0Resolution` — the type `ShellSourceCode.resolveInvokedCommand` returns, re-exported from
|
|
127
|
-
`sh-
|
|
128
|
-
- `resolveWord` — adapts a parsed lint Word to `sh-ast`'s word-resolution helper, so a project that installs only
|
|
129
|
-
this package can write custom rules that resolve static shell words (e.g. the `no-rm-rf` example
|
|
130
|
-
in the [custom-rule tutorial](./docs/custom-rule-tutorial.md)) without a separate `sh-ast`
|
|
131
|
-
install. Fabricated nodes are rejected because they have no original syntax association.
|
|
144
|
+
`sh-analysis`.
|
|
132
145
|
- `DeclarationConvention` / `DeclaredCommand` / `commentPragma` — the extension point for how a
|
|
133
146
|
project declares the external commands its scripts use, bound with
|
|
134
147
|
`settings: { sh: { declarationConvention } }`. `commentPragma` is the reference convention,
|
|
@@ -140,8 +153,9 @@ ShellLanguage }, rules, configs: { recommended, 'agent-authored', 'bash-3.2', 'p
|
|
|
140
153
|
snapshot), and the
|
|
141
154
|
linted file a convention is told about so it can find a per-script sidecar. See [declarations
|
|
142
155
|
outside the script](./docs/declaration-conventions.md#declarations-outside-the-script).
|
|
143
|
-
- `
|
|
144
|
-
|
|
156
|
+
- `getDeclaredCommands` — reads validated declarations for the linted file using
|
|
157
|
+
`settings.sh.declarationConvention` only. Returns `null` when no convention is bound and `[]`
|
|
158
|
+
when a bound convention declares nothing. See [reading
|
|
145
159
|
the convention in your own
|
|
146
160
|
rule](./docs/declaration-conventions.md#reading-the-convention-in-your-own-rule).
|
|
147
161
|
- `defineShellRule` / `ShellRule` / `ShellRuleSpec` / `ShellRuleMeta` / `ShellRuleContext` /
|
|
@@ -153,10 +167,10 @@ ShellLanguage }, rules, configs: { recommended, 'agent-authored', 'bash-3.2', 'p
|
|
|
153
167
|
it too. `ShellListener<Node>` is the type of one listener, so a helper that builds listeners for
|
|
154
168
|
several rules can name its return type; `ShellTypedListeners` is the node-type-keyed half of
|
|
155
169
|
`ShellRuleVisitor`. See [Writing your own rules](#writing-your-own-rules).
|
|
156
|
-
- `resolveDeclarationConvention`
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
170
|
+
- `resolveDeclarationConvention` — resolves the convention in
|
|
171
|
+
`settings.sh.declarationConvention`, or `null` when absent. It accepts `{ settings }` and checks
|
|
172
|
+
the convention's hooks for rules that need `removeDeclaration` or another hook. Read
|
|
173
|
+
declarations through `getDeclaredCommands` so their output is validated too. See [declaration
|
|
160
174
|
conventions](./docs/declaration-conventions.md#reading-the-convention-in-your-own-rule).
|
|
161
175
|
- `resolveTransparentWrappers` / `TransparentWrappersBindingContext` — resolves project wrapper
|
|
162
176
|
facts from `settings: { sh: { transparentWrappers: ['with-retry'] } }` and the shared network
|
|
@@ -172,37 +186,28 @@ ShellLanguage }, rules, configs: { recommended, 'agent-authored', 'bash-3.2', 'p
|
|
|
172
186
|
reported, such as `curl --version` or `git clone ./x`. See
|
|
173
187
|
[wrapper rules](./docs/wrapper-rules.md#local-only-invocations).
|
|
174
188
|
|
|
175
|
-
## Faithful syntax:
|
|
189
|
+
## Faithful syntax: `sh-ast`
|
|
176
190
|
|
|
177
|
-
The root
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
helpers. Import them from this package's subpaths, not from `sh-ast`:
|
|
191
|
+
The plugin root owns ESLint view types, source helpers and rule policy. For raw syntax
|
|
192
|
+
operations and types, install and import `sh-ast` directly. For reusable word and command
|
|
193
|
+
observations, install and import `sh-analysis` directly:
|
|
181
194
|
|
|
182
195
|
```js
|
|
183
|
-
|
|
184
|
-
import {
|
|
185
|
-
|
|
186
|
-
import { parseSync, printSync, walk } from '@eslint-sh/eslint-plugin/syntax';
|
|
187
|
-
// sh-ast/analyze: command enumeration and wrapper resolution over faithful records.
|
|
188
|
-
import {
|
|
189
|
-
DEFAULT_TRANSPARENT_WRAPPERS,
|
|
190
|
-
enumerateCommands,
|
|
191
|
-
} from '@eslint-sh/eslint-plugin/syntax/analyze';
|
|
196
|
+
import { defineShellRule } from '@eslint-sh/eslint-plugin';
|
|
197
|
+
import { parseSync, printSync, walk } from 'sh-ast';
|
|
198
|
+
import { DEFAULT_TRANSPARENT_WRAPPERS, enumerateCommands } from 'sh-analysis';
|
|
192
199
|
```
|
|
193
200
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
an `sh-ast` 0.x minor bump is a minor bump of this plugin, and the changelog entry names the
|
|
205
|
-
new `sh-ast` version.
|
|
201
|
+
The supported dependency ranges are `sh-ast@^0.11.0` and `sh-analysis@^0.1.0`.
|
|
202
|
+
The plugin has no syntax forwarding subpaths. Raw `resolveWord` from `sh-analysis` accepts
|
|
203
|
+
faithful syntax records; `context.sourceCode.resolveWord` maps an ESLint Word view to its
|
|
204
|
+
original syntax and applies grammar-position defaults.
|
|
205
|
+
|
|
206
|
+
`context.sourceCode.getCommandInventory()` returns `{ commands, uncertainties }`, with
|
|
207
|
+
both command sites and opaque execution boundaries mapped to original ESLint nodes. Known
|
|
208
|
+
command policies may inspect `commands`. An inventory with uncertainties cannot establish
|
|
209
|
+
complete execution knowledge: a Zsh subscript preserved as raw text may contain executable
|
|
210
|
+
code even when no nested command node exists. The helper never reparses that text.
|
|
206
211
|
|
|
207
212
|
Syntax failures surface as fatal lint messages at mvdan/sh's reported byte offset, converted to
|
|
208
213
|
the source's UTF-16 location. Failures without a valid syntax position use a 1:1 fallback. A
|
|
@@ -216,22 +221,16 @@ the file again, or in a fresh process, usually gets past a runtime failure.
|
|
|
216
221
|
|
|
217
222
|
### Known parser gaps
|
|
218
223
|
|
|
219
|
-
The parser is the upstream `sh-ast`, and it rejects
|
|
224
|
+
The parser is the upstream `sh-ast`, and it rejects two valid Bash forms. Each is reported as a
|
|
220
225
|
syntax error. Until the parser accepts them, write the workaround in the right-hand column.
|
|
221
226
|
|
|
222
227
|
| Valid Bash form | Workaround |
|
|
223
228
|
| ------------------------ | -------------------------- |
|
|
224
229
|
| `x=$((a \|\| b) \| c)` | `x=$( (a \|\| b) \| c )` |
|
|
225
|
-
| `x=(${y}[0])` | `word=${y}[0]; x=($word)` |
|
|
226
230
|
| `declare -A m=([a.b]=1)` | `declare -A m=(["a.b"]=1)` |
|
|
227
231
|
|
|
228
232
|
- `x=$((a || b) | c)`: the parser reads `$((` as the start of arithmetic. A space after `$(` makes
|
|
229
233
|
it a command substitution containing a subshell.
|
|
230
|
-
- `x=(${y}[0])`: inside an array literal, any element word that ends in an unquoted `[…]` is read
|
|
231
|
-
as an indexed element (`[0]=value`) and must be followed by `=`. It is not limited to a word
|
|
232
|
-
that starts with an expansion: `x=(a[0])`, `x=(a${y}[0])` and `x=("${y}"[0])` are rejected too
|
|
233
|
-
(a `[0]` that is meant as a glob character class). Building the word in its own statement keeps
|
|
234
|
-
the same splitting and globbing.
|
|
235
234
|
- An associative-array subscript containing a `.` that is not quoted: the parser reads the
|
|
236
235
|
subscript as arithmetic and rejects the dot ("floating point arithmetic is a zsh feature"). The
|
|
237
236
|
gap is wider than the `declare` form above. It also rejects `m[a.b]=1` and `${m[a.b]}`, which
|
|
@@ -279,3 +278,5 @@ fixes (and when a printed fix reflows code, so a position-based text edit is the
|
|
|
279
278
|
and a TypeScript rule. `docs/` ships with this package (see `package.json#files`), so the
|
|
280
279
|
tutorial and its example files (`docs/examples/`) are available in every installed copy — not just
|
|
281
280
|
on GitHub.
|
|
281
|
+
|
|
282
|
+
See the [error-code reference](docs/error-codes.md) for stable failure identities and dependency boundaries.
|
package/dist/api.d.ts
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The plugin boundary: registered runtime language, instance types and rule helpers.
|
|
3
|
+
* Language/source classes are type-only here; ESLint owns their construction and
|
|
4
|
+
* supplies validated source instances to rules through the registered language.
|
|
5
|
+
*/
|
|
6
|
+
import type { ConfigObject } from '@eslint/core';
|
|
7
|
+
import { ShellLanguage } from './language/shell-language.js';
|
|
8
|
+
export type { ShellLanguage } from './language/shell-language.js';
|
|
9
|
+
export type { ShellSourceCode } from './language/shell-source-code.js';
|
|
10
|
+
export type { NormalizedShellLanguageOptions, ShellLanguageOptions, ShellLanguageOptionsJSON, } from './language/shell-language-options.js';
|
|
11
|
+
export type { Argv0Resolution } from 'sh-analysis';
|
|
12
|
+
export type { CommandContext, ResolveArgv0Options, WordResolution } from 'sh-analysis';
|
|
13
|
+
export type { ShellCommandSite, ShellCommandInventory, ShellCommandUncertainty, } from './language/command-resolution.js';
|
|
14
|
+
export type { ShellComment, ShellFile, ShellNode, ShellNodeField, ShellNodeMap, ShellNodeOf, ShellNodeType, ShellPosition, } from './language/syntax-view.js';
|
|
15
|
+
export type { ShellDialect } from './language/shell-language-options.js';
|
|
16
|
+
export type { DeclarationConvention, DeclaredCommand, FileDeclaredCommand, LintedFile, DescribedDeclaredCommand, ScriptDeclaredCommand, } from './declaration-conventions/declaration-convention.js';
|
|
17
|
+
export { getDeclaredCommands } from './declaration-conventions/get-declared-commands.js';
|
|
18
|
+
export { commentPragma } from './declaration-conventions/comment-pragma.js';
|
|
19
|
+
export { resolveTransparentWrappers } from './rules/resolve-transparent-wrappers.js';
|
|
20
|
+
export type { TransparentWrappersBindingContext } from './rules/resolve-transparent-wrappers.js';
|
|
21
|
+
export { resolveDeclarationConvention } from './rules/resolve-declaration-convention.js';
|
|
22
|
+
export { defineShellRule } from './rules/define-shell-rule.js';
|
|
23
|
+
export type { ShellListener, ShellRule, ShellRuleContext, ShellRuleMeta, ShellRuleSpec, ShellRuleVisitor, ShellTypedListeners, } from './rules/define-shell-rule.js';
|
|
24
|
+
export { createWrapperRule } from './rules/create-wrapper-rule.js';
|
|
25
|
+
export type { WrapperRuleConfig, WrapperRuleLocalInvocation, WrapperRuleLocalOperand, WrapperRuleSubcommands, } from './rules/create-wrapper-rule.js';
|
|
26
|
+
export type { WrapperSpec } from 'sh-analysis';
|
|
27
|
+
/**
|
|
28
|
+
* The `@eslint-sh/eslint-plugin` plugin object, this package's default
|
|
29
|
+
* export (`import sh from '@eslint-sh/eslint-plugin'`). `languages.sh` provides
|
|
30
|
+
* `ShellLanguage` / `ShellSourceCode`, selected in a flat config via
|
|
31
|
+
* `language: "sh/sh"` (`namespace: "sh"`). `meta.version` is read from this
|
|
32
|
+
* package's own `package.json` at runtime — never hardcoded (see
|
|
33
|
+
* `version.ts`).
|
|
34
|
+
*
|
|
35
|
+
* `rules` holds the plugin's built-in rules, each built with
|
|
36
|
+
* `defineShellRule` (so each declares `meta.languages: ["sh/sh"]`) and
|
|
37
|
+
* linking its docs page from `meta.docs.url`. Consumers can also supply their
|
|
38
|
+
* own rules, built with the same `defineShellRule`, while sharing parsing,
|
|
39
|
+
* selectors, source coordinates, and directive semantics.
|
|
40
|
+
*
|
|
41
|
+
* `configs.recommended` is the `sh/recommended` preset: a single config
|
|
42
|
+
* object carrying `plugins: { sh }` and `language: "sh/sh"` but no `files`,
|
|
43
|
+
* so it inherits the globs of the entry that extends it:
|
|
44
|
+
* `{ files: [...], extends: [sh.configs.recommended] }`. It enables the
|
|
45
|
+
* convention-free policy rules. The rules index at
|
|
46
|
+
* https://github.com/mike-north/eslint-sh/blob/main/packages/eslint-plugin/docs/rules/README.md
|
|
47
|
+
* describes preset membership and available autofixes.
|
|
48
|
+
* `configs['agent-authored']` is the strict `sh/agent-authored` preset for
|
|
49
|
+
* machine-written, human-reviewed scripts:
|
|
50
|
+
* every `recommended` rule plus the contract rules, all at `error`.
|
|
51
|
+
* `configs['bash-3.2']` and `configs['posix-portable']` are deployment-target
|
|
52
|
+
* packs: the first sets `languageOptions.minBashVersion: "3.2"` and enables
|
|
53
|
+
* the version-gated `compat/*` rules except the opt-in
|
|
54
|
+
* `compat/no-nounset-empty-array`; the second sets
|
|
55
|
+
* `languageOptions.dialect: "posix"`, enables the effective `compat/*` rules and the
|
|
56
|
+
* shebang/dialect check; it reports named constructs
|
|
57
|
+
* that fail on dash, not every non-POSIX construct, and leaves `local`,
|
|
58
|
+
* `echo -e` and the rest of shellcheck's SC3xxx catalog to shellcheck. Every
|
|
59
|
+
* shipped config is a
|
|
60
|
+
* single object with no `files`; the two packs also carry `languageOptions`,
|
|
61
|
+
* because the target they name is their meaning. Beyond plugin registration
|
|
62
|
+
* and naming, target packs contain only language, languageOptions, and rules
|
|
63
|
+
* whose findings depend on that target. The shebang check belongs because it
|
|
64
|
+
* compares the declared interpreter with the target dialect. Error-handling
|
|
65
|
+
* policy comes from composing recommended, whose POSIX default is `set -eu`.
|
|
66
|
+
* The Bash-only empty-array nounset check cannot report under POSIX and is
|
|
67
|
+
* omitted from posix-portable.
|
|
68
|
+
*
|
|
69
|
+
* Re-exported, unchanged, as the default export of the `eslint-sh` umbrella
|
|
70
|
+
* package: importing this package or the umbrella package both yield the
|
|
71
|
+
* same plugin object.
|
|
72
|
+
*
|
|
73
|
+
* @public
|
|
74
|
+
*/
|
|
75
|
+
declare const plugin: {
|
|
76
|
+
meta: {
|
|
77
|
+
name: string;
|
|
78
|
+
version: string;
|
|
79
|
+
namespace: string;
|
|
80
|
+
};
|
|
81
|
+
languages: {
|
|
82
|
+
sh: ShellLanguage;
|
|
83
|
+
};
|
|
84
|
+
rules: Record<string, import("@eslint/core").RuleDefinition<import("@eslint/core").RuleDefinitionTypeOptions>>;
|
|
85
|
+
configs: {
|
|
86
|
+
recommended: ConfigObject;
|
|
87
|
+
"agent-authored": ConfigObject;
|
|
88
|
+
"bash-3.2": ConfigObject;
|
|
89
|
+
"posix-portable": ConfigObject;
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
export default plugin;
|
package/dist/api.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { createAgentAuthoredConfig } from './configs/agent-authored.js';
|
|
2
|
+
import { createBash32Config } from './configs/bash-3-2.js';
|
|
3
|
+
import { createPosixPortableConfig } from './configs/posix-portable.js';
|
|
4
|
+
import { createRecommendedConfig } from './configs/recommended.js';
|
|
5
|
+
import { ShellLanguage } from './language/shell-language.js';
|
|
6
|
+
import { rules } from './rules/index.js';
|
|
7
|
+
import { readPackageVersion } from './version.js';
|
|
8
|
+
export { getDeclaredCommands } from './declaration-conventions/get-declared-commands.js';
|
|
9
|
+
export { commentPragma } from './declaration-conventions/comment-pragma.js';
|
|
10
|
+
export { resolveTransparentWrappers } from './rules/resolve-transparent-wrappers.js';
|
|
11
|
+
export { resolveDeclarationConvention } from './rules/resolve-declaration-convention.js';
|
|
12
|
+
export { defineShellRule } from './rules/define-shell-rule.js';
|
|
13
|
+
export { createWrapperRule } from './rules/create-wrapper-rule.js';
|
|
14
|
+
/* eslint-disable @api-extractor-tools/public-on-non-exported -- `plugin` is exported below as
|
|
15
|
+
`export default plugin`; the rule only recognizes inline exports. */
|
|
16
|
+
/**
|
|
17
|
+
* The `@eslint-sh/eslint-plugin` plugin object, this package's default
|
|
18
|
+
* export (`import sh from '@eslint-sh/eslint-plugin'`). `languages.sh` provides
|
|
19
|
+
* `ShellLanguage` / `ShellSourceCode`, selected in a flat config via
|
|
20
|
+
* `language: "sh/sh"` (`namespace: "sh"`). `meta.version` is read from this
|
|
21
|
+
* package's own `package.json` at runtime — never hardcoded (see
|
|
22
|
+
* `version.ts`).
|
|
23
|
+
*
|
|
24
|
+
* `rules` holds the plugin's built-in rules, each built with
|
|
25
|
+
* `defineShellRule` (so each declares `meta.languages: ["sh/sh"]`) and
|
|
26
|
+
* linking its docs page from `meta.docs.url`. Consumers can also supply their
|
|
27
|
+
* own rules, built with the same `defineShellRule`, while sharing parsing,
|
|
28
|
+
* selectors, source coordinates, and directive semantics.
|
|
29
|
+
*
|
|
30
|
+
* `configs.recommended` is the `sh/recommended` preset: a single config
|
|
31
|
+
* object carrying `plugins: { sh }` and `language: "sh/sh"` but no `files`,
|
|
32
|
+
* so it inherits the globs of the entry that extends it:
|
|
33
|
+
* `{ files: [...], extends: [sh.configs.recommended] }`. It enables the
|
|
34
|
+
* convention-free policy rules. The rules index at
|
|
35
|
+
* https://github.com/mike-north/eslint-sh/blob/main/packages/eslint-plugin/docs/rules/README.md
|
|
36
|
+
* describes preset membership and available autofixes.
|
|
37
|
+
* `configs['agent-authored']` is the strict `sh/agent-authored` preset for
|
|
38
|
+
* machine-written, human-reviewed scripts:
|
|
39
|
+
* every `recommended` rule plus the contract rules, all at `error`.
|
|
40
|
+
* `configs['bash-3.2']` and `configs['posix-portable']` are deployment-target
|
|
41
|
+
* packs: the first sets `languageOptions.minBashVersion: "3.2"` and enables
|
|
42
|
+
* the version-gated `compat/*` rules except the opt-in
|
|
43
|
+
* `compat/no-nounset-empty-array`; the second sets
|
|
44
|
+
* `languageOptions.dialect: "posix"`, enables the effective `compat/*` rules and the
|
|
45
|
+
* shebang/dialect check; it reports named constructs
|
|
46
|
+
* that fail on dash, not every non-POSIX construct, and leaves `local`,
|
|
47
|
+
* `echo -e` and the rest of shellcheck's SC3xxx catalog to shellcheck. Every
|
|
48
|
+
* shipped config is a
|
|
49
|
+
* single object with no `files`; the two packs also carry `languageOptions`,
|
|
50
|
+
* because the target they name is their meaning. Beyond plugin registration
|
|
51
|
+
* and naming, target packs contain only language, languageOptions, and rules
|
|
52
|
+
* whose findings depend on that target. The shebang check belongs because it
|
|
53
|
+
* compares the declared interpreter with the target dialect. Error-handling
|
|
54
|
+
* policy comes from composing recommended, whose POSIX default is `set -eu`.
|
|
55
|
+
* The Bash-only empty-array nounset check cannot report under POSIX and is
|
|
56
|
+
* omitted from posix-portable.
|
|
57
|
+
*
|
|
58
|
+
* Re-exported, unchanged, as the default export of the `eslint-sh` umbrella
|
|
59
|
+
* package: importing this package or the umbrella package both yield the
|
|
60
|
+
* same plugin object.
|
|
61
|
+
*
|
|
62
|
+
* @public
|
|
63
|
+
*/
|
|
64
|
+
const plugin = {
|
|
65
|
+
meta: {
|
|
66
|
+
name: '@eslint-sh/eslint-plugin',
|
|
67
|
+
version: readPackageVersion(),
|
|
68
|
+
namespace: 'sh',
|
|
69
|
+
},
|
|
70
|
+
languages: {
|
|
71
|
+
sh: new ShellLanguage(),
|
|
72
|
+
},
|
|
73
|
+
rules,
|
|
74
|
+
// Filled in below: each shipped config registers this very object under
|
|
75
|
+
// `plugins.sh`, so the plugin must exist before its configs can.
|
|
76
|
+
configs: {},
|
|
77
|
+
};
|
|
78
|
+
/* eslint-enable @api-extractor-tools/public-on-non-exported */
|
|
79
|
+
plugin.configs.recommended = createRecommendedConfig(plugin);
|
|
80
|
+
plugin.configs['agent-authored'] = createAgentAuthoredConfig(plugin);
|
|
81
|
+
plugin.configs['bash-3.2'] = createBash32Config(plugin);
|
|
82
|
+
plugin.configs['posix-portable'] = createPosixPortableConfig(plugin);
|
|
83
|
+
export default plugin;
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
*
|
|
23
23
|
* @see https://bats-core.readthedocs.io/en/stable/writing-tests.html
|
|
24
24
|
*/
|
|
25
|
-
import type { WrapperSpec } from 'sh-
|
|
25
|
+
import type { WrapperSpec } from 'sh-analysis';
|
|
26
26
|
/**
|
|
27
27
|
* Every helper function bats-core provides to test files.
|
|
28
28
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { WrapperSpec } from 'sh-
|
|
2
|
-
import type { ShellCommandSite } from '../language/command-resolution.js';
|
|
1
|
+
import type { WrapperSpec } from 'sh-analysis';
|
|
2
|
+
import type { ShellCommandSite, ShellCommandUncertainty } from '../language/command-resolution.js';
|
|
3
3
|
import type { ShellSourceCode } from '../language/shell-source-code.js';
|
|
4
4
|
import type { ShellNode } from '../language/syntax-view.js';
|
|
5
5
|
/**
|
|
@@ -10,7 +10,7 @@ import type { ShellNode } from '../language/syntax-view.js';
|
|
|
10
10
|
export interface HarvestCommandsOptions {
|
|
11
11
|
/**
|
|
12
12
|
* The transparent-wrapper table to follow, forwarded to
|
|
13
|
-
* `resolveInvokedCommand` unchanged. It **replaces** `sh-
|
|
13
|
+
* `resolveInvokedCommand` unchanged. It **replaces** `sh-analysis`'s
|
|
14
14
|
* `DEFAULT_TRANSPARENT_WRAPPERS` (spread the defaults in to extend them).
|
|
15
15
|
* Defaults to `DEFAULT_TRANSPARENT_WRAPPERS`.
|
|
16
16
|
*/
|
|
@@ -34,6 +34,17 @@ export interface HarvestedCommand {
|
|
|
34
34
|
/** The command site of that first use. */
|
|
35
35
|
readonly site: ShellCommandSite;
|
|
36
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Observed external dependencies and execution boundaries retained from analysis.
|
|
39
|
+
* The map alone is deliberately insufficient to claim complete dependencies.
|
|
40
|
+
* @internal
|
|
41
|
+
*/
|
|
42
|
+
export interface CommandHarvest {
|
|
43
|
+
/** Known static external commands, keyed by name in first-use order. */
|
|
44
|
+
readonly commands: ReadonlyMap<string, HarvestedCommand>;
|
|
45
|
+
/** Opaque syntax whose dependencies remain unknown. */
|
|
46
|
+
readonly uncertainties: readonly ShellCommandUncertainty[];
|
|
47
|
+
}
|
|
37
48
|
/**
|
|
38
49
|
* The names of every function the file defines, anywhere in it (top level,
|
|
39
50
|
* nested in another function, inside a conditional, …). Position is not read,
|
|
@@ -46,7 +57,7 @@ export interface HarvestedCommand {
|
|
|
46
57
|
*/
|
|
47
58
|
export declare function definedFunctionNames(sourceCode: ShellSourceCode): ReadonlySet<string>;
|
|
48
59
|
/**
|
|
49
|
-
* Returns
|
|
60
|
+
* Returns known represented external commands `sourceCode` runs, keyed by name, each with
|
|
50
61
|
* its first use. The map iterates in first-use (source) order.
|
|
51
62
|
*
|
|
52
63
|
* A command is every static word in an invocation's wrapper chain (the
|
|
@@ -56,11 +67,11 @@ export declare function definedFunctionNames(sourceCode: ShellSourceCode): Reado
|
|
|
56
67
|
* - builtins of the file's dialect (`sourceCode.dialect`);
|
|
57
68
|
* - functions the file defines anywhere.
|
|
58
69
|
*
|
|
59
|
-
* @throws `ShAnalyzeMaxDepthError` (from `sh-
|
|
70
|
+
* @throws `ShAnalyzeMaxDepthError` (`SH_ANALYSIS_MAX_DEPTH`, from `sh-analysis`) when the file's
|
|
60
71
|
* nesting exceeds analysis's recursion guard: a partial harvest would miss
|
|
61
72
|
* real commands.
|
|
62
|
-
* @throws `ShAnalyzeInvalidWrapperSpecError` (from `sh-
|
|
73
|
+
* @throws `ShAnalyzeInvalidWrapperSpecError` (`SH_ANALYSIS_INVALID_WRAPPER_SPEC`, from `sh-analysis`) when
|
|
63
74
|
* `options.transparentWrappers` contains a malformed entry.
|
|
64
75
|
* @internal
|
|
65
76
|
*/
|
|
66
|
-
export declare function harvestCommands(sourceCode: ShellSourceCode, options?: HarvestCommandsOptions):
|
|
77
|
+
export declare function harvestCommands(sourceCode: ShellSourceCode, options?: HarvestCommandsOptions): CommandHarvest;
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* the shell's builtins and minus functions the file defines itself, following
|
|
7
7
|
* transparent wrappers so that `sudo curl …` uses both `sudo` and `curl`.
|
|
8
8
|
*
|
|
9
|
-
* Every fact comes from `sh-
|
|
10
|
-
* helpers.
|
|
9
|
+
* Every fact comes from `sh-analysis` through the `ShellSourceCode`
|
|
10
|
+
* helpers. The inventory supplies represented commands in the file, wherever it
|
|
11
11
|
* is nested (function bodies, `$(…)` in arguments, assignment values,
|
|
12
12
|
* redirect targets, loop lists, case subjects, …), and each site's
|
|
13
13
|
* `resolveInvokedCommand` supplies the wrapper chain. Whether a word is
|
|
@@ -23,10 +23,11 @@
|
|
|
23
23
|
* - Commands inside strings that another program runs (`bash -c '…'`,
|
|
24
24
|
* `env -S '…'`). Those are text, not syntax.
|
|
25
25
|
*
|
|
26
|
-
* This module
|
|
27
|
-
*
|
|
26
|
+
* This module owns ESLint dependency policy: builtin/function exclusion and
|
|
27
|
+
* first-use report nodes. Opaque analysis boundaries travel with the harvest;
|
|
28
|
+
* known observations do not prove exhaustive dependencies.
|
|
28
29
|
*/
|
|
29
|
-
import { DEFAULT_TRANSPARENT_WRAPPERS } from 'sh-
|
|
30
|
+
import { DEFAULT_TRANSPARENT_WRAPPERS } from 'sh-analysis';
|
|
30
31
|
import { walkShell } from '../language/syntax-view.js';
|
|
31
32
|
import { builtinsForDialect } from './builtins/index.js';
|
|
32
33
|
/**
|
|
@@ -60,7 +61,7 @@ function wordNodeAt(site, index) {
|
|
|
60
61
|
return site.node.args[index] ?? site.node;
|
|
61
62
|
}
|
|
62
63
|
/**
|
|
63
|
-
* Returns
|
|
64
|
+
* Returns known represented external commands `sourceCode` runs, keyed by name, each with
|
|
64
65
|
* its first use. The map iterates in first-use (source) order.
|
|
65
66
|
*
|
|
66
67
|
* A command is every static word in an invocation's wrapper chain (the
|
|
@@ -70,10 +71,10 @@ function wordNodeAt(site, index) {
|
|
|
70
71
|
* - builtins of the file's dialect (`sourceCode.dialect`);
|
|
71
72
|
* - functions the file defines anywhere.
|
|
72
73
|
*
|
|
73
|
-
* @throws `ShAnalyzeMaxDepthError` (from `sh-
|
|
74
|
+
* @throws `ShAnalyzeMaxDepthError` (`SH_ANALYSIS_MAX_DEPTH`, from `sh-analysis`) when the file's
|
|
74
75
|
* nesting exceeds analysis's recursion guard: a partial harvest would miss
|
|
75
76
|
* real commands.
|
|
76
|
-
* @throws `ShAnalyzeInvalidWrapperSpecError` (from `sh-
|
|
77
|
+
* @throws `ShAnalyzeInvalidWrapperSpecError` (`SH_ANALYSIS_INVALID_WRAPPER_SPEC`, from `sh-analysis`) when
|
|
77
78
|
* `options.transparentWrappers` contains a malformed entry.
|
|
78
79
|
* @internal
|
|
79
80
|
*/
|
|
@@ -82,7 +83,7 @@ export function harvestCommands(sourceCode, options = {}) {
|
|
|
82
83
|
const builtins = builtinsForDialect(sourceCode.dialect);
|
|
83
84
|
const functions = definedFunctionNames(sourceCode);
|
|
84
85
|
const harvested = new Map();
|
|
85
|
-
for (const site of sourceCode.
|
|
86
|
+
for (const site of sourceCode.getCommandInventory().commands) {
|
|
86
87
|
const { chain, chainIndices } = site.resolveInvokedCommand({ transparentWrappers });
|
|
87
88
|
for (const [position, word] of chain.entries()) {
|
|
88
89
|
if (!word.static)
|
|
@@ -93,5 +94,5 @@ export function harvestCommands(sourceCode, options = {}) {
|
|
|
93
94
|
harvested.set(name, { name, node: wordNodeAt(site, chainIndices[position]), site });
|
|
94
95
|
}
|
|
95
96
|
}
|
|
96
|
-
return harvested;
|
|
97
|
+
return { commands: harvested, uncertainties: sourceCode.getCommandInventory().uncertainties };
|
|
97
98
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Both declaration rules compose this dialect scope with the shared project
|
|
4
4
|
* facts through resolveTransparentWrappers, so they compute the same usage.
|
|
5
5
|
*/
|
|
6
|
-
import { DEFAULT_TRANSPARENT_WRAPPERS } from 'sh-
|
|
6
|
+
import { DEFAULT_TRANSPARENT_WRAPPERS } from 'sh-analysis';
|
|
7
7
|
import { BATS_RUN_WRAPPER } from './builtins/bats.js';
|
|
8
8
|
/** Wrappers a dialect runtime provides beyond sh-ast's defaults. */
|
|
9
9
|
const DIALECT_WRAPPERS = {
|
|
@@ -14,18 +14,14 @@
|
|
|
14
14
|
* shellcheck, which is why it does not promise "any POSIX `sh`". The scope and
|
|
15
15
|
* the shell behaviour behind it are stated for users in `docs/compat.md`.
|
|
16
16
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* `recommended
|
|
21
|
-
*
|
|
22
|
-
* ash reject. A pack that asked for `pipefail` would make its own autofix
|
|
23
|
-
* break a working `#!/bin/sh` script.
|
|
17
|
+
* Target presets carry only target facts and findings that depend on them.
|
|
18
|
+
* The shebang check belongs here because it verifies the declared interpreter
|
|
19
|
+
* against the configured target. Error-handling policy belongs to recommended:
|
|
20
|
+
* `extends: [sh.configs.recommended, sh.configs['posix-portable']]` requires
|
|
21
|
+
* the dialect-aware POSIX default, `set -eu`.
|
|
24
22
|
*
|
|
25
23
|
* It follows the shape contract in `./recommended.ts`, extended with
|
|
26
|
-
* `languageOptions`
|
|
27
|
-
* through `extends: [sh.configs.recommended, sh.configs['posix-portable']]`;
|
|
28
|
-
* the later entry's `require-strict-mode` options win.
|
|
24
|
+
* `languageOptions` because the target is the preset's meaning.
|
|
29
25
|
*
|
|
30
26
|
* Rule membership follows the **Configs** column of the rule catalog (rows
|
|
31
27
|
* marked `P`), which a test checks against this module.
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The rules `sh/posix-portable` enables, all at `error`, keyed as a user
|
|
3
|
-
* writes them (`sh/<rule-name>`):
|
|
4
|
-
* `dialect: 'posix'
|
|
5
|
-
* `bash-3.2` has no use for, the shebang/dialect check
|
|
6
|
-
* POSIX
|
|
3
|
+
* writes them (`sh/<rule-name>`): the effective `compat/*` rules under
|
|
4
|
+
* `dialect: 'posix'`, including the POSIX-only gates
|
|
5
|
+
* `bash-3.2` has no use for, and the shebang/dialect check. The empty-array
|
|
6
|
+
* nounset rule is omitted because it checks Bash targets and cannot report under POSIX.
|
|
7
7
|
*
|
|
8
8
|
* @internal
|
|
9
9
|
*/
|
|
10
10
|
const posixPortableRules = {
|
|
11
|
-
'sh/require-strict-mode': ['error', { mode: 'set -eu' }],
|
|
12
11
|
'sh/shebang-matches-dialect': 'error',
|
|
13
12
|
'sh/compat/no-append-all-redirect': 'error',
|
|
14
13
|
'sh/compat/no-associative-arrays': 'error',
|
|
@@ -27,7 +26,6 @@ const posixPortableRules = {
|
|
|
27
26
|
'sh/compat/no-mapfile': 'error',
|
|
28
27
|
'sh/compat/no-nameref': 'error',
|
|
29
28
|
'sh/compat/no-negative-array-index': 'error',
|
|
30
|
-
'sh/compat/no-nounset-empty-array': 'error',
|
|
31
29
|
'sh/compat/no-parameter-transformation': 'error',
|
|
32
30
|
'sh/compat/no-pipe-all': 'error',
|
|
33
31
|
'sh/compat/no-printf-time-format': 'error',
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Human diagnostics for project-owned configuration boundaries. Codes belong to
|
|
3
|
+
* the rejecting boundary; this module only keeps paths and received values
|
|
4
|
+
* consistent, without constructing errors or coupling runtime packages.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Render a rejected value using the project's short JSON-first convention.
|
|
8
|
+
* Non-JSON values must not replace the intended configuration failure with a
|
|
9
|
+
* serialization exception. The rendering is diagnostic text, never stored state.
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export declare function describeConfigurationValue(value: unknown): string;
|
|
13
|
+
/** The user's path identifies the binding; prose may evolve independently of the error code. @internal */
|
|
14
|
+
export declare function configurationMessage(where: string, detail: string, value: unknown): string;
|