@unotest/eslint-plugin
v0.52.1
Published
ESLint plugin for unotest web DSL scenarios: one `dsl` rule that runs the exact same validator as `unotest-web lint` (vocabulary, linter rules, config severities) on the tree ESLint parsed and reports its diagnostics through ESLint, plus a flat `recommend
Readme
@unotest/eslint-plugin
ESLint plugin for unotest web DSL scenarios.
Two rules — @unotest/dsl for errors and @unotest/dsl-warning for
warnings — run your scenarios through the exact same validator as
unotest-web lint and the viewer's live editor: vocabulary checks, linter
rules, and the severity overrides from your unotest.config.mjs. The rule checks the tree ESLint has already parsed,
so a file is parsed once. ESLint and the CLI can never disagree, and a new
validator rule needs zero plugin updates.
Setup
npm install --save-dev eslint @unotest/eslint-plugin@unotest/web must be installed in the project (it usually already is —
the plugin delegates all checking to it).
// eslint.config.mjs
import unotest from "@unotest/eslint-plugin";
export default [...(await unotest.configs.recommended())];The factory is async because it loads your unotest.config.{js,mjs,ts}
(severity overrides), discovers helper names from unotest/e2e/_helpers/
and your variable names from unotest/.env / .secrets (names only —
values are never read into the config).
Then:
npx eslint unotest/e2eWhat recommended wires
files: ["unotest/e2e/**/*.js"]— scenarios and helpers only.@unotest/dsl: "error"— every engine error, at its line/column.@unotest/dsl-warning: "warn"— every engine warning. ESLint gives a severity to a rule, not to a report, hence two rules over one check: the file is validated once for both.- The engine's own rule id and severity ride in the message
(
[warning lint:pause-explicit] …). no-undef: "off"— names are the engine's job:unknown-functionfor a call,implicit-globalfor a variable assigned without a declaration.- Globals for the DSL vocabulary, your helpers and your
UPPER_SNAKEvariables, so other plugins' rules don't trip on them.
Fixes
npx eslint --fix unotest/e2e applies the fixes the engine offers — the
same edits as unotest-web lint --fix: let i; at the start of a test
for a variable assigned without a declaration.
Severity
Rule severities come from linter.rules in unotest.config.mjs — the
same source the CLI uses. A rule set to error there is reported by
@unotest/dsl, one set to warn by @unotest/dsl-warning; "off"
removes the diagnostic entirely. On the ESLint side, change only the
level of a whole rule — for example, warnings that fail the build:
// eslint.config.mjs
import unotest from "@unotest/eslint-plugin";
export default [
...(await unotest.configs.recommended()),
{ files: ["unotest/e2e/**/*.js"], rules: { "@unotest/dsl-warning": "error" } },
];Wiring the plugin by hand instead of recommended(): name both rules,
or the warnings are not reported at all.
rules: {
"@unotest/dsl": "error",
"@unotest/dsl-warning": "warn",
}License
MIT © Ivan Volkov
