# Conflicts: # .github/workflows/dev-test.yml # jest.config.mjs # package.json # scripts/vendors/vendor-meta.json # scripts/vendors/vendors.mjs # src/cli/format.js # src/cli/options/create-minimist-options.js # src/cli/options/parse-cli-arguments.js # src/cli/usage.js # src/cli/utils.js # src/common/create-ignorer.js # src/common/load-plugins.js # src/config/resolve-config.js # src/index.js # src/language-css/utils/css-units.evaluate.js # src/language-html/ast.js # src/language-html/print-preprocess.js # src/language-html/utils/index.js # src/main/multiparser.js # tests/format/markdown/auto-link/jsfmt.spec.js # tests/integration/__tests__/__snapshots__/config-resolution.js.snap # tests/integration/__tests__/__snapshots__/with-config-precedence.js.snap # tests/integration/__tests__/file-info.js # yarn.lock
38 lines
917 B
JavaScript
38 lines
917 B
JavaScript
import prettierInteral from "../prettier-internal.js";
|
|
|
|
const {
|
|
utils: { partition },
|
|
} = prettierInteral
|
|
|
|
export default function createMinimistOptions(detailedOptions) {
|
|
const [boolean, string] = partition(
|
|
detailedOptions,
|
|
({ type }) => type === "boolean"
|
|
).map((detailedOptions) =>
|
|
detailedOptions.flatMap(({ name, alias }) =>
|
|
alias ? [name, alias] : [name]
|
|
)
|
|
);
|
|
|
|
const defaults = Object.fromEntries(
|
|
detailedOptions
|
|
.filter(
|
|
(option) =>
|
|
!option.deprecated &&
|
|
(!option.forwardToApi ||
|
|
option.name === "plugin" ||
|
|
option.name === "plugin-search-dir") &&
|
|
option.default !== undefined
|
|
)
|
|
.map((option) => [option.name, option.default])
|
|
);
|
|
|
|
return {
|
|
// we use vnopts' AliasSchema to handle aliases for better error messages
|
|
alias: {},
|
|
boolean,
|
|
string,
|
|
default: defaults,
|
|
};
|
|
}
|