@eslint-sh/eslint-plugin 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -40
- package/dist/api.d.ts +92 -0
- package/dist/api.js +83 -0
- package/dist/command-harvest/builtins/bash.d.ts +1 -1
- package/dist/command-harvest/builtins/bash.js +1 -1
- package/dist/command-harvest/builtins/bats.d.ts +2 -0
- package/dist/command-harvest/builtins/bats.js +3 -0
- package/dist/command-harvest/harvest-commands.d.ts +2 -2
- package/dist/command-harvest/harvest-commands.js +2 -2
- package/dist/command-harvest/wrapper-table.d.ts +3 -19
- package/dist/command-harvest/wrapper-table.js +8 -38
- package/dist/configs/bash-3-2.d.ts +7 -6
- package/dist/configs/bash-3-2.js +4 -3
- package/dist/configs/posix-portable.d.ts +7 -11
- 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 +1506 -0
- package/dist/eslint-plugin-syntax-analyze.d.ts +3 -3
- package/dist/eslint-plugin-syntax.d.ts +7 -4
- package/dist/eslint-plugin.d.ts +16 -1514
- package/dist/index.d.ts +14 -78
- package/dist/index.js +22 -74
- package/dist/language/command-resolution.d.ts +5 -5
- package/dist/language/command-resolution.js +11 -7
- 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 +21 -18
- package/dist/language/shell-language-options.js +41 -39
- package/dist/language/shell-language.d.ts +13 -10
- package/dist/language/shell-language.js +23 -45
- package/dist/language/shell-source-code.d.ts +74 -49
- package/dist/language/shell-source-code.js +135 -68
- package/dist/language/source-coordinates.d.ts +2 -0
- package/dist/language/source-coordinates.js +8 -4
- package/dist/language/syntax-view.js +19 -7
- package/dist/language/word-resolution.d.ts +2 -1
- package/dist/language/word-resolution.js +8 -3
- package/dist/rules/bash-variable-semantics.d.ts +22 -0
- package/dist/rules/bash-variable-semantics.js +41 -0
- package/dist/rules/compat/create-compat-rule.js +1 -1
- package/dist/rules/compat/declaration-options.d.ts +2 -2
- package/dist/rules/compat/declaration-options.js +5 -2
- package/dist/rules/compat/no-append-all-redirect.js +1 -1
- package/dist/rules/compat/no-associative-arrays.js +2 -2
- package/dist/rules/compat/no-brace-sequence-padding-step.js +4 -4
- package/dist/rules/compat/no-case-attributes.js +3 -3
- package/dist/rules/compat/no-case-fallthrough.js +2 -2
- package/dist/rules/compat/no-case-modification.js +2 -2
- package/dist/rules/compat/no-coproc.js +1 -1
- package/dist/rules/compat/no-declare-g.js +3 -3
- package/dist/rules/compat/no-double-bracket.js +2 -2
- package/dist/rules/compat/no-epoch-variables.js +2 -2
- package/dist/rules/compat/no-fd-variable.js +1 -1
- package/dist/rules/compat/no-globstar.js +1 -1
- package/dist/rules/compat/no-lastpipe-semantics.js +2 -2
- package/dist/rules/compat/no-let.js +2 -1
- package/dist/rules/compat/no-mapfile.js +4 -2
- package/dist/rules/compat/no-nameref.js +3 -3
- package/dist/rules/compat/no-negative-array-index.js +39 -9
- package/dist/rules/compat/no-nounset-empty-array.js +15 -4
- package/dist/rules/compat/no-parameter-transformation.js +2 -2
- package/dist/rules/compat/no-pipe-all.js +1 -1
- package/dist/rules/compat/no-printf-time-format.js +4 -2
- package/dist/rules/compat/no-source.js +2 -1
- package/dist/rules/compat/no-test-v.js +4 -2
- package/dist/rules/compat/no-unicode-escape.js +2 -2
- package/dist/rules/compat/no-wait-n.js +4 -2
- package/dist/rules/compat/nounset-array-proof.d.ts +8 -0
- package/dist/rules/compat/nounset-array-proof.js +563 -0
- package/dist/rules/compat/posix-absent-command.d.ts +7 -8
- package/dist/rules/compat/posix-absent-command.js +17 -15
- package/dist/rules/compat/shopt-options.js +3 -1
- package/dist/rules/compat/version-gates.d.ts +9 -9
- package/dist/rules/compat/version-gates.js +13 -13
- package/dist/rules/create-wrapper-rule.d.ts +1 -1
- package/dist/rules/create-wrapper-rule.js +23 -16
- package/dist/rules/define-shell-rule.js +1 -1
- package/dist/rules/no-dynamic-invocation.d.ts +0 -8
- package/dist/rules/no-dynamic-invocation.js +7 -15
- package/dist/rules/no-eval.js +3 -1
- package/dist/rules/no-masked-exit-status.d.ts +4 -3
- package/dist/rules/no-masked-exit-status.js +18 -10
- package/dist/rules/no-secret-env-reads.d.ts +6 -3
- package/dist/rules/no-secret-env-reads.js +49 -15
- package/dist/rules/no-secret-flags.d.ts +4 -1
- package/dist/rules/no-secret-flags.js +21 -11
- package/dist/rules/no-unchecked-cd.js +6 -3
- package/dist/rules/no-undeclared-commands.d.ts +1 -15
- package/dist/rules/no-undeclared-commands.js +11 -18
- package/dist/rules/no-unused-declarations.d.ts +1 -18
- package/dist/rules/no-unused-declarations.js +15 -36
- package/dist/rules/prefer-local.d.ts +3 -2
- package/dist/rules/prefer-local.js +7 -4
- package/dist/rules/quote-expansions.js +3 -28
- package/dist/rules/require-network-wrapper.d.ts +3 -18
- package/dist/rules/require-network-wrapper.js +43 -10
- 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 +8 -1
- package/dist/rules/resolve-declaration-convention.d.ts +9 -89
- package/dist/rules/resolve-declaration-convention.js +19 -72
- package/dist/rules/resolve-network-wrapper.d.ts +20 -2
- package/dist/rules/resolve-network-wrapper.js +71 -36
- package/dist/rules/resolve-transparent-wrappers.d.ts +38 -0
- package/dist/rules/resolve-transparent-wrappers.js +108 -0
- package/dist/rules/set-options.d.ts +3 -2
- package/dist/rules/set-options.js +18 -6
- package/dist/rules/shebang-interpreter.js +4 -2
- 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 +4 -3
- package/dist/rules/transparent-wrappers.js +5 -4
- package/dist/rules/user-pattern.d.ts +9 -6
- package/dist/rules/user-pattern.js +16 -12
- package/dist/shell-dialect.d.ts +8 -0
- package/dist/shell-dialect.js +22 -0
- package/dist/syntax/analyze.d.ts +3 -3
- package/dist/syntax/analyze.js +3 -3
- package/dist/syntax/index.d.ts +7 -4
- package/dist/syntax/index.js +7 -4
- package/dist/version.js +2 -1
- package/docs/compat.md +81 -33
- package/docs/custom-rule-tutorial.md +31 -21
- package/docs/declaration-conventions.md +20 -23
- package/docs/error-codes.md +93 -0
- package/docs/examples/no-listed-commands-rule.ts +2 -2
- 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 +46 -6
- package/docs/rules/_template.md +2 -2
- package/docs/rules/compat/no-append-all-redirect.md +12 -12
- package/docs/rules/compat/no-associative-arrays.md +14 -14
- package/docs/rules/compat/no-brace-sequence-padding-step.md +12 -12
- package/docs/rules/compat/no-case-attributes.md +13 -13
- package/docs/rules/compat/no-case-fallthrough.md +12 -12
- package/docs/rules/compat/no-case-modification.md +11 -11
- package/docs/rules/compat/no-coproc.md +13 -13
- package/docs/rules/compat/no-declare-g.md +13 -13
- package/docs/rules/compat/no-double-bracket.md +2 -2
- package/docs/rules/compat/no-epoch-variables.md +13 -13
- package/docs/rules/compat/no-fd-variable.md +12 -12
- package/docs/rules/compat/no-globstar.md +13 -13
- package/docs/rules/compat/no-lastpipe-semantics.md +13 -13
- package/docs/rules/compat/no-let.md +2 -2
- package/docs/rules/compat/no-mapfile.md +16 -16
- package/docs/rules/compat/no-nameref.md +13 -13
- package/docs/rules/compat/no-negative-array-index.md +14 -14
- package/docs/rules/compat/no-nounset-empty-array.md +72 -17
- package/docs/rules/compat/no-parameter-transformation.md +19 -19
- package/docs/rules/compat/no-pipe-all.md +13 -13
- package/docs/rules/compat/no-printf-time-format.md +13 -13
- package/docs/rules/compat/no-source.md +2 -2
- package/docs/rules/compat/no-test-v.md +12 -12
- package/docs/rules/compat/no-unicode-escape.md +13 -13
- package/docs/rules/compat/no-wait-n.md +13 -13
- package/docs/rules/no-dynamic-invocation.md +17 -12
- package/docs/rules/no-eval.md +6 -1
- package/docs/rules/no-masked-exit-status.md +6 -2
- package/docs/rules/no-secret-env-reads.md +46 -5
- package/docs/rules/no-secret-flags.md +32 -6
- package/docs/rules/no-unchecked-cd.md +22 -2
- package/docs/rules/no-undeclared-commands.md +16 -15
- package/docs/rules/no-unused-declarations.md +17 -20
- package/docs/rules/prefer-local.md +20 -2
- package/docs/rules/quote-expansions.md +8 -5
- package/docs/rules/require-network-wrapper.md +26 -21
- package/docs/rules/require-shebang.md +10 -4
- package/docs/rules/require-strict-mode.md +31 -23
- package/docs/rules/require-tty-guard.md +12 -3
- package/docs/selectors.md +7 -2
- package/docs/shellcheck.md +9 -5
- package/docs/transparent-wrappers.md +97 -0
- package/docs/wrapper-rules.md +11 -0
- package/package.json +3 -3
- package/dist/declaration-conventions/read-declared-commands.d.ts +0 -70
- package/dist/language/end-of-input-marker.d.ts +0 -29
- package/dist/language/end-of-input-marker.js +0 -88
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolves project wrapper facts once per consuming rule. Shared facts precede
|
|
3
|
+
* the rule's built-in table, so an explicit option shape replaces the default
|
|
4
|
+
* for that name. Rules retain their distinct built-in scopes, but never their
|
|
5
|
+
* own interpretation of a configured project wrapper.
|
|
6
|
+
*
|
|
7
|
+
* ESLINT_SH_WRAPPER_SETTING rejects malformed bindings; ESLINT_SH_WRAPPER_CONFLICT rejects contradictory shared facts instead of choosing a policy by list order.
|
|
8
|
+
*/
|
|
9
|
+
import { configurationMessage } from '../configuration-message.js';
|
|
10
|
+
import { DEFAULT_TRANSPARENT_WRAPPERS } from 'sh-ast/analyze';
|
|
11
|
+
import { networkWrapperSpec, sameWrapperOptions, validateWrapperSetting, } from './resolve-network-wrapper.js';
|
|
12
|
+
/** The user-written setting path, extended with indices and fields in configuration errors. */
|
|
13
|
+
const SETTING = 'settings.sh.transparentWrappers';
|
|
14
|
+
/** A name-only entry preserves a known utility's default flag handling. */
|
|
15
|
+
function asSpec(value) {
|
|
16
|
+
if (typeof value !== 'string') {
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
19
|
+
return (DEFAULT_TRANSPARENT_WRAPPERS.find((spec) => spec.names.includes(value)) ?? { names: [value] });
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Returns the shared project wrappers followed by `builtIns` (defaults when
|
|
23
|
+
* omitted). Entries accept command names or JSON-expressible `WrapperSpec`s
|
|
24
|
+
* in `settings: { sh: { transparentWrappers: [...] } }`. The shared network
|
|
25
|
+
* wrapper is also transparent; conflicting specs for the same project name
|
|
26
|
+
* throw rather than allowing policies to disagree. Shared specs compare effective
|
|
27
|
+
* grammars for overlapping names, normalizing matcher defaults and retaining
|
|
28
|
+
* expanded built-in flag patterns; an extra transparent alias does not acquire
|
|
29
|
+
* network approval. Explicit specs remain complete replacements. Duplicate project
|
|
30
|
+
* names are rejected so list order cannot silently choose their meaning.
|
|
31
|
+
*
|
|
32
|
+
* Utility wrappers match absolute and relative paths by basename. Path words
|
|
33
|
+
* remain unchanged in analysis results. `shellBuiltin: true` entries match
|
|
34
|
+
* exact names only: an executable path cannot acquire in-process semantics.
|
|
35
|
+
* An explicit path spec takes precedence over a basename fallback regardless
|
|
36
|
+
* of configuration order.
|
|
37
|
+
* Aliases are built even when only `builtIns` are supplied. Overridden names
|
|
38
|
+
* are removed from lower-priority entries, preserving their unrelated aliases
|
|
39
|
+
* and preventing a utility entry from undoing an exact-name builtin override.
|
|
40
|
+
* The input tables are never mutated.
|
|
41
|
+
*
|
|
42
|
+
* @param context - The consuming rule's context.
|
|
43
|
+
* @param builtIns - The rule's own built-in wrapper scope.
|
|
44
|
+
* @throws Error with `ESLINT_SH_WRAPPER_SETTING` for malformed bindings, or
|
|
45
|
+
* `ESLINT_SH_WRAPPER_CONFLICT` for duplicate names or contradictory shared policies.
|
|
46
|
+
* @public
|
|
47
|
+
*/
|
|
48
|
+
export function resolveTransparentWrappers(context, builtIns = DEFAULT_TRANSPARENT_WRAPPERS) {
|
|
49
|
+
const sh = context.settings.sh;
|
|
50
|
+
const value = typeof sh === 'object' && sh !== null
|
|
51
|
+
? sh.transparentWrappers
|
|
52
|
+
: undefined;
|
|
53
|
+
if (value !== undefined && !Array.isArray(value)) {
|
|
54
|
+
throw Object.assign(new Error(configurationMessage(SETTING, 'expected an array of command names or wrapper specs', value)), { code: 'ESLINT_SH_WRAPPER_SETTING' });
|
|
55
|
+
}
|
|
56
|
+
const configured = (value ?? []).map((entry, index) => asSpec(validateWrapperSetting(entry, `${SETTING}[${String(index)}]`)));
|
|
57
|
+
const names = new Set();
|
|
58
|
+
for (const [index, spec] of configured.entries()) {
|
|
59
|
+
for (const name of spec.names) {
|
|
60
|
+
if (names.has(name)) {
|
|
61
|
+
throw Object.assign(new Error(configurationMessage(`${SETTING}[${String(index)}]`, `duplicate wrapper name ${JSON.stringify(name)}`, value?.[index])), { code: 'ESLINT_SH_WRAPPER_CONFLICT' });
|
|
62
|
+
}
|
|
63
|
+
names.add(name);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const network = networkWrapperSpec(context.settings);
|
|
67
|
+
for (const [index, spec] of configured.entries()) {
|
|
68
|
+
if (network !== null &&
|
|
69
|
+
spec.names.some((name) => network.names.includes(name)) &&
|
|
70
|
+
!sameWrapperOptions(spec, network)) {
|
|
71
|
+
throw Object.assign(new Error(configurationMessage(`${SETTING}[${String(index)}]`, 'wrapper spec conflicts with settings.sh.networkWrapper', value?.[index])), { code: 'ESLINT_SH_WRAPPER_CONFLICT' });
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
// Precedence applies to names, including their path-matching semantics.
|
|
75
|
+
// Keeping a shadowed utility name could recreate an alias that a higher
|
|
76
|
+
// priority shellBuiltin entry explicitly excludes.
|
|
77
|
+
const table = [];
|
|
78
|
+
const claimed = new Set();
|
|
79
|
+
for (const spec of [...configured, ...(network === null ? [] : [network]), ...builtIns]) {
|
|
80
|
+
const remaining = spec.names.filter((name) => !claimed.has(name));
|
|
81
|
+
if (remaining.length === 0) {
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
table.push(remaining.length === spec.names.length ? spec : { ...spec, names: remaining });
|
|
85
|
+
for (const name of remaining) {
|
|
86
|
+
claimed.add(name);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// Relative utility paths need exact aliases in sh-ast. Derive them only from
|
|
90
|
+
// static argv words in this file; no path is resolved or executed here.
|
|
91
|
+
const paths = new Map();
|
|
92
|
+
for (const site of context.sourceCode.getCommandSites()) {
|
|
93
|
+
for (const word of site.argv) {
|
|
94
|
+
if (!word.static || !word.text.includes('/') || paths.has(word.text)) {
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
const base = word.text.slice(word.text.lastIndexOf('/') + 1);
|
|
98
|
+
const spec = table.find((entry) => entry.names.includes(word.text)) ??
|
|
99
|
+
table.find((entry) => entry.shellBuiltin !== true && entry.names.includes(base));
|
|
100
|
+
// Keep the selected exact spelling ahead of generic entries; deriving
|
|
101
|
+
// an alias from an earlier basename would erase an explicit path's flags.
|
|
102
|
+
if (spec !== undefined) {
|
|
103
|
+
paths.set(word.text, { ...spec, names: [word.text] });
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return [...paths.values(), ...table];
|
|
108
|
+
}
|
|
@@ -90,7 +90,7 @@ export declare function applySetOptionChanges(enabled: Set<string>, changes: rea
|
|
|
90
90
|
export declare function formatSetCommand(options: readonly string[]): string;
|
|
91
91
|
/**
|
|
92
92
|
* The option changes the shebang line passes to the shell (read by
|
|
93
|
-
*
|
|
93
|
+
* the shared prologue definition and by
|
|
94
94
|
* `compat/no-nounset-empty-array`). Only spellings the kernel hands to the shell as written
|
|
95
95
|
* are read:
|
|
96
96
|
*
|
|
@@ -99,7 +99,8 @@ export declare function formatSetCommand(options: readonly string[]): string;
|
|
|
99
99
|
* (`#!/bin/bash -eu`); more than one word (`#!/bin/bash -e -u`) arrives as a
|
|
100
100
|
* single argument the shell rejects, and counts as nothing.
|
|
101
101
|
* - `#!/usr/bin/env -S <shell> <words…>`: `env -S` splits the rest into words,
|
|
102
|
-
* so every word after the shell name is read.
|
|
102
|
+
* so every word after the shell name is read. GNU env's
|
|
103
|
+
* `--split-string=<shell> <words…>` is read the same way; macOS env supports only `-S`.
|
|
103
104
|
*
|
|
104
105
|
* Plain `#!/usr/bin/env <shell> <flags>` counts as nothing: without `-S`,
|
|
105
106
|
* Linux passes `<shell> <flags>` to `env` as one command name.
|
|
@@ -159,7 +159,7 @@ export function formatSetCommand(options) {
|
|
|
159
159
|
}
|
|
160
160
|
/**
|
|
161
161
|
* The option changes the shebang line passes to the shell (read by
|
|
162
|
-
*
|
|
162
|
+
* the shared prologue definition and by
|
|
163
163
|
* `compat/no-nounset-empty-array`). Only spellings the kernel hands to the shell as written
|
|
164
164
|
* are read:
|
|
165
165
|
*
|
|
@@ -168,7 +168,8 @@ export function formatSetCommand(options) {
|
|
|
168
168
|
* (`#!/bin/bash -eu`); more than one word (`#!/bin/bash -e -u`) arrives as a
|
|
169
169
|
* single argument the shell rejects, and counts as nothing.
|
|
170
170
|
* - `#!/usr/bin/env -S <shell> <words…>`: `env -S` splits the rest into words,
|
|
171
|
-
* so every word after the shell name is read.
|
|
171
|
+
* so every word after the shell name is read. GNU env's
|
|
172
|
+
* `--split-string=<shell> <words…>` is read the same way; macOS env supports only `-S`.
|
|
172
173
|
*
|
|
173
174
|
* Plain `#!/usr/bin/env <shell> <flags>` counts as nothing: without `-S`,
|
|
174
175
|
* Linux passes `<shell> <flags>` to `env` as one command name.
|
|
@@ -184,13 +185,24 @@ export function shebangOptionChanges(text) {
|
|
|
184
185
|
.trim()
|
|
185
186
|
.split(/\s+/u);
|
|
186
187
|
const [interpreter = '', ...rest] = words;
|
|
187
|
-
|
|
188
|
+
// Relative interpreters are resolved against the caller's directory, never through PATH.
|
|
189
|
+
if (!interpreter.startsWith('/'))
|
|
190
|
+
return [];
|
|
191
|
+
const isEnv = interpreter.endsWith('/env');
|
|
188
192
|
let flagWords;
|
|
189
193
|
if (isEnv) {
|
|
190
|
-
const [split, , ...shellArgs] = rest;
|
|
191
|
-
|
|
194
|
+
const [split = '', , ...shellArgs] = rest;
|
|
195
|
+
// The kernel's single argument makes `--split-string bash -eu` an unknown long option.
|
|
196
|
+
if (split === '-S') {
|
|
197
|
+
flagWords = shellArgs;
|
|
198
|
+
}
|
|
199
|
+
else if (split.startsWith('--split-string=')) {
|
|
200
|
+
// The first word carries the command when attached; an empty value puts it next.
|
|
201
|
+
flagWords = rest.slice(split === '--split-string=' ? 2 : 1);
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
192
204
|
return [];
|
|
193
|
-
|
|
205
|
+
}
|
|
194
206
|
}
|
|
195
207
|
else {
|
|
196
208
|
if (rest.length !== 1)
|
|
@@ -34,9 +34,11 @@ function envCommand(words) {
|
|
|
34
34
|
if (word === '--') {
|
|
35
35
|
return words.slice(index + 1).find((operand) => !ENV_ASSIGNMENT.test(operand));
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
// GNU env sees the whole kernel argument as an option name unless the long form uses '='.
|
|
38
|
+
if (word === '--split-string')
|
|
39
|
+
return undefined;
|
|
40
|
+
if (word === '-S')
|
|
38
41
|
continue;
|
|
39
|
-
}
|
|
40
42
|
if (word.startsWith('--split-string=')) {
|
|
41
43
|
return word.slice('--split-string='.length) || words[index + 1];
|
|
42
44
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { SettingsConfig } from '@eslint/core';
|
|
2
|
+
import type { ShellFile, ShellNodeOf } from '../language/syntax-view.js';
|
|
3
|
+
import type { ShellSourceCode } from '../language/shell-source-code.js';
|
|
4
|
+
import type { SetOptionChange } from './set-options.js';
|
|
5
|
+
/** The normalized project definition, independent of any required option list. @internal */
|
|
6
|
+
export interface StrictModePrologue {
|
|
7
|
+
/** Whether interpreter flags count, despite being bypassed by `bash script.sh`. */
|
|
8
|
+
readonly allowShebangOnly: boolean;
|
|
9
|
+
/** Positive number of top-level statements whose final option state counts. */
|
|
10
|
+
readonly withinStatements: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Normalizes the shared project fact at rule creation, following the other
|
|
14
|
+
* shared-settings resolvers: absence uses defaults, malformed explicit values
|
|
15
|
+
* throw a named configuration error. No cache can leak a file's configuration.
|
|
16
|
+
* @throws Error with `ESLINT_SH_STRICT_MODE_SETTING` for malformed shared project facts.
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
export declare function resolveStrictModePrologue(settings: SettingsConfig): StrictModePrologue;
|
|
20
|
+
/**
|
|
21
|
+
* Whether `stmt` is a plain, foreground, top-level `set` command, and if so
|
|
22
|
+
* the option changes its arguments make (read through `sourceCode`, so a
|
|
23
|
+
* non-static argument ends the reading).
|
|
24
|
+
*
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
export declare function setStatementChanges(stmt: ShellNodeOf<'Stmt'>, sourceCode: ShellSourceCode): readonly SetOptionChange[];
|
|
28
|
+
/**
|
|
29
|
+
* The options enabled after applying `seed`, then each statement's `set`
|
|
30
|
+
* changes in order.
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
export declare function enabledAfter(seed: readonly SetOptionChange[], statementChanges: readonly (readonly SetOptionChange[])[]): Set<string>;
|
|
34
|
+
/**
|
|
35
|
+
* The options a file's prologue leaves enabled: the state after the first
|
|
36
|
+
* `withinStatements` top-level statements of `file`, plus the shebang's
|
|
37
|
+
* options when `allowShebangOnly` is set. This is the single definition of
|
|
38
|
+
* "what the prologue enables", shared with other rules (such as
|
|
39
|
+
* `no-unchecked-cd`) that need to know whether strict mode is in force.
|
|
40
|
+
*
|
|
41
|
+
* @internal
|
|
42
|
+
*/
|
|
43
|
+
export declare function prologueEnabledOptions(file: ShellFile, sourceCode: ShellSourceCode, config: StrictModePrologue): ReadonlySet<string>;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shared definition of where a script establishes shell options. Policy
|
|
3
|
+
* rules consume the same normalized project fact, without owning one another's
|
|
4
|
+
* requirements or retaining state across configs or files.
|
|
5
|
+
* ESLINT_SH_STRICT_MODE_SETTING identifies a malformed project prologue fact;
|
|
6
|
+
* rule-option schema failures remain ESLint responsibilities.
|
|
7
|
+
*/
|
|
8
|
+
import { configurationMessage } from '../configuration-message.js';
|
|
9
|
+
import { applySetOptionChanges, parseSetArguments, shebangOptionChanges } from './set-options.js';
|
|
10
|
+
/** The user-written path of the shared project fact, extended with its offending field. */
|
|
11
|
+
const SETTING = 'settings.sh.strictModePrologue';
|
|
12
|
+
/**
|
|
13
|
+
* Normalizes the shared project fact at rule creation, following the other
|
|
14
|
+
* shared-settings resolvers: absence uses defaults, malformed explicit values
|
|
15
|
+
* throw a named configuration error. No cache can leak a file's configuration.
|
|
16
|
+
* @throws Error with `ESLINT_SH_STRICT_MODE_SETTING` for malformed shared project facts.
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
export function resolveStrictModePrologue(settings) {
|
|
20
|
+
const sh = settings.sh;
|
|
21
|
+
const value = typeof sh === 'object' && sh !== null && 'strictModePrologue' in sh
|
|
22
|
+
? sh.strictModePrologue
|
|
23
|
+
: undefined;
|
|
24
|
+
if (value === undefined) {
|
|
25
|
+
return { allowShebangOnly: false, withinStatements: 5 };
|
|
26
|
+
}
|
|
27
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
28
|
+
throw Object.assign(new Error(configurationMessage(SETTING, 'expected a prologue definition object', value)), { code: 'ESLINT_SH_STRICT_MODE_SETTING' });
|
|
29
|
+
}
|
|
30
|
+
for (const key of Object.keys(value)) {
|
|
31
|
+
if (key !== 'allowShebangOnly' && key !== 'withinStatements') {
|
|
32
|
+
throw Object.assign(new Error(configurationMessage(`${SETTING}.${key}`, 'unknown prologue definition field', value[key])), { code: 'ESLINT_SH_STRICT_MODE_SETTING' });
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const allowShebangOnly = 'allowShebangOnly' in value ? value.allowShebangOnly : undefined;
|
|
36
|
+
const withinStatements = 'withinStatements' in value ? value.withinStatements : undefined;
|
|
37
|
+
if (allowShebangOnly !== undefined && typeof allowShebangOnly !== 'boolean') {
|
|
38
|
+
throw Object.assign(new Error(configurationMessage(`${SETTING}.allowShebangOnly`, 'must be a boolean', allowShebangOnly)), { code: 'ESLINT_SH_STRICT_MODE_SETTING' });
|
|
39
|
+
}
|
|
40
|
+
if (withinStatements !== undefined &&
|
|
41
|
+
(typeof withinStatements !== 'number' ||
|
|
42
|
+
!Number.isInteger(withinStatements) ||
|
|
43
|
+
withinStatements < 1)) {
|
|
44
|
+
throw Object.assign(new Error(configurationMessage(`${SETTING}.withinStatements`, 'must be a positive integer', withinStatements)), { code: 'ESLINT_SH_STRICT_MODE_SETTING' });
|
|
45
|
+
}
|
|
46
|
+
return { allowShebangOnly: allowShebangOnly ?? false, withinStatements: withinStatements ?? 5 };
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Whether `stmt` is a plain, foreground, top-level `set` command, and if so
|
|
50
|
+
* the option changes its arguments make (read through `sourceCode`, so a
|
|
51
|
+
* non-static argument ends the reading).
|
|
52
|
+
*
|
|
53
|
+
* @internal
|
|
54
|
+
*/
|
|
55
|
+
export function setStatementChanges(stmt, sourceCode) {
|
|
56
|
+
if (stmt.background) {
|
|
57
|
+
return [];
|
|
58
|
+
}
|
|
59
|
+
const { cmd } = stmt;
|
|
60
|
+
if (cmd?.type !== 'CallExpr' || sourceCode.getCommandName(cmd) !== 'set') {
|
|
61
|
+
return [];
|
|
62
|
+
}
|
|
63
|
+
const args = cmd.args.slice(1);
|
|
64
|
+
return parseSetArguments(args.map((word) => sourceCode.resolveWordText(word))).changes;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* The options enabled after applying `seed`, then each statement's `set`
|
|
68
|
+
* changes in order.
|
|
69
|
+
* @internal
|
|
70
|
+
*/
|
|
71
|
+
export function enabledAfter(seed, statementChanges) {
|
|
72
|
+
const enabled = applySetOptionChanges(new Set(), seed);
|
|
73
|
+
for (const changes of statementChanges) {
|
|
74
|
+
applySetOptionChanges(enabled, changes);
|
|
75
|
+
}
|
|
76
|
+
return enabled;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The options a file's prologue leaves enabled: the state after the first
|
|
80
|
+
* `withinStatements` top-level statements of `file`, plus the shebang's
|
|
81
|
+
* options when `allowShebangOnly` is set. This is the single definition of
|
|
82
|
+
* "what the prologue enables", shared with other rules (such as
|
|
83
|
+
* `no-unchecked-cd`) that need to know whether strict mode is in force.
|
|
84
|
+
*
|
|
85
|
+
* @internal
|
|
86
|
+
*/
|
|
87
|
+
export function prologueEnabledOptions(file, sourceCode, config) {
|
|
88
|
+
const shebangChanges = config.allowShebangOnly ? shebangOptionChanges(sourceCode.text) : [];
|
|
89
|
+
const statements = file.stmts.slice(0, config.withinStatements);
|
|
90
|
+
return enabledAfter(shebangChanges, statements.map((stmt) => setStatementChanges(stmt, sourceCode)));
|
|
91
|
+
}
|
|
@@ -11,7 +11,8 @@ import type { WrapperSpec } from 'sh-ast/analyze';
|
|
|
11
11
|
/**
|
|
12
12
|
* Bash's `builtin [shell-builtin [args …]]`: runs the named builtin, bypassing
|
|
13
13
|
* any function of the same name. It takes no options of its own, so the word
|
|
14
|
-
* after it is the command it runs.
|
|
14
|
+
* after it is the command it runs. Only the exact builtin name has these
|
|
15
|
+
* semantics; an executable path with the same basename is an ordinary program.
|
|
15
16
|
*
|
|
16
17
|
* `sh-ast/analyze`'s default wrapper table leaves `builtin` out, so
|
|
17
18
|
* `builtin "$x"` would otherwise resolve to the static command `builtin`.
|
|
@@ -42,8 +43,8 @@ export declare const BUILTIN_WRAPPER: WrapperSpec;
|
|
|
42
43
|
* clusters ending in `c` or `s` are listed as exact tokens. Longer clusters
|
|
43
44
|
* (`-xec`) end in `'unknown-flag'`.
|
|
44
45
|
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
46
|
+
* Wrapper names also match the final segment of absolute paths (`/bin/bash`).
|
|
47
|
+
* Relative paths require an exact table entry.
|
|
47
48
|
*
|
|
48
49
|
* @see https://www.gnu.org/software/bash/manual/bash.html#Invoking-Bash
|
|
49
50
|
* @see https://pubs.opengroup.org/onlinepubs/9699919799/utilities/sh.html — POSIX `sh`
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Bash's `builtin [shell-builtin [args …]]`: runs the named builtin, bypassing
|
|
3
3
|
* any function of the same name. It takes no options of its own, so the word
|
|
4
|
-
* after it is the command it runs.
|
|
4
|
+
* after it is the command it runs. Only the exact builtin name has these
|
|
5
|
+
* semantics; an executable path with the same basename is an ordinary program.
|
|
5
6
|
*
|
|
6
7
|
* `sh-ast/analyze`'s default wrapper table leaves `builtin` out, so
|
|
7
8
|
* `builtin "$x"` would otherwise resolve to the static command `builtin`.
|
|
@@ -9,7 +10,7 @@
|
|
|
9
10
|
* @see https://www.gnu.org/software/bash/manual/bash.html#Bash-Builtins — `builtin`
|
|
10
11
|
* @internal
|
|
11
12
|
*/
|
|
12
|
-
export const BUILTIN_WRAPPER = { names: ['builtin'] };
|
|
13
|
+
export const BUILTIN_WRAPPER = { names: ['builtin'], shellBuiltin: true };
|
|
13
14
|
/**
|
|
14
15
|
* The single-letter shell options that take no operand when a shell is
|
|
15
16
|
* invoked: every option letter the `set` builtin accepts, plus Bash's
|
|
@@ -67,8 +68,8 @@ const SHELL_NO_ARG_LETTERS = [
|
|
|
67
68
|
* clusters ending in `c` or `s` are listed as exact tokens. Longer clusters
|
|
68
69
|
* (`-xec`) end in `'unknown-flag'`.
|
|
69
70
|
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
71
|
+
* Wrapper names also match the final segment of absolute paths (`/bin/bash`).
|
|
72
|
+
* Relative paths require an exact table entry.
|
|
72
73
|
*
|
|
73
74
|
* @see https://www.gnu.org/software/bash/manual/bash.html#Invoking-Bash
|
|
74
75
|
* @see https://pubs.opengroup.org/onlinepubs/9699919799/utilities/sh.html — POSIX `sh`
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Compiling regular-expression sources that a rule takes from its options and
|
|
3
|
-
* tests against text from the linted script.
|
|
3
|
+
* tests against text from the linted script. Every source uses Unicode (`u`)
|
|
4
|
+
* semantics; callers choose whether matching also ignores case.
|
|
4
5
|
*
|
|
5
6
|
* The configuration is trusted, but the subject is not: when the plugin lints
|
|
6
7
|
* a repository it does not control, the script's author picks the names a
|
|
@@ -28,7 +29,7 @@
|
|
|
28
29
|
*
|
|
29
30
|
* @internal
|
|
30
31
|
*/
|
|
31
|
-
|
|
32
|
+
interface NestedRepetition {
|
|
32
33
|
/** The outer repeating quantifier as written, such as `*` or `{2,}`. */
|
|
33
34
|
readonly outer: string;
|
|
34
35
|
/** The text of the group the outer quantifier repeats, such as `([A-Z]+_?)`. */
|
|
@@ -44,20 +45,22 @@ export interface NestedRepetition {
|
|
|
44
45
|
*
|
|
45
46
|
* @internal
|
|
46
47
|
*/
|
|
47
|
-
|
|
48
|
+
declare function findNestedRepetition(source: string): NestedRepetition | undefined;
|
|
48
49
|
/**
|
|
49
50
|
* Compiles a regular-expression source from a rule option that will be tested
|
|
50
51
|
* against script-controlled text. Throws a `TypeError` naming the rule and the
|
|
51
|
-
* option when
|
|
52
|
+
* option and source when it is not a valid Unicode expression, or when it nests one
|
|
52
53
|
* repetition inside another (see {@link findNestedRepetition}). ESLint reports
|
|
53
54
|
* the error from the rule's `create()`, so it surfaces on the first file linted
|
|
54
55
|
* with the rule ("Occurred while linting <file>"), not when the config loads.
|
|
55
56
|
*
|
|
56
|
-
* @param rule - The rule
|
|
57
|
+
* @param rule - The configured rule ID (context.id), including the caller's plugin namespace.
|
|
57
58
|
* @param option - The option as the user wrote it, such as `patterns[0]`.
|
|
58
59
|
* @param source - The regular-expression source.
|
|
59
|
-
* @param flags -
|
|
60
|
+
* @param flags - Rule-specific flags. Unicode semantics are always added;
|
|
61
|
+
* case-insensitivity is preserved without changing the subject or source.
|
|
60
62
|
*
|
|
61
63
|
* @internal
|
|
62
64
|
*/
|
|
63
65
|
export declare function compileUserPattern(rule: string, option: string, source: string, flags: string): RegExp;
|
|
66
|
+
export { findNestedRepetition };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Compiling regular-expression sources that a rule takes from its options and
|
|
3
|
-
* tests against text from the linted script.
|
|
3
|
+
* tests against text from the linted script. Every source uses Unicode (`u`)
|
|
4
|
+
* semantics; callers choose whether matching also ignores case.
|
|
4
5
|
*
|
|
5
6
|
* The configuration is trusted, but the subject is not: when the plugin lints
|
|
6
7
|
* a repository it does not control, the script's author picks the names a
|
|
@@ -23,6 +24,7 @@
|
|
|
23
24
|
*
|
|
24
25
|
* @see https://github.com/mike-north/eslint-sh/issues/221
|
|
25
26
|
*/
|
|
27
|
+
import { configurationMessage } from '../configuration-message.js';
|
|
26
28
|
/** Matches a `{n}`, `{n,}` or `{n,m}` quantifier at the start of the string. */
|
|
27
29
|
const BRACE_QUANTIFIER = /^\{\d+(?:,\d*)?\}/u;
|
|
28
30
|
/**
|
|
@@ -102,7 +104,7 @@ function skipClass(source, i) {
|
|
|
102
104
|
*
|
|
103
105
|
* @internal
|
|
104
106
|
*/
|
|
105
|
-
|
|
107
|
+
function findNestedRepetition(source) {
|
|
106
108
|
const stack = [{ start: 0, containsRepetition: false }];
|
|
107
109
|
let i = 0;
|
|
108
110
|
while (i < source.length) {
|
|
@@ -153,32 +155,34 @@ export function findNestedRepetition(source) {
|
|
|
153
155
|
/**
|
|
154
156
|
* Compiles a regular-expression source from a rule option that will be tested
|
|
155
157
|
* against script-controlled text. Throws a `TypeError` naming the rule and the
|
|
156
|
-
* option when
|
|
158
|
+
* option and source when it is not a valid Unicode expression, or when it nests one
|
|
157
159
|
* repetition inside another (see {@link findNestedRepetition}). ESLint reports
|
|
158
160
|
* the error from the rule's `create()`, so it surfaces on the first file linted
|
|
159
161
|
* with the rule ("Occurred while linting <file>"), not when the config loads.
|
|
160
162
|
*
|
|
161
|
-
* @param rule - The rule
|
|
163
|
+
* @param rule - The configured rule ID (context.id), including the caller's plugin namespace.
|
|
162
164
|
* @param option - The option as the user wrote it, such as `patterns[0]`.
|
|
163
165
|
* @param source - The regular-expression source.
|
|
164
|
-
* @param flags -
|
|
166
|
+
* @param flags - Rule-specific flags. Unicode semantics are always added;
|
|
167
|
+
* case-insensitivity is preserved without changing the subject or source.
|
|
165
168
|
*
|
|
166
169
|
* @internal
|
|
167
170
|
*/
|
|
168
171
|
export function compileUserPattern(rule, option, source, flags) {
|
|
169
172
|
let pattern;
|
|
170
173
|
try {
|
|
171
|
-
pattern = new RegExp(source, flags);
|
|
174
|
+
pattern = new RegExp(source, flags.includes('u') ? flags : `${flags}u`);
|
|
172
175
|
}
|
|
173
|
-
catch {
|
|
174
|
-
|
|
176
|
+
catch (cause) {
|
|
177
|
+
// Syntax and policy refusal are separate identities: only syntax has a compiler cause.
|
|
178
|
+
throw Object.assign(new TypeError(configurationMessage(`rules[${JSON.stringify(rule)}].${option}`, 'must be a valid regular expression', source), { cause }), { code: 'ESLINT_SH_PATTERN_SYNTAX' });
|
|
175
179
|
}
|
|
176
180
|
const nested = findNestedRepetition(source);
|
|
177
181
|
if (nested !== undefined) {
|
|
178
|
-
throw new TypeError(
|
|
179
|
-
'
|
|
180
|
-
'
|
|
181
|
-
'of repetition, for example `[A-Z0-9_]*` instead of `([A-Z]+_?)*`.');
|
|
182
|
+
throw Object.assign(new TypeError(configurationMessage(`rules[${JSON.stringify(rule)}].${option}`, `repeats ${nested.group} with \`${nested.outer}\`, and that group already repeats. ` +
|
|
183
|
+
'The pattern runs against names the linted script chooses, and a nested repetition can take exponential time on a long name. ' +
|
|
184
|
+
'Rewrite it with one level of repetition, for example `[A-Z0-9_]*` instead of `([A-Z]+_?)*`', source)), { code: 'ESLINT_SH_PATTERN_REPETITION' });
|
|
182
185
|
}
|
|
183
186
|
return pattern;
|
|
184
187
|
}
|
|
188
|
+
export { findNestedRepetition };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Project names for the five supported shell grammars. @public */
|
|
2
|
+
export type ShellDialect = 'bash' | 'posix' | 'mksh' | 'bats' | 'zsh';
|
|
3
|
+
/** The single project-label translation to the pinned parser's grammar constants. @internal */
|
|
4
|
+
export declare const SHELL_VARIANTS: Readonly<Record<ShellDialect, number>>;
|
|
5
|
+
/** Stable diagnostic ordering follows the canonical mapping, without another hand-maintained list. @internal */
|
|
6
|
+
export declare const SUPPORTED_SHELL_DIALECTS: readonly string[];
|
|
7
|
+
/** Labels are own keys; object-prototype names never select a grammar. @internal */
|
|
8
|
+
export declare function isShellDialect(value: unknown): value is ShellDialect;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Generated from shared/shell-dialect.ts; edit the canonical source.
|
|
2
|
+
/**
|
|
3
|
+
* Project shell vocabulary shared by linting and non-lint services. A label
|
|
4
|
+
* selects one definite grammar; parser constants are an implementation detail.
|
|
5
|
+
* This module is compiled into each consumer artifact, so shared semantics do
|
|
6
|
+
* not require a runtime dependency between separately released packages.
|
|
7
|
+
*/
|
|
8
|
+
import { LangBash, LangBats, LangMirBSDKorn, LangPOSIX, LangZsh } from 'sh-ast';
|
|
9
|
+
/** The single project-label translation to the pinned parser's grammar constants. @internal */
|
|
10
|
+
export const SHELL_VARIANTS = {
|
|
11
|
+
bash: LangBash,
|
|
12
|
+
posix: LangPOSIX,
|
|
13
|
+
mksh: LangMirBSDKorn,
|
|
14
|
+
bats: LangBats,
|
|
15
|
+
zsh: LangZsh,
|
|
16
|
+
};
|
|
17
|
+
/** Stable diagnostic ordering follows the canonical mapping, without another hand-maintained list. @internal */
|
|
18
|
+
export const SUPPORTED_SHELL_DIALECTS = Object.keys(SHELL_VARIANTS);
|
|
19
|
+
/** Labels are own keys; object-prototype names never select a grammar. @internal */
|
|
20
|
+
export function isShellDialect(value) {
|
|
21
|
+
return typeof value === 'string' && Object.hasOwn(SHELL_VARIANTS, value);
|
|
22
|
+
}
|
package/dist/syntax/analyze.d.ts
CHANGED
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
* arguments in its site's `argv`), `DEFAULT_TRANSPARENT_WRAPPERS`, `WrapperSpec`, the raw
|
|
8
8
|
* `resolveWord(Node)`, and the named operator constants with `rawOperator` for comparing and
|
|
9
9
|
* constructing the operator values those records carry. All of it works on the faithful records
|
|
10
|
-
* from `@eslint-sh/eslint-plugin/syntax`.
|
|
11
|
-
* `
|
|
12
|
-
*
|
|
10
|
+
* from `@eslint-sh/eslint-plugin/syntax`. For lint-view Word nodes, rules use
|
|
11
|
+
* `context.sourceCode.resolveWord(word)`, whose default policy comes from grammar position.
|
|
12
|
+
* This raw analyzer retains upstream defaults and never infers lint-view context.
|
|
13
13
|
*
|
|
14
14
|
* Like `@eslint-sh/eslint-plugin/syntax`, it tracks the plugin's pinned `sh-ast` minor and never
|
|
15
15
|
* wraps or renames anything.
|
package/dist/syntax/analyze.js
CHANGED
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
* arguments in its site's `argv`), `DEFAULT_TRANSPARENT_WRAPPERS`, `WrapperSpec`, the raw
|
|
10
10
|
* `resolveWord(Node)`, and the named operator constants with `rawOperator` for comparing and
|
|
11
11
|
* constructing the operator values those records carry. All of it works on the faithful records
|
|
12
|
-
* from `@eslint-sh/eslint-plugin/syntax`.
|
|
13
|
-
* `
|
|
14
|
-
*
|
|
12
|
+
* from `@eslint-sh/eslint-plugin/syntax`. For lint-view Word nodes, rules use
|
|
13
|
+
* `context.sourceCode.resolveWord(word)`, whose default policy comes from grammar position.
|
|
14
|
+
* This raw analyzer retains upstream defaults and never infers lint-view context.
|
|
15
15
|
*
|
|
16
16
|
* Like `@eslint-sh/eslint-plugin/syntax`, it tracks the plugin's pinned `sh-ast` minor and never
|
|
17
17
|
* wraps or renames anything.
|
package/dist/syntax/index.d.ts
CHANGED
|
@@ -13,10 +13,13 @@
|
|
|
13
13
|
*
|
|
14
14
|
* This entry point tracks the plugin's pinned `sh-ast` minor, so an `sh-ast` 0.x minor bump is a
|
|
15
15
|
* minor release of this plugin. It never wraps or renames anything: every name has `sh-ast`'s
|
|
16
|
-
* own contract.
|
|
17
|
-
*
|
|
18
|
-
* `@eslint-sh/eslint-plugin/syntax/analyze
|
|
19
|
-
*
|
|
16
|
+
* own contract. Rules analyze lint-view words through `context.sourceCode.resolveWord(word)`,
|
|
17
|
+
* which supplies the word's grammar context. Raw syntax analysis lives in
|
|
18
|
+
* `@eslint-sh/eslint-plugin/syntax/analyze`, separate from the lint view.
|
|
19
|
+
*
|
|
20
|
+
* The low-level `printSync` keeps upstream behavior, including changes to literal vertical tabs
|
|
21
|
+
* and form feeds. It does not apply the high-level content refusal used by `format` and
|
|
22
|
+
* `ShellSourceCode.getPrintedReplacement`; callers printing directly must account for that loss.
|
|
20
23
|
*
|
|
21
24
|
* @packageDocumentation
|
|
22
25
|
*/
|
package/dist/syntax/index.js
CHANGED
|
@@ -15,10 +15,13 @@
|
|
|
15
15
|
*
|
|
16
16
|
* This entry point tracks the plugin's pinned `sh-ast` minor, so an `sh-ast` 0.x minor bump is a
|
|
17
17
|
* minor release of this plugin. It never wraps or renames anything: every name has `sh-ast`'s
|
|
18
|
-
* own contract.
|
|
19
|
-
*
|
|
20
|
-
* `@eslint-sh/eslint-plugin/syntax/analyze
|
|
21
|
-
*
|
|
18
|
+
* own contract. Rules analyze lint-view words through `context.sourceCode.resolveWord(word)`,
|
|
19
|
+
* which supplies the word's grammar context. Raw syntax analysis lives in
|
|
20
|
+
* `@eslint-sh/eslint-plugin/syntax/analyze`, separate from the lint view.
|
|
21
|
+
*
|
|
22
|
+
* The low-level `printSync` keeps upstream behavior, including changes to literal vertical tabs
|
|
23
|
+
* and form feeds. It does not apply the high-level content refusal used by `format` and
|
|
24
|
+
* `ShellSourceCode.getPrintedReplacement`; callers printing directly must account for that loss.
|
|
22
25
|
*
|
|
23
26
|
* @packageDocumentation
|
|
24
27
|
*/
|
package/dist/version.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** Plugin version metadata comes from its own package; ESLINT_SH_PACKAGE_METADATA identifies an invalid package shape. Filesystem/JSON exceptions retain their native identity. */
|
|
1
2
|
import { readFileSync } from 'node:fs';
|
|
2
3
|
import { dirname, join } from 'node:path';
|
|
3
4
|
import { fileURLToPath } from 'node:url';
|
|
@@ -24,5 +25,5 @@ export function readPackageVersion() {
|
|
|
24
25
|
typeof parsed.version === 'string') {
|
|
25
26
|
return parsed.version;
|
|
26
27
|
}
|
|
27
|
-
throw new Error(`@eslint-sh/eslint-plugin: package.json at ${packageJsonPath} is missing a string "version" field`);
|
|
28
|
+
throw Object.assign(new Error(`@eslint-sh/eslint-plugin: package.json at ${packageJsonPath} is missing a string "version" field`), { code: 'ESLINT_SH_PACKAGE_METADATA' });
|
|
28
29
|
}
|