@eslint-sh/eslint-plugin 0.7.0 → 0.9.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 (182) hide show
  1. package/README.md +53 -40
  2. package/dist/api.d.ts +92 -0
  3. package/dist/api.js +83 -0
  4. package/dist/command-harvest/builtins/bash.d.ts +1 -1
  5. package/dist/command-harvest/builtins/bash.js +1 -1
  6. package/dist/command-harvest/builtins/bats.d.ts +2 -0
  7. package/dist/command-harvest/builtins/bats.js +3 -0
  8. package/dist/command-harvest/harvest-commands.d.ts +2 -2
  9. package/dist/command-harvest/harvest-commands.js +2 -2
  10. package/dist/command-harvest/wrapper-table.d.ts +3 -19
  11. package/dist/command-harvest/wrapper-table.js +8 -38
  12. package/dist/configs/bash-3-2.d.ts +7 -6
  13. package/dist/configs/bash-3-2.js +4 -3
  14. package/dist/configs/posix-portable.d.ts +7 -11
  15. package/dist/configs/posix-portable.js +4 -6
  16. package/dist/configuration-message.d.ts +14 -0
  17. package/dist/configuration-message.js +33 -0
  18. package/dist/declaration-conventions/get-declared-commands.d.ts +41 -0
  19. package/dist/declaration-conventions/{read-declared-commands.js → get-declared-commands.js} +43 -43
  20. package/dist/eslint-plugin-api.d.ts +1506 -0
  21. package/dist/eslint-plugin-syntax-analyze.d.ts +3 -3
  22. package/dist/eslint-plugin-syntax.d.ts +7 -4
  23. package/dist/eslint-plugin.d.ts +16 -1514
  24. package/dist/index.d.ts +14 -78
  25. package/dist/index.js +22 -74
  26. package/dist/language/command-resolution.d.ts +5 -5
  27. package/dist/language/command-resolution.js +11 -7
  28. package/dist/language/selector-classes.d.ts +7 -3
  29. package/dist/language/selector-classes.js +13 -4
  30. package/dist/language/shell-language-options.d.ts +21 -18
  31. package/dist/language/shell-language-options.js +41 -39
  32. package/dist/language/shell-language.d.ts +13 -10
  33. package/dist/language/shell-language.js +23 -45
  34. package/dist/language/shell-source-code.d.ts +74 -49
  35. package/dist/language/shell-source-code.js +135 -68
  36. package/dist/language/source-coordinates.d.ts +2 -0
  37. package/dist/language/source-coordinates.js +8 -4
  38. package/dist/language/syntax-view.js +19 -7
  39. package/dist/language/word-resolution.d.ts +2 -1
  40. package/dist/language/word-resolution.js +8 -3
  41. package/dist/rules/bash-variable-semantics.d.ts +22 -0
  42. package/dist/rules/bash-variable-semantics.js +41 -0
  43. package/dist/rules/compat/create-compat-rule.js +1 -1
  44. package/dist/rules/compat/declaration-options.d.ts +2 -2
  45. package/dist/rules/compat/declaration-options.js +5 -2
  46. package/dist/rules/compat/no-append-all-redirect.js +1 -1
  47. package/dist/rules/compat/no-associative-arrays.js +2 -2
  48. package/dist/rules/compat/no-brace-sequence-padding-step.js +4 -4
  49. package/dist/rules/compat/no-case-attributes.js +3 -3
  50. package/dist/rules/compat/no-case-fallthrough.js +2 -2
  51. package/dist/rules/compat/no-case-modification.js +2 -2
  52. package/dist/rules/compat/no-coproc.js +1 -1
  53. package/dist/rules/compat/no-declare-g.js +3 -3
  54. package/dist/rules/compat/no-double-bracket.js +2 -2
  55. package/dist/rules/compat/no-epoch-variables.js +2 -2
  56. package/dist/rules/compat/no-fd-variable.js +1 -1
  57. package/dist/rules/compat/no-globstar.js +1 -1
  58. package/dist/rules/compat/no-lastpipe-semantics.js +2 -2
  59. package/dist/rules/compat/no-let.js +2 -1
  60. package/dist/rules/compat/no-mapfile.js +4 -2
  61. package/dist/rules/compat/no-nameref.js +3 -3
  62. package/dist/rules/compat/no-negative-array-index.js +39 -9
  63. package/dist/rules/compat/no-nounset-empty-array.js +15 -4
  64. package/dist/rules/compat/no-parameter-transformation.js +2 -2
  65. package/dist/rules/compat/no-pipe-all.js +1 -1
  66. package/dist/rules/compat/no-printf-time-format.js +4 -2
  67. package/dist/rules/compat/no-source.js +2 -1
  68. package/dist/rules/compat/no-test-v.js +4 -2
  69. package/dist/rules/compat/no-unicode-escape.js +2 -2
  70. package/dist/rules/compat/no-wait-n.js +4 -2
  71. package/dist/rules/compat/nounset-array-proof.d.ts +8 -0
  72. package/dist/rules/compat/nounset-array-proof.js +563 -0
  73. package/dist/rules/compat/posix-absent-command.d.ts +7 -8
  74. package/dist/rules/compat/posix-absent-command.js +17 -15
  75. package/dist/rules/compat/shopt-options.js +3 -1
  76. package/dist/rules/compat/version-gates.d.ts +9 -9
  77. package/dist/rules/compat/version-gates.js +13 -13
  78. package/dist/rules/create-wrapper-rule.d.ts +1 -1
  79. package/dist/rules/create-wrapper-rule.js +23 -16
  80. package/dist/rules/define-shell-rule.js +1 -1
  81. package/dist/rules/no-dynamic-invocation.d.ts +0 -8
  82. package/dist/rules/no-dynamic-invocation.js +7 -15
  83. package/dist/rules/no-eval.js +3 -1
  84. package/dist/rules/no-masked-exit-status.d.ts +4 -3
  85. package/dist/rules/no-masked-exit-status.js +18 -10
  86. package/dist/rules/no-secret-env-reads.d.ts +6 -3
  87. package/dist/rules/no-secret-env-reads.js +49 -15
  88. package/dist/rules/no-secret-flags.d.ts +4 -1
  89. package/dist/rules/no-secret-flags.js +21 -11
  90. package/dist/rules/no-unchecked-cd.js +6 -3
  91. package/dist/rules/no-undeclared-commands.d.ts +1 -15
  92. package/dist/rules/no-undeclared-commands.js +11 -18
  93. package/dist/rules/no-unused-declarations.d.ts +1 -18
  94. package/dist/rules/no-unused-declarations.js +15 -36
  95. package/dist/rules/prefer-local.d.ts +3 -2
  96. package/dist/rules/prefer-local.js +7 -4
  97. package/dist/rules/quote-expansions.js +3 -28
  98. package/dist/rules/require-network-wrapper.d.ts +3 -18
  99. package/dist/rules/require-network-wrapper.js +43 -10
  100. package/dist/rules/require-strict-mode.d.ts +5 -46
  101. package/dist/rules/require-strict-mode.js +17 -107
  102. package/dist/rules/require-tty-guard.d.ts +2 -0
  103. package/dist/rules/require-tty-guard.js +8 -1
  104. package/dist/rules/resolve-declaration-convention.d.ts +9 -89
  105. package/dist/rules/resolve-declaration-convention.js +19 -72
  106. package/dist/rules/resolve-network-wrapper.d.ts +20 -2
  107. package/dist/rules/resolve-network-wrapper.js +71 -36
  108. package/dist/rules/resolve-transparent-wrappers.d.ts +38 -0
  109. package/dist/rules/resolve-transparent-wrappers.js +108 -0
  110. package/dist/rules/set-options.d.ts +3 -2
  111. package/dist/rules/set-options.js +18 -6
  112. package/dist/rules/shebang-interpreter.js +4 -2
  113. package/dist/rules/strict-mode-prologue.d.ts +43 -0
  114. package/dist/rules/strict-mode-prologue.js +91 -0
  115. package/dist/rules/transparent-wrappers.d.ts +4 -3
  116. package/dist/rules/transparent-wrappers.js +5 -4
  117. package/dist/rules/user-pattern.d.ts +9 -6
  118. package/dist/rules/user-pattern.js +16 -12
  119. package/dist/shell-dialect.d.ts +8 -0
  120. package/dist/shell-dialect.js +22 -0
  121. package/dist/syntax/analyze.d.ts +3 -3
  122. package/dist/syntax/analyze.js +3 -3
  123. package/dist/syntax/index.d.ts +7 -4
  124. package/dist/syntax/index.js +7 -4
  125. package/dist/version.js +2 -1
  126. package/docs/compat.md +81 -33
  127. package/docs/custom-rule-tutorial.md +31 -21
  128. package/docs/declaration-conventions.md +20 -23
  129. package/docs/error-codes.md +93 -0
  130. package/docs/examples/no-listed-commands-rule.ts +2 -2
  131. package/docs/examples/no-rm-rf-rule.mjs +8 -10
  132. package/docs/examples/sorted-declarations-rule.mjs +6 -9
  133. package/docs/examples/tsconfig.json +10 -0
  134. package/docs/rules/README.md +46 -6
  135. package/docs/rules/_template.md +2 -2
  136. package/docs/rules/compat/no-append-all-redirect.md +12 -12
  137. package/docs/rules/compat/no-associative-arrays.md +14 -14
  138. package/docs/rules/compat/no-brace-sequence-padding-step.md +12 -12
  139. package/docs/rules/compat/no-case-attributes.md +13 -13
  140. package/docs/rules/compat/no-case-fallthrough.md +12 -12
  141. package/docs/rules/compat/no-case-modification.md +11 -11
  142. package/docs/rules/compat/no-coproc.md +13 -13
  143. package/docs/rules/compat/no-declare-g.md +13 -13
  144. package/docs/rules/compat/no-double-bracket.md +2 -2
  145. package/docs/rules/compat/no-epoch-variables.md +13 -13
  146. package/docs/rules/compat/no-fd-variable.md +12 -12
  147. package/docs/rules/compat/no-globstar.md +13 -13
  148. package/docs/rules/compat/no-lastpipe-semantics.md +13 -13
  149. package/docs/rules/compat/no-let.md +2 -2
  150. package/docs/rules/compat/no-mapfile.md +16 -16
  151. package/docs/rules/compat/no-nameref.md +13 -13
  152. package/docs/rules/compat/no-negative-array-index.md +14 -14
  153. package/docs/rules/compat/no-nounset-empty-array.md +72 -17
  154. package/docs/rules/compat/no-parameter-transformation.md +19 -19
  155. package/docs/rules/compat/no-pipe-all.md +13 -13
  156. package/docs/rules/compat/no-printf-time-format.md +13 -13
  157. package/docs/rules/compat/no-source.md +2 -2
  158. package/docs/rules/compat/no-test-v.md +12 -12
  159. package/docs/rules/compat/no-unicode-escape.md +13 -13
  160. package/docs/rules/compat/no-wait-n.md +13 -13
  161. package/docs/rules/no-dynamic-invocation.md +17 -12
  162. package/docs/rules/no-eval.md +6 -1
  163. package/docs/rules/no-masked-exit-status.md +6 -2
  164. package/docs/rules/no-secret-env-reads.md +46 -5
  165. package/docs/rules/no-secret-flags.md +32 -6
  166. package/docs/rules/no-unchecked-cd.md +22 -2
  167. package/docs/rules/no-undeclared-commands.md +16 -15
  168. package/docs/rules/no-unused-declarations.md +17 -20
  169. package/docs/rules/prefer-local.md +20 -2
  170. package/docs/rules/quote-expansions.md +8 -5
  171. package/docs/rules/require-network-wrapper.md +26 -21
  172. package/docs/rules/require-shebang.md +10 -4
  173. package/docs/rules/require-strict-mode.md +31 -23
  174. package/docs/rules/require-tty-guard.md +12 -3
  175. package/docs/selectors.md +7 -2
  176. package/docs/shellcheck.md +9 -5
  177. package/docs/transparent-wrappers.md +97 -0
  178. package/docs/wrapper-rules.md +11 -0
  179. package/package.json +3 -3
  180. package/dist/declaration-conventions/read-declared-commands.d.ts +0 -70
  181. package/dist/language/end-of-input-marker.d.ts +0 -29
  182. package/dist/language/end-of-input-marker.js +0 -88
@@ -27,7 +27,7 @@ See the [canonical quickstart](https://github.com/mike-north/eslint-sh/blob/main
27
27
  | [`sh/compat/no-mapfile`](./compat/no-mapfile.md) | `bash-3.2`, `posix-portable` | No | Yes | Disallow `mapfile` / `readarray` when the target shell lacks them, suggesting a read loop. |
28
28
  | [`sh/compat/no-nameref`](./compat/no-nameref.md) | `bash-3.2`, `posix-portable` | No | No | Disallow namerefs (`declare -n`, `local -n`) when the target shell lacks them. |
29
29
  | [`sh/compat/no-negative-array-index`](./compat/no-negative-array-index.md) | `bash-3.2`, `posix-portable` | No | Yes | Disallow negative array subscripts when the target shell lacks them, suggesting a length-based index. |
30
- | [`sh/compat/no-nounset-empty-array`](./compat/no-nounset-empty-array.md) | `bash-3.2`, `posix-portable` | No | Yes | Disallow whole-array expansions under `set -u` when the target shell aborts on an empty array, suggesting a guarded form. |
30
+ | [`sh/compat/no-nounset-empty-array`](./compat/no-nounset-empty-array.md) | None (opt-in) | No | Yes | Disallow whole-array expansions under `set -u` when the target shell aborts on an empty array, suggesting a guarded form. |
31
31
  | [`sh/compat/no-parameter-transformation`](./compat/no-parameter-transformation.md) | `bash-3.2`, `posix-portable` | No | No | Disallow `${v@op}` transformations when the target shell lacks the operator. |
32
32
  | [`sh/compat/no-pipe-all`](./compat/no-pipe-all.md) | `bash-3.2`, `posix-portable` | No | Yes | Disallow the stderr-merging pipe (pipe-ampersand) when the target shell lacks it, suggesting an explicit `2>&1` before the pipe. |
33
33
  | [`sh/compat/no-printf-time-format`](./compat/no-printf-time-format.md) | `bash-3.2`, `posix-portable` | No | No | Disallow `printf`'s `%(fmt)T` date format when the target shell lacks it. |
@@ -48,7 +48,7 @@ See the [canonical quickstart](https://github.com/mike-north/eslint-sh/blob/main
48
48
  | [`sh/quote-expansions`](./quote-expansions.md) | `recommended`, `agent-authored` | No | Yes | Require double quotes around expansions in words the shell splits and globs. |
49
49
  | [`sh/require-network-wrapper`](./require-network-wrapper.md) | `agent-authored` | No | No | Require network commands to run through your configured wrapper. |
50
50
  | [`sh/require-shebang`](./require-shebang.md) | `recommended`, `agent-authored` | Yes (missing shebang only) | No | Require a recognized shell interpreter on line 1. |
51
- | [`sh/require-strict-mode`](./require-strict-mode.md) | `recommended`, `agent-authored`, `posix-portable` (with set -eu) | Yes (when insertion satisfies the rule) | No | Require strict-mode options near the start of the script. |
51
+ | [`sh/require-strict-mode`](./require-strict-mode.md) | `recommended`, `agent-authored` | Yes (when insertion satisfies the rule) | No | Require strict-mode options near the start of the script. |
52
52
  | [`sh/require-tty-guard`](./require-tty-guard.md) | `agent-authored` | No | Yes | Require `read`, `select` and configured interactive commands to be guarded by a TTY test or supplied input. |
53
53
  | [`sh/shebang-matches-dialect`](./shebang-matches-dialect.md) | `recommended`, `agent-authored`, `posix-portable` | No | No | Require the shebang to name the same kind of shell (bash or POSIX) as `languageOptions.dialect`. |
54
54
 
@@ -60,12 +60,14 @@ describes edits available through `eslint --fix`. `quote-expansions` suggests qu
60
60
  fixing because only the script's author knows whether the splitting was intended.
61
61
 
62
62
  The version-gated `compat/*` rules (`compat/no-append-all-redirect`, `compat/no-associative-arrays`, `compat/no-brace-sequence-padding-step`, `compat/no-case-attributes`, `compat/no-case-fallthrough`, `compat/no-case-modification`, `compat/no-coproc`, `compat/no-declare-g`, `compat/no-epoch-variables`, `compat/no-fd-variable`, `compat/no-globstar`, `compat/no-lastpipe-semantics`, `compat/no-mapfile`, `compat/no-nameref`, `compat/no-negative-array-index`, `compat/no-nounset-empty-array`, `compat/no-parameter-transformation`, `compat/no-pipe-all`, `compat/no-printf-time-format`, `compat/no-test-v`, `compat/no-unicode-escape`, `compat/no-wait-n`) report
63
- shell features that your target shell lacks, as set by `languageOptions.shellVersion` and
64
- `dialect`. They report nothing when `shellVersion` is unset, so the `bash-3.2` preset sets it to `3.2`
65
- and the `posix-portable` preset sets `dialect: "posix"`; each enables all of them.
63
+ shell features that your target shell lacks, as set by `languageOptions.minBashVersion` and
64
+ `dialect`. They report nothing when `minBashVersion` is unset, so the `bash-3.2` preset sets it to `3.2`
65
+ and the `posix-portable` preset sets `dialect: "posix"`. `bash-3.2` enables all except
66
+ `compat/no-nounset-empty-array`, which is opt-in for scripts using `set -u` on Bash below 4.4
67
+ with arrays that can really be empty; `posix-portable` omits that Bash-only check because it cannot fire there.
66
68
  See [version compatibility](../compat.md). `compat/*` means target gates only; `shebang-matches-dialect`
67
69
  compares the file with your config whatever the target, so it lives outside that namespace. `posix-portable` also enables
68
- `shebang-matches-dialect`, `require-strict-mode` (as `set -eu`) and the POSIX-only gates
70
+ `shebang-matches-dialect` (to check the target against the declared interpreter) and the POSIX-only gates
69
71
  `compat/no-double-bracket`, `compat/no-let` and `compat/no-source`, which report those constructs
70
72
  under `dialect: "posix"` because they fail on dash. It does not report `local`, `echo -e` or the
71
73
  other constructs listed under
@@ -77,3 +79,41 @@ To run these rules beside shellcheck, see [shellcheck](../shellcheck.md).
77
79
  `require-network-wrapper` reports nothing until you set its `wrapper` option (see
78
80
  [wrapper rules](../wrapper-rules.md)). Each linked rule page documents its options, limitations,
79
81
  and relationship to shellcheck.
82
+
83
+ ## Replacement and additive lists
84
+
85
+ For the secret rules, `patterns` replaces the defaults and `additionalPatterns` adds to the
86
+ replacement (or defaults when omitted). For the TTY and network wrapper rules, `commands` and
87
+ `additionalCommands` have the same relationship. An empty replacement removes defaults; an empty
88
+ addition changes nothing. Overlapping entries do not duplicate findings. Lists without defaults,
89
+ such as `allowedSinks`, retain their plain names. Shared wrapper settings follow their own contract.
90
+
91
+ ## Regular-expression options
92
+
93
+ Every regular-expression source in a rule option is compiled with JavaScript's `u` flag
94
+ (Unicode). `sh/no-secret-flags` also uses `i`, preserving case-insensitive matching for
95
+ both default and custom patterns. `sh/no-secret-env-reads` and `sh/prefer-local` match
96
+ case-sensitively. The original name and pattern are used without lower-casing either.
97
+ Thus `patterns: ['token']` catches `--TOKEN` in `no-secret-flags`, but does not catch
98
+ `$GITHUB_TOKEN` in `no-secret-env-reads`. `allowPattern: '^g_'` exempts `g_cache`, but not
99
+ `G_cache`, in `prefer-local`. Sources are strings, without `/` delimiters or flag suffixes;
100
+ write `\\p{Lu}` in a JavaScript string to match an uppercase Unicode letter.
101
+
102
+ The shared compiler validates syntax with these actual flags, then applies the
103
+ [pattern-safety guard](./no-secret-flags.md#patterns-run-against-script-controlled-text).
104
+ All regex syntax errors, including `(`, fail when the enabled rule first runs on a file.
105
+ The error names the rule, option (including the array index) and pattern; ESLint reports
106
+ "Occurred while linting <file>" and exits with status 2.
107
+
108
+ Config resolution does not compile regex sources: `--print-config` will not catch any regex syntax errors.
109
+ The schemas still check option types and array lengths, but deliberately omit the `regex`
110
+ format. ESLint validates that format without flags, which would reject Unicode-valid sources
111
+ such as `^[\u{41}-\u{5A}]+$` (an uppercase-letter range under `u`). Keeping compilation in the
112
+ rule allows these sources and gives every syntax error the same first-rule-run timing.
113
+
114
+ Migration: sources accepted without `u` may now fail, including identity escapes such as
115
+ `\-` outside a character class, `\q` (also invalid inside `[\q]`), and incomplete quantifiers
116
+ such as `a{,5}`. Use `-`, `q` or `a\\{,5\\}` respectively in JavaScript strings for those
117
+ literal characters. An escaped hyphen **inside** a class (`[\-]`, written `'[\\-]'` in a
118
+ JavaScript string) remains valid. Unicode property escapes (`\p{Lu}`) and code point escapes
119
+ (`\u{1F510}`) now have their Unicode meaning in every regex option.
@@ -15,7 +15,7 @@
15
15
  `{"options": {"maxNesting": 2}, "dialect": "bash"}`, then the usual closing. See any
16
16
  existing page, e.g. `max-script-complexity.md`, for the exact spelling.
17
17
 
18
- Keys: `options` (the rule's options value), `dialect`, `shellVersion`, `convention`
18
+ Keys: `options` (the rule's options value), `dialect`, `minBashVersion`, `convention`
19
19
  (`"commentPragma"`) and `filename`. Under `### Incorrect` you may also state what the prose
20
20
  claims exactly: `findings` (a count), `messageIds` (in report order), `output` (the source
21
21
  after autofix) and `suggestionOutputs`. A typo in the annotation fails the test.
@@ -38,7 +38,7 @@
38
38
 
39
39
  <Why this policy matters for shell scripts, and exactly what the rule reports. Say which
40
40
  node types or constructs it inspects and which it deliberately ignores. If the rule depends on
41
- `languageOptions` (`dialect`, `shellVersion`), say how.>
41
+ `languageOptions` (`dialect`, `minBashVersion`), say how.>
42
42
 
43
43
  ## Options
44
44
 
@@ -21,15 +21,15 @@ Under `dialect: "posix"` the parser itself rejects `&>>`, so a POSIX file that u
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.0`.
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.0`.
26
26
  - `dialect: "mksh"` or `"zsh"`: never reports.
27
27
 
28
28
  ### Suggestion
29
29
 
30
30
  A suggestion rewrites the redirection:
31
31
 
32
- <!-- transform: {"kind": "suggestion", "dialect": "bash", "shellVersion": "3.2"} -->
32
+ <!-- transform: {"kind": "suggestion", "dialect": "bash", "minBashVersion": "3.2"} -->
33
33
  ```sh
34
34
  build &>> build.log
35
35
  # becomes
@@ -38,12 +38,12 @@ build >> build.log 2>&1
38
38
 
39
39
  ## Options
40
40
 
41
- This rule has no options. Set the target through `languageOptions`:
41
+ This rule has no options. Set the required support through `languageOptions`:
42
42
 
43
43
  ```js
44
44
  // eslint.config.js
45
45
  {
46
- languageOptions: { dialect: 'bash', shellVersion: '3.2' },
46
+ languageOptions: { dialect: 'bash', minBashVersion: '3.2' },
47
47
  rules: {
48
48
  'sh/compat/no-append-all-redirect': 'error',
49
49
  },
@@ -54,29 +54,29 @@ This rule has no options. Set the target through `languageOptions`:
54
54
 
55
55
  ### Incorrect
56
56
 
57
- With `shellVersion: "3.2"`:
57
+ With `minBashVersion: "3.2"`:
58
58
 
59
- <!-- example: {"dialect": "bash", "shellVersion": "3.2", "findings": 1} -->
59
+ <!-- example: {"dialect": "bash", "minBashVersion": "3.2", "findings": 1} -->
60
60
  ```sh
61
61
  build &>> build.log
62
62
  ```
63
63
 
64
64
  ### Correct
65
65
 
66
- With `shellVersion: "3.2"`:
66
+ With `minBashVersion: "3.2"`:
67
67
 
68
- <!-- example: {"dialect": "bash", "shellVersion": "3.2"} -->
68
+ <!-- example: {"dialect": "bash", "minBashVersion": "3.2"} -->
69
69
  ```sh
70
70
  build >> build.log 2>&1
71
71
  build &> build.log
72
72
  echo "use &>> on Bash 4"
73
73
  ```
74
74
 
75
- With `shellVersion: "4.0"` or newer, or with no `shellVersion`, `&>>` is fine.
75
+ With `minBashVersion: "4.0"` or newer, or with no `minBashVersion`, `&>>` is fine.
76
76
 
77
77
  ## When not to use it
78
78
 
79
- Turn the rule off when your scripts never run on Bash older than 4.0, or leave `shellVersion`
79
+ Turn the rule off when your scripts never run on Bash older than 4.0, or leave `minBashVersion`
80
80
  unset, which makes the rule report nothing.
81
81
 
82
82
  ## Relationship to shellcheck
@@ -84,4 +84,4 @@ unset, which makes the rule report nothing.
84
84
  eslint-sh is a convention and contract linter: a policy layer, where shellcheck is the gotcha
85
85
  layer. Run shellcheck beside it.
86
86
 
87
- shellcheck 0.11.0 reports nothing for `cmd &>> log` under either `-s sh` or `-s bash`. (`cmd &> log` is different: it reports SC3020 under `-s sh`.) So shellcheck gives no finding for `&>>` in a POSIX sh script or in a Bash 3.2 target. This rule exists for both.
87
+ shellcheck 0.11.0 reports nothing for `cmd &>> log` under either `-s sh` or `-s bash`. (`cmd &> log` is different: it reports SC3020 under `-s sh`.) So shellcheck gives no finding for `&>>` in a POSIX sh script or in a script that must support Bash 3.2. This rule exists for both.
@@ -1,6 +1,6 @@
1
1
  # `sh/compat/no-associative-arrays`
2
2
 
3
- Disallow associative arrays (`declare -A`, `typeset -A`) in scripts whose target shell lacks
3
+ Disallow associative arrays (`declare -A`, `typeset -A`) 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 |
@@ -17,9 +17,9 @@ return the wrong values without an error.
17
17
  This is a version-compat rule. Whether it reports depends only on `languageOptions`, as
18
18
  described in [version compatibility](../../compat.md):
19
19
 
20
- - `shellVersion` unset: never reports. An unset version means the newest Bash.
21
- - `dialect: "bash"` (the default) or `"bats"`: reports when `shellVersion` is older than `4.0`.
22
- - `dialect: "posix"`: reports at any `shellVersion`, because POSIX sh has no arrays.
20
+ - `minBashVersion` unset: no Bash version constraint, so no report under `bash` or `bats`.
21
+ - `dialect: "bash"` (the default) or `"bats"`: reports when `minBashVersion` is older than `4.0`.
22
+ - `dialect: "posix"`: reports regardless of Bash releases, because POSIX sh has no arrays.
23
23
  - `dialect: "mksh"` or `"zsh"`: never reports.
24
24
 
25
25
  The rule reads the options of every `declare` and `typeset` command, up to the first operand,
@@ -37,12 +37,12 @@ The rule deliberately ignores:
37
37
 
38
38
  ## Options
39
39
 
40
- This rule has no options. Set the target through `languageOptions`:
40
+ This rule has no options. Set the required support through `languageOptions`:
41
41
 
42
42
  ```js
43
43
  // eslint.config.js
44
44
  {
45
- languageOptions: { dialect: 'bash', shellVersion: '3.2' },
45
+ languageOptions: { dialect: 'bash', minBashVersion: '3.2' },
46
46
  rules: {
47
47
  'sh/compat/no-associative-arrays': 'error',
48
48
  },
@@ -53,9 +53,9 @@ This rule has no options. Set the target through `languageOptions`:
53
53
 
54
54
  ### Incorrect
55
55
 
56
- With `shellVersion: "3.2"`:
56
+ With `minBashVersion: "3.2"`:
57
57
 
58
- <!-- example: {"dialect": "bash", "shellVersion": "3.2", "findings": 4} -->
58
+ <!-- example: {"dialect": "bash", "minBashVersion": "3.2", "findings": 4} -->
59
59
  ```sh
60
60
  declare -A ports # associative arrays need Bash 4.0
61
61
  typeset -A ports # the same declaration through typeset
@@ -65,9 +65,9 @@ builtin declare -A ports # reached through the builtin wrapper
65
65
 
66
66
  ### Correct
67
67
 
68
- With `shellVersion: "3.2"`:
68
+ With `minBashVersion: "3.2"`:
69
69
 
70
- <!-- example: {"dialect": "bash", "shellVersion": "3.2"} -->
70
+ <!-- example: {"dialect": "bash", "minBashVersion": "3.2"} -->
71
71
  ```sh
72
72
  # Keep the mapping as JSON and look keys up with jq.
73
73
  port=$(jq -r --arg k "$service" '.[$k]' ports.json)
@@ -75,16 +75,16 @@ port=$(jq -r --arg k "$service" '.[$k]' ports.json)
75
75
  declare -a hosts # indexed arrays exist in Bash 3.2
76
76
  ```
77
77
 
78
- With `shellVersion: "4.0"` or newer, or with no `shellVersion`:
78
+ With `minBashVersion: "4.0"` or newer, or with no `minBashVersion`:
79
79
 
80
- <!-- example: {"dialect": "bash", "shellVersion": "4.0"} -->
80
+ <!-- example: {"dialect": "bash", "minBashVersion": "4.0"} -->
81
81
  ```sh
82
82
  declare -A ports
83
83
  ```
84
84
 
85
85
  ## When not to use it
86
86
 
87
- Turn the rule off when your scripts never run on Bash older than 4.0, or leave `shellVersion`
87
+ Turn the rule off when your scripts never run on Bash older than 4.0, or leave `minBashVersion`
88
88
  unset, which makes the rule report nothing.
89
89
 
90
90
  ## Relationship to shellcheck
@@ -92,4 +92,4 @@ unset, which makes the rule report nothing.
92
92
  eslint-sh is a convention and contract linter: a policy layer, where shellcheck is the gotcha
93
93
  layer. Run shellcheck beside it.
94
94
 
95
- shellcheck 0.11.0 reports the command, not the option: under `-s sh`, `declare -A` draws SC3044 (`declare` is undefined in POSIX sh), and `local -A` draws SC3043. Under `-s bash` it reports nothing. It has no way to target a Bash version, so it reports nothing for `declare -A` in a script that must run on Bash 3.2. This rule exists for that target.
95
+ shellcheck 0.11.0 reports the command, not the option: under `-s sh`, `declare -A` draws SC3044 (`declare` is undefined in POSIX sh), and `local -A` draws SC3043. Under `-s bash` it reports nothing. It has no way to check support for a minimum Bash version, so it reports nothing for `declare -A` in a script that must run on Bash 3.2. This rule checks that support requirement.
@@ -28,19 +28,19 @@ The portable alternative is to count in a loop and format with `printf`, for exa
28
28
  This is a version-compat rule. Whether it reports depends only on `languageOptions`, as
29
29
  described in [version compatibility](../../compat.md):
30
30
 
31
- - `shellVersion` unset: never reports. An unset version means the newest Bash.
32
- - `dialect: "bash"` (the default) or `"bats"`: reports when `shellVersion` is older than `4.0`.
33
- - `dialect: "posix"`: reports at any `shellVersion`, because POSIX does not specify brace expansion.
31
+ - `minBashVersion` unset: no Bash version constraint, so no report under `bash` or `bats`.
32
+ - `dialect: "bash"` (the default) or `"bats"`: reports when `minBashVersion` is older than `4.0`.
33
+ - `dialect: "posix"`: reports regardless of Bash releases, because POSIX does not specify brace expansion.
34
34
  - `dialect: "mksh"` or `"zsh"`: never reports.
35
35
 
36
36
  ## Options
37
37
 
38
- This rule has no options. Set the target through `languageOptions`:
38
+ This rule has no options. Set the required support through `languageOptions`:
39
39
 
40
40
  ```js
41
41
  // eslint.config.js
42
42
  {
43
- languageOptions: { dialect: 'bash', shellVersion: '3.2' },
43
+ languageOptions: { dialect: 'bash', minBashVersion: '3.2' },
44
44
  rules: {
45
45
  'sh/compat/no-brace-sequence-padding-step': 'error',
46
46
  },
@@ -51,9 +51,9 @@ This rule has no options. Set the target through `languageOptions`:
51
51
 
52
52
  ### Incorrect
53
53
 
54
- With `shellVersion: "3.2"`:
54
+ With `minBashVersion: "3.2"`:
55
55
 
56
- <!-- example: {"dialect": "bash", "shellVersion": "3.2", "findings": 3} -->
56
+ <!-- example: {"dialect": "bash", "minBashVersion": "3.2", "findings": 3} -->
57
57
 
58
58
  ```sh
59
59
  for n in {01..12}; do echo "report-$n"; done
@@ -63,9 +63,9 @@ cp backup{a..e..2}.tar /tmp
63
63
 
64
64
  ### Correct
65
65
 
66
- With `shellVersion: "3.2"`:
66
+ With `minBashVersion: "3.2"`:
67
67
 
68
- <!-- example: {"dialect": "bash", "shellVersion": "3.2"} -->
68
+ <!-- example: {"dialect": "bash", "minBashVersion": "3.2"} -->
69
69
 
70
70
  ```sh
71
71
  n=1
@@ -75,11 +75,11 @@ echo '{01..12}'
75
75
  a={01..03}
76
76
  ```
77
77
 
78
- With `shellVersion: "4.0"` or newer, or with no `shellVersion`, both forms are fine.
78
+ With `minBashVersion: "4.0"` or newer, or with no `minBashVersion`, both forms are fine.
79
79
 
80
80
  ## When not to use it
81
81
 
82
- Turn the rule off when your scripts never run on Bash older than 4.0, or leave `shellVersion`
82
+ Turn the rule off when your scripts never run on Bash older than 4.0, or leave `minBashVersion`
83
83
  unset, which makes the rule report nothing.
84
84
 
85
85
  ## Relationship to shellcheck
@@ -87,4 +87,4 @@ unset, which makes the rule report nothing.
87
87
  eslint-sh is a convention and contract linter: a policy layer, where shellcheck is the gotcha
88
88
  layer. Run shellcheck beside it.
89
89
 
90
- shellcheck 0.11.0 reports SC3009 (brace expansion is undefined in POSIX sh) under `-s sh` for every brace expansion, a plain `{1..3}` and `{a,b}` included. Under `-s bash` it reports nothing for these sequences. It does not know which Bash release a script must run on, so it cannot report the padded and stepped forms for a Bash 3.2 target. This rule exists for that target.
90
+ shellcheck 0.11.0 reports SC3009 (brace expansion is undefined in POSIX sh) under `-s sh` for every brace expansion, a plain `{1..3}` and `{a,b}` included. Under `-s bash` it reports nothing for these sequences. It does not know which Bash release a script must run on, so it cannot report the padded and stepped forms for a script that must support Bash 3.2. This rule checks that support requirement.
@@ -1,7 +1,7 @@
1
1
  # `sh/compat/no-case-attributes`
2
2
 
3
3
  Disallow the case-converting attributes `declare -l` and `declare -u` (also through `typeset` and
4
- `local`) in scripts whose target shell lacks them: Bash older than 4.0, including the Bash 3.2
4
+ `local`) in scripts that must support a shell lacking them: Bash older than 4.0, including the Bash 3.2
5
5
  that macOS ships as `/bin/bash`, and POSIX sh.
6
6
 
7
7
  | Configs | Fixable | Languages |
@@ -19,19 +19,19 @@ The portable alternative is to convert the value when it is assigned, with `tr`:
19
19
  This is a version-compat rule. Whether it reports depends only on `languageOptions`, as
20
20
  described in [version compatibility](../../compat.md):
21
21
 
22
- - `shellVersion` unset: never reports. An unset version means the newest Bash.
23
- - `dialect: "bash"` (the default) or `"bats"`: reports when `shellVersion` is older than `4.0`.
24
- - `dialect: "posix"`: reports at any `shellVersion`, because POSIX sh has no `declare`.
22
+ - `minBashVersion` unset: no Bash version constraint, so no report under `bash` or `bats`.
23
+ - `dialect: "bash"` (the default) or `"bats"`: reports when `minBashVersion` is older than `4.0`.
24
+ - `dialect: "posix"`: reports regardless of Bash releases, because POSIX sh has no `declare`.
25
25
  - `dialect: "mksh"` or `"zsh"`: never reports.
26
26
 
27
27
  ## Options
28
28
 
29
- This rule has no options. Set the target through `languageOptions`:
29
+ This rule has no options. Set the required support through `languageOptions`:
30
30
 
31
31
  ```js
32
32
  // eslint.config.js
33
33
  {
34
- languageOptions: { dialect: 'bash', shellVersion: '3.2' },
34
+ languageOptions: { dialect: 'bash', minBashVersion: '3.2' },
35
35
  rules: {
36
36
  'sh/compat/no-case-attributes': 'error',
37
37
  },
@@ -42,9 +42,9 @@ This rule has no options. Set the target through `languageOptions`:
42
42
 
43
43
  ### Incorrect
44
44
 
45
- With `shellVersion: "3.2"`:
45
+ With `minBashVersion: "3.2"`:
46
46
 
47
- <!-- example: {"dialect": "bash", "shellVersion": "3.2", "findings": 2} -->
47
+ <!-- example: {"dialect": "bash", "minBashVersion": "3.2", "findings": 2} -->
48
48
 
49
49
  ```sh
50
50
  declare -l answer=$1
@@ -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
 
62
62
  ```sh
63
63
  answer=$(printf '%s' "$1" | tr '[:upper:]' '[:lower:]')
@@ -67,11 +67,11 @@ f() {
67
67
  }
68
68
  ```
69
69
 
70
- With `shellVersion: "4.0"` or newer, or with no `shellVersion`, the attributes are fine.
70
+ With `minBashVersion: "4.0"` or newer, or with no `minBashVersion`, the attributes are fine.
71
71
 
72
72
  ## When not to use it
73
73
 
74
- Turn the rule off when your scripts never run on Bash older than 4.0, or leave `shellVersion`
74
+ Turn the rule off when your scripts never run on Bash older than 4.0, or leave `minBashVersion`
75
75
  unset, which makes the rule report nothing.
76
76
 
77
77
  ## Relationship to shellcheck
@@ -79,4 +79,4 @@ unset, which makes the rule report nothing.
79
79
  eslint-sh is a convention and contract linter: a policy layer, where shellcheck is the gotcha
80
80
  layer. Run shellcheck beside it.
81
81
 
82
- Under `-s sh`, shellcheck 0.11.0 reports the command, not the option: `declare -l` and `declare -u` draw SC3044 (`declare` is undefined in POSIX sh), and `local -l` and `local -u` draw SC3043. Under `-s bash` it reports nothing for these options. It does not know which Bash release a script must run on, so it reports nothing for `declare -l` in a Bash 3.2 target. This rule exists for that target.
82
+ Under `-s sh`, shellcheck 0.11.0 reports the command, not the option: `declare -l` and `declare -u` draw SC3044 (`declare` is undefined in POSIX sh), and `local -l` and `local -u` draw SC3043. Under `-s bash` it reports nothing for these options. It does not know which Bash release a script must run on, so it reports nothing for `declare -l` in a script that must support Bash 3.2. This rule checks that support requirement.
@@ -1,7 +1,7 @@
1
1
  # `sh/compat/no-case-fallthrough`
2
2
 
3
3
  Disallow the `case` terminators `;&` (run the next branch without testing its pattern) and `;;&`
4
- (go on testing the next patterns) in scripts whose target shell lacks them: Bash older than 4.0,
4
+ (go on testing the next patterns) in scripts that must support a shell lacking them: Bash older than 4.0,
5
5
  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 both terminators, so a POSIX
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.0`.
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.0`.
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-case-fallthrough': '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
  case $level in
51
51
  debug) verbose=1 ;&
@@ -59,9 +59,9 @@ esac
59
59
 
60
60
  ### Correct
61
61
 
62
- With `shellVersion: "3.2"`:
62
+ With `minBashVersion: "3.2"`:
63
63
 
64
- <!-- example: {"dialect": "bash", "shellVersion": "3.2"} -->
64
+ <!-- example: {"dialect": "bash", "minBashVersion": "3.2"} -->
65
65
  ```sh
66
66
  case $level in
67
67
  debug) verbose=1; log=1 ;;
@@ -75,11 +75,11 @@ case $file in
75
75
  esac
76
76
  ```
77
77
 
78
- With `shellVersion: "4.0"` or newer, or with no `shellVersion`, both terminators are fine.
78
+ With `minBashVersion: "4.0"` or newer, or with no `minBashVersion`, both terminators are fine.
79
79
 
80
80
  ## When not to use it
81
81
 
82
- Turn the rule off when your scripts never run on Bash older than 4.0, or leave `shellVersion`
82
+ Turn the rule off when your scripts never run on Bash older than 4.0, or leave `minBashVersion`
83
83
  unset, which makes the rule report nothing.
84
84
 
85
85
  ## Relationship to shellcheck
@@ -87,4 +87,4 @@ unset, which makes the rule report nothing.
87
87
  eslint-sh is a convention and contract linter: a policy layer, where shellcheck is the gotcha
88
88
  layer. Run shellcheck beside it.
89
89
 
90
- Under `-s sh`, shellcheck 0.11.0 reports `;&` and `;;&` as an error, SC2127 ("To use cases with ;&, specify #!/usr/bin/env bash or ksh", or the `;;&` equivalent naming bash), not as one of its SC3xxx portability checks. It reports the same SC2127 under `-s dash`, reports `;;&` (but not `;&`) under `-s ksh`, and reports nothing under `-s bash`. It does not know which Bash release a script must run on, so it reports nothing for either operator in a Bash 3.2 target. This rule exists for that target.
90
+ Under `-s sh`, shellcheck 0.11.0 reports `;&` and `;;&` as an error, SC2127 ("To use cases with ;&, specify #!/usr/bin/env bash or ksh", or the `;;&` equivalent naming bash), not as one of its SC3xxx portability checks. It reports the same SC2127 under `-s dash`, reports `;;&` (but not `;&`) under `-s ksh`, and reports nothing under `-s bash`. It does not know which Bash release a script must run on, so it reports nothing for either operator in a script that must support Bash 3.2. This rule checks that support requirement.
@@ -17,19 +17,19 @@ The report is on the whole expansion, with or without a trailing pattern (`${v^^
17
17
  This is a version-compat rule. Whether it reports depends only on `languageOptions`, as
18
18
  described in [version compatibility](../../compat.md):
19
19
 
20
- - `shellVersion` unset: never reports. An unset version means the newest Bash.
21
- - `dialect: "bash"` (the default) or `"bats"`: reports when `shellVersion` is older than `4.0`.
20
+ - `minBashVersion` unset: no Bash version constraint, so no report under `bash` or `bats`.
21
+ - `dialect: "bash"` (the default) or `"bats"`: reports when `minBashVersion` is older than `4.0`.
22
22
  - `dialect: "posix"`: reports nothing in practice for this syntax, because the POSIX parser rejects it with a parse error before any rule runs.
23
23
  - `dialect: "mksh"` or `"zsh"`: never reports.
24
24
 
25
25
  ## Options
26
26
 
27
- This rule has no options. Set the target through `languageOptions`:
27
+ This rule has no options. Set the required support through `languageOptions`:
28
28
 
29
29
  ```js
30
30
  // eslint.config.js
31
31
  {
32
- languageOptions: { dialect: 'bash', shellVersion: '3.2' },
32
+ languageOptions: { dialect: 'bash', minBashVersion: '3.2' },
33
33
  rules: {
34
34
  'sh/compat/no-case-modification': 'error',
35
35
  },
@@ -40,9 +40,9 @@ This rule has no options. Set the target through `languageOptions`:
40
40
 
41
41
  ### Incorrect
42
42
 
43
- With `shellVersion: "3.2"`:
43
+ With `minBashVersion: "3.2"`:
44
44
 
45
- <!-- example: {"dialect": "bash", "shellVersion": "3.2", "findings": 3} -->
45
+ <!-- example: {"dialect": "bash", "minBashVersion": "3.2", "findings": 3} -->
46
46
  ```sh
47
47
  name=${input,,} # lowercase every character
48
48
  title=${word^} # uppercase the first character
@@ -51,24 +51,24 @@ flag=${arg^^[a-z]} # with a pattern
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
  name=$(printf '%s' "$input" | tr '[:upper:]' '[:lower:]')
59
59
  title=$(printf '%s' "${word%"${word#?}"}" | tr '[:lower:]' '[:upper:]')"${word#?}"
60
60
  ```
61
61
 
62
- With `shellVersion: "4.0"` or newer, or with no `shellVersion`, the original forms are fine.
62
+ With `minBashVersion: "4.0"` or newer, or with no `minBashVersion`, the original forms are fine.
63
63
 
64
64
  ## When not to use it
65
65
 
66
66
  Turn the rule off when your scripts never run on Bash older than 4.0, or leave
67
- `shellVersion` unset, which makes the rule report nothing.
67
+ `minBashVersion` unset, which makes the rule report nothing.
68
68
 
69
69
  ## Relationship to shellcheck
70
70
 
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 case-modifying expansions in scripts it treats as POSIX sh (SC3059), but it cannot target a Bash version, so it cannot report `${v,,}` in a script that must run on Bash 3.2. This rule exists for that target.
74
+ shellcheck reports case-modifying expansions in scripts it treats as POSIX sh (SC3059), but it cannot check support for a minimum Bash version, so it cannot report `${v,,}` in a script that must run on Bash 3.2. This rule checks that support requirement.
@@ -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.