* 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`
27 lines
445 B
JavaScript
27 lines
445 B
JavaScript
"use strict";
|
|
|
|
module.exports = {
|
|
languages: [
|
|
{
|
|
name: "foo",
|
|
parsers: ["foo-parser"],
|
|
extensions: [".foo"]
|
|
}
|
|
],
|
|
defaultOptions: {
|
|
tabWidth: 8
|
|
},
|
|
parsers: {
|
|
"foo-parser": {
|
|
parse: text => ({ text }),
|
|
astFormat: "foo-ast"
|
|
}
|
|
},
|
|
printers: {
|
|
"foo-ast": {
|
|
print: (path, options) =>
|
|
options.tabWidth ? `tabWidth:${options.tabWidth}` : path.getValue().text
|
|
}
|
|
}
|
|
};
|