@eslint-sh/eslint-plugin 0.6.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/README.md +19 -8
  2. package/dist/command-harvest/builtins/bash.d.ts +1 -1
  3. package/dist/command-harvest/builtins/bash.js +1 -1
  4. package/dist/command-harvest/builtins/bats.d.ts +2 -0
  5. package/dist/command-harvest/builtins/bats.js +3 -0
  6. package/dist/command-harvest/wrapper-table.d.ts +3 -19
  7. package/dist/command-harvest/wrapper-table.js +8 -38
  8. package/dist/configs/bash-3-2.d.ts +7 -6
  9. package/dist/configs/bash-3-2.js +5 -3
  10. package/dist/configs/posix-portable.d.ts +1 -1
  11. package/dist/configs/posix-portable.js +1 -0
  12. package/dist/declaration-conventions/read-declared-commands.d.ts +2 -2
  13. package/dist/declaration-conventions/read-declared-commands.js +2 -2
  14. package/dist/eslint-plugin-syntax.d.ts +4 -0
  15. package/dist/eslint-plugin.d.ts +86 -40
  16. package/dist/index.d.ts +5 -2
  17. package/dist/index.js +4 -2
  18. package/dist/language/shell-language-options.d.ts +18 -15
  19. package/dist/language/shell-language-options.js +33 -26
  20. package/dist/language/shell-language.d.ts +10 -9
  21. package/dist/language/shell-language.js +18 -35
  22. package/dist/language/shell-source-code.d.ts +17 -9
  23. package/dist/language/shell-source-code.js +53 -12
  24. package/dist/rules/bash-variable-semantics.d.ts +22 -0
  25. package/dist/rules/bash-variable-semantics.js +41 -0
  26. package/dist/rules/compat/create-compat-rule.js +1 -1
  27. package/dist/rules/compat/declaration-options.d.ts +2 -2
  28. package/dist/rules/compat/declaration-options.js +5 -2
  29. package/dist/rules/compat/no-append-all-redirect.js +1 -1
  30. package/dist/rules/compat/no-associative-arrays.js +2 -2
  31. package/dist/rules/compat/no-brace-sequence-padding-step.d.ts +15 -0
  32. package/dist/rules/compat/no-brace-sequence-padding-step.js +287 -0
  33. package/dist/rules/compat/no-case-attributes.js +3 -3
  34. package/dist/rules/compat/no-case-fallthrough.js +2 -2
  35. package/dist/rules/compat/no-case-modification.js +2 -2
  36. package/dist/rules/compat/no-coproc.js +1 -1
  37. package/dist/rules/compat/no-declare-g.js +3 -3
  38. package/dist/rules/compat/no-double-bracket.js +2 -2
  39. package/dist/rules/compat/no-epoch-variables.js +2 -2
  40. package/dist/rules/compat/no-fd-variable.js +1 -1
  41. package/dist/rules/compat/no-globstar.js +1 -1
  42. package/dist/rules/compat/no-lastpipe-semantics.js +2 -2
  43. package/dist/rules/compat/no-let.js +2 -1
  44. package/dist/rules/compat/no-mapfile.js +4 -2
  45. package/dist/rules/compat/no-nameref.js +3 -3
  46. package/dist/rules/compat/no-negative-array-index.js +39 -9
  47. package/dist/rules/compat/no-nounset-empty-array.js +15 -4
  48. package/dist/rules/compat/no-parameter-transformation.js +2 -2
  49. package/dist/rules/compat/no-pipe-all.js +1 -1
  50. package/dist/rules/compat/no-printf-time-format.js +4 -2
  51. package/dist/rules/compat/no-source.js +2 -1
  52. package/dist/rules/compat/no-test-v.js +4 -2
  53. package/dist/rules/compat/no-unicode-escape.js +2 -2
  54. package/dist/rules/compat/no-wait-n.js +4 -2
  55. package/dist/rules/compat/nounset-array-proof.d.ts +8 -0
  56. package/dist/rules/compat/nounset-array-proof.js +563 -0
  57. package/dist/rules/compat/posix-absent-command.d.ts +7 -8
  58. package/dist/rules/compat/posix-absent-command.js +17 -15
  59. package/dist/rules/compat/shopt-options.js +3 -1
  60. package/dist/rules/compat/version-gates.d.ts +10 -10
  61. package/dist/rules/compat/version-gates.js +21 -13
  62. package/dist/rules/create-wrapper-rule.js +12 -7
  63. package/dist/rules/index.js +2 -0
  64. package/dist/rules/no-dynamic-invocation.d.ts +0 -8
  65. package/dist/rules/no-dynamic-invocation.js +7 -15
  66. package/dist/rules/no-eval.js +3 -1
  67. package/dist/rules/no-masked-exit-status.js +15 -8
  68. package/dist/rules/no-secret-env-reads.d.ts +4 -3
  69. package/dist/rules/no-secret-env-reads.js +37 -14
  70. package/dist/rules/no-secret-flags.d.ts +2 -1
  71. package/dist/rules/no-secret-flags.js +7 -8
  72. package/dist/rules/no-unchecked-cd.js +3 -1
  73. package/dist/rules/no-undeclared-commands.d.ts +1 -15
  74. package/dist/rules/no-undeclared-commands.js +3 -15
  75. package/dist/rules/no-unused-declarations.d.ts +1 -18
  76. package/dist/rules/no-unused-declarations.js +9 -34
  77. package/dist/rules/prefer-local.js +4 -3
  78. package/dist/rules/quote-expansions.js +3 -28
  79. package/dist/rules/require-network-wrapper.d.ts +2 -17
  80. package/dist/rules/require-network-wrapper.js +33 -4
  81. package/dist/rules/require-tty-guard.js +30 -1
  82. package/dist/rules/resolve-declaration-convention.d.ts +5 -6
  83. package/dist/rules/resolve-declaration-convention.js +5 -6
  84. package/dist/rules/resolve-network-wrapper.d.ts +19 -0
  85. package/dist/rules/resolve-network-wrapper.js +57 -26
  86. package/dist/rules/resolve-transparent-wrappers.d.ts +43 -0
  87. package/dist/rules/resolve-transparent-wrappers.js +98 -0
  88. package/dist/rules/set-options.d.ts +2 -1
  89. package/dist/rules/set-options.js +17 -5
  90. package/dist/rules/shebang-interpreter.js +4 -2
  91. package/dist/rules/transparent-wrappers.d.ts +4 -3
  92. package/dist/rules/transparent-wrappers.js +5 -4
  93. package/dist/rules/user-pattern.d.ts +5 -3
  94. package/dist/rules/user-pattern.js +6 -4
  95. package/dist/syntax/index.d.ts +4 -0
  96. package/dist/syntax/index.js +4 -0
  97. package/docs/compat.md +90 -34
  98. package/docs/custom-rule-tutorial.md +9 -3
  99. package/docs/examples/no-listed-commands-rule.ts +2 -2
  100. package/docs/rules/README.md +38 -5
  101. package/docs/rules/_template.md +2 -2
  102. package/docs/rules/compat/no-append-all-redirect.md +12 -12
  103. package/docs/rules/compat/no-associative-arrays.md +14 -14
  104. package/docs/rules/compat/no-brace-sequence-padding-step.md +90 -0
  105. package/docs/rules/compat/no-case-attributes.md +13 -13
  106. package/docs/rules/compat/no-case-fallthrough.md +12 -12
  107. package/docs/rules/compat/no-case-modification.md +11 -11
  108. package/docs/rules/compat/no-coproc.md +13 -13
  109. package/docs/rules/compat/no-declare-g.md +13 -13
  110. package/docs/rules/compat/no-double-bracket.md +2 -2
  111. package/docs/rules/compat/no-epoch-variables.md +13 -13
  112. package/docs/rules/compat/no-fd-variable.md +12 -12
  113. package/docs/rules/compat/no-globstar.md +13 -13
  114. package/docs/rules/compat/no-lastpipe-semantics.md +13 -13
  115. package/docs/rules/compat/no-let.md +2 -2
  116. package/docs/rules/compat/no-mapfile.md +16 -16
  117. package/docs/rules/compat/no-nameref.md +13 -13
  118. package/docs/rules/compat/no-negative-array-index.md +14 -14
  119. package/docs/rules/compat/no-nounset-empty-array.md +72 -17
  120. package/docs/rules/compat/no-parameter-transformation.md +19 -19
  121. package/docs/rules/compat/no-pipe-all.md +13 -13
  122. package/docs/rules/compat/no-printf-time-format.md +13 -13
  123. package/docs/rules/compat/no-source.md +2 -2
  124. package/docs/rules/compat/no-test-v.md +12 -12
  125. package/docs/rules/compat/no-unicode-escape.md +13 -13
  126. package/docs/rules/compat/no-wait-n.md +13 -13
  127. package/docs/rules/no-dynamic-invocation.md +17 -12
  128. package/docs/rules/no-eval.md +6 -1
  129. package/docs/rules/no-masked-exit-status.md +4 -0
  130. package/docs/rules/no-secret-env-reads.md +34 -3
  131. package/docs/rules/no-secret-flags.md +19 -2
  132. package/docs/rules/no-unchecked-cd.md +9 -2
  133. package/docs/rules/no-undeclared-commands.md +16 -15
  134. package/docs/rules/no-unused-declarations.md +17 -20
  135. package/docs/rules/prefer-local.md +20 -2
  136. package/docs/rules/quote-expansions.md +8 -5
  137. package/docs/rules/require-network-wrapper.md +22 -17
  138. package/docs/rules/require-shebang.md +10 -4
  139. package/docs/rules/require-strict-mode.md +6 -0
  140. package/docs/rules/require-tty-guard.md +4 -1
  141. package/docs/shellcheck.md +10 -5
  142. package/docs/transparent-wrappers.md +97 -0
  143. package/docs/untrusted-code.md +440 -0
  144. package/docs/wrapper-rules.md +9 -0
  145. package/package.json +2 -2
  146. package/dist/language/end-of-input-marker.d.ts +0 -29
  147. package/dist/language/end-of-input-marker.js +0 -88
@@ -1,6 +1,6 @@
1
1
  # `sh/compat/no-coproc`
2
2
 
3
- Disallow the `coproc` reserved word in scripts whose target shell lacks it: Bash older than 4.0,
3
+ Disallow the `coproc` reserved word in scripts that must support a shell lacking it: Bash older than 4.0,
4
4
  including the Bash 3.2 that macOS ships as `/bin/bash`, and POSIX sh.
5
5
 
6
6
  | Configs | Fixable | Languages |
@@ -18,19 +18,19 @@ The portable alternative is a named pipe: create it with `mkfifo`, start the cop
18
18
  This is a version-compat rule. Whether it reports depends only on `languageOptions`, as
19
19
  described in [version compatibility](../../compat.md):
20
20
 
21
- - `shellVersion` unset: never reports. An unset version means the newest Bash.
22
- - `dialect: "bash"` (the default) or `"bats"`: reports when `shellVersion` is older than `4.0`.
23
- - `dialect: "posix"`: reports at any `shellVersion`.
21
+ - `minBashVersion` unset: no Bash version constraint, so no report under `bash` or `bats`.
22
+ - `dialect: "bash"` (the default) or `"bats"`: reports when `minBashVersion` is older than `4.0`.
23
+ - `dialect: "posix"`: reports regardless of Bash releases.
24
24
  - `dialect: "mksh"` or `"zsh"`: never reports.
25
25
 
26
26
  ## Options
27
27
 
28
- This rule has no options. Set the target through `languageOptions`:
28
+ This rule has no options. Set the required support through `languageOptions`:
29
29
 
30
30
  ```js
31
31
  // eslint.config.js
32
32
  {
33
- languageOptions: { dialect: 'bash', shellVersion: '3.2' },
33
+ languageOptions: { dialect: 'bash', minBashVersion: '3.2' },
34
34
  rules: {
35
35
  'sh/compat/no-coproc': 'error',
36
36
  },
@@ -41,9 +41,9 @@ This rule has no options. Set the target through `languageOptions`:
41
41
 
42
42
  ### Incorrect
43
43
 
44
- With `shellVersion: "3.2"`:
44
+ With `minBashVersion: "3.2"`:
45
45
 
46
- <!-- example: {"dialect": "bash", "shellVersion": "3.2", "findings": 2} -->
46
+ <!-- example: {"dialect": "bash", "minBashVersion": "3.2", "findings": 2} -->
47
47
  ```sh
48
48
  coproc worker { cat; }
49
49
  coproc sort
@@ -51,9 +51,9 @@ coproc sort
51
51
 
52
52
  ### Correct
53
53
 
54
- With `shellVersion: "3.2"`:
54
+ With `minBashVersion: "3.2"`:
55
55
 
56
- <!-- example: {"dialect": "bash", "shellVersion": "3.2"} -->
56
+ <!-- example: {"dialect": "bash", "minBashVersion": "3.2"} -->
57
57
  ```sh
58
58
  fifo=$(mktemp -u) && mkfifo "$fifo"
59
59
  cat < "$fifo" &
@@ -61,16 +61,16 @@ exec 3> "$fifo"
61
61
  printf '%s\n' hello >&3
62
62
  ```
63
63
 
64
- With `shellVersion: "4.0"` or newer, or with no `shellVersion`, the original forms are fine.
64
+ With `minBashVersion: "4.0"` or newer, or with no `minBashVersion`, the original forms are fine.
65
65
 
66
66
  ## When not to use it
67
67
 
68
68
  Turn the rule off when your scripts never run on Bash older than 4.0, or leave
69
- `shellVersion` unset, which makes the rule report nothing.
69
+ `minBashVersion` unset, which makes the rule report nothing.
70
70
 
71
71
  ## Relationship to shellcheck
72
72
 
73
73
  eslint-sh is a convention and contract linter: a policy layer, where shellcheck is the gotcha
74
74
  layer. Run shellcheck beside it.
75
75
 
76
- shellcheck has no check for `coproc` in a script that must run on an older Bash; it cannot target a Bash version. This rule exists for that target.
76
+ shellcheck has no check for `coproc` in a script that must run on an older Bash; it cannot check support for a minimum Bash version. This rule checks that support requirement.
@@ -1,6 +1,6 @@
1
1
  # `sh/compat/no-declare-g`
2
2
 
3
- Disallow `declare -g` and `typeset -g` in scripts whose target shell lacks the `-g` option: Bash
3
+ Disallow `declare -g` and `typeset -g` in scripts that must support a shell lacking the `-g` option: Bash
4
4
  older than 4.2, including the Bash 3.2 that macOS ships as `/bin/bash`, and POSIX sh.
5
5
 
6
6
  | Configs | Fixable | Languages |
@@ -20,19 +20,19 @@ The message says so. For a plain `-g` (and `-gx`, which `export name=value` cove
20
20
  This is a version-compat rule. Whether it reports depends only on `languageOptions`, as
21
21
  described in [version compatibility](../../compat.md):
22
22
 
23
- - `shellVersion` unset: never reports. An unset version means the newest Bash.
24
- - `dialect: "bash"` (the default) or `"bats"`: reports when `shellVersion` is older than `4.2`.
25
- - `dialect: "posix"`: reports at any `shellVersion`, because POSIX sh has no `declare`.
23
+ - `minBashVersion` unset: no Bash version constraint, so no report under `bash` or `bats`.
24
+ - `dialect: "bash"` (the default) or `"bats"`: reports when `minBashVersion` is older than `4.2`.
25
+ - `dialect: "posix"`: reports regardless of Bash releases, because POSIX sh has no `declare`.
26
26
  - `dialect: "mksh"` or `"zsh"`: never reports.
27
27
 
28
28
  ## Options
29
29
 
30
- This rule has no options. Set the target through `languageOptions`:
30
+ This rule has no options. Set the required support through `languageOptions`:
31
31
 
32
32
  ```js
33
33
  // eslint.config.js
34
34
  {
35
- languageOptions: { dialect: 'bash', shellVersion: '3.2' },
35
+ languageOptions: { dialect: 'bash', minBashVersion: '3.2' },
36
36
  rules: {
37
37
  'sh/compat/no-declare-g': 'error',
38
38
  },
@@ -43,9 +43,9 @@ This rule has no options. Set the target through `languageOptions`:
43
43
 
44
44
  ### Incorrect
45
45
 
46
- With `shellVersion: "3.2"`:
46
+ With `minBashVersion: "3.2"`:
47
47
 
48
- <!-- example: {"dialect": "bash", "shellVersion": "3.2", "findings": 2} -->
48
+ <!-- example: {"dialect": "bash", "minBashVersion": "3.2", "findings": 2} -->
49
49
  ```sh
50
50
  f() {
51
51
  declare -g counter=0
@@ -55,9 +55,9 @@ f() {
55
55
 
56
56
  ### Correct
57
57
 
58
- With `shellVersion: "3.2"`:
58
+ With `minBashVersion: "3.2"`:
59
59
 
60
- <!-- example: {"dialect": "bash", "shellVersion": "3.2"} -->
60
+ <!-- example: {"dialect": "bash", "minBashVersion": "3.2"} -->
61
61
  ```sh
62
62
  f() {
63
63
  counter=0
@@ -65,16 +65,16 @@ f() {
65
65
  }
66
66
  ```
67
67
 
68
- With `shellVersion: "4.2"` or newer, or with no `shellVersion`, the original forms are fine.
68
+ With `minBashVersion: "4.2"` or newer, or with no `minBashVersion`, the original forms are fine.
69
69
 
70
70
  ## When not to use it
71
71
 
72
72
  Turn the rule off when your scripts never run on Bash older than 4.2, or leave
73
- `shellVersion` unset, which makes the rule report nothing.
73
+ `minBashVersion` unset, which makes the rule report nothing.
74
74
 
75
75
  ## Relationship to shellcheck
76
76
 
77
77
  eslint-sh is a convention and contract linter: a policy layer, where shellcheck is the gotcha
78
78
  layer. Run shellcheck beside it.
79
79
 
80
- shellcheck does not know which Bash a script must run on, so it cannot report `declare -g` for a Bash 3.2 target. This rule exists for that target.
80
+ shellcheck does not know which Bash a script must run on, so it cannot report `declare -g` for a script that must support Bash 3.2. This rule checks that support requirement.
@@ -18,12 +18,12 @@ The portable alternatives are `[ … ]` for tests and `case` for pattern matchin
18
18
 
19
19
  This is a POSIX-only gate. Every Bash has `[[`, so whether the rule reports depends only on `dialect`, as described in [version compatibility](../../compat.md):
20
20
 
21
- - `dialect: "posix"`: reports at any `shellVersion`.
21
+ - `dialect: "posix"`: reports regardless of Bash releases.
22
22
  - `dialect: "bash"` (the default), `"bats"`, `"mksh"` or `"zsh"`: never reports.
23
23
 
24
24
  ## Options
25
25
 
26
- This rule has no options. Set the target through `languageOptions`:
26
+ This rule has no options. Set the required support through `languageOptions`:
27
27
 
28
28
  ```js
29
29
  // eslint.config.js
@@ -1,6 +1,6 @@
1
1
  # `sh/compat/no-epoch-variables`
2
2
 
3
- Disallow `$EPOCHSECONDS` and `$EPOCHREALTIME` in scripts whose target shell lacks them: Bash older
3
+ Disallow `$EPOCHSECONDS` and `$EPOCHREALTIME` in scripts that must support a shell lacking them: Bash older
4
4
  than 5.0, including the Bash 3.2 that macOS ships as `/bin/bash`, and POSIX sh.
5
5
 
6
6
  | Configs | Fixable | Languages |
@@ -20,19 +20,19 @@ The usual alternative is `$(date +%s)`. It is not POSIX: `%s` is an extension th
20
20
  This is a version-compat rule. Whether it reports depends only on `languageOptions`, as
21
21
  described in [version compatibility](../../compat.md):
22
22
 
23
- - `shellVersion` unset: never reports. An unset version means the newest Bash.
24
- - `dialect: "bash"` (the default) or `"bats"`: reports when `shellVersion` is older than `5.0`.
25
- - `dialect: "posix"`: reports at any `shellVersion`, because POSIX sh does not set either variable.
23
+ - `minBashVersion` unset: no Bash version constraint, so no report under `bash` or `bats`.
24
+ - `dialect: "bash"` (the default) or `"bats"`: reports when `minBashVersion` is older than `5.0`.
25
+ - `dialect: "posix"`: reports regardless of Bash releases, because POSIX sh does not set either variable.
26
26
  - `dialect: "mksh"` or `"zsh"`: never reports.
27
27
 
28
28
  ## Options
29
29
 
30
- This rule has no options. Set the target through `languageOptions`:
30
+ This rule has no options. Set the required support through `languageOptions`:
31
31
 
32
32
  ```js
33
33
  // eslint.config.js
34
34
  {
35
- languageOptions: { dialect: 'bash', shellVersion: '3.2' },
35
+ languageOptions: { dialect: 'bash', minBashVersion: '3.2' },
36
36
  rules: {
37
37
  'sh/compat/no-epoch-variables': 'error',
38
38
  },
@@ -43,9 +43,9 @@ This rule has no options. Set the target through `languageOptions`:
43
43
 
44
44
  ### Incorrect
45
45
 
46
- With `shellVersion: "3.2"`:
46
+ With `minBashVersion: "3.2"`:
47
47
 
48
- <!-- example: {"dialect": "bash", "shellVersion": "3.2", "findings": 2} -->
48
+ <!-- example: {"dialect": "bash", "minBashVersion": "3.2", "findings": 2} -->
49
49
  ```sh
50
50
  start=$EPOCHSECONDS
51
51
  run_tests
@@ -54,9 +54,9 @@ echo "took $(( EPOCHSECONDS - start ))s"
54
54
 
55
55
  ### Correct
56
56
 
57
- With `shellVersion: "3.2"`:
57
+ With `minBashVersion: "3.2"`:
58
58
 
59
- <!-- example: {"dialect": "bash", "shellVersion": "3.2"} -->
59
+ <!-- example: {"dialect": "bash", "minBashVersion": "3.2"} -->
60
60
  ```sh
61
61
  start=$(date +%s)
62
62
  run_tests
@@ -64,11 +64,11 @@ echo "took $(( $(date +%s) - start ))s"
64
64
  echo 'the variable is spelled $EPOCHSECONDS'
65
65
  ```
66
66
 
67
- With `shellVersion: "5.0"` or newer, or with no `shellVersion`, both variables are fine.
67
+ With `minBashVersion: "5.0"` or newer, or with no `minBashVersion`, both variables are fine.
68
68
 
69
69
  ## When not to use it
70
70
 
71
- Turn the rule off when your scripts never run on Bash older than 5.0, or leave `shellVersion`
71
+ Turn the rule off when your scripts never run on Bash older than 5.0, or leave `minBashVersion`
72
72
  unset, which makes the rule report nothing.
73
73
 
74
74
  ## Relationship to shellcheck
@@ -76,4 +76,4 @@ unset, which makes the rule report nothing.
76
76
  eslint-sh is a convention and contract linter: a policy layer, where shellcheck is the gotcha
77
77
  layer. Run shellcheck beside it.
78
78
 
79
- shellcheck 0.11.0 reports `$EPOCHSECONDS` and `$EPOCHREALTIME` as undefined in POSIX sh (SC3028) under `-s sh`, and nothing under `-s bash`. It does not know which Bash release a script must run on, so it reports nothing for either variable in a Bash 4.4 target. This rule exists for that target.
79
+ shellcheck 0.11.0 reports `$EPOCHSECONDS` and `$EPOCHREALTIME` as undefined in POSIX sh (SC3028) under `-s sh`, and nothing under `-s bash`. It does not know which Bash release a script must run on, so it reports nothing for either variable in a script that must support Bash 4.4. This rule checks that support requirement.
@@ -1,7 +1,7 @@
1
1
  # `sh/compat/no-fd-variable`
2
2
 
3
3
  Disallow `{varname}` redirections, which have the shell pick a free file descriptor and store its
4
- number in a variable (`exec {fd}>file`), in scripts whose target shell lacks them: Bash older than
4
+ number in a variable (`exec {fd}>file`), in scripts that must support a shell lacking them: Bash older than
5
5
  4.1, including the Bash 3.2 that macOS ships as `/bin/bash`, and POSIX sh.
6
6
 
7
7
  | Configs | Fixable | Languages |
@@ -21,18 +21,18 @@ Under `dialect: "posix"` the parser itself rejects `{varname}` redirections, so
21
21
  This is a version-compat rule. Whether it reports depends only on `languageOptions`, as
22
22
  described in [version compatibility](../../compat.md):
23
23
 
24
- - `shellVersion` unset: never reports. An unset version means the newest Bash.
25
- - `dialect: "bash"` (the default) or `"bats"`: reports when `shellVersion` is older than `4.1`.
24
+ - `minBashVersion` unset: no Bash version constraint, so no report under `bash` or `bats`.
25
+ - `dialect: "bash"` (the default) or `"bats"`: reports when `minBashVersion` is older than `4.1`.
26
26
  - `dialect: "mksh"` or `"zsh"`: never reports.
27
27
 
28
28
  ## Options
29
29
 
30
- This rule has no options. Set the target through `languageOptions`:
30
+ This rule has no options. Set the required support through `languageOptions`:
31
31
 
32
32
  ```js
33
33
  // eslint.config.js
34
34
  {
35
- languageOptions: { dialect: 'bash', shellVersion: '3.2' },
35
+ languageOptions: { dialect: 'bash', minBashVersion: '3.2' },
36
36
  rules: {
37
37
  'sh/compat/no-fd-variable': 'error',
38
38
  },
@@ -43,9 +43,9 @@ This rule has no options. Set the target through `languageOptions`:
43
43
 
44
44
  ### Incorrect
45
45
 
46
- With `shellVersion: "3.2"`:
46
+ With `minBashVersion: "3.2"`:
47
47
 
48
- <!-- example: {"dialect": "bash", "shellVersion": "3.2", "findings": 2} -->
48
+ <!-- example: {"dialect": "bash", "minBashVersion": "3.2", "findings": 2} -->
49
49
  ```sh
50
50
  exec {log}>>"$logfile"
51
51
  echo started >&"$log"
@@ -54,20 +54,20 @@ exec {log}>&-
54
54
 
55
55
  ### Correct
56
56
 
57
- With `shellVersion: "3.2"`:
57
+ With `minBashVersion: "3.2"`:
58
58
 
59
- <!-- example: {"dialect": "bash", "shellVersion": "3.2"} -->
59
+ <!-- example: {"dialect": "bash", "minBashVersion": "3.2"} -->
60
60
  ```sh
61
61
  exec 3>>"$logfile"
62
62
  echo started >&3
63
63
  exec 3>&-
64
64
  ```
65
65
 
66
- With `shellVersion: "4.1"` or newer, or with no `shellVersion`, `{varname}` redirections are fine.
66
+ With `minBashVersion: "4.1"` or newer, or with no `minBashVersion`, `{varname}` redirections are fine.
67
67
 
68
68
  ## When not to use it
69
69
 
70
- Turn the rule off when your scripts never run on Bash older than 4.1, or leave `shellVersion`
70
+ Turn the rule off when your scripts never run on Bash older than 4.1, or leave `minBashVersion`
71
71
  unset, which makes the rule report nothing.
72
72
 
73
73
  ## Relationship to shellcheck
@@ -75,4 +75,4 @@ unset, which makes the rule report nothing.
75
75
  eslint-sh is a convention and contract linter: a policy layer, where shellcheck is the gotcha
76
76
  layer. Run shellcheck beside it.
77
77
 
78
- shellcheck reports `{varname}` redirections only for a script it treats as POSIX `sh` (its SC3xxx portability checks). It does not know which Bash release a script must run on, so it cannot report them for a Bash 3.2 target. This rule exists for that target.
78
+ shellcheck reports `{varname}` redirections only for a script it treats as POSIX `sh` (its SC3xxx portability checks). It does not know which Bash release a script must run on, so it cannot report them for a script that must support Bash 3.2. This rule checks that support requirement.
@@ -1,6 +1,6 @@
1
1
  # `sh/compat/no-globstar`
2
2
 
3
- Disallow `shopt -s globstar` in scripts whose target shell lacks the option: Bash older than 4.0,
3
+ Disallow `shopt -s globstar` in scripts that must support a shell lacking the option: Bash older than 4.0,
4
4
  including the Bash 3.2 that macOS ships as `/bin/bash`, and POSIX sh.
5
5
 
6
6
  | Configs | Fixable | Languages |
@@ -18,19 +18,19 @@ The portable alternative is `find`, for example `find dir -name '*.txt'`.
18
18
  This is a version-compat rule. Whether it reports depends only on `languageOptions`, as
19
19
  described in [version compatibility](../../compat.md):
20
20
 
21
- - `shellVersion` unset: never reports. An unset version means the newest Bash.
22
- - `dialect: "bash"` (the default) or `"bats"`: reports when `shellVersion` is older than `4.0`.
23
- - `dialect: "posix"`: reports at any `shellVersion`, because POSIX sh has no `shopt`.
21
+ - `minBashVersion` unset: no Bash version constraint, so no report under `bash` or `bats`.
22
+ - `dialect: "bash"` (the default) or `"bats"`: reports when `minBashVersion` is older than `4.0`.
23
+ - `dialect: "posix"`: reports regardless of Bash releases, because POSIX sh has no `shopt`.
24
24
  - `dialect: "mksh"` or `"zsh"`: never reports.
25
25
 
26
26
  ## Options
27
27
 
28
- This rule has no options. Set the target through `languageOptions`:
28
+ This rule has no options. Set the required support through `languageOptions`:
29
29
 
30
30
  ```js
31
31
  // eslint.config.js
32
32
  {
33
- languageOptions: { dialect: 'bash', shellVersion: '3.2' },
33
+ languageOptions: { dialect: 'bash', minBashVersion: '3.2' },
34
34
  rules: {
35
35
  'sh/compat/no-globstar': 'error',
36
36
  },
@@ -41,9 +41,9 @@ This rule has no options. Set the target through `languageOptions`:
41
41
 
42
42
  ### Incorrect
43
43
 
44
- With `shellVersion: "3.2"`:
44
+ With `minBashVersion: "3.2"`:
45
45
 
46
- <!-- example: {"dialect": "bash", "shellVersion": "3.2", "findings": 1} -->
46
+ <!-- example: {"dialect": "bash", "minBashVersion": "3.2", "findings": 1} -->
47
47
  ```sh
48
48
  shopt -s nullglob globstar
49
49
  for f in src/**/*.sh; do lint "$f"; done
@@ -51,19 +51,19 @@ for f in src/**/*.sh; do lint "$f"; done
51
51
 
52
52
  ### Correct
53
53
 
54
- With `shellVersion: "3.2"`:
54
+ With `minBashVersion: "3.2"`:
55
55
 
56
- <!-- example: {"dialect": "bash", "shellVersion": "3.2"} -->
56
+ <!-- example: {"dialect": "bash", "minBashVersion": "3.2"} -->
57
57
  ```sh
58
58
  find src -name '*.sh' -exec lint {} \;
59
59
  shopt -s nullglob
60
60
  ```
61
61
 
62
- With `shellVersion: "4.0"` or newer, or with no `shellVersion`, `globstar` is fine.
62
+ With `minBashVersion: "4.0"` or newer, or with no `minBashVersion`, `globstar` is fine.
63
63
 
64
64
  ## When not to use it
65
65
 
66
- Turn the rule off when your scripts never run on Bash older than 4.0, or leave `shellVersion`
66
+ Turn the rule off when your scripts never run on Bash older than 4.0, or leave `minBashVersion`
67
67
  unset, which makes the rule report nothing.
68
68
 
69
69
  ## Relationship to shellcheck
@@ -71,4 +71,4 @@ unset, which makes the rule report nothing.
71
71
  eslint-sh is a convention and contract linter: a policy layer, where shellcheck is the gotcha
72
72
  layer. Run shellcheck beside it.
73
73
 
74
- shellcheck reports `shopt` only for a script it treats as POSIX `sh` (its SC3xxx portability checks). It does not know which Bash release a script must run on, so it cannot report `globstar` for a Bash 3.2 target. This rule exists for that target.
74
+ shellcheck reports `shopt` only for a script it treats as POSIX `sh` (its SC3xxx portability checks). It does not know which Bash release a script must run on, so it cannot report `globstar` for a script that must support Bash 3.2. This rule checks that support requirement.
@@ -1,6 +1,6 @@
1
1
  # `sh/compat/no-lastpipe-semantics`
2
2
 
3
- Disallow `shopt -s lastpipe` in scripts whose target shell lacks the option: Bash older than 4.2,
3
+ Disallow `shopt -s lastpipe` in scripts that must support a shell lacking the option: Bash older than 4.2,
4
4
  including the Bash 3.2 that macOS ships as `/bin/bash`, and POSIX sh.
5
5
 
6
6
  | Configs | Fixable | Languages |
@@ -18,19 +18,19 @@ The portable alternative is process substitution: `while read -r line; do …; d
18
18
  This is a version-compat rule. Whether it reports depends only on `languageOptions`, as
19
19
  described in [version compatibility](../../compat.md):
20
20
 
21
- - `shellVersion` unset: never reports. An unset version means the newest Bash.
22
- - `dialect: "bash"` (the default) or `"bats"`: reports when `shellVersion` is older than `4.2`.
23
- - `dialect: "posix"`: reports at any `shellVersion`.
21
+ - `minBashVersion` unset: no Bash version constraint, so no report under `bash` or `bats`.
22
+ - `dialect: "bash"` (the default) or `"bats"`: reports when `minBashVersion` is older than `4.2`.
23
+ - `dialect: "posix"`: reports regardless of Bash releases.
24
24
  - `dialect: "mksh"` or `"zsh"`: never reports.
25
25
 
26
26
  ## Options
27
27
 
28
- This rule has no options. Set the target through `languageOptions`:
28
+ This rule has no options. Set the required support through `languageOptions`:
29
29
 
30
30
  ```js
31
31
  // eslint.config.js
32
32
  {
33
- languageOptions: { dialect: 'bash', shellVersion: '3.2' },
33
+ languageOptions: { dialect: 'bash', minBashVersion: '3.2' },
34
34
  rules: {
35
35
  'sh/compat/no-lastpipe-semantics': 'error',
36
36
  },
@@ -41,9 +41,9 @@ This rule has no options. Set the target through `languageOptions`:
41
41
 
42
42
  ### Incorrect
43
43
 
44
- With `shellVersion: "3.2"`:
44
+ With `minBashVersion: "3.2"`:
45
45
 
46
- <!-- example: {"dialect": "bash", "shellVersion": "3.2", "findings": 1} -->
46
+ <!-- example: {"dialect": "bash", "minBashVersion": "3.2", "findings": 1} -->
47
47
  ```sh
48
48
  shopt -s lastpipe
49
49
  cmd | while read -r line; do total=$line; done
@@ -51,23 +51,23 @@ cmd | while read -r line; do total=$line; done
51
51
 
52
52
  ### Correct
53
53
 
54
- With `shellVersion: "3.2"`:
54
+ With `minBashVersion: "3.2"`:
55
55
 
56
- <!-- example: {"dialect": "bash", "shellVersion": "3.2"} -->
56
+ <!-- example: {"dialect": "bash", "minBashVersion": "3.2"} -->
57
57
  ```sh
58
58
  while read -r line; do total=$line; done < <(cmd)
59
59
  ```
60
60
 
61
- With `shellVersion: "4.2"` or newer, or with no `shellVersion`, the original forms are fine.
61
+ With `minBashVersion: "4.2"` or newer, or with no `minBashVersion`, the original forms are fine.
62
62
 
63
63
  ## When not to use it
64
64
 
65
65
  Turn the rule off when your scripts never run on Bash older than 4.2, or leave
66
- `shellVersion` unset, which makes the rule report nothing.
66
+ `minBashVersion` unset, which makes the rule report nothing.
67
67
 
68
68
  ## Relationship to shellcheck
69
69
 
70
70
  eslint-sh is a convention and contract linter: a policy layer, where shellcheck is the gotcha
71
71
  layer. Run shellcheck beside it.
72
72
 
73
- shellcheck warns that variables assigned in the last pipeline element are lost (SC2030/SC2031), and understands `shopt -s lastpipe` for that purpose, but it cannot target a Bash version, so it cannot report the option for a Bash 3.2 target. This rule exists for that target.
73
+ shellcheck warns that variables assigned in the last pipeline element are lost (SC2030/SC2031), and understands `shopt -s lastpipe` for that purpose, but it cannot check support for a minimum Bash version, so it cannot report the option for a script that must support Bash 3.2. This rule checks that support requirement.
@@ -27,12 +27,12 @@ The portable alternative is arithmetic expansion, `n=$((1 + 2))`. The rule offer
27
27
 
28
28
  This is a POSIX-only gate. Every Bash has `let`, so whether the rule reports depends only on `dialect`, as described in [version compatibility](../../compat.md):
29
29
 
30
- - `dialect: "posix"`: reports at any `shellVersion`.
30
+ - `dialect: "posix"`: reports regardless of Bash releases.
31
31
  - `dialect: "bash"` (the default), `"bats"`, `"mksh"` or `"zsh"`: never reports.
32
32
 
33
33
  ## Options
34
34
 
35
- This rule has no options. Set the target through `languageOptions`:
35
+ This rule has no options. Set the required support through `languageOptions`:
36
36
 
37
37
  ```js
38
38
  // eslint.config.js
@@ -1,6 +1,6 @@
1
1
  # `sh/compat/no-mapfile`
2
2
 
3
- Disallow the `mapfile` builtin and its synonym `readarray` in scripts whose target shell lacks
3
+ Disallow the `mapfile` builtin and its synonym `readarray` in scripts that must support a shell lacking
4
4
  them: Bash older than 4.0, including the Bash 3.2 that macOS ships as `/bin/bash`, and POSIX sh.
5
5
 
6
6
  | Configs | Fixable | Languages |
@@ -16,9 +16,9 @@ never filled.
16
16
  This is a version-compat rule. Whether it reports depends only on `languageOptions`, as
17
17
  described in [version compatibility](../../compat.md):
18
18
 
19
- - `shellVersion` unset: never reports. An unset version means the newest Bash.
20
- - `dialect: "bash"` (the default) or `"bats"`: reports when `shellVersion` is older than `4.0`.
21
- - `dialect: "posix"`: reports at any `shellVersion`.
19
+ - `minBashVersion` unset: no Bash version constraint, so no report under `bash` or `bats`.
20
+ - `dialect: "bash"` (the default) or `"bats"`: reports when `minBashVersion` is older than `4.0`.
21
+ - `dialect: "posix"`: reports regardless of Bash releases.
22
22
  - `dialect: "mksh"` or `"zsh"`: never reports.
23
23
 
24
24
  The rule reports every command whose effective command is `mapfile` or `readarray`, after
@@ -31,7 +31,7 @@ For `mapfile -t NAME` or `readarray -t NAME`, written directly (no wrapper and n
31
31
  `VAR=value`) in a Bash or Bats file, the rule suggests a `while IFS= read -r` loop that fills
32
32
  the same array the same way:
33
33
 
34
- <!-- transform: {"kind": "suggestion", "dialect": "bash", "shellVersion": "3.2"} -->
34
+ <!-- transform: {"kind": "suggestion", "dialect": "bash", "minBashVersion": "3.2"} -->
35
35
 
36
36
  ```sh
37
37
  mapfile -t lines < in.txt
@@ -57,12 +57,12 @@ assignment, a wrapper, and every file under `dialect: "posix"`.
57
57
 
58
58
  ## Options
59
59
 
60
- This rule has no options. Set the target through `languageOptions`:
60
+ This rule has no options. Set the required support through `languageOptions`:
61
61
 
62
62
  ```js
63
63
  // eslint.config.js
64
64
  {
65
- languageOptions: { dialect: 'bash', shellVersion: '3.2' },
65
+ languageOptions: { dialect: 'bash', minBashVersion: '3.2' },
66
66
  rules: {
67
67
  'sh/compat/no-mapfile': 'error',
68
68
  },
@@ -73,9 +73,9 @@ This rule has no options. Set the target through `languageOptions`:
73
73
 
74
74
  ### Incorrect
75
75
 
76
- With `shellVersion: "3.2"`:
76
+ With `minBashVersion: "3.2"`:
77
77
 
78
- <!-- example: {"dialect": "bash", "shellVersion": "3.2", "findings": 3} -->
78
+ <!-- example: {"dialect": "bash", "minBashVersion": "3.2", "findings": 3} -->
79
79
  ```sh
80
80
  mapfile -t lines < in.txt # mapfile needs Bash 4.0
81
81
  git ls-files | readarray -t files # readarray is the same builtin
@@ -84,9 +84,9 @@ command mapfile -t lines < in.txt # reached through the command wrapper
84
84
 
85
85
  ### Correct
86
86
 
87
- With `shellVersion: "3.2"`:
87
+ With `minBashVersion: "3.2"`:
88
88
 
89
- <!-- example: {"dialect": "bash", "shellVersion": "3.2"} -->
89
+ <!-- example: {"dialect": "bash", "minBashVersion": "3.2"} -->
90
90
  ```sh
91
91
  { lines=(); while IFS= read -r || [ -n "$REPLY" ]; do lines+=("$REPLY"); done; } < in.txt
92
92
 
@@ -95,16 +95,16 @@ while IFS= read -r line; do
95
95
  done < in.txt
96
96
  ```
97
97
 
98
- With `shellVersion: "4.0"` or newer, or with no `shellVersion`:
98
+ With `minBashVersion: "4.0"` or newer, or with no `minBashVersion`:
99
99
 
100
- <!-- example: {"dialect": "bash", "shellVersion": "4.0"} -->
100
+ <!-- example: {"dialect": "bash", "minBashVersion": "4.0"} -->
101
101
  ```sh
102
102
  mapfile -t lines < in.txt
103
103
  ```
104
104
 
105
105
  ## When not to use it
106
106
 
107
- Turn the rule off when your scripts never run on Bash older than 4.0, or leave `shellVersion`
107
+ Turn the rule off when your scripts never run on Bash older than 4.0, or leave `minBashVersion`
108
108
  unset, which makes the rule report nothing.
109
109
 
110
110
  ## Relationship to shellcheck
@@ -113,6 +113,6 @@ eslint-sh is a convention and contract linter: a policy layer, where shellcheck
113
113
  layer. Run shellcheck beside it.
114
114
 
115
115
  shellcheck reports Bash-only features in scripts it treats as POSIX sh (the SC3xxx checks), but
116
- it cannot target a Bash version, so it cannot report `mapfile` in a script that must run on
116
+ it cannot check support for a minimum Bash version, so it cannot report `mapfile` in a script that must run on
117
117
  Bash 3.2. shellcheck 0.11.0 does recommend `mapfile` or `read -a` over `a=($(cmd))` splitting (SC2207) under `-s bash`, which is
118
- the opposite advice for a Bash 3.2 target. This rule exists for that target.
118
+ the opposite advice for a script that must support Bash 3.2. This rule checks that support requirement.