* refactor(cli): defer default value applying * Allow plugins to override default options * Move "defaultOptions" to top level of plugin * Simplify implementation * Attach plugin name * Add pluginOptions to cli help * Update snapshots * Code review (immutable style) * Add test for help output * Use snapshot test, fix Object.assign * Refactor to immutable style * Add test case for automatic plugin resolution * Add tests for applying and overriding default opts * Remove "since" option * Only set defaults for CLI args when no pluginDefaults are present * Revert workaround, rebase to #4045 * Add basic documentation for `options` and `defaultOptions`
30 lines
658 B
JavaScript
30 lines
658 B
JavaScript
"use strict";
|
|
|
|
const runPrettier = require("../runPrettier");
|
|
|
|
describe("plugin default options should work", () => {
|
|
runPrettier(
|
|
"plugins/defaultOptions",
|
|
["--stdin-filepath", "example.foo", "--plugin=./plugin"],
|
|
{ input: "hello-world" }
|
|
).test({
|
|
stdout: "tabWidth:8",
|
|
stderr: "",
|
|
status: 0,
|
|
write: []
|
|
});
|
|
});
|
|
|
|
describe("overriding plugin default options should work", () => {
|
|
runPrettier(
|
|
"plugins/defaultOptions",
|
|
["--stdin-filepath", "example.foo", "--plugin=./plugin", "--tab-width=4"],
|
|
{ input: "hello-world" }
|
|
).test({
|
|
stdout: "tabWidth:4",
|
|
stderr: "",
|
|
status: 0,
|
|
write: []
|
|
});
|
|
});
|