@eslint-sh/eslint-plugin 0.8.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +58 -57
- package/dist/api.d.ts +92 -0
- package/dist/api.js +83 -0
- package/dist/command-harvest/builtins/bats.d.ts +1 -1
- package/dist/command-harvest/harvest-commands.d.ts +18 -7
- package/dist/command-harvest/harvest-commands.js +11 -10
- package/dist/command-harvest/wrapper-table.d.ts +1 -1
- package/dist/command-harvest/wrapper-table.js +1 -1
- package/dist/configs/posix-portable.d.ts +6 -10
- package/dist/configs/posix-portable.js +4 -6
- package/dist/configuration-message.d.ts +14 -0
- package/dist/configuration-message.js +33 -0
- package/dist/declaration-conventions/get-declared-commands.d.ts +41 -0
- package/dist/declaration-conventions/{read-declared-commands.js → get-declared-commands.js} +43 -43
- package/dist/eslint-plugin-api.d.ts +1516 -0
- package/dist/eslint-plugin.d.ts +16 -1560
- package/dist/index.d.ts +14 -81
- package/dist/index.js +22 -76
- package/dist/language/command-resolution.d.ts +47 -13
- package/dist/language/command-resolution.js +48 -18
- package/dist/language/selector-classes.d.ts +7 -3
- package/dist/language/selector-classes.js +13 -4
- package/dist/language/shell-language-options.d.ts +3 -3
- package/dist/language/shell-language-options.js +12 -17
- package/dist/language/shell-language.d.ts +3 -1
- package/dist/language/shell-language.js +6 -11
- package/dist/language/shell-source-code.d.ts +77 -77
- package/dist/language/shell-source-code.js +107 -98
- package/dist/language/source-coordinates.d.ts +2 -0
- package/dist/language/source-coordinates.js +8 -4
- package/dist/language/syntax-view.d.ts +1 -1
- package/dist/language/syntax-view.js +19 -7
- package/dist/language/word-resolution.d.ts +4 -3
- package/dist/language/word-resolution.js +10 -5
- package/dist/rules/compat/declaration-options.js +2 -2
- package/dist/rules/compat/no-brace-sequence-padding-step.js +1 -1
- package/dist/rules/compat/no-mapfile.js +2 -2
- package/dist/rules/compat/no-negative-array-index.js +2 -2
- package/dist/rules/compat/no-printf-time-format.js +2 -2
- package/dist/rules/compat/no-test-v.js +2 -2
- package/dist/rules/compat/no-wait-n.js +2 -2
- package/dist/rules/compat/posix-absent-command.js +2 -2
- package/dist/rules/compat/shopt-options.js +2 -2
- package/dist/rules/create-wrapper-rule.d.ts +4 -4
- package/dist/rules/create-wrapper-rule.js +19 -13
- package/dist/rules/define-shell-rule.js +1 -1
- package/dist/rules/no-dynamic-invocation.d.ts +1 -1
- package/dist/rules/no-dynamic-invocation.js +12 -4
- package/dist/rules/no-eval.js +6 -2
- package/dist/rules/no-masked-exit-status.d.ts +4 -3
- package/dist/rules/no-masked-exit-status.js +4 -3
- package/dist/rules/no-secret-env-reads.d.ts +2 -0
- package/dist/rules/no-secret-env-reads.js +14 -3
- package/dist/rules/no-secret-flags.d.ts +2 -0
- package/dist/rules/no-secret-flags.js +14 -3
- package/dist/rules/no-unchecked-cd.js +4 -3
- package/dist/rules/no-undeclared-commands.js +10 -4
- package/dist/rules/no-unused-declarations.js +13 -4
- package/dist/rules/prefer-local.d.ts +3 -2
- package/dist/rules/prefer-local.js +4 -2
- package/dist/rules/quote-expansions.js +1 -1
- package/dist/rules/require-network-wrapper.d.ts +2 -2
- package/dist/rules/require-network-wrapper.js +21 -11
- package/dist/rules/require-strict-mode.d.ts +5 -46
- package/dist/rules/require-strict-mode.js +17 -107
- package/dist/rules/require-tty-guard.d.ts +2 -0
- package/dist/rules/require-tty-guard.js +9 -2
- package/dist/rules/resolve-declaration-convention.d.ts +9 -88
- package/dist/rules/resolve-declaration-convention.js +19 -71
- package/dist/rules/resolve-network-wrapper.d.ts +3 -4
- package/dist/rules/resolve-network-wrapper.js +23 -19
- package/dist/rules/resolve-transparent-wrappers.d.ts +3 -8
- package/dist/rules/resolve-transparent-wrappers.js +21 -11
- package/dist/rules/set-options.d.ts +1 -1
- package/dist/rules/set-options.js +1 -1
- package/dist/rules/strict-mode-prologue.d.ts +43 -0
- package/dist/rules/strict-mode-prologue.js +91 -0
- package/dist/rules/transparent-wrappers.d.ts +3 -3
- package/dist/rules/transparent-wrappers.js +1 -1
- package/dist/rules/user-pattern.d.ts +4 -3
- package/dist/rules/user-pattern.js +10 -8
- package/dist/shell-dialect.d.ts +8 -0
- package/dist/shell-dialect.js +22 -0
- package/dist/version.js +2 -1
- package/docs/compat.md +5 -6
- package/docs/custom-rule-tutorial.md +55 -51
- package/docs/declaration-conventions.md +20 -23
- package/docs/error-codes.md +94 -0
- package/docs/examples/no-backticks-rule.mjs +1 -1
- package/docs/examples/no-curl-in-functions-rule.mjs +2 -2
- package/docs/examples/no-listed-commands-rule.ts +1 -1
- package/docs/examples/no-rm-rf-rule.mjs +8 -10
- package/docs/examples/sorted-declarations-rule.mjs +6 -9
- package/docs/examples/tsconfig.json +10 -0
- package/docs/rules/README.md +12 -4
- package/docs/rules/compat/no-nounset-empty-array.md +1 -1
- package/docs/rules/no-dynamic-invocation.md +5 -0
- package/docs/rules/no-masked-exit-status.md +2 -2
- package/docs/rules/no-secret-env-reads.md +13 -3
- package/docs/rules/no-secret-flags.md +14 -5
- package/docs/rules/no-unchecked-cd.md +15 -2
- package/docs/rules/no-undeclared-commands.md +4 -0
- package/docs/rules/no-unused-declarations.md +4 -0
- package/docs/rules/require-network-wrapper.md +6 -6
- package/docs/rules/require-strict-mode.md +25 -23
- package/docs/rules/require-tty-guard.md +12 -3
- package/docs/selectors.md +7 -2
- package/docs/wrapper-rules.md +3 -1
- package/package.json +9 -20
- package/dist/declaration-conventions/read-declared-commands.d.ts +0 -70
- package/dist/eslint-plugin-syntax-analyze.d.ts +0 -23
- package/dist/eslint-plugin-syntax.d.ts +0 -31
- package/dist/syntax/analyze.d.ts +0 -19
- package/dist/syntax/analyze.js +0 -21
- package/dist/syntax/index.d.ts +0 -27
- package/dist/syntax/index.js +0 -29
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
* `-t`, which keeps each newline) and POSIX files, which have no arrays at
|
|
28
28
|
* all, get the report without a suggestion.
|
|
29
29
|
*/
|
|
30
|
-
import { DEFAULT_TRANSPARENT_WRAPPERS } from 'sh-
|
|
30
|
+
import { DEFAULT_TRANSPARENT_WRAPPERS } from 'sh-analysis';
|
|
31
31
|
import { resolveTransparentWrappers } from '../resolve-transparent-wrappers.js';
|
|
32
32
|
import { BUILTIN_WRAPPER } from '../transparent-wrappers.js';
|
|
33
33
|
import { createCompatRule } from './create-compat-rule.js';
|
|
@@ -39,7 +39,7 @@ const DEFAULT_ARRAY = 'MAPFILE';
|
|
|
39
39
|
const IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_]*$/u;
|
|
40
40
|
/**
|
|
41
41
|
* The wrappers followed to find the command an invocation runs:
|
|
42
|
-
* `sh-
|
|
42
|
+
* `sh-analysis`'s defaults (which include `command`) plus Bash's
|
|
43
43
|
* `builtin`.
|
|
44
44
|
*/
|
|
45
45
|
const TRANSPARENT_WRAPPERS = [
|
|
@@ -28,14 +28,14 @@
|
|
|
28
28
|
* ordinary word; option words (`-v`) never match an element name.
|
|
29
29
|
*/
|
|
30
30
|
import { Minus } from 'sh-ast';
|
|
31
|
-
import { DEFAULT_TRANSPARENT_WRAPPERS } from 'sh-
|
|
31
|
+
import { DEFAULT_TRANSPARENT_WRAPPERS } from 'sh-analysis';
|
|
32
32
|
import { resolveTransparentWrappers } from '../resolve-transparent-wrappers.js';
|
|
33
33
|
import { BUILTIN_WRAPPER } from '../transparent-wrappers.js';
|
|
34
34
|
import { createCompatRule } from './create-compat-rule.js';
|
|
35
35
|
/** A bare negative-subscript read, the only shape the suggestion rewrites. */
|
|
36
36
|
const BARE_READ = /^\$\{([A-Za-z_][A-Za-z0-9_]*)\[\s*-\s*(\d+)\s*\]\}$/u;
|
|
37
37
|
/**
|
|
38
|
-
* The wrappers followed to find an `unset` command: `sh-
|
|
38
|
+
* The wrappers followed to find an `unset` command: `sh-analysis`'s
|
|
39
39
|
* defaults (which include `command`) plus Bash's `builtin`.
|
|
40
40
|
*/
|
|
41
41
|
const TRANSPARENT_WRAPPERS = [
|
|
@@ -15,12 +15,12 @@
|
|
|
15
15
|
* static cannot be read, and is not reported. The report is on the format
|
|
16
16
|
* word.
|
|
17
17
|
*/
|
|
18
|
-
import { DEFAULT_TRANSPARENT_WRAPPERS } from 'sh-
|
|
18
|
+
import { DEFAULT_TRANSPARENT_WRAPPERS } from 'sh-analysis';
|
|
19
19
|
import { resolveTransparentWrappers } from '../resolve-transparent-wrappers.js';
|
|
20
20
|
import { BUILTIN_WRAPPER } from '../transparent-wrappers.js';
|
|
21
21
|
import { createCompatRule } from './create-compat-rule.js';
|
|
22
22
|
/**
|
|
23
|
-
* The wrappers followed to find the `printf` command: `sh-
|
|
23
|
+
* The wrappers followed to find the `printf` command: `sh-analysis`'s
|
|
24
24
|
* defaults (which include `command`) plus Bash's `builtin`.
|
|
25
25
|
*/
|
|
26
26
|
const TRANSPARENT_WRAPPERS = [
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
* The report is on the `[[` test, or on the `-v` word.
|
|
27
27
|
*/
|
|
28
28
|
import { TsVarSet } from 'sh-ast';
|
|
29
|
-
import { DEFAULT_TRANSPARENT_WRAPPERS } from 'sh-
|
|
29
|
+
import { DEFAULT_TRANSPARENT_WRAPPERS } from 'sh-analysis';
|
|
30
30
|
import { resolveTransparentWrappers } from '../resolve-transparent-wrappers.js';
|
|
31
31
|
import { BUILTIN_WRAPPER } from '../transparent-wrappers.js';
|
|
32
32
|
import { createCompatRule } from './create-compat-rule.js';
|
|
33
33
|
/**
|
|
34
|
-
* The wrappers followed to find the `test` command: `sh-
|
|
34
|
+
* The wrappers followed to find the `test` command: `sh-analysis`'s
|
|
35
35
|
* defaults (which include `command`) plus Bash's `builtin`.
|
|
36
36
|
*/
|
|
37
37
|
const TRANSPARENT_WRAPPERS = [
|
|
@@ -15,12 +15,12 @@
|
|
|
15
15
|
* (Bash 5.1's `wait -p var`) is its operand, not an option. The report is on
|
|
16
16
|
* the option word.
|
|
17
17
|
*/
|
|
18
|
-
import { DEFAULT_TRANSPARENT_WRAPPERS } from 'sh-
|
|
18
|
+
import { DEFAULT_TRANSPARENT_WRAPPERS } from 'sh-analysis';
|
|
19
19
|
import { resolveTransparentWrappers } from '../resolve-transparent-wrappers.js';
|
|
20
20
|
import { BUILTIN_WRAPPER } from '../transparent-wrappers.js';
|
|
21
21
|
import { createCompatRule } from './create-compat-rule.js';
|
|
22
22
|
/**
|
|
23
|
-
* The wrappers followed to find the `wait` command: `sh-
|
|
23
|
+
* The wrappers followed to find the `wait` command: `sh-analysis`'s
|
|
24
24
|
* defaults (which include `command`) plus Bash's `builtin`.
|
|
25
25
|
*/
|
|
26
26
|
const TRANSPARENT_WRAPPERS = [
|
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
* directly. Anything else, including a version captured in another variable,
|
|
23
23
|
* reports.
|
|
24
24
|
*/
|
|
25
|
-
import { DEFAULT_TRANSPARENT_WRAPPERS } from 'sh-
|
|
25
|
+
import { DEFAULT_TRANSPARENT_WRAPPERS } from 'sh-analysis';
|
|
26
26
|
import { resolveTransparentWrappers } from '../resolve-transparent-wrappers.js';
|
|
27
27
|
import { BUILTIN_WRAPPER } from '../transparent-wrappers.js';
|
|
28
28
|
/**
|
|
29
29
|
* The wrappers followed to find the command an invocation runs:
|
|
30
|
-
* `sh-
|
|
30
|
+
* `sh-analysis`'s defaults (which include `command`) plus Bash's `builtin`.
|
|
31
31
|
*/
|
|
32
32
|
const TRANSPARENT_WRAPPERS = [
|
|
33
33
|
...DEFAULT_TRANSPARENT_WRAPPERS,
|
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
* `-s`), `shopt -o` names `set -o` options, and an operand that is not a
|
|
10
10
|
* static word cannot be read, so none of those count.
|
|
11
11
|
*/
|
|
12
|
-
import { DEFAULT_TRANSPARENT_WRAPPERS } from 'sh-
|
|
12
|
+
import { DEFAULT_TRANSPARENT_WRAPPERS } from 'sh-analysis';
|
|
13
13
|
import { resolveTransparentWrappers } from '../resolve-transparent-wrappers.js';
|
|
14
14
|
import { BUILTIN_WRAPPER } from '../transparent-wrappers.js';
|
|
15
15
|
/**
|
|
16
|
-
* The wrappers followed to find the `shopt` command: `sh-
|
|
16
|
+
* The wrappers followed to find the `shopt` command: `sh-analysis`'s
|
|
17
17
|
* defaults (which include `command`) plus Bash's `builtin`.
|
|
18
18
|
*/
|
|
19
19
|
const TRANSPARENT_WRAPPERS = [
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { WrapperSpec } from 'sh-
|
|
1
|
+
import type { WrapperSpec } from 'sh-analysis';
|
|
2
2
|
import type { ShellRule } from './define-shell-rule.js';
|
|
3
3
|
/**
|
|
4
4
|
* Restricts a listed command to some of its subcommands, for commands such as
|
|
@@ -73,7 +73,7 @@ export interface WrapperRuleConfig {
|
|
|
73
73
|
/**
|
|
74
74
|
* The wrapper the commands must be run through. A string names a wrapper
|
|
75
75
|
* that takes no options of its own (`retry curl x`), unless it names one of
|
|
76
|
-
* `sh-
|
|
76
|
+
* `sh-analysis`'s default transparent wrappers (`timeout`, `nice`, …),
|
|
77
77
|
* whose known option shape is used. A `WrapperSpec` declares the wrapper's
|
|
78
78
|
* option shape, so that `retry -n 3 curl x` is recognized as `curl` run
|
|
79
79
|
* through `retry`; any of its `names` counts as the wrapper. Like
|
|
@@ -147,7 +147,7 @@ export declare function buildWrapperRule<RuleOptions extends unknown[] = []>(con
|
|
|
147
147
|
* naming the command and the wrapper. Its `meta.docs.url` and
|
|
148
148
|
* `meta.docs.description` default to this package's wrapper-rules page and a
|
|
149
149
|
* sentence naming the policy; `config.docs` overrides either. A listed
|
|
150
|
-
* command is wrapped when the wrapper encloses it in `sh-
|
|
150
|
+
* command is wrapped when the wrapper encloses it in `sh-analysis`'s
|
|
151
151
|
* transparent-wrapper chain, so `audit-run sudo kubectl apply` is wrapped.
|
|
152
152
|
* Command and wrapper words written as paths match by basename
|
|
153
153
|
* (`/usr/bin/kubectl`). Commands inside `$(…)`, functions, and pipelines are
|
|
@@ -157,7 +157,7 @@ export declare function buildWrapperRule<RuleOptions extends unknown[] = []>(con
|
|
|
157
157
|
* subcommand restrictions, and optional `meta.docs` overrides.
|
|
158
158
|
* @returns A {@link ShellRule}: an ESLint rule for the `sh/sh` language,
|
|
159
159
|
* typed so a pack's own declarations need no `@eslint/core` import to name it.
|
|
160
|
-
* @throws TypeError when `config` is malformed (no `commands` array, an empty
|
|
160
|
+
* @throws TypeError with `ESLINT_SH_WRAPPER_CONFIG` when `config` is malformed (no `commands` array, an empty
|
|
161
161
|
* wrapper name, a subcommand restriction without `names`, or an empty or
|
|
162
162
|
* non-string `docs.url` / `docs.description`).
|
|
163
163
|
*
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* `sh/require-network-wrapper` is the built-in instance whose wrapper comes
|
|
10
10
|
* from the user's rule options.
|
|
11
11
|
*
|
|
12
|
-
* "Run through" is decided from `sh-
|
|
12
|
+
* "Run through" is decided from `sh-analysis`'s transparent-wrapper
|
|
13
13
|
* resolution, never by reading words locally: each command site's argv0 is
|
|
14
14
|
* followed through the default wrapper table (`sudo`, `env`, `nohup`, …), the
|
|
15
15
|
* bound wrapper, and any command with modeled subcommands, and the resulting
|
|
@@ -35,8 +35,13 @@
|
|
|
35
35
|
* listed command does not report, and neither does a subcommand that is not
|
|
36
36
|
* static. Commands inside command strings (`bash -c '…'`) are not commands to
|
|
37
37
|
* this analysis and are out of scope.
|
|
38
|
+
*
|
|
39
|
+
* This policy checks represented, statically identified commands. Opaque executable
|
|
40
|
+
* syntax is outside that named-command scope; no-dynamic-invocation reports those
|
|
41
|
+
* inventory limits when a project requires execution completeness.
|
|
38
42
|
*/
|
|
39
|
-
import {
|
|
43
|
+
import { configurationMessage } from '../configuration-message.js';
|
|
44
|
+
import { DEFAULT_TRANSPARENT_WRAPPERS } from 'sh-analysis';
|
|
40
45
|
import { resolveTransparentWrappers } from './resolve-transparent-wrappers.js';
|
|
41
46
|
import { definedFunctionNames } from '../command-harvest/harvest-commands.js';
|
|
42
47
|
import { createRule, packageDocsUrl } from './create-rule.js';
|
|
@@ -91,14 +96,15 @@ function isStringArray(value) {
|
|
|
91
96
|
* offending field, so a malformed binding fails when a rule pack is loaded
|
|
92
97
|
* rather than in the middle of linting a file.
|
|
93
98
|
*/
|
|
99
|
+
// ESLINT_SH_WRAPPER_CONFIG rejects factory bindings before any rule state is created.
|
|
94
100
|
function compileWrapperRule(config) {
|
|
95
101
|
const { commands, wrapper, subcommands = {}, localInvocations = {}, docs = {}, } = config;
|
|
96
102
|
if (!isStringArray(commands)) {
|
|
97
|
-
throw new TypeError('createWrapperRule
|
|
103
|
+
throw Object.assign(new TypeError(configurationMessage('createWrapperRule config.commands', 'must be an array of non-empty strings', commands)), { code: 'ESLINT_SH_WRAPPER_CONFIG' });
|
|
98
104
|
}
|
|
99
105
|
for (const field of ['url', 'description']) {
|
|
100
106
|
if (docs[field] !== undefined && !isNonEmptyString(docs[field])) {
|
|
101
|
-
throw new TypeError(`createWrapperRule
|
|
107
|
+
throw Object.assign(new TypeError(configurationMessage(`createWrapperRule config.docs.${field}`, 'must be a non-empty string', docs[field])), { code: 'ESLINT_SH_WRAPPER_CONFIG' });
|
|
102
108
|
}
|
|
103
109
|
}
|
|
104
110
|
let wrapperSpec;
|
|
@@ -113,13 +119,13 @@ function compileWrapperRule(config) {
|
|
|
113
119
|
wrapperSpec = wrapper;
|
|
114
120
|
}
|
|
115
121
|
else {
|
|
116
|
-
throw new TypeError('createWrapperRule
|
|
122
|
+
throw Object.assign(new TypeError(configurationMessage('createWrapperRule config.wrapper', 'must be a non-empty string or a WrapperSpec with non-empty `names`', wrapper)), { code: 'ESLINT_SH_WRAPPER_CONFIG' });
|
|
117
123
|
}
|
|
118
124
|
const subcommandSpecs = [];
|
|
119
125
|
const subcommandNames = new Map();
|
|
120
126
|
for (const [command, restriction] of Object.entries(subcommands)) {
|
|
121
127
|
if (!isStringArray(restriction.names) || restriction.names.length === 0) {
|
|
122
|
-
throw new TypeError(`createWrapperRule
|
|
128
|
+
throw Object.assign(new TypeError(configurationMessage(`createWrapperRule config.subcommands.${command}.names`, 'must be a non-empty array of non-empty strings', restriction.names)), { code: 'ESLINT_SH_WRAPPER_CONFIG' });
|
|
123
129
|
}
|
|
124
130
|
subcommandNames.set(command, new Set(restriction.names));
|
|
125
131
|
// Modeling the command as a transparent wrapper makes `resolveArgv0`
|
|
@@ -135,18 +141,18 @@ function compileWrapperRule(config) {
|
|
|
135
141
|
for (const [label, local] of Object.entries(localInvocations)) {
|
|
136
142
|
const where = `localInvocations.${label}`;
|
|
137
143
|
if (!isRecord(local)) {
|
|
138
|
-
throw new TypeError(`createWrapperRule
|
|
144
|
+
throw Object.assign(new TypeError(configurationMessage(`createWrapperRule config.${where}`, 'must be an object', local)), { code: 'ESLINT_SH_WRAPPER_CONFIG' });
|
|
139
145
|
}
|
|
140
146
|
const { argLists, localOperand } = local;
|
|
141
147
|
if (argLists !== undefined &&
|
|
142
148
|
!(Array.isArray(argLists) &&
|
|
143
149
|
argLists.every((list) => Array.isArray(list) && isStringArray(list)))) {
|
|
144
|
-
throw new TypeError(`createWrapperRule
|
|
150
|
+
throw Object.assign(new TypeError(configurationMessage(`createWrapperRule config.${where}.argLists`, 'must be an array of arrays of non-empty strings', argLists)), { code: 'ESLINT_SH_WRAPPER_CONFIG' });
|
|
145
151
|
}
|
|
146
152
|
if (localOperand === undefined)
|
|
147
153
|
continue;
|
|
148
154
|
if (!isRecord(localOperand)) {
|
|
149
|
-
throw new TypeError(`createWrapperRule
|
|
155
|
+
throw Object.assign(new TypeError(configurationMessage(`createWrapperRule config.${where}.localOperand`, 'must be an object', localOperand)), { code: 'ESLINT_SH_WRAPPER_CONFIG' });
|
|
150
156
|
}
|
|
151
157
|
for (const field of ['localPrefixes', 'noArgFlags', 'argFlags']) {
|
|
152
158
|
const value = localOperand[field];
|
|
@@ -154,7 +160,7 @@ function compileWrapperRule(config) {
|
|
|
154
160
|
? isStringArray(value)
|
|
155
161
|
: value === undefined || isStringArray(value);
|
|
156
162
|
if (!valid) {
|
|
157
|
-
throw new TypeError(`createWrapperRule
|
|
163
|
+
throw Object.assign(new TypeError(configurationMessage(`createWrapperRule config.${where}.localOperand.${field}`, 'must be an array of non-empty strings', value)), { code: 'ESLINT_SH_WRAPPER_CONFIG' });
|
|
158
164
|
}
|
|
159
165
|
}
|
|
160
166
|
}
|
|
@@ -220,7 +226,7 @@ function wrapperRuleListeners(compiled, context) {
|
|
|
220
226
|
return {
|
|
221
227
|
File() {
|
|
222
228
|
let functions;
|
|
223
|
-
for (const site of sourceCode.
|
|
229
|
+
for (const site of sourceCode.getCommandInventory().commands) {
|
|
224
230
|
const resolution = resolveChain(compiled, site);
|
|
225
231
|
const finding = findListedCommand(compiled, resolution.chain);
|
|
226
232
|
if (finding === null || finding.wrapped)
|
|
@@ -391,7 +397,7 @@ export function buildWrapperRule(config) {
|
|
|
391
397
|
* naming the command and the wrapper. Its `meta.docs.url` and
|
|
392
398
|
* `meta.docs.description` default to this package's wrapper-rules page and a
|
|
393
399
|
* sentence naming the policy; `config.docs` overrides either. A listed
|
|
394
|
-
* command is wrapped when the wrapper encloses it in `sh-
|
|
400
|
+
* command is wrapped when the wrapper encloses it in `sh-analysis`'s
|
|
395
401
|
* transparent-wrapper chain, so `audit-run sudo kubectl apply` is wrapped.
|
|
396
402
|
* Command and wrapper words written as paths match by basename
|
|
397
403
|
* (`/usr/bin/kubectl`). Commands inside `$(…)`, functions, and pipelines are
|
|
@@ -401,7 +407,7 @@ export function buildWrapperRule(config) {
|
|
|
401
407
|
* subcommand restrictions, and optional `meta.docs` overrides.
|
|
402
408
|
* @returns A {@link ShellRule}: an ESLint rule for the `sh/sh` language,
|
|
403
409
|
* typed so a pack's own declarations need no `@eslint/core` import to name it.
|
|
404
|
-
* @throws TypeError when `config` is malformed (no `commands` array, an empty
|
|
410
|
+
* @throws TypeError with `ESLINT_SH_WRAPPER_CONFIG` when `config` is malformed (no `commands` array, an empty
|
|
405
411
|
* wrapper name, a subcommand restriction without `names`, or an empty or
|
|
406
412
|
* non-string `docs.url` / `docs.description`).
|
|
407
413
|
*
|
|
@@ -43,7 +43,7 @@ export function defineShellRule(spec) {
|
|
|
43
43
|
// The type requires `meta`, but ESLint accepts a rule without one, so an
|
|
44
44
|
// untyped (JavaScript) caller's missing `meta` is read as empty rather than
|
|
45
45
|
// crashing. The types cannot see that caller, hence the suppression.
|
|
46
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- Untyped JavaScript callers may omit the required metadata.
|
|
47
47
|
const meta = spec.meta ?? {};
|
|
48
48
|
// Drop the deprecated singular key an untyped caller may have supplied, so
|
|
49
49
|
// the only language declaration ESLint sees is the one set here.
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*
|
|
12
12
|
* The rule asks, never decides:
|
|
13
13
|
*
|
|
14
|
-
* -
|
|
14
|
+
* - Represented commands come from `ShellSourceCode.getCommandInventory().commands`,
|
|
15
15
|
* so commands nested in command substitutions, process substitutions,
|
|
16
16
|
* pipelines and function bodies are all checked, each once.
|
|
17
17
|
* - Which command each one runs comes from `resolveInvokedCommand`, which
|
|
@@ -20,7 +20,9 @@
|
|
|
20
20
|
* reports. `'embedded-command'` reports as `embeddedCommand`; every other
|
|
21
21
|
* reason (an expansion, a glob, a tilde, an unrecognized wrapper flag, …)
|
|
22
22
|
* reports as `dynamicInvocation`.
|
|
23
|
-
* -
|
|
23
|
+
* - Opaque executable syntax reports independently at the original construct.
|
|
24
|
+
* Dispatcher exemptions permit computed argv words, never embedded opaque code.
|
|
25
|
+
* - The wrappers followed are `sh-analysis`'s defaults, Bash's `builtin`,
|
|
24
26
|
* shells invoked as commands (so `bash -c` is an embedded command and
|
|
25
27
|
* `bash script.sh` runs `script.sh`), and the shared project wrapper facts.
|
|
26
28
|
*
|
|
@@ -30,7 +32,7 @@
|
|
|
30
32
|
* command word. The rule offers no fix and no suggestion; choosing the
|
|
31
33
|
* command is a human decision.
|
|
32
34
|
*/
|
|
33
|
-
import { DEFAULT_TRANSPARENT_WRAPPERS } from 'sh-
|
|
35
|
+
import { DEFAULT_TRANSPARENT_WRAPPERS } from 'sh-analysis';
|
|
34
36
|
import { resolveTransparentWrappers } from './resolve-transparent-wrappers.js';
|
|
35
37
|
import { createRule } from './create-rule.js';
|
|
36
38
|
import { BUILTIN_WRAPPER, SHELL_WRAPPER } from './transparent-wrappers.js';
|
|
@@ -80,6 +82,7 @@ export const noDynamicInvocation = createRule({
|
|
|
80
82
|
],
|
|
81
83
|
defaultOptions: [{ allowInFunctions: [] }],
|
|
82
84
|
messages: {
|
|
85
|
+
opaqueExecutable: 'This syntax contains opaque executable text, so its commands cannot be statically reviewed. Write the commands directly instead.',
|
|
83
86
|
dynamicInvocation: 'The command this runs is not known until run time, so the script cannot be statically reviewed. Name the command with a literal word instead.',
|
|
84
87
|
embeddedCommand: 'This runs shell code embedded in a string, which cannot be statically reviewed. Write the commands directly instead.',
|
|
85
88
|
},
|
|
@@ -92,7 +95,12 @@ export const noDynamicInvocation = createRule({
|
|
|
92
95
|
const transparentWrappers = resolveTransparentWrappers(context, BUILT_IN_WRAPPERS);
|
|
93
96
|
return {
|
|
94
97
|
File() {
|
|
95
|
-
|
|
98
|
+
const inventory = sourceCode.getCommandInventory();
|
|
99
|
+
// Dispatcher exemptions cover computed argv words, never opaque embedded code.
|
|
100
|
+
for (const uncertainty of inventory.uncertainties) {
|
|
101
|
+
context.report({ node: uncertainty.node, messageId: 'opaqueExecutable' });
|
|
102
|
+
}
|
|
103
|
+
for (const site of inventory.commands) {
|
|
96
104
|
const { effective } = site.resolveInvokedCommand({ transparentWrappers });
|
|
97
105
|
if (effective.static)
|
|
98
106
|
continue;
|
package/dist/rules/no-eval.js
CHANGED
|
@@ -23,8 +23,12 @@
|
|
|
23
23
|
* (`$cmd args`) and embedded command strings (`bash -c "$x"`) belong to
|
|
24
24
|
* `no-dynamic-invocation`. The rule has no options and offers no fix or
|
|
25
25
|
* suggestion, because no mechanical rewrite of `eval` preserves behavior.
|
|
26
|
+
*
|
|
27
|
+
* This policy checks represented, statically identified commands. Opaque executable
|
|
28
|
+
* syntax is outside that named-command scope; no-dynamic-invocation reports those
|
|
29
|
+
* inventory limits when a project requires execution completeness.
|
|
26
30
|
*/
|
|
27
|
-
import { DEFAULT_TRANSPARENT_WRAPPERS } from 'sh-
|
|
31
|
+
import { DEFAULT_TRANSPARENT_WRAPPERS } from 'sh-analysis';
|
|
28
32
|
import { resolveTransparentWrappers } from './resolve-transparent-wrappers.js';
|
|
29
33
|
import { createRule } from './create-rule.js';
|
|
30
34
|
import { BUILTIN_WRAPPER } from './transparent-wrappers.js';
|
|
@@ -32,7 +36,7 @@ import { BUILTIN_WRAPPER } from './transparent-wrappers.js';
|
|
|
32
36
|
const RULE_NAME = 'no-eval';
|
|
33
37
|
/**
|
|
34
38
|
* The wrappers followed to find the command an invocation actually runs:
|
|
35
|
-
* `sh-
|
|
39
|
+
* `sh-analysis`'s defaults (`command`, `exec`, `env`, `sudo`, …) plus
|
|
36
40
|
* Bash's `builtin`, so `builtin eval …` is recognized as `eval`.
|
|
37
41
|
*/
|
|
38
42
|
const TRANSPARENT_WRAPPERS = [
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @internal
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
interface NoMaskedExitStatusOptions {
|
|
7
7
|
/** Report only where `errexit` is known to be on. Defaults to `false`. */
|
|
8
8
|
readonly onlyWithErrexit?: boolean;
|
|
9
9
|
/**
|
|
@@ -16,6 +16,7 @@ export interface NoMaskedExitStatusOptions {
|
|
|
16
16
|
readonly builtins?: readonly string[];
|
|
17
17
|
}
|
|
18
18
|
/** Message ids this rule reports with. @internal */
|
|
19
|
-
|
|
19
|
+
type NoMaskedExitStatusMessageId = 'maskedExitStatus' | 'declareThenAssign' | 'assignThenExport' | 'assignThenReadonly';
|
|
20
20
|
/** Built-in rule `sh/no-masked-exit-status`. @internal */
|
|
21
|
-
|
|
21
|
+
declare const noMaskedExitStatus: import("./define-shell-rule.js").ShellRule<[NoMaskedExitStatusOptions], NoMaskedExitStatusMessageId>;
|
|
22
|
+
export { noMaskedExitStatus };
|
|
@@ -84,13 +84,13 @@
|
|
|
84
84
|
* `-r` (and `readonly` itself) forbids a later assignment, so those forms are
|
|
85
85
|
* split into the declaration, the assignment, then `readonly <names>`.
|
|
86
86
|
*/
|
|
87
|
-
import { DEFAULT_TRANSPARENT_WRAPPERS } from 'sh-
|
|
87
|
+
import { DEFAULT_TRANSPARENT_WRAPPERS } from 'sh-analysis';
|
|
88
88
|
import { resolveTransparentWrappers } from './resolve-transparent-wrappers.js';
|
|
89
89
|
import { childNodes } from '../language/syntax-view.js';
|
|
90
90
|
import { lineBreakOf } from '../language/line-breaks.js';
|
|
91
91
|
import { createRule } from './create-rule.js';
|
|
92
92
|
import { batsErrexitIsOn, isStatusChecked } from './no-unchecked-cd.js';
|
|
93
|
-
import { setStatementChanges } from './
|
|
93
|
+
import { setStatementChanges } from './strict-mode-prologue.js';
|
|
94
94
|
import { applySetOptionChanges, shebangOptionChanges } from './set-options.js';
|
|
95
95
|
import { BUILTIN_WRAPPER } from './transparent-wrappers.js';
|
|
96
96
|
/** Every declaration builtin the rule can check; the default for `builtins`. */
|
|
@@ -535,7 +535,7 @@ function splitText(declaration, scoped, separator, functionNames, sourceCode, tr
|
|
|
535
535
|
};
|
|
536
536
|
}
|
|
537
537
|
/** Built-in rule `sh/no-masked-exit-status`. @internal */
|
|
538
|
-
|
|
538
|
+
const noMaskedExitStatus = createRule({
|
|
539
539
|
name: 'no-masked-exit-status',
|
|
540
540
|
meta: {
|
|
541
541
|
type: 'problem',
|
|
@@ -672,3 +672,4 @@ export const noMaskedExitStatus = createRule({
|
|
|
672
672
|
};
|
|
673
673
|
},
|
|
674
674
|
});
|
|
675
|
+
export { noMaskedExitStatus };
|
|
@@ -10,6 +10,8 @@ export interface NoSecretEnvReadsOptions {
|
|
|
10
10
|
* {@link DEFAULT_PATTERNS} entirely.
|
|
11
11
|
*/
|
|
12
12
|
readonly patterns?: readonly string[];
|
|
13
|
+
/** Regex sources added to `patterns`, or to the built-in defaults when it is omitted. */
|
|
14
|
+
readonly additionalPatterns?: readonly string[];
|
|
13
15
|
/**
|
|
14
16
|
* Command names whose own arguments may read a secret-shaped variable. Wrapper-owned operands are still checked normally. A command
|
|
15
17
|
* run by path matches by basename.
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
* command index separates wrapper operands from the sink's arguments.
|
|
29
29
|
* - Matching is a name pattern, not secret detection.
|
|
30
30
|
*/
|
|
31
|
-
import { AlternateUnset, AlternateUnsetOrNull } from 'sh-ast
|
|
31
|
+
import { AlternateUnset, AlternateUnsetOrNull } from 'sh-ast';
|
|
32
32
|
import { resolveTransparentWrappers } from './resolve-transparent-wrappers.js';
|
|
33
33
|
import { createRule } from './create-rule.js';
|
|
34
34
|
import { compileUserPattern } from './user-pattern.js';
|
|
@@ -71,12 +71,17 @@ export const noSecretEnvReads = createRule({
|
|
|
71
71
|
{
|
|
72
72
|
type: 'object',
|
|
73
73
|
properties: {
|
|
74
|
+
additionalPatterns: {
|
|
75
|
+
type: 'array',
|
|
76
|
+
// Validate with the rule's actual Unicode/case flags in create(),
|
|
77
|
+
// so syntax and safety errors identify the original option and source.
|
|
78
|
+
items: { type: 'string' },
|
|
79
|
+
},
|
|
74
80
|
patterns: {
|
|
75
81
|
type: 'array',
|
|
76
82
|
// The shared compiler validates Unicode syntax and identifies
|
|
77
83
|
// the option index and source; flagless schema checks cannot.
|
|
78
84
|
items: { type: 'string' },
|
|
79
|
-
minItems: 1,
|
|
80
85
|
},
|
|
81
86
|
allowedSinks: {
|
|
82
87
|
type: 'array',
|
|
@@ -93,7 +98,13 @@ export const noSecretEnvReads = createRule({
|
|
|
93
98
|
},
|
|
94
99
|
create(context) {
|
|
95
100
|
const options = context.options[0];
|
|
96
|
-
|
|
101
|
+
// An explicit replacement, including [], owns the base policy. Additions
|
|
102
|
+
// extend that base per file; compile separately to retain each option's identity.
|
|
103
|
+
// Diagnostic rule paths follow the configured ID, including plugin registration aliases.
|
|
104
|
+
const patterns = [
|
|
105
|
+
...(options?.patterns ?? DEFAULT_PATTERNS).map((source, index) => compileUserPattern(context.id, `patterns[${String(index)}]`, source, 'u')),
|
|
106
|
+
...(options?.additionalPatterns ?? []).map((source, index) => compileUserPattern(context.id, `additionalPatterns[${String(index)}]`, source, 'u')),
|
|
107
|
+
];
|
|
97
108
|
const allowedSinks = new Set(options?.allowedSinks ?? []);
|
|
98
109
|
const { sourceCode } = context;
|
|
99
110
|
const transparentWrappers = resolveTransparentWrappers(context);
|
|
@@ -11,6 +11,8 @@ export interface NoSecretFlagsOptions {
|
|
|
11
11
|
* Replaces {@link DEFAULT_PATTERNS} entirely.
|
|
12
12
|
*/
|
|
13
13
|
readonly patterns?: readonly string[];
|
|
14
|
+
/** Regex sources added to `patterns`, or to the built-in defaults when it is omitted. */
|
|
15
|
+
readonly additionalPatterns?: readonly string[];
|
|
14
16
|
}
|
|
15
17
|
/**
|
|
16
18
|
* One secret-shaped flag found in a command's arguments.
|
|
@@ -95,12 +95,17 @@ export const noSecretFlags = createRule({
|
|
|
95
95
|
{
|
|
96
96
|
type: 'object',
|
|
97
97
|
properties: {
|
|
98
|
+
additionalPatterns: {
|
|
99
|
+
type: 'array',
|
|
100
|
+
// Validate with the rule's actual Unicode/case flags in create(),
|
|
101
|
+
// so syntax and safety errors identify the original option and source.
|
|
102
|
+
items: { type: 'string' },
|
|
103
|
+
},
|
|
98
104
|
patterns: {
|
|
99
105
|
type: 'array',
|
|
100
106
|
// Syntax is checked with the actual flags by compileUserPattern,
|
|
101
107
|
// which also names the option index and source in errors.
|
|
102
108
|
items: { type: 'string' },
|
|
103
|
-
minItems: 1,
|
|
104
109
|
},
|
|
105
110
|
},
|
|
106
111
|
additionalProperties: false,
|
|
@@ -111,8 +116,14 @@ export const noSecretFlags = createRule({
|
|
|
111
116
|
},
|
|
112
117
|
},
|
|
113
118
|
create(context) {
|
|
114
|
-
const
|
|
115
|
-
|
|
119
|
+
const options = context.options[0];
|
|
120
|
+
// An explicit replacement, including [], owns the base policy. Additions
|
|
121
|
+
// extend that base per file; compile separately to retain each option's identity.
|
|
122
|
+
// Diagnostic rule paths follow the configured ID, including plugin registration aliases.
|
|
123
|
+
const patterns = [
|
|
124
|
+
...(options?.patterns ?? DEFAULT_PATTERNS).map((source, index) => compileUserPattern(context.id, `patterns[${String(index)}]`, source, PATTERN_FLAGS)),
|
|
125
|
+
...(options?.additionalPatterns ?? []).map((source, index) => compileUserPattern(context.id, `additionalPatterns[${String(index)}]`, source, PATTERN_FLAGS)),
|
|
126
|
+
];
|
|
116
127
|
const isSecretFlag = (name) => patterns.some((pattern) => pattern.test(name));
|
|
117
128
|
const { sourceCode } = context;
|
|
118
129
|
/** Finds every secret-shaped flag with a literal value among `args` (argv, command word first). */
|
|
@@ -47,10 +47,10 @@
|
|
|
47
47
|
* negated, in the background, or carrying a here-document (the text after the
|
|
48
48
|
* statement is the document body, not shell code).
|
|
49
49
|
*/
|
|
50
|
-
import { DEFAULT_TRANSPARENT_WRAPPERS } from 'sh-
|
|
50
|
+
import { DEFAULT_TRANSPARENT_WRAPPERS } from 'sh-analysis';
|
|
51
51
|
import { resolveTransparentWrappers } from './resolve-transparent-wrappers.js';
|
|
52
52
|
import { createRule } from './create-rule.js';
|
|
53
|
-
import { prologueEnabledOptions, setStatementChanges } from './
|
|
53
|
+
import { prologueEnabledOptions, resolveStrictModePrologue, setStatementChanges, } from './strict-mode-prologue.js';
|
|
54
54
|
import { BUILTIN_WRAPPER } from './transparent-wrappers.js';
|
|
55
55
|
/** The commands that change the working directory and can fail doing so. */
|
|
56
56
|
const DIRECTORY_COMMANDS = new Set(['cd', 'pushd', 'popd']);
|
|
@@ -203,13 +203,14 @@ export const noUncheckedCd = createRule({
|
|
|
203
203
|
create(context) {
|
|
204
204
|
const [options] = context.options;
|
|
205
205
|
const { sourceCode } = context;
|
|
206
|
+
const prologue = resolveStrictModePrologue(context.settings);
|
|
206
207
|
const transparentWrappers = resolveTransparentWrappers(context, TRANSPARENT_WRAPPERS);
|
|
207
208
|
let errexitInForce = false;
|
|
208
209
|
return {
|
|
209
210
|
File(node) {
|
|
210
211
|
errexitInForce =
|
|
211
212
|
options.ignoreWhenErrexit !== false &&
|
|
212
|
-
prologueEnabledOptions(node, sourceCode).has('errexit');
|
|
213
|
+
prologueEnabledOptions(node, sourceCode, prologue).has('errexit');
|
|
213
214
|
},
|
|
214
215
|
CallExpr(node) {
|
|
215
216
|
if (errexitInForce)
|
|
@@ -28,10 +28,11 @@
|
|
|
28
28
|
* convention's own words when it has a `declarationHint` hook, since only the
|
|
29
29
|
* convention knows its syntax.
|
|
30
30
|
*/
|
|
31
|
+
import { configurationMessage } from '../configuration-message.js';
|
|
31
32
|
import { harvestCommands } from '../command-harvest/harvest-commands.js';
|
|
32
33
|
import { harvestWrapperTable } from '../command-harvest/wrapper-table.js';
|
|
33
34
|
import { createRule } from './create-rule.js';
|
|
34
|
-
import {
|
|
35
|
+
import { getDeclaredCommands, toLintedFile, } from '../declaration-conventions/get-declared-commands.js';
|
|
35
36
|
import { resolveDeclarationConvention } from './resolve-declaration-convention.js';
|
|
36
37
|
import { resolveTransparentWrappers } from './resolve-transparent-wrappers.js';
|
|
37
38
|
/** The registry name of this rule (`sh/no-undeclared-commands` in a user's config). */
|
|
@@ -51,7 +52,7 @@ function howToDeclare(convention, command, sourceCode, file) {
|
|
|
51
52
|
if (hint === null)
|
|
52
53
|
return GENERIC_HINT;
|
|
53
54
|
if (typeof hint !== 'string' || hint.trim() === '' || /[\r\n\u2028\u2029]/u.test(hint)) {
|
|
54
|
-
throw new Error(
|
|
55
|
+
throw Object.assign(new Error(configurationMessage('settings.sh.declarationConvention.declarationHint', `must return null or a non-empty single-line string for ${JSON.stringify(command)}`, hint)), { code: 'ESLINT_SH_DECLARATION_OUTPUT' });
|
|
55
56
|
}
|
|
56
57
|
return hint;
|
|
57
58
|
}
|
|
@@ -82,10 +83,15 @@ export const noUndeclaredCommands = createRule({
|
|
|
82
83
|
return {
|
|
83
84
|
File() {
|
|
84
85
|
// Only names matter here, so every kind of declaration counts the same.
|
|
85
|
-
const
|
|
86
|
+
const declarations = getDeclaredCommands(context);
|
|
87
|
+
if (declarations === null) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const declared = new Set(declarations.map(({ name }) => name));
|
|
91
|
+
// Report known dependencies even when opaque syntax prevents an exhaustive harvest.
|
|
86
92
|
for (const { name, node } of harvestCommands(sourceCode, {
|
|
87
93
|
transparentWrappers,
|
|
88
|
-
}).values()) {
|
|
94
|
+
}).commands.values()) {
|
|
89
95
|
if (declared.has(name))
|
|
90
96
|
continue;
|
|
91
97
|
context.report({
|
|
@@ -2,7 +2,7 @@ import { resolveTransparentWrappers } from './resolve-transparent-wrappers.js';
|
|
|
2
2
|
import { harvestCommands } from '../command-harvest/harvest-commands.js';
|
|
3
3
|
import { harvestWrapperTable } from '../command-harvest/wrapper-table.js';
|
|
4
4
|
import { createRule } from './create-rule.js';
|
|
5
|
-
import {
|
|
5
|
+
import { getDeclaredCommands } from '../declaration-conventions/get-declared-commands.js';
|
|
6
6
|
import { resolveDeclarationConvention } from './resolve-declaration-convention.js';
|
|
7
7
|
import { SHELL_WRAPPER } from './transparent-wrappers.js';
|
|
8
8
|
/** The registry name of this rule (`sh/no-unused-declarations` in a user's config). */
|
|
@@ -189,11 +189,16 @@ export const noUnusedDeclarations = createRule({
|
|
|
189
189
|
const removeDeclaration = convention.removeDeclaration?.bind(convention);
|
|
190
190
|
return {
|
|
191
191
|
File() {
|
|
192
|
-
const
|
|
192
|
+
const inventory = sourceCode.getCommandInventory();
|
|
193
|
+
// Opaque syntax may use any declaration, so absence cannot justify deletion.
|
|
194
|
+
if (inventory.uncertainties.length > 0) {
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
const sites = inventory.commands;
|
|
193
198
|
if (sites.some((site) => runsUnknownCode(site, completenessWrappers)))
|
|
194
199
|
return;
|
|
195
200
|
const used = new Set();
|
|
196
|
-
for (const name of harvestCommands(sourceCode, { transparentWrappers }).keys()) {
|
|
201
|
+
for (const name of harvestCommands(sourceCode, { transparentWrappers }).commands.keys()) {
|
|
197
202
|
for (const each of namesFor(name))
|
|
198
203
|
used.add(each);
|
|
199
204
|
}
|
|
@@ -204,7 +209,11 @@ export const noUnusedDeclarations = createRule({
|
|
|
204
209
|
used.add(each);
|
|
205
210
|
}
|
|
206
211
|
}
|
|
207
|
-
|
|
212
|
+
const declarations = getDeclaredCommands(context);
|
|
213
|
+
if (declarations === null) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
for (const declared of declarations) {
|
|
208
217
|
if (used.has(declared.name))
|
|
209
218
|
continue;
|
|
210
219
|
if (declared.kind === 'script') {
|