@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
package/dist/index.d.ts
CHANGED
|
@@ -1,85 +1,18 @@
|
|
|
1
|
-
/** Exposes the ESLint language, source view, and rule-author helpers as one plugin boundary. */
|
|
2
|
-
import type { ConfigObject } from '@eslint/core';
|
|
3
|
-
import { ShellLanguage } from './language/shell-language.js';
|
|
4
|
-
export { ShellLanguage } from './language/shell-language.js';
|
|
5
|
-
export { ShellSourceCode } from './language/shell-source-code.js';
|
|
6
|
-
export type { NormalizedShellLanguageOptions, ShellLanguageOptions, ShellLanguageOptionsJSON, } from './language/shell-language-options.js';
|
|
7
|
-
export { resolveWord } from './language/word-resolution.js';
|
|
8
|
-
export type { Argv0Resolution } from 'sh-ast/analyze';
|
|
9
|
-
export type { CommandContext, ResolveArgv0Options, WordResolution } from 'sh-ast/analyze';
|
|
10
|
-
export type { ShellCommandSite } from './language/command-resolution.js';
|
|
11
|
-
export type { ShellComment, ShellFile, ShellNode, ShellNodeField, ShellNodeMap, ShellNodeOf, ShellNodeType, ShellPosition, } from './language/syntax-view.js';
|
|
12
|
-
export type { ShellDialect } from './language/shell-language-options.js';
|
|
13
|
-
export type { DeclarationConvention, DeclaredCommand, FileDeclaredCommand, LintedFile, DescribedDeclaredCommand, ScriptDeclaredCommand, } from './declaration-conventions/declaration-convention.js';
|
|
14
|
-
export { readDeclaredCommands } from './declaration-conventions/read-declared-commands.js';
|
|
15
|
-
export type { DeclarationReadContext } from './declaration-conventions/read-declared-commands.js';
|
|
16
|
-
export { commentPragma } from './declaration-conventions/comment-pragma.js';
|
|
17
|
-
export { resolveTransparentWrappers } from './rules/resolve-transparent-wrappers.js';
|
|
18
|
-
export type { TransparentWrappersBindingContext } from './rules/resolve-transparent-wrappers.js';
|
|
19
|
-
export { resolveDeclarationConvention } from './rules/resolve-declaration-convention.js';
|
|
20
|
-
export type { DeclarationConventionBindingContext } from './rules/resolve-declaration-convention.js';
|
|
21
|
-
export { defineShellRule } from './rules/define-shell-rule.js';
|
|
22
|
-
export type { ShellListener, ShellRule, ShellRuleContext, ShellRuleMeta, ShellRuleSpec, ShellRuleVisitor, ShellTypedListeners, } from './rules/define-shell-rule.js';
|
|
23
|
-
export { createWrapperRule } from './rules/create-wrapper-rule.js';
|
|
24
|
-
export type { WrapperRuleConfig, WrapperRuleLocalInvocation, WrapperRuleLocalOperand, WrapperRuleSubcommands, } from './rules/create-wrapper-rule.js';
|
|
25
|
-
export type { WrapperSpec } from 'sh-ast/analyze';
|
|
26
1
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
|
|
32
|
-
*
|
|
33
|
-
|
|
34
|
-
*
|
|
35
|
-
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* `configs.recommended` is the `sh/recommended` preset: a single config
|
|
41
|
-
* object carrying `plugins: { sh }` and `language: "sh/sh"` but no `files`,
|
|
42
|
-
* so it inherits the globs of the entry that extends it:
|
|
43
|
-
* `{ files: [...], extends: [sh.configs.recommended] }`. It enables the
|
|
44
|
-
* convention-free policy rules. The rules index at
|
|
45
|
-
* https://github.com/mike-north/eslint-sh/blob/main/packages/eslint-plugin/docs/rules/README.md
|
|
46
|
-
* describes preset membership and available autofixes.
|
|
47
|
-
* `configs['agent-authored']` is the strict `sh/agent-authored` preset for
|
|
48
|
-
* machine-written, human-reviewed scripts:
|
|
49
|
-
* every `recommended` rule plus the contract rules, all at `error`.
|
|
50
|
-
* `configs['bash-3.2']` and `configs['posix-portable']` are deployment-target
|
|
51
|
-
* packs: the first sets `languageOptions.minBashVersion: "3.2"` and enables
|
|
52
|
-
* the version-gated `compat/*` rules except the opt-in
|
|
53
|
-
* `compat/no-nounset-empty-array`; the second sets
|
|
54
|
-
* `languageOptions.dialect: "posix"`, enables the `compat/*` rules and the
|
|
55
|
-
* shebang/dialect check, and requires `set -eu`; it reports named constructs
|
|
56
|
-
* that fail on dash, not every non-POSIX construct, and leaves `local`,
|
|
57
|
-
* `echo -e` and the rest of shellcheck's SC3xxx catalog to shellcheck. Every
|
|
58
|
-
* shipped config is a
|
|
59
|
-
* single object with no `files`; the two packs also carry `languageOptions`,
|
|
60
|
-
* because the target they name is their meaning.
|
|
61
|
-
*
|
|
62
|
-
* Re-exported, unchanged, as the default export of the `eslint-sh` umbrella
|
|
63
|
-
* package: importing this package or the umbrella package both yield the
|
|
64
|
-
* same plugin object.
|
|
2
|
+
* Node's CommonJS entry uses the same plugin as ESM and every preset. Helpers
|
|
3
|
+
* remain non-enumerable so ESLint's plugin/config traversal sees only plugin
|
|
4
|
+
* data, while existing namespace-style require properties retain their identity.
|
|
5
|
+
* API Extractor reads api.ts instead: it cannot represent quoted export names.
|
|
6
|
+
*/
|
|
7
|
+
import plugin, * as api from './api.js';
|
|
8
|
+
export { default } from './api.js';
|
|
9
|
+
export * from './api.js';
|
|
10
|
+
/**
|
|
11
|
+
* The require(ESM) result is the plugin itself, augmented with the ESM namespace's
|
|
12
|
+
* default and named values. This assertion describes the properties installed
|
|
13
|
+
* above; it neither wraps nor copies the plugin, preserving preset identity.
|
|
65
14
|
*
|
|
66
15
|
* @public
|
|
67
16
|
*/
|
|
68
|
-
declare const
|
|
69
|
-
|
|
70
|
-
name: string;
|
|
71
|
-
version: string;
|
|
72
|
-
namespace: string;
|
|
73
|
-
};
|
|
74
|
-
languages: {
|
|
75
|
-
sh: ShellLanguage;
|
|
76
|
-
};
|
|
77
|
-
rules: Record<string, import("@eslint/core").RuleDefinition<import("@eslint/core").RuleDefinitionTypeOptions>>;
|
|
78
|
-
configs: {
|
|
79
|
-
recommended: ConfigObject;
|
|
80
|
-
"agent-authored": ConfigObject;
|
|
81
|
-
"bash-3.2": ConfigObject;
|
|
82
|
-
"posix-portable": ConfigObject;
|
|
83
|
-
};
|
|
84
|
-
};
|
|
85
|
-
export default plugin;
|
|
17
|
+
declare const commonJsModule: typeof plugin & Readonly<typeof api>;
|
|
18
|
+
export { commonJsModule as 'module.exports' };
|
package/dist/index.js
CHANGED
|
@@ -1,80 +1,26 @@
|
|
|
1
|
-
import { createAgentAuthoredConfig } from './configs/agent-authored.js';
|
|
2
|
-
import { createBash32Config } from './configs/bash-3-2.js';
|
|
3
|
-
import { createPosixPortableConfig } from './configs/posix-portable.js';
|
|
4
|
-
import { createRecommendedConfig } from './configs/recommended.js';
|
|
5
|
-
import { ShellLanguage } from './language/shell-language.js';
|
|
6
|
-
import { rules } from './rules/index.js';
|
|
7
|
-
import { readPackageVersion } from './version.js';
|
|
8
|
-
export { ShellLanguage } from './language/shell-language.js';
|
|
9
|
-
export { ShellSourceCode } from './language/shell-source-code.js';
|
|
10
|
-
export { resolveWord } from './language/word-resolution.js';
|
|
11
|
-
export { readDeclaredCommands } from './declaration-conventions/read-declared-commands.js';
|
|
12
|
-
export { commentPragma } from './declaration-conventions/comment-pragma.js';
|
|
13
|
-
export { resolveTransparentWrappers } from './rules/resolve-transparent-wrappers.js';
|
|
14
|
-
export { resolveDeclarationConvention } from './rules/resolve-declaration-convention.js';
|
|
15
|
-
export { defineShellRule } from './rules/define-shell-rule.js';
|
|
16
|
-
export { createWrapperRule } from './rules/create-wrapper-rule.js';
|
|
17
|
-
/* eslint-disable @api-extractor-tools/public-on-non-exported -- `plugin` is exported below as
|
|
18
|
-
`export default plugin`; the rule only recognizes inline exports. */
|
|
19
1
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
|
|
25
|
-
*
|
|
26
|
-
|
|
27
|
-
*
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* `configs['agent-authored']` is the strict `sh/agent-authored` preset for
|
|
41
|
-
* machine-written, human-reviewed scripts:
|
|
42
|
-
* every `recommended` rule plus the contract rules, all at `error`.
|
|
43
|
-
* `configs['bash-3.2']` and `configs['posix-portable']` are deployment-target
|
|
44
|
-
* packs: the first sets `languageOptions.minBashVersion: "3.2"` and enables
|
|
45
|
-
* the version-gated `compat/*` rules except the opt-in
|
|
46
|
-
* `compat/no-nounset-empty-array`; the second sets
|
|
47
|
-
* `languageOptions.dialect: "posix"`, enables the `compat/*` rules and the
|
|
48
|
-
* shebang/dialect check, and requires `set -eu`; it reports named constructs
|
|
49
|
-
* that fail on dash, not every non-POSIX construct, and leaves `local`,
|
|
50
|
-
* `echo -e` and the rest of shellcheck's SC3xxx catalog to shellcheck. Every
|
|
51
|
-
* shipped config is a
|
|
52
|
-
* single object with no `files`; the two packs also carry `languageOptions`,
|
|
53
|
-
* because the target they name is their meaning.
|
|
54
|
-
*
|
|
55
|
-
* Re-exported, unchanged, as the default export of the `eslint-sh` umbrella
|
|
56
|
-
* package: importing this package or the umbrella package both yield the
|
|
57
|
-
* same plugin object.
|
|
2
|
+
* Node's CommonJS entry uses the same plugin as ESM and every preset. Helpers
|
|
3
|
+
* remain non-enumerable so ESLint's plugin/config traversal sees only plugin
|
|
4
|
+
* data, while existing namespace-style require properties retain their identity.
|
|
5
|
+
* API Extractor reads api.ts instead: it cannot represent quoted export names.
|
|
6
|
+
*/
|
|
7
|
+
import plugin, * as api from './api.js';
|
|
8
|
+
export { default } from './api.js';
|
|
9
|
+
export * from './api.js';
|
|
10
|
+
for (const [name, value] of Object.entries(api)) {
|
|
11
|
+
Object.defineProperty(plugin, name, {
|
|
12
|
+
value,
|
|
13
|
+
enumerable: false,
|
|
14
|
+
writable: false,
|
|
15
|
+
configurable: false,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The require(ESM) result is the plugin itself, augmented with the ESM namespace's
|
|
20
|
+
* default and named values. This assertion describes the properties installed
|
|
21
|
+
* above; it neither wraps nor copies the plugin, preserving preset identity.
|
|
58
22
|
*
|
|
59
23
|
* @public
|
|
60
24
|
*/
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
name: '@eslint-sh/eslint-plugin',
|
|
64
|
-
version: readPackageVersion(),
|
|
65
|
-
namespace: 'sh',
|
|
66
|
-
},
|
|
67
|
-
languages: {
|
|
68
|
-
sh: new ShellLanguage(),
|
|
69
|
-
},
|
|
70
|
-
rules,
|
|
71
|
-
// Filled in below: each shipped config registers this very object under
|
|
72
|
-
// `plugins.sh`, so the plugin must exist before its configs can.
|
|
73
|
-
configs: {},
|
|
74
|
-
};
|
|
75
|
-
/* eslint-enable @api-extractor-tools/public-on-non-exported */
|
|
76
|
-
plugin.configs.recommended = createRecommendedConfig(plugin);
|
|
77
|
-
plugin.configs['agent-authored'] = createAgentAuthoredConfig(plugin);
|
|
78
|
-
plugin.configs['bash-3.2'] = createBash32Config(plugin);
|
|
79
|
-
plugin.configs['posix-portable'] = createPosixPortableConfig(plugin);
|
|
80
|
-
export default plugin;
|
|
25
|
+
const commonJsModule = plugin;
|
|
26
|
+
export { commonJsModule as 'module.exports' };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { Argv0Resolution,
|
|
1
|
+
import type { Argv0Resolution, CommandUncertainty, CommandContext, CommandSite, ResolveArgv0Options, WordResolution } from 'sh-analysis';
|
|
2
|
+
import type { CallExpr } from 'sh-ast';
|
|
2
3
|
import type { ShellFile, ShellNode, ShellNodeOf } from './syntax-view.js';
|
|
3
4
|
/**
|
|
4
5
|
* Every command site in one parsed file, from a single `enumerateCommands`
|
|
@@ -10,19 +11,21 @@ import type { ShellFile, ShellNode, ShellNodeOf } from './syntax-view.js';
|
|
|
10
11
|
*/
|
|
11
12
|
export interface CommandSiteIndex {
|
|
12
13
|
readonly sites: readonly CommandSite[];
|
|
14
|
+
/** Opaque execution boundaries retained alongside represented commands. */
|
|
15
|
+
readonly uncertainties: readonly CommandUncertainty[];
|
|
13
16
|
readonly byNode: ReadonlyMap<CallExpr, CommandSite>;
|
|
14
17
|
}
|
|
15
18
|
/**
|
|
16
19
|
* One command invocation in a linted shell file, in lint-view terms: an
|
|
17
|
-
* `sh-
|
|
20
|
+
* `sh-analysis` `CommandSite` whose `node` is the `CallExpr` view node
|
|
18
21
|
* ESLint passes to rule visitors, so a rule can `context.report()` on it.
|
|
19
22
|
*
|
|
20
|
-
* The data comes from `sh-
|
|
23
|
+
* The data comes from `sh-analysis`'s `enumerateCommands` and is facts
|
|
21
24
|
* only: how the command is reached and what its words resolve to, never a
|
|
22
25
|
* verdict on whether running it is safe. A dynamic (`static: false`) `argv0`
|
|
23
26
|
* is a normal result.
|
|
24
27
|
*
|
|
25
|
-
* Read one through `ShellSourceCode.
|
|
28
|
+
* Read one through `ShellSourceCode.getCommandInventory().commands`.
|
|
26
29
|
*
|
|
27
30
|
* Every rule linting a file sees the same sites, so each one is deeply
|
|
28
31
|
* frozen: the entry, its `context` array and every frame in it, its `argv`
|
|
@@ -43,7 +46,7 @@ export interface ShellCommandSite {
|
|
|
43
46
|
readonly node: ShellNodeOf<'CallExpr'>;
|
|
44
47
|
/**
|
|
45
48
|
* The path from the file root to this command, outermost frame first,
|
|
46
|
-
* exactly as `sh-
|
|
49
|
+
* exactly as `sh-analysis` reports it. For example, `date` in
|
|
47
50
|
* `f() { echo "$(date)"; }` has
|
|
48
51
|
* `[{ kind: 'function', name: 'f' }, { kind: 'cmdSubst' }]`.
|
|
49
52
|
*/
|
|
@@ -58,23 +61,47 @@ export interface ShellCommandSite {
|
|
|
58
61
|
readonly argv: readonly WordResolution[];
|
|
59
62
|
/**
|
|
60
63
|
* Follows this command's argv0 through transparent wrappers (`env`, `sudo`,
|
|
61
|
-
* `nohup`, `exec`, …) and returns `sh-
|
|
64
|
+
* `nohup`, `exec`, …) and returns `sh-analysis`'s `resolveArgv0`
|
|
62
65
|
* result. Same answer as
|
|
63
66
|
* `ShellSourceCode.resolveInvokedCommand(node, options)`; both read the
|
|
64
67
|
* same per-file index.
|
|
65
68
|
*
|
|
66
69
|
* @param options - Forwarded to `resolveArgv0` unchanged.
|
|
67
|
-
* `transparentWrappers` replaces `sh-
|
|
70
|
+
* `transparentWrappers` replaces `sh-analysis`'s
|
|
68
71
|
* `DEFAULT_TRANSPARENT_WRAPPERS`; spread the defaults into the array to
|
|
69
72
|
* extend them instead.
|
|
70
73
|
* @returns A new result on every call. Its `chain` and `chainIndices`
|
|
71
74
|
* arrays belong to the caller. `chainIndices` gives each chain entry's
|
|
72
75
|
* position in this site's `argv`.
|
|
73
|
-
* @throws `ShAnalyzeInvalidWrapperSpecError` (from `sh-
|
|
76
|
+
* @throws `ShAnalyzeInvalidWrapperSpecError` (`SH_ANALYSIS_INVALID_WRAPPER_SPEC`, from `sh-analysis`) when
|
|
74
77
|
* `options.transparentWrappers` contains a malformed entry.
|
|
75
78
|
*/
|
|
76
79
|
resolveInvokedCommand(options?: ResolveArgv0Options): Argv0Resolution;
|
|
77
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* An opaque executable construct projected onto the original ESLint view.
|
|
83
|
+
* Its presence limits inventory completeness; it does not assert a hidden command.
|
|
84
|
+
* @public
|
|
85
|
+
*/
|
|
86
|
+
export interface ShellCommandUncertainty {
|
|
87
|
+
/** The analysis observation, without a lint-policy interpretation. */
|
|
88
|
+
readonly reason: CommandUncertainty['reason'];
|
|
89
|
+
/** Original projected construct, with this file's UTF-16 range and location. */
|
|
90
|
+
readonly node: ShellNode;
|
|
91
|
+
/** Context reaching the opaque construct, outermost frame first. */
|
|
92
|
+
readonly context: readonly CommandContext[];
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Represented commands and opaque execution boundaries in one linted file.
|
|
96
|
+
* Consumers requiring complete execution knowledge must consider uncertainties.
|
|
97
|
+
* @public
|
|
98
|
+
*/
|
|
99
|
+
export interface ShellCommandInventory {
|
|
100
|
+
/** Known represented command sites, in source order. */
|
|
101
|
+
readonly commands: readonly ShellCommandSite[];
|
|
102
|
+
/** Opaque constructs whose executable contents cannot be enumerated. */
|
|
103
|
+
readonly uncertainties: readonly ShellCommandUncertainty[];
|
|
104
|
+
}
|
|
78
105
|
/**
|
|
79
106
|
* Builds the {@link CommandSiteIndex} for a whole parsed file with a single
|
|
80
107
|
* `enumerateCommands` call over the file's original syntax. Each site's
|
|
@@ -86,13 +113,13 @@ export interface ShellCommandSite {
|
|
|
86
113
|
* this bridge exists to prevent.
|
|
87
114
|
*
|
|
88
115
|
* The index is shared by every rule linting the file, and its data reaches
|
|
89
|
-
* rules: `
|
|
116
|
+
* rules: `getCommandInventory` exposes each site's `context`, `argv0` and `argv`.
|
|
90
117
|
* Analysis also shares one `context` array and its frames between
|
|
91
118
|
* sibling commands. So every site is frozen in place here, before any rule
|
|
92
119
|
* can see it (see {@link freezeCommandSite}).
|
|
93
120
|
*
|
|
94
|
-
* @throws TypeError when `file` has no associated parsed syntax.
|
|
95
|
-
* @throws `ShAnalyzeMaxDepthError` (from `sh-
|
|
121
|
+
* @throws TypeError with `ESLINT_SH_FILE_NODE` when `file` has no associated parsed syntax.
|
|
122
|
+
* @throws `ShAnalyzeMaxDepthError` (`SH_ANALYSIS_MAX_DEPTH`, from `sh-analysis`) when the file's
|
|
96
123
|
* nesting exceeds analysis's recursion guard. It propagates unchanged: a
|
|
97
124
|
* partial index would silently omit real commands, so callers fail closed.
|
|
98
125
|
* @internal
|
|
@@ -107,17 +134,24 @@ export declare function buildCommandSiteIndex(file: ShellFile): CommandSiteIndex
|
|
|
107
134
|
* when the index was built: the same array is shared by every rule linting
|
|
108
135
|
* this file.
|
|
109
136
|
*
|
|
110
|
-
* @throws Error when a site's `CallExpr` has no view node in `file`. Analysis
|
|
137
|
+
* @throws Error with `ESLINT_SH_COMMAND_SITE_VIEW` when a site's `CallExpr` has no view node in `file`. Analysis
|
|
111
138
|
* of the same parse only reports parser nodes the projection saw, so this
|
|
112
139
|
* marks a broken invariant rather than a shell construct; failing loudly is
|
|
113
140
|
* safer than silently dropping a command.
|
|
114
141
|
* @internal
|
|
115
142
|
*/
|
|
116
143
|
export declare function viewCommandSites(file: ShellFile, index: CommandSiteIndex): readonly ShellCommandSite[];
|
|
144
|
+
/**
|
|
145
|
+
* Projects inventory limits by original syntax identity, using the same associations
|
|
146
|
+
* as command sites. A missing association is an adapter invariant failure, never
|
|
147
|
+
* permission to silently discard uncertainty or reinterpret shell source text.
|
|
148
|
+
* @internal
|
|
149
|
+
*/
|
|
150
|
+
export declare function viewCommandInventory(file: ShellFile, index: CommandSiteIndex): ShellCommandInventory;
|
|
117
151
|
/**
|
|
118
152
|
* Returns the parser's own `CallExpr` behind a lint `CallExpr`.
|
|
119
153
|
*
|
|
120
|
-
* @throws TypeError when `callExpr` is not a parsed `CallExpr` from this
|
|
154
|
+
* @throws TypeError with `ESLINT_SH_CALL_NODE` when `callExpr` is not a parsed `CallExpr` from this
|
|
121
155
|
* language adapter (a fabricated or synthetic view node has no syntax).
|
|
122
156
|
* @internal
|
|
123
157
|
*/
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
2
|
+
* Maps reusable command observations onto ESLint source identity. sh-analysis owns
|
|
3
|
+
* represented command sites, their context and opaque execution boundaries; this
|
|
4
|
+
* adapter indexes the original syntax nodes and maps every observation to its
|
|
5
|
+
* original lint view without interpreting source text or choosing lint policy.
|
|
6
|
+
*
|
|
7
|
+
* Missing source associations are invariant failures. Commands and uncertainties
|
|
8
|
+
* must never disappear during projection; analysis resource/configuration errors
|
|
9
|
+
* propagate unchanged instead of becoming partial inventories or parser errors.
|
|
8
10
|
*/
|
|
9
|
-
import { enumerateCommands, resolveArgv0 } from 'sh-
|
|
11
|
+
import { enumerateCommands, resolveArgv0 } from 'sh-analysis';
|
|
10
12
|
import { syntaxForNode, viewForSyntax, withoutCrlfCarriageReturn } from './syntax-view.js';
|
|
11
13
|
/**
|
|
12
14
|
* Builds the {@link CommandSiteIndex} for a whole parsed file with a single
|
|
@@ -19,13 +21,13 @@ import { syntaxForNode, viewForSyntax, withoutCrlfCarriageReturn } from './synta
|
|
|
19
21
|
* this bridge exists to prevent.
|
|
20
22
|
*
|
|
21
23
|
* The index is shared by every rule linting the file, and its data reaches
|
|
22
|
-
* rules: `
|
|
24
|
+
* rules: `getCommandInventory` exposes each site's `context`, `argv0` and `argv`.
|
|
23
25
|
* Analysis also shares one `context` array and its frames between
|
|
24
26
|
* sibling commands. So every site is frozen in place here, before any rule
|
|
25
27
|
* can see it (see {@link freezeCommandSite}).
|
|
26
28
|
*
|
|
27
|
-
* @throws TypeError when `file` has no associated parsed syntax.
|
|
28
|
-
* @throws `ShAnalyzeMaxDepthError` (from `sh-
|
|
29
|
+
* @throws TypeError with `ESLINT_SH_FILE_NODE` when `file` has no associated parsed syntax.
|
|
30
|
+
* @throws `ShAnalyzeMaxDepthError` (`SH_ANALYSIS_MAX_DEPTH`, from `sh-analysis`) when the file's
|
|
29
31
|
* nesting exceeds analysis's recursion guard. It propagates unchanged: a
|
|
30
32
|
* partial index would silently omit real commands, so callers fail closed.
|
|
31
33
|
* @internal
|
|
@@ -33,10 +35,20 @@ import { syntaxForNode, viewForSyntax, withoutCrlfCarriageReturn } from './synta
|
|
|
33
35
|
export function buildCommandSiteIndex(file) {
|
|
34
36
|
const syntax = syntaxForNode(file);
|
|
35
37
|
if (syntax?.Type !== 'File') {
|
|
36
|
-
throw new TypeError('expected a parsed shell File from this language adapter')
|
|
38
|
+
throw Object.assign(new TypeError('expected a parsed shell File from this language adapter'), {
|
|
39
|
+
code: 'ESLINT_SH_FILE_NODE',
|
|
40
|
+
});
|
|
37
41
|
}
|
|
38
|
-
const
|
|
39
|
-
|
|
42
|
+
const inventory = enumerateCommands(syntax);
|
|
43
|
+
const sites = Object.freeze(inventory.commands.map((site) => freezeCommandSite(withLfArgv(site))));
|
|
44
|
+
const uncertainties = Object.freeze(inventory.uncertainties.map((uncertainty) => {
|
|
45
|
+
for (const frame of uncertainty.context) {
|
|
46
|
+
Object.freeze(frame);
|
|
47
|
+
}
|
|
48
|
+
Object.freeze(uncertainty.context);
|
|
49
|
+
return Object.freeze(uncertainty);
|
|
50
|
+
}));
|
|
51
|
+
return { sites, uncertainties, byNode: new Map(sites.map((site) => [site.node, site])) };
|
|
40
52
|
}
|
|
41
53
|
/**
|
|
42
54
|
* `site` with each argv word resolved as its LF equivalent (see
|
|
@@ -60,7 +72,7 @@ function withLfArgv(site) {
|
|
|
60
72
|
*
|
|
61
73
|
* Freezing in place, instead of copying, keeps every value identical to what
|
|
62
74
|
* analysis returned. That is safe because `enumerateCommands` builds these
|
|
63
|
-
* objects fresh on each call, and nothing in `sh-
|
|
75
|
+
* objects fresh on each call, and nothing in `sh-analysis` writes to them
|
|
64
76
|
* after it returns: `resolveArgv0` only reads a site. A frame's fields are
|
|
65
77
|
* primitives or source text, so freezing each frame shallowly is complete.
|
|
66
78
|
*/
|
|
@@ -83,7 +95,7 @@ function freezeCommandSite(site) {
|
|
|
83
95
|
* when the index was built: the same array is shared by every rule linting
|
|
84
96
|
* this file.
|
|
85
97
|
*
|
|
86
|
-
* @throws Error when a site's `CallExpr` has no view node in `file`. Analysis
|
|
98
|
+
* @throws Error with `ESLINT_SH_COMMAND_SITE_VIEW` when a site's `CallExpr` has no view node in `file`. Analysis
|
|
87
99
|
* of the same parse only reports parser nodes the projection saw, so this
|
|
88
100
|
* marks a broken invariant rather than a shell construct; failing loudly is
|
|
89
101
|
* safer than silently dropping a command.
|
|
@@ -93,7 +105,7 @@ export function viewCommandSites(file, index) {
|
|
|
93
105
|
return Object.freeze(index.sites.map((site) => {
|
|
94
106
|
const node = viewForSyntax(file, site.node);
|
|
95
107
|
if (node?.type !== 'CallExpr') {
|
|
96
|
-
throw new Error('command site has no CallExpr in the lint view of this file');
|
|
108
|
+
throw Object.assign(new Error('command site has no CallExpr in the lint view of this file'), { code: 'ESLINT_SH_COMMAND_SITE_VIEW' });
|
|
97
109
|
}
|
|
98
110
|
return Object.freeze({
|
|
99
111
|
node,
|
|
@@ -104,17 +116,35 @@ export function viewCommandSites(file, index) {
|
|
|
104
116
|
});
|
|
105
117
|
}));
|
|
106
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* Projects inventory limits by original syntax identity, using the same associations
|
|
121
|
+
* as command sites. A missing association is an adapter invariant failure, never
|
|
122
|
+
* permission to silently discard uncertainty or reinterpret shell source text.
|
|
123
|
+
* @internal
|
|
124
|
+
*/
|
|
125
|
+
export function viewCommandInventory(file, index) {
|
|
126
|
+
const uncertainties = Object.freeze(index.uncertainties.map((uncertainty) => {
|
|
127
|
+
const node = viewForSyntax(file, uncertainty.node);
|
|
128
|
+
if (node === undefined) {
|
|
129
|
+
throw Object.assign(new Error('command uncertainty has no node in the lint view of this file'), {
|
|
130
|
+
code: 'ESLINT_SH_COMMAND_UNCERTAINTY_VIEW',
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
return Object.freeze({ reason: uncertainty.reason, node, context: uncertainty.context });
|
|
134
|
+
}));
|
|
135
|
+
return Object.freeze({ commands: viewCommandSites(file, index), uncertainties });
|
|
136
|
+
}
|
|
107
137
|
/**
|
|
108
138
|
* Returns the parser's own `CallExpr` behind a lint `CallExpr`.
|
|
109
139
|
*
|
|
110
|
-
* @throws TypeError when `callExpr` is not a parsed `CallExpr` from this
|
|
140
|
+
* @throws TypeError with `ESLINT_SH_CALL_NODE` when `callExpr` is not a parsed `CallExpr` from this
|
|
111
141
|
* language adapter (a fabricated or synthetic view node has no syntax).
|
|
112
142
|
* @internal
|
|
113
143
|
*/
|
|
114
144
|
export function rawCallExprFor(callExpr) {
|
|
115
145
|
const syntax = syntaxForNode(callExpr);
|
|
116
146
|
if (syntax?.Type !== 'CallExpr') {
|
|
117
|
-
throw new TypeError('expected a parsed shell CallExpr from this language adapter');
|
|
147
|
+
throw Object.assign(new TypeError('expected a parsed shell CallExpr from this language adapter'), { code: 'ESLINT_SH_CALL_NODE' });
|
|
118
148
|
}
|
|
119
149
|
return syntax;
|
|
120
150
|
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import type { ShellNode as ShNode } from './syntax-view.js';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
* implements.
|
|
3
|
+
* Candidate node types for the six launch esquery selector classes
|
|
4
|
+
* `ShellLanguage.matchesSelectorClass` implements. `:command` additionally
|
|
5
|
+
* requires a command word: a `CallExpr` with nonempty `args` has a command
|
|
6
|
+
* site, including when that word is dynamic. Assignment-only calls such as
|
|
7
|
+
* `FOO=1` have no site; consumers wanting every call select `CallExpr` directly.
|
|
8
|
+
* Keys are the *bare* class name —
|
|
5
9
|
* esquery strips the leading `:` before invoking a language's
|
|
6
10
|
* `matchesSelectorClass` (confirmed against `esquery`'s own `case 'class'`
|
|
7
11
|
* matcher, which calls `options.matchClass(selector.name, node, ancestry)`
|
|
@@ -41,7 +45,7 @@ export type SelectorClassName = keyof typeof SELECTOR_CLASS_NODE_TYPES;
|
|
|
41
45
|
/**
|
|
42
46
|
* Implements the matching behavior behind `ShellLanguage.matchesSelectorClass`
|
|
43
47
|
* (`@eslint/core`'s `Language.matchesSelectorClass`): `true` when `node`'s
|
|
44
|
-
*
|
|
48
|
+
* construct belongs to the named launch class, `false` for every other node
|
|
45
49
|
* type (including the five other launch classes' node types) and for any
|
|
46
50
|
* unrecognized `className` (a class name this language does not define —
|
|
47
51
|
* per the `Language` contract, an unknown class simply never matches,
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* implements.
|
|
2
|
+
* Candidate node types for the six launch esquery selector classes
|
|
3
|
+
* `ShellLanguage.matchesSelectorClass` implements. `:command` additionally
|
|
4
|
+
* requires a command word: a `CallExpr` with nonempty `args` has a command
|
|
5
|
+
* site, including when that word is dynamic. Assignment-only calls such as
|
|
6
|
+
* `FOO=1` have no site; consumers wanting every call select `CallExpr` directly.
|
|
7
|
+
* Keys are the *bare* class name —
|
|
4
8
|
* esquery strips the leading `:` before invoking a language's
|
|
5
9
|
* `matchesSelectorClass` (confirmed against `esquery`'s own `case 'class'`
|
|
6
10
|
* matcher, which calls `options.matchClass(selector.name, node, ancestry)`
|
|
@@ -30,7 +34,7 @@ export const SELECTOR_CLASS_NODE_TYPES = {
|
|
|
30
34
|
quoted: ['SglQuoted', 'DblQuoted'],
|
|
31
35
|
function: ['FuncDecl'],
|
|
32
36
|
};
|
|
33
|
-
/**
|
|
37
|
+
/** Candidate types are shared across matches; command-word presence is checked per node. */
|
|
34
38
|
const nodeTypesByClassName = new Map(Object.entries(SELECTOR_CLASS_NODE_TYPES).map(([className, nodeTypes]) => [
|
|
35
39
|
className,
|
|
36
40
|
new Set(nodeTypes),
|
|
@@ -38,7 +42,7 @@ const nodeTypesByClassName = new Map(Object.entries(SELECTOR_CLASS_NODE_TYPES).m
|
|
|
38
42
|
/**
|
|
39
43
|
* Implements the matching behavior behind `ShellLanguage.matchesSelectorClass`
|
|
40
44
|
* (`@eslint/core`'s `Language.matchesSelectorClass`): `true` when `node`'s
|
|
41
|
-
*
|
|
45
|
+
* construct belongs to the named launch class, `false` for every other node
|
|
42
46
|
* type (including the five other launch classes' node types) and for any
|
|
43
47
|
* unrecognized `className` (a class name this language does not define —
|
|
44
48
|
* per the `Language` contract, an unknown class simply never matches,
|
|
@@ -47,5 +51,10 @@ const nodeTypesByClassName = new Map(Object.entries(SELECTOR_CLASS_NODE_TYPES).m
|
|
|
47
51
|
* @public
|
|
48
52
|
*/
|
|
49
53
|
export function matchesSelectorClass(className, node) {
|
|
54
|
+
// A command site exists exactly when a call has a command word. Its name
|
|
55
|
+
// need not be statically known, and assignments before it do not remove it.
|
|
56
|
+
if (className === 'command') {
|
|
57
|
+
return node.type === 'CallExpr' && node.args.length > 0;
|
|
58
|
+
}
|
|
50
59
|
return nodeTypesByClassName.get(className)?.has(node.type) ?? false;
|
|
51
60
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export type ShellDialect = 'bash' | 'posix' | 'mksh' | 'bats' | 'zsh';
|
|
1
|
+
import type { ShellDialect } from '../shell-dialect.js';
|
|
2
|
+
export type { ShellDialect } from '../shell-dialect.js';
|
|
4
3
|
/**
|
|
5
4
|
* `languageOptions` accepted by {@link ShellLanguage}: `dialect` selects
|
|
6
5
|
* mvdan/sh's `LangVariant` through a consumer-owned mapping (default `"bash"`); `minBashVersion`
|
|
@@ -95,6 +94,7 @@ export interface NormalizedShellLanguageOptions extends Record<string, unknown>
|
|
|
95
94
|
* this function's entire job is validating an untrusted boundary: the
|
|
96
95
|
* caller-supplied object may not actually match the declared shape.
|
|
97
96
|
*
|
|
97
|
+
* @throws TypeError with `ESLINT_SH_LANGUAGE_OPTION` for an invalid project binding.
|
|
98
98
|
* @public
|
|
99
99
|
*/
|
|
100
100
|
export declare function validateShellLanguageOptions(languageOptions: Record<string, unknown>): void;
|
|
@@ -1,14 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* the consumer's configuration labels; the syntax interface itself accepts
|
|
5
|
-
* upstream numeric constants rather than these configuration strings.
|
|
6
|
-
*/
|
|
7
|
-
const SUPPORTED_SHELL_DIALECTS = ['bash', 'posix', 'mksh', 'bats', 'zsh'];
|
|
8
|
-
/** Narrows configuration labels without treating arbitrary strings as parser variants. */
|
|
9
|
-
function isShellDialect(value) {
|
|
10
|
-
return (typeof value === 'string' && SUPPORTED_SHELL_DIALECTS.includes(value));
|
|
11
|
-
}
|
|
1
|
+
/** Validates ESLint-specific language options before parsing; shared vocabulary owns the grammar labels. */
|
|
2
|
+
import { configurationMessage } from '../configuration-message.js';
|
|
3
|
+
import { isShellDialect, SUPPORTED_SHELL_DIALECTS } from '../shell-dialect.js';
|
|
12
4
|
/**
|
|
13
5
|
* Default for {@link ShellLanguageOptions.directivePrefix} — the
|
|
14
6
|
* ESLint-conventional spelling. The directive prefix is configurable but
|
|
@@ -57,32 +49,35 @@ function isValidMinBashVersionShape(value) {
|
|
|
57
49
|
* this function's entire job is validating an untrusted boundary: the
|
|
58
50
|
* caller-supplied object may not actually match the declared shape.
|
|
59
51
|
*
|
|
52
|
+
* @throws TypeError with `ESLINT_SH_LANGUAGE_OPTION` for an invalid project binding.
|
|
60
53
|
* @public
|
|
61
54
|
*/
|
|
62
55
|
export function validateShellLanguageOptions(languageOptions) {
|
|
56
|
+
// ESLINT_SH_LANGUAGE_OPTION means a project language option cannot be honored,
|
|
57
|
+
// including combinations whose individual values would otherwise be valid.
|
|
63
58
|
// A removed key must not disappear during normalization: that would
|
|
64
59
|
// silently disable the consumer's compatibility requirement.
|
|
65
60
|
if ('shellVersion' in languageOptions) {
|
|
66
|
-
throw new TypeError('
|
|
61
|
+
throw Object.assign(new TypeError(configurationMessage('languageOptions.shellVersion', 'has been removed; use languageOptions.minBashVersion with dialect "bash" or "bats" instead', languageOptions.shellVersion)), { code: 'ESLINT_SH_LANGUAGE_OPTION' });
|
|
67
62
|
}
|
|
68
63
|
const { dialect, minBashVersion, directivePrefix } = languageOptions;
|
|
69
64
|
if (dialect !== undefined && !isShellDialect(dialect)) {
|
|
70
|
-
throw new TypeError(
|
|
65
|
+
throw Object.assign(new TypeError(configurationMessage('languageOptions.dialect', `must be one of ${SUPPORTED_SHELL_DIALECTS.join(', ')}`, dialect)), { code: 'ESLINT_SH_LANGUAGE_OPTION' });
|
|
71
66
|
}
|
|
72
67
|
if (minBashVersion !== undefined &&
|
|
73
68
|
dialect !== undefined &&
|
|
74
69
|
dialect !== 'bash' &&
|
|
75
70
|
dialect !== 'bats') {
|
|
76
|
-
throw new TypeError(
|
|
71
|
+
throw Object.assign(new TypeError(configurationMessage('languageOptions.minBashVersion', `applies only to bash and bats; dialect is "${dialect}". Remove minBashVersion or set dialect to "bash" or "bats"`, minBashVersion)), { code: 'ESLINT_SH_LANGUAGE_OPTION' });
|
|
77
72
|
}
|
|
78
73
|
if (minBashVersion !== undefined && typeof minBashVersion !== 'string') {
|
|
79
|
-
throw new TypeError(
|
|
74
|
+
throw Object.assign(new TypeError(configurationMessage('languageOptions.minBashVersion', 'must be a string (e.g. "3.2")', minBashVersion)), { code: 'ESLINT_SH_LANGUAGE_OPTION' });
|
|
80
75
|
}
|
|
81
76
|
if (typeof minBashVersion === 'string' && !isValidMinBashVersionShape(minBashVersion)) {
|
|
82
|
-
throw new TypeError(
|
|
77
|
+
throw Object.assign(new TypeError(configurationMessage('languageOptions.minBashVersion', 'must match the shape MAJOR[.MINOR] (e.g. "3.2", "5")', minBashVersion)), { code: 'ESLINT_SH_LANGUAGE_OPTION' });
|
|
83
78
|
}
|
|
84
79
|
if (directivePrefix !== undefined && !isValidDirectivePrefix(directivePrefix)) {
|
|
85
|
-
throw new TypeError(
|
|
80
|
+
throw Object.assign(new TypeError(configurationMessage('languageOptions.directivePrefix', 'must be one or more lowercase, hyphen-separated words (e.g. "eslint", "shellcheck-sh")', directivePrefix)), { code: 'ESLINT_SH_LANGUAGE_OPTION' });
|
|
86
81
|
}
|
|
87
82
|
}
|
|
88
83
|
/**
|
|
@@ -5,7 +5,8 @@ import { type NormalizedShellLanguageOptions, type ShellLanguageOptions } from '
|
|
|
5
5
|
/**
|
|
6
6
|
* `ShellLanguage` — the `@eslint/core` `Language` implementation for shell
|
|
7
7
|
* scripts. Registered by the plugin as `languages.sh`, so consumers select
|
|
8
|
-
* it via `language: "sh/sh"`.
|
|
8
|
+
* it via `language: "sh/sh"`. Its root export is type-only: `plugin.languages.sh`
|
|
9
|
+
* is the single runtime language handle, and the language pipeline owns source construction.
|
|
9
10
|
*
|
|
10
11
|
* Implements `matchesSelectorClass` (the six launch esquery selector
|
|
11
12
|
* classes — see `./selector-classes.js`), so rules and end users can write
|
|
@@ -33,6 +34,7 @@ export declare class ShellLanguage implements Language {
|
|
|
33
34
|
* label, if present). The removed `shellVersion` key throws with
|
|
34
35
|
* migration guidance; other unknown keys are silently ignored. See `shell-language-options.ts`'s
|
|
35
36
|
* `validateShellLanguageOptions` for the full rationale.
|
|
37
|
+
* @throws TypeError with `ESLINT_SH_LANGUAGE_OPTION` for an invalid project binding.
|
|
36
38
|
*/
|
|
37
39
|
validateLanguageOptions(languageOptions: ShellLanguageOptions): void;
|
|
38
40
|
/**
|