@eslint-sh/eslint-plugin 0.12.0 → 0.13.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 +5 -2
- package/dist/api.d.ts +1 -1
- package/dist/command-harvest/harvest-commands.d.ts +5 -3
- package/dist/command-harvest/harvest-commands.js +34 -12
- package/dist/eslint-plugin-api.d.ts +25 -11
- package/dist/language/command-resolution.d.ts +16 -6
- package/dist/language/command-resolution.js +44 -17
- package/dist/language/shell-source-code.d.ts +18 -10
- package/dist/language/shell-source-code.js +24 -25
- package/dist/language/word-resolution.d.ts +18 -12
- package/dist/language/word-resolution.js +133 -3
- package/dist/rules/compat/bash-builtin-destination.d.ts +2 -0
- package/dist/rules/compat/bash-builtin-destination.js +4 -0
- package/dist/rules/compat/declaration-options.d.ts +2 -2
- package/dist/rules/compat/declaration-options.js +23 -17
- package/dist/rules/compat/no-case-attributes.js +2 -4
- package/dist/rules/compat/no-mapfile.js +16 -19
- package/dist/rules/compat/no-negative-array-index.d.ts +3 -8
- package/dist/rules/compat/no-negative-array-index.js +7 -30
- package/dist/rules/compat/no-nounset-empty-array.js +10 -7
- package/dist/rules/compat/no-parameter-transformation.js +2 -1
- package/dist/rules/compat/no-printf-time-format.js +38 -16
- package/dist/rules/compat/no-source.d.ts +3 -8
- package/dist/rules/compat/no-source.js +3 -40
- package/dist/rules/compat/no-test-v.js +243 -61
- package/dist/rules/compat/no-wait-n.js +43 -12
- package/dist/rules/compat/nounset-array-proof.d.ts +3 -1
- package/dist/rules/compat/nounset-array-proof.js +84 -63
- package/dist/rules/compat/posix-absent-command.js +3 -2
- package/dist/rules/compat/shopt-options.js +3 -2
- package/dist/rules/create-wrapper-rule.js +16 -9
- package/dist/rules/no-dynamic-invocation.js +8 -9
- package/dist/rules/no-eval.js +19 -8
- package/dist/rules/no-masked-exit-status.js +29 -17
- package/dist/rules/no-secret-flags.js +4 -3
- package/dist/rules/no-unchecked-cd.d.ts +8 -3
- package/dist/rules/no-unchecked-cd.js +54 -25
- package/dist/rules/no-unused-declarations.js +51 -19
- package/dist/rules/prefer-local.js +136 -16
- package/dist/rules/require-strict-mode.d.ts +2 -2
- package/dist/rules/require-strict-mode.js +27 -18
- package/dist/rules/require-tty-guard.d.ts +2 -0
- package/dist/rules/require-tty-guard.js +197 -45
- package/dist/rules/set-options.d.ts +3 -1
- package/dist/rules/set-options.js +5 -1
- package/dist/rules/strict-mode-prologue.d.ts +9 -2
- package/dist/rules/strict-mode-prologue.js +45 -8
- package/docs/custom-rule-tutorial.md +10 -7
- package/docs/error-codes.md +4 -0
- package/docs/examples/no-curl-in-functions-rule.mjs +7 -5
- package/docs/rules/README.md +4 -4
- package/docs/rules/compat/no-mapfile.md +11 -20
- package/docs/rules/compat/no-negative-array-index.md +9 -22
- package/docs/rules/compat/no-nounset-empty-array.md +5 -5
- package/docs/rules/compat/no-printf-time-format.md +2 -1
- package/docs/rules/compat/no-source.md +8 -17
- package/docs/rules/compat/no-test-v.md +7 -1
- package/docs/rules/compat/no-wait-n.md +3 -1
- package/docs/rules/no-dynamic-invocation.md +3 -0
- package/docs/rules/no-eval.md +22 -1
- package/docs/rules/no-masked-exit-status.md +2 -1
- package/docs/rules/no-secret-flags.md +22 -2
- package/docs/rules/no-unchecked-cd.md +2 -1
- package/docs/rules/no-undeclared-commands.md +1 -1
- package/docs/rules/no-unused-declarations.md +10 -6
- package/docs/rules/prefer-local.md +4 -0
- package/docs/rules/require-network-wrapper.md +1 -1
- package/docs/rules/require-strict-mode.md +19 -11
- package/docs/rules/require-tty-guard.md +26 -4
- package/docs/wrapper-rules.md +1 -1
- package/package.json +4 -4
|
@@ -30,13 +30,19 @@ A command has its input supplied explicitly, and is not reported, when:
|
|
|
30
30
|
|
|
31
31
|
- it, or any statement that encloses it, redirects fd 0 from a file, here-document or
|
|
32
32
|
here-string (`read x < file`, `read x <<< "$v"`, `while read l; do …; done < file`), or from
|
|
33
|
-
|
|
33
|
+
a known nonzero descriptor (`read x <&3`), or closes fd 0 (`read x <&-`). In the `zsh` and
|
|
34
|
+
`mksh` dialects, a target that resolves to `p` takes input from the coprocess (`read x <&p`).
|
|
35
|
+
A computed duplication target can still refer to stdin;
|
|
34
36
|
- it is on the right of a pipe (`echo a | read x`, `cat f | while read l; do …; done`);
|
|
35
37
|
- it is inside a `coproc`, which reads its own input pipe;
|
|
36
|
-
- it is `read -u N`
|
|
37
|
-
|
|
38
|
+
- it is Bash or Zsh `read -u N` with a known nonzero final descriptor, or mksh
|
|
39
|
+
`read -uN` with a known nonzero attached descriptor. Bash accepts zero padding
|
|
40
|
+
and leading whitespace in a `read -u` descriptor. The rule can step past a
|
|
41
|
+
Bash prompt option whose argument is guaranteed to produce one field, as in
|
|
42
|
+
`read -p "$prompt" -u 3 answer`.
|
|
43
|
+
- it is mksh or Zsh `read -p`, which reads from the coprocess. In mksh, `read -up`
|
|
44
|
+
also selects the coprocess. In Bash and dash, `-p` supplies a prompt.
|
|
38
45
|
|
|
39
|
-
A `read` with `-p` is still reported: the prompt does not make it safe without a terminal.
|
|
40
46
|
|
|
41
47
|
### Limits
|
|
42
48
|
|
|
@@ -52,6 +58,22 @@ The rule is honest about what it cannot see:
|
|
|
52
58
|
or with a dynamic name is not matched.
|
|
53
59
|
- A CR on a delimiter-like heredoc line can make the guard suggestion end inside the body.
|
|
54
60
|
|
|
61
|
+
Zsh `read -k` can open the terminal even when stdin is redirected. An explicit descriptor or coprocess option supplies input instead.
|
|
62
|
+
|
|
63
|
+
The guard test replaces the current exit status and pipeline status. The rule withholds the
|
|
64
|
+
wrapper when it sees a reference to `$?`, Bash's `PIPESTATUS`, or Zsh's `status` or
|
|
65
|
+
`pipestatus` in the statement or its redirections, including expanding here-documents.
|
|
66
|
+
It also withholds the wrapper for Bash indirect parameter expansions that can read status.
|
|
67
|
+
|
|
68
|
+
An unresolved descriptor duplication such as `read answer 0<&"$fd"`, an unsupported
|
|
69
|
+
input target such as `read answer 0<&foo`, or an unresolved option word such as
|
|
70
|
+
`read "$arg" answer` can still report. The rule withholds the wrapper because the command
|
|
71
|
+
could read from an alternate descriptor or fail while setting up input. It also withholds
|
|
72
|
+
the wrapper when a known or unresolved option can fail before input is read,
|
|
73
|
+
when a final `-u 0` follows a nonzero descriptor that Bash checks first, or
|
|
74
|
+
when a duplication target is invalid for the dialect. For example, dash and
|
|
75
|
+
mksh reject `0<&00`, and Bash rejects `read -t nope -u 00 answer`.
|
|
76
|
+
|
|
55
77
|
## Options
|
|
56
78
|
|
|
57
79
|
- `commands` (`string[]`, default `['read', 'select']`): the interactive commands to check. A
|
package/docs/wrapper-rules.md
CHANGED
|
@@ -199,7 +199,7 @@ A command word that contains a slash is matched by its basename, so running a co
|
|
|
199
199
|
cannot bypass the policy. `/usr/bin/curl x` and `./bin/curl x` are `curl`, and the message names
|
|
200
200
|
`curl`. The same holds for wrappers: `/usr/local/bin/retry curl x` is `curl` run through `retry`,
|
|
201
201
|
with `retry`'s declared options, and `/usr/bin/sudo curl x` is `curl` run through `sudo`. Only the
|
|
202
|
-
whole basename is compared
|
|
202
|
+
whole basename is compared. A word like `"$dir"/curl` matches when analysis guarantees one field ending in `/curl`. Following a wrapper through an unresolved path or resolving a subcommand after it still requires an analyzable chain.
|
|
203
203
|
|
|
204
204
|
### Subcommands
|
|
205
205
|
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
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.13.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.
|
|
10
|
-
"sh-analysis": "^0.
|
|
9
|
+
"sh-ast": "^0.13.0",
|
|
10
|
+
"sh-analysis": "^0.4.0"
|
|
11
11
|
},
|
|
12
12
|
"devDependencies": {
|
|
13
|
-
"eslint": "^10.
|
|
13
|
+
"eslint": "^10.15.0"
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|
|
16
16
|
"eslint": "^10.2.0"
|