feat(plugins): change external options to be plugin-level (#3924)
parent
26ceb854c2
commit
47714f5d4b
|
@ -213,21 +213,11 @@ function getSupportInfo(version, opts) {
|
|||
const options = util
|
||||
.arrayify(
|
||||
Object.assign(
|
||||
plugins
|
||||
.reduce(
|
||||
(currentPrinters, plugin) =>
|
||||
currentPrinters.concat(
|
||||
Object.keys(plugin.printers).map(
|
||||
printerName => plugin.printers[printerName]
|
||||
)
|
||||
),
|
||||
[]
|
||||
)
|
||||
.reduce(
|
||||
(currentOptions, printer) =>
|
||||
Object.assign(currentOptions, printer.options),
|
||||
{}
|
||||
),
|
||||
plugins.reduce(
|
||||
(currentOptions, plugin) =>
|
||||
Object.assign(currentOptions, plugin.options),
|
||||
{}
|
||||
),
|
||||
supportOptions
|
||||
),
|
||||
"name"
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
"use strict";
|
||||
|
||||
const printer = require("./printer-postcss");
|
||||
const options = require("./options");
|
||||
|
||||
// Based on:
|
||||
// https://github.com/github/linguist/blob/master/lib/linguist/languages.yml
|
||||
|
@ -67,6 +68,7 @@ const printers = {
|
|||
|
||||
module.exports = {
|
||||
languages,
|
||||
options,
|
||||
parsers,
|
||||
printers
|
||||
};
|
||||
|
|
|
@ -12,7 +12,6 @@ const softline = docBuilders.softline;
|
|||
const group = docBuilders.group;
|
||||
const fill = docBuilders.fill;
|
||||
const indent = docBuilders.indent;
|
||||
const printerOptions = require("./options");
|
||||
|
||||
const removeLines = doc.utils.removeLines;
|
||||
|
||||
|
@ -789,7 +788,6 @@ function isWideKeywords(value) {
|
|||
}
|
||||
|
||||
module.exports = {
|
||||
options: printerOptions,
|
||||
print: genericPrint,
|
||||
hasPrettierIgnore: util.hasIgnoreComment,
|
||||
massageAstNode: clean
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
"use strict";
|
||||
|
||||
const printer = require("./printer-graphql");
|
||||
const options = require("./options");
|
||||
|
||||
// Based on:
|
||||
// https://github.com/github/linguist/blob/master/lib/linguist/languages.yml
|
||||
|
@ -33,6 +34,7 @@ const printers = {
|
|||
|
||||
module.exports = {
|
||||
languages,
|
||||
options,
|
||||
parsers,
|
||||
printers
|
||||
};
|
||||
|
|
|
@ -9,7 +9,6 @@ const softline = docBuilders.softline;
|
|||
const group = docBuilders.group;
|
||||
const indent = docBuilders.indent;
|
||||
const ifBreak = docBuilders.ifBreak;
|
||||
const printerOptions = require("./options");
|
||||
|
||||
const util = require("../common/util");
|
||||
|
||||
|
@ -618,7 +617,6 @@ function printComment(commentPath) {
|
|||
}
|
||||
|
||||
module.exports = {
|
||||
options: printerOptions,
|
||||
print: genericPrint,
|
||||
hasPrettierIgnore: util.hasIgnoreComment,
|
||||
printComment,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
"use strict";
|
||||
|
||||
const printer = require("./printer-estree");
|
||||
const options = require("./options");
|
||||
|
||||
// Based on:
|
||||
// https://github.com/github/linguist/blob/master/lib/linguist/languages.yml
|
||||
|
@ -133,6 +134,7 @@ const printers = {
|
|||
|
||||
module.exports = {
|
||||
languages,
|
||||
options,
|
||||
parsers,
|
||||
printers
|
||||
};
|
||||
|
|
|
@ -6,7 +6,6 @@ const comments = require("../main/comments");
|
|||
const util = require("../common/util");
|
||||
const isIdentifierName = require("esutils").keyword.isIdentifierNameES6;
|
||||
const embed = require("./embed");
|
||||
const printerOptions = require("./options");
|
||||
const clean = require("./clean");
|
||||
|
||||
const doc = require("../doc");
|
||||
|
@ -5276,7 +5275,6 @@ function printJsDocComment(comment) {
|
|||
}
|
||||
|
||||
module.exports = {
|
||||
options: printerOptions,
|
||||
print: genericPrint,
|
||||
embed,
|
||||
massageAstNode: clean,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
"use strict";
|
||||
|
||||
const printer = require("./printer-markdown");
|
||||
const options = require("./options");
|
||||
|
||||
// Based on:
|
||||
// https://github.com/github/linguist/blob/master/lib/linguist/languages.yml
|
||||
|
@ -52,6 +53,7 @@ const printers = {
|
|||
|
||||
module.exports = {
|
||||
languages,
|
||||
options,
|
||||
parsers,
|
||||
printers
|
||||
};
|
||||
|
|
|
@ -13,7 +13,6 @@ const fill = docBuilders.fill;
|
|||
const align = docBuilders.align;
|
||||
const group = docBuilders.group;
|
||||
const printDocToString = doc.printer.printDocToString;
|
||||
const printerOptions = require("./options");
|
||||
|
||||
const SINGLE_LINE_NODE_TYPES = ["heading", "tableCell", "link"];
|
||||
|
||||
|
@ -697,7 +696,6 @@ function clean(ast, newObj) {
|
|||
}
|
||||
|
||||
module.exports = {
|
||||
options: printerOptions,
|
||||
print: genericPrint,
|
||||
embed,
|
||||
massageAstNode: clean,
|
||||
|
|
|
@ -9,6 +9,23 @@ module.exports = {
|
|||
since: "1.0.0"
|
||||
}
|
||||
],
|
||||
options: {
|
||||
fooOption: {
|
||||
type: "choice",
|
||||
default: "bar",
|
||||
description: "foo description",
|
||||
choices: [
|
||||
{
|
||||
value: "bar",
|
||||
description: "bar description"
|
||||
},
|
||||
{
|
||||
value: "baz",
|
||||
description: "baz description"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
parsers: {
|
||||
"foo-parser": {
|
||||
parse: text => ({ text }),
|
||||
|
@ -18,24 +35,7 @@ module.exports = {
|
|||
printers: {
|
||||
"foo-ast": {
|
||||
print: (path, options) =>
|
||||
options.fooOption ? `foo:${options.fooOption}` : path.getValue().text,
|
||||
options: {
|
||||
fooOption: {
|
||||
type: "choice",
|
||||
default: "bar",
|
||||
description: "foo description",
|
||||
choices: [
|
||||
{
|
||||
value: "bar",
|
||||
description: "bar description"
|
||||
},
|
||||
{
|
||||
value: "baz",
|
||||
description: "baz description"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
options.fooOption ? `foo:${options.fooOption}` : path.getValue().text
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue