@eslint-sh/eslint-plugin 0.1.0 → 0.2.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
CHANGED
|
@@ -1,36 +1,14 @@
|
|
|
1
1
|
# @eslint-sh/eslint-plugin
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
traverse `.sh`/`.bash` files,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
| ----------------- | ----------------------------------------------------------------------- | ---------- | --------------------------------------------------------------------------------------------------------------------------------- |
|
|
13
|
-
| `dialect` | `"bash"`, `"posix"`, `"mksh"`, `"bats"`, `"zsh"` | `"bash"` | Selects which shell grammar the parser accepts; parsing a construct outside the chosen dialect produces a parse error. |
|
|
14
|
-
| `shellVersion` | A numeric `MAJOR` or `MAJOR.MINOR` string, e.g. `"5"` or `"3.2"` | unset | Reserved for the rule layer (e.g. a future bash-3.2 compatibility check); has no effect on parsing today since no rules ship yet. |
|
|
15
|
-
| `directivePrefix` | Lowercase, hyphen-separated words, e.g. `"eslint"` or `"shellcheck-sh"` | `"eslint"` | The prefix directive/inline-config comments must start with — e.g. the default recognizes `# eslint-disable-next-line ...`. |
|
|
16
|
-
|
|
17
|
-
This release reports shell syntax (parse) errors only — no lint rules ship yet, so a "0 problems"
|
|
18
|
-
result means the script parsed without a syntax error, not that it is problem-free.
|
|
19
|
-
|
|
20
|
-
```js
|
|
21
|
-
// eslint.config.mjs
|
|
22
|
-
import { defineConfig } from 'eslint/config';
|
|
23
|
-
import sh from '@eslint-sh/eslint-plugin'; // or the umbrella: import sh from "eslint-sh"
|
|
24
|
-
|
|
25
|
-
export default defineConfig([
|
|
26
|
-
{
|
|
27
|
-
files: ['**/*.sh', '**/*.bash'],
|
|
28
|
-
plugins: { sh },
|
|
29
|
-
language: 'sh/sh',
|
|
30
|
-
languageOptions: { dialect: 'bash', shellVersion: '3.2' },
|
|
31
|
-
},
|
|
32
|
-
]);
|
|
33
|
-
```
|
|
3
|
+
The underlying ESLint plugin behind the `eslint-sh` umbrella package: shell script parsing and
|
|
4
|
+
syntax-error reporting for ESLint, with custom-rule authoring over a typed shell AST. Provides the
|
|
5
|
+
`ShellLanguage` / `ShellSourceCode` core that lets ESLint parse and traverse `.sh`/`.bash` files,
|
|
6
|
+
backed by `sh-ast`.
|
|
7
|
+
|
|
8
|
+
For installation, the config example, the `languageOptions` reference table, the capability
|
|
9
|
+
caveat, and troubleshooting, see the [`eslint-sh` package's README](https://github.com/mike-north/eslint-sh/blob/main/packages/eslint-sh/README.md) —
|
|
10
|
+
that's the canonical quickstart for this project, and applies whether you install `eslint-sh` or
|
|
11
|
+
this package directly.
|
|
34
12
|
|
|
35
13
|
## Status
|
|
36
14
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ShAstError, ShParseError, parseSync, visitorKeys as shellVisitorKeys } from 'sh-ast';
|
|
2
2
|
import { matchesSelectorClass as matchesShellSelectorClass } from './selector-classes.js';
|
|
3
3
|
import { ShellSourceCode } from './shell-source-code.js';
|
|
4
4
|
import { normalizeShellLanguageOptions, validateShellLanguageOptions, } from './shell-language-options.js';
|
|
@@ -63,7 +63,7 @@ function stripPositionPrefix(message, filename) {
|
|
|
63
63
|
*
|
|
64
64
|
* Any other error reaching here (`ShInvalidDialectError` — unreachable in
|
|
65
65
|
* practice, since `validateLanguageOptions` rejects a bad dialect before
|
|
66
|
-
* ESLint ever calls `parse()`; or `
|
|
66
|
+
* ESLint ever calls `parse()`; or `ShInternalError` — a shim contract
|
|
67
67
|
* violation) has no real source position to report, so `1:1` is used as an
|
|
68
68
|
* explicit, honest fallback for the "no position available" case — not a
|
|
69
69
|
* stand-in for an actual parse error's position.
|
|
@@ -76,7 +76,7 @@ function toFileError(error) {
|
|
|
76
76
|
column: error.column,
|
|
77
77
|
};
|
|
78
78
|
}
|
|
79
|
-
const message = error instanceof
|
|
79
|
+
const message = error instanceof ShAstError || error instanceof Error ? error.message : String(error);
|
|
80
80
|
return { message, line: 1, column: 1 };
|
|
81
81
|
}
|
|
82
82
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell-language.js","sourceRoot":"","sources":["../../src/language/shell-language.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"shell-language.js","sourceRoot":"","sources":["../../src/language/shell-language.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,IAAI,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAG9F,OAAO,EAAE,oBAAoB,IAAI,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAC1F,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EACL,6BAA6B,EAC7B,4BAA4B,GAG7B,MAAM,6BAA6B,CAAC;AAErC;;;;;;;;GAQG;AACH,MAAM,uBAAuB,GAA6B,MAAM,CAAC,WAAW,CAC1E,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAC1E,CAAC;AAEF;;;;;;GAMG;AACH,SAAS,YAAY,CAAC,KAAa;IACjC,OAAO,KAAK,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;AACtD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAS,mBAAmB,CAAC,OAAe,EAAE,QAAgB;IAC5D,MAAM,aAAa,GAAG,IAAI,MAAM,CAAC,IAAI,YAAY,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC;IAC9E,OAAO,OAAO,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;AAC5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G,IAAI,CAAC,IAAc,CAAC;QACjC,MAAM,OAAO,GAAiB,OAAO,CAAC,eAAe,CAAC,OAAO,IAAI,MAAM,CAAC;QAExE,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,SAAS,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;YAC9D,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;QAC3B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;QACrD,CAAC;IACH,CAAC;IAED;;;;;;;;;;OAUG;IACH,gBAAgB,CACd,IAAU,EACV,WAAkC,EAClC,OAAkD;QAElD,OAAO,IAAI,eAAe,CAAC;YACzB,IAAI,EAAE,IAAI,CAAC,IAAc;YACzB,GAAG,EAAE,WAAW,CAAC,GAAG;YACpB,eAAe,EAAE,OAAO,CAAC,eAAe,CAAC,eAAe,IAAI,QAAQ;SACrE,CAAC,CAAC;IACL,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-sh/eslint-plugin",
|
|
3
3
|
"description": "Shell script parsing and syntax-error reporting for ESLint, with custom-rule authoring over a typed shell AST, backed by sh-ast.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.2.0",
|
|
5
5
|
"author": "Mike North <michael.l.north@gmail.com>",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@eslint/core": "^1.2.1",
|
|
8
8
|
"@eslint/plugin-kit": "^0.7.2",
|
|
9
|
-
"sh-ast": "^0.
|
|
9
|
+
"sh-ast": "^0.3.0"
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
12
12
|
"eslint": "^10.7.0"
|