@eslint/shell 0.1.0 → 0.1.2
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 +20 -10
- package/dist/index.js +1 -1
- package/dist/rules/no-backticks.d.ts +0 -1
- package/dist/rules/no-backticks.js +1 -2
- package/dist/rules/no-expansions-in-single-quotes.d.ts +0 -1
- package/dist/rules/no-expansions-in-single-quotes.js +1 -2
- package/dist/rules/no-ls-iteration.d.ts +0 -1
- package/dist/rules/no-ls-iteration.js +1 -2
- package/dist/rules/no-unquoted-expansions.d.ts +1 -1
- package/dist/rules/no-unquoted-expansions.js +3 -3
- package/dist/rules/no-unused-vars.d.ts +0 -1
- package/dist/rules/no-unused-vars.js +1 -2
- package/dist/rules/no-useless-cat.d.ts +0 -1
- package/dist/rules/no-useless-cat.js +1 -2
- package/dist/rules/no-useless-echo.d.ts +0 -1
- package/dist/rules/no-useless-echo.js +1 -2
- package/dist/rules/no-variables-in-printf-format.d.ts +0 -1
- package/dist/rules/no-variables-in-printf-format.js +1 -2
- package/dist/rules/require-cd-guard.d.ts +0 -1
- package/dist/rules/require-cd-guard.js +1 -2
- package/dist/rules/require-read-r.d.ts +0 -1
- package/dist/rules/require-read-r.js +1 -2
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -22,20 +22,26 @@ Requires Node.js `^20.19.0 || ^22.13.0 || >=24`. Tested with ESLint v10.
|
|
|
22
22
|
Add the plugin to your `eslint.config.js`:
|
|
23
23
|
|
|
24
24
|
```js
|
|
25
|
+
import { defineConfig } from "eslint/config";
|
|
25
26
|
import shell from "@eslint/shell";
|
|
26
27
|
|
|
27
|
-
export default [
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
]
|
|
28
|
+
export default defineConfig([
|
|
29
|
+
{
|
|
30
|
+
// use the recommended rules for *.sh and *.bash files
|
|
31
|
+
files: ["**/*.sh", "**/*.bash"],
|
|
32
|
+
plugins: { shell },
|
|
33
|
+
extends: ["shell/recommended"],
|
|
34
|
+
},
|
|
35
|
+
]);
|
|
31
36
|
```
|
|
32
37
|
|
|
33
38
|
Or configure it manually:
|
|
34
39
|
|
|
35
40
|
```js
|
|
41
|
+
import { defineConfig } from "eslint/config";
|
|
36
42
|
import shell from "@eslint/shell";
|
|
37
43
|
|
|
38
|
-
export default [
|
|
44
|
+
export default defineConfig([
|
|
39
45
|
{
|
|
40
46
|
files: ["**/*.sh"],
|
|
41
47
|
plugins: { shell },
|
|
@@ -45,7 +51,7 @@ export default [
|
|
|
45
51
|
"shell/no-unquoted-expansions": "error",
|
|
46
52
|
},
|
|
47
53
|
},
|
|
48
|
-
];
|
|
54
|
+
]);
|
|
49
55
|
```
|
|
50
56
|
|
|
51
57
|
### Languages
|
|
@@ -59,14 +65,17 @@ The plugin provides one language per shell dialect:
|
|
|
59
65
|
| `shell/mksh` | MirBSD Korn shell. |
|
|
60
66
|
|
|
61
67
|
```js
|
|
62
|
-
|
|
68
|
+
import { defineConfig } from "eslint/config";
|
|
69
|
+
import shell from "@eslint/shell";
|
|
70
|
+
|
|
71
|
+
export default defineConfig([
|
|
63
72
|
{
|
|
64
73
|
files: ["**/*.sh"],
|
|
65
74
|
plugins: { shell },
|
|
75
|
+
extends: ["shell/recommended"],
|
|
66
76
|
language: "shell/posix",
|
|
67
|
-
rules: { "shell/no-backticks": "error" },
|
|
68
77
|
},
|
|
69
|
-
];
|
|
78
|
+
]);
|
|
70
79
|
```
|
|
71
80
|
|
|
72
81
|
## Rules
|
|
@@ -143,13 +152,14 @@ Apache-2.0
|
|
|
143
152
|
<!-- NOTE: This section is autogenerated. Do not manually edit.-->
|
|
144
153
|
<!--sponsorsstart-->
|
|
145
154
|
|
|
155
|
+
|
|
146
156
|
## Sponsors
|
|
147
157
|
|
|
148
158
|
The following companies, organizations, and individuals support ESLint's ongoing maintenance and development. [Become a Sponsor](https://eslint.org/donate)
|
|
149
159
|
to get your logo on our READMEs and [website](https://eslint.org/sponsors).
|
|
150
160
|
|
|
151
161
|
<h3>Gold Sponsors</h3>
|
|
152
|
-
<p><a href="#"><img src="https://images.opencollective.com/vite-ecosystem-fund/logo.png" alt="Vite Ecosystem Fund" height="96"></a> <a href="https://qlty.sh/"><img src="https://images.opencollective.com/qltysh/33d157d/logo.png" alt="Qlty Software" height="96"></a> <a href="https://shopify.engineering/"><img src="https://avatars.githubusercontent.com/u/8085" alt="Shopify" height="96"></a> <a href="https://www.coderabbit.ai/?utm_source=cr_org&utm_medium=github"><img src="https://avatars.githubusercontent.com/u/132028505" alt="CodeRabbit" height="96"></a> <a href="https://automattic.com"><img src="https://avatars.githubusercontent.com/u/887802" alt="Automattic" height="96"></a></p><h3>Silver Sponsors</h3>
|
|
162
|
+
<p><a href="#"><img src="https://images.opencollective.com/vite-ecosystem-fund/logo.png" alt="Vite Ecosystem Fund" height="96"></a> <a href="https://forceindexer.com"><img src="https://images.opencollective.com/forceindexer/588566e/logo.png" alt="ForceIndexer" height="96"></a> <a href="https://qlty.sh/"><img src="https://images.opencollective.com/qltysh/33d157d/logo.png" alt="Qlty Software" height="96"></a> <a href="https://shopify.engineering/"><img src="https://avatars.githubusercontent.com/u/8085" alt="Shopify" height="96"></a> <a href="https://www.coderabbit.ai/?utm_source=cr_org&utm_medium=github"><img src="https://avatars.githubusercontent.com/u/132028505" alt="CodeRabbit" height="96"></a> <a href="https://automattic.com"><img src="https://avatars.githubusercontent.com/u/887802" alt="Automattic" height="96"></a></p><h3>Silver Sponsors</h3>
|
|
153
163
|
<p><a href="https://vite.dev/"><img src="https://images.opencollective.com/vite/d472863/logo.png" alt="Vite" height="64"></a> <a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/2d6c3b6/logo.png" alt="Liftoff" height="64"></a> <a href="https://stackblitz.com"><img src="https://avatars.githubusercontent.com/u/28635252" alt="StackBlitz" height="64"></a></p><h3>Bronze Sponsors</h3>
|
|
154
164
|
<p><a href="https://cybozu.co.jp/"><img src="https://images.opencollective.com/cybozu/933e46d/logo.png" alt="Cybozu" height="32"></a> <a href="https://opensource.sap.com"><img src="https://avatars.githubusercontent.com/u/2531208" alt="SAP" height="32"></a> <a href="https://discord.com"><img src="https://images.opencollective.com/discordapp/f9645d9/logo.png" alt="Discord" height="32"></a> <a href="https://www.gitbook.com"><img src="https://avatars.githubusercontent.com/u/7111340" alt="GitBook" height="32"></a> <a href="https://citadel-ai.com"><img src="https://avatars.githubusercontent.com/u/75781367" alt="Citadel AI" height="32"></a> <a href="https://www.testmuai.com"><img src="https://avatars.githubusercontent.com/u/171592363" alt="TestMu AI Open Source Office (Formerly LambdaTest)" height="32"></a></p>
|
|
155
165
|
<h3>Technology Sponsors</h3>
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview Rule to disallow legacy backtick command substitution.
|
|
3
|
-
* Mirrors ShellCheck SC2006.
|
|
4
3
|
*/
|
|
5
4
|
//------------------------------------------------------------------------------
|
|
6
5
|
// Rule Definition
|
|
@@ -16,7 +15,7 @@ const rule = {
|
|
|
16
15
|
fixable: "code",
|
|
17
16
|
schema: [],
|
|
18
17
|
messages: {
|
|
19
|
-
useDollarParen: "Use $(...) notation instead of legacy backticks.
|
|
18
|
+
useDollarParen: "Use $(...) notation instead of legacy backticks.",
|
|
20
19
|
},
|
|
21
20
|
},
|
|
22
21
|
create(context) {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview Rule to flag expansion-like text inside single quotes.
|
|
3
|
-
* Mirrors ShellCheck SC2016.
|
|
4
3
|
*/
|
|
5
4
|
//------------------------------------------------------------------------------
|
|
6
5
|
// Helpers
|
|
@@ -24,7 +23,7 @@ const rule = {
|
|
|
24
23
|
},
|
|
25
24
|
schema: [],
|
|
26
25
|
messages: {
|
|
27
|
-
expansionInSingleQuotes: "Expressions don't expand in single quotes; use double quotes for that.
|
|
26
|
+
expansionInSingleQuotes: "Expressions don't expand in single quotes; use double quotes for that.",
|
|
28
27
|
},
|
|
29
28
|
},
|
|
30
29
|
create(context) {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview Rule to disallow iterating over `ls` output.
|
|
3
|
-
* Mirrors ShellCheck SC2045.
|
|
4
3
|
*/
|
|
5
4
|
//------------------------------------------------------------------------------
|
|
6
5
|
// Imports
|
|
@@ -19,7 +18,7 @@ const rule = {
|
|
|
19
18
|
},
|
|
20
19
|
schema: [],
|
|
21
20
|
messages: {
|
|
22
|
-
lsIteration: "Iterating over ls output is fragile. Use globs (e.g. *) instead.
|
|
21
|
+
lsIteration: "Iterating over ls output is fragile. Use globs (e.g. *) instead.",
|
|
23
22
|
},
|
|
24
23
|
},
|
|
25
24
|
create(context) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview Rule to require quoting expansions that undergo word
|
|
3
|
-
* splitting and globbing.
|
|
3
|
+
* splitting and globbing.
|
|
4
4
|
*/
|
|
5
5
|
import type { ShellRuleDefinition } from "../types.js";
|
|
6
6
|
declare const rule: ShellRuleDefinition<{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview Rule to require quoting expansions that undergo word
|
|
3
|
-
* splitting and globbing.
|
|
3
|
+
* splitting and globbing.
|
|
4
4
|
*/
|
|
5
5
|
import { startsWithCommand } from "./utils.js";
|
|
6
6
|
//------------------------------------------------------------------------------
|
|
@@ -27,8 +27,8 @@ const rule = {
|
|
|
27
27
|
fixable: "code",
|
|
28
28
|
schema: [],
|
|
29
29
|
messages: {
|
|
30
|
-
unquotedParameterExpansion: 'Double quote "{{expansion}}" to prevent word splitting and globbing.
|
|
31
|
-
unquotedCommandSubstitution: "Quote this command substitution to prevent word splitting.
|
|
30
|
+
unquotedParameterExpansion: 'Double quote "{{expansion}}" to prevent word splitting and globbing.',
|
|
31
|
+
unquotedCommandSubstitution: "Quote this command substitution to prevent word splitting.",
|
|
32
32
|
},
|
|
33
33
|
},
|
|
34
34
|
create(context) {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview Rule to flag variables that are assigned but never used.
|
|
3
|
-
* Mirrors ShellCheck SC2034.
|
|
4
3
|
*/
|
|
5
4
|
//------------------------------------------------------------------------------
|
|
6
5
|
// Imports
|
|
@@ -81,7 +80,7 @@ const rule = {
|
|
|
81
80
|
],
|
|
82
81
|
defaultOptions: [{}],
|
|
83
82
|
messages: {
|
|
84
|
-
unusedVariable: "Variable '{{name}}' is assigned but never used.
|
|
83
|
+
unusedVariable: "Variable '{{name}}' is assigned but never used.",
|
|
85
84
|
},
|
|
86
85
|
},
|
|
87
86
|
create(context) {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview Rule to disallow piping from a single-file `cat`.
|
|
3
|
-
* Mirrors ShellCheck SC2002.
|
|
4
3
|
*/
|
|
5
4
|
//------------------------------------------------------------------------------
|
|
6
5
|
// Imports
|
|
@@ -42,7 +41,7 @@ const rule = {
|
|
|
42
41
|
},
|
|
43
42
|
schema: [],
|
|
44
43
|
messages: {
|
|
45
|
-
uselessCat: "Useless cat. Consider 'cmd < file' or 'cmd file' instead.
|
|
44
|
+
uselessCat: "Useless cat. Consider 'cmd < file' or 'cmd file' instead.",
|
|
46
45
|
},
|
|
47
46
|
},
|
|
48
47
|
create(context) {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview Rule to disallow `$(echo ...)` command substitutions.
|
|
3
|
-
* Mirrors ShellCheck SC2116.
|
|
4
3
|
*/
|
|
5
4
|
//------------------------------------------------------------------------------
|
|
6
5
|
// Imports
|
|
@@ -19,7 +18,7 @@ const rule = {
|
|
|
19
18
|
},
|
|
20
19
|
schema: [],
|
|
21
20
|
messages: {
|
|
22
|
-
uselessEcho: "Useless echo? Instead of 'cmd $(echo foo)', just use 'cmd foo'.
|
|
21
|
+
uselessEcho: "Useless echo? Instead of 'cmd $(echo foo)', just use 'cmd foo'.",
|
|
23
22
|
},
|
|
24
23
|
},
|
|
25
24
|
create(context) {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview Rule to disallow variables in the printf format string.
|
|
3
|
-
* Mirrors ShellCheck SC2059.
|
|
4
3
|
*/
|
|
5
4
|
//------------------------------------------------------------------------------
|
|
6
5
|
// Imports
|
|
@@ -19,7 +18,7 @@ const rule = {
|
|
|
19
18
|
},
|
|
20
19
|
schema: [],
|
|
21
20
|
messages: {
|
|
22
|
-
variableInFormat: "Don't use variables in the printf format string. Use printf '...%s...' \"$foo\".
|
|
21
|
+
variableInFormat: "Don't use variables in the printf format string. Use printf '...%s...' \"$foo\".",
|
|
23
22
|
},
|
|
24
23
|
},
|
|
25
24
|
create(context) {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview Rule to require handling `cd` failure.
|
|
3
|
-
* Mirrors ShellCheck SC2164.
|
|
4
3
|
*/
|
|
5
4
|
//------------------------------------------------------------------------------
|
|
6
5
|
// Imports
|
|
@@ -20,7 +19,7 @@ const rule = {
|
|
|
20
19
|
hasSuggestions: true,
|
|
21
20
|
schema: [],
|
|
22
21
|
messages: {
|
|
23
|
-
uncheckedCd: "Use 'cd ... || exit' or 'cd ... || return' in case cd fails.
|
|
22
|
+
uncheckedCd: "Use 'cd ... || exit' or 'cd ... || return' in case cd fails.",
|
|
24
23
|
addGuard: "Add '|| exit' after the cd command.",
|
|
25
24
|
},
|
|
26
25
|
},
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview Rule to require the `-r` flag when using `read`.
|
|
3
|
-
* Mirrors ShellCheck SC2162.
|
|
4
3
|
*/
|
|
5
4
|
//------------------------------------------------------------------------------
|
|
6
5
|
// Imports
|
|
@@ -24,7 +23,7 @@ const rule = {
|
|
|
24
23
|
fixable: "code",
|
|
25
24
|
schema: [],
|
|
26
25
|
messages: {
|
|
27
|
-
missingR: "read without -r will mangle backslashes.
|
|
26
|
+
missingR: "Using read without -r will mangle backslashes.",
|
|
28
27
|
},
|
|
29
28
|
},
|
|
30
29
|
create(context) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint/shell",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Shell language plugin for ESLint",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -66,6 +66,7 @@
|
|
|
66
66
|
"@types/node": "~20.19.0",
|
|
67
67
|
"@vitest/coverage-v8": "^4.1.10",
|
|
68
68
|
"eslint": "^10.8.1",
|
|
69
|
+
"eslint-plugin-eslint-plugin": "^7.6.2",
|
|
69
70
|
"lint-staged": "^16.4.0",
|
|
70
71
|
"prettier": "^3.9.6",
|
|
71
72
|
"typescript": "^6.0.3",
|