mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
fix(lint): Deno.lint.runPlugin
throws in deno run
(#28063)
This commit changes `Deno.lint.runPlugin` to throw in non-`deno test` subcommand, instead of returning `undefined`.
This commit is contained in:
parent
3ff9ca2533
commit
d29f9f99dd
6 changed files with 43 additions and 2 deletions
4
cli/tsc/dts/lib.deno.unstable.d.ts
vendored
4
cli/tsc/dts/lib.deno.unstable.d.ts
vendored
|
@ -1487,7 +1487,9 @@ declare namespace Deno {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This API is a noop in `deno run`...
|
* This API is useful for testing lint plugins.
|
||||||
|
*
|
||||||
|
* It throws an error if it's not used in `deno test` subcommand.
|
||||||
* @category Linter
|
* @category Linter
|
||||||
* @experimental
|
* @experimental
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -585,7 +585,11 @@ const finalDenoNs = {
|
||||||
test: () => {},
|
test: () => {},
|
||||||
bench: () => {},
|
bench: () => {},
|
||||||
lint: {
|
lint: {
|
||||||
runPlugin: () => {},
|
runPlugin: () => {
|
||||||
|
throw new Error(
|
||||||
|
"`Deno.lint.runPlugin` is only available in `deno test` subcommand.",
|
||||||
|
);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
13
tests/specs/lint/lint_plugin_runtime_api/__test__.jsonc
Normal file
13
tests/specs/lint/lint_plugin_runtime_api/__test__.jsonc
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"args": "run main.ts",
|
||||||
|
"output": "run.out",
|
||||||
|
"exitCode": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"args": "test main.ts",
|
||||||
|
"output": "test.out"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
12
tests/specs/lint/lint_plugin_runtime_api/main.ts
Normal file
12
tests/specs/lint/lint_plugin_runtime_api/main.ts
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
const plugin = {
|
||||||
|
name: "test-plugin",
|
||||||
|
rules: {
|
||||||
|
testRule: {
|
||||||
|
create() {
|
||||||
|
return {};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
Deno.lint.runPlugin(plugin, "source.ts", "export default {}");
|
5
tests/specs/lint/lint_plugin_runtime_api/run.out
Normal file
5
tests/specs/lint/lint_plugin_runtime_api/run.out
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
error: Uncaught (in promise) Error: `Deno.lint.runPlugin` is only available in `deno test` subcommand.
|
||||||
|
Deno.lint.runPlugin(plugin, "source.ts", "export default {}");
|
||||||
|
^
|
||||||
|
at Object.runPlugin ([WILDCARD])
|
||||||
|
at [WILDCARD]main.ts:12:11
|
5
tests/specs/lint/lint_plugin_runtime_api/test.out
Normal file
5
tests/specs/lint/lint_plugin_runtime_api/test.out
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
Check [WILDCARD]main.ts
|
||||||
|
running 0 tests from ./main.ts
|
||||||
|
|
||||||
|
ok | 0 passed | 0 failed [WILDCARD]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue