91 lines
2.2 KiB
TypeScript
91 lines
2.2 KiB
TypeScript
import type { Config, Options } from "prettier";
|
|
|
|
type Overrides = Readonly<{
|
|
excludeFiles?: Array<string> | string;
|
|
files: Array<string> | string;
|
|
options?: Options;
|
|
}>;
|
|
|
|
export const configIni: Overrides = {
|
|
files: [".npmrc", ".env", ".env.*"],
|
|
options: { parser: "ini" },
|
|
};
|
|
|
|
export const configJson: ReadonlyArray<Overrides> = [
|
|
// Pour le tri des clés des fichiers JSON.
|
|
{
|
|
files: ["*.json"],
|
|
excludeFiles: ["package.json"],
|
|
options: {
|
|
plugins: ["prettier-plugin-sort-json"],
|
|
jsonRecursiveSort: true,
|
|
},
|
|
},
|
|
// Pour package.json.
|
|
{
|
|
files: ["package.json"],
|
|
options: {
|
|
plugins: ["prettier-plugin-pkg"],
|
|
},
|
|
},
|
|
];
|
|
|
|
/** Pour les fichiers PHP. */
|
|
export const configPhp: Overrides = {
|
|
files: ["*.php"],
|
|
options: {
|
|
braceStyle: "1tbs",
|
|
parser: "php",
|
|
phpVersion: "auto",
|
|
plugins: ["@prettier/plugin-php"],
|
|
trailingCommaPHP: true,
|
|
},
|
|
};
|
|
|
|
/** Pour les fichiers XML. */
|
|
export const configXml: Overrides = {
|
|
files: ["*.xml"],
|
|
options: {
|
|
bracketSameLine: false,
|
|
parser: "xml",
|
|
plugins: ["@prettier/plugin-xml"],
|
|
printWidth: 120,
|
|
singleAttributePerLine: true,
|
|
tabWidth: 2,
|
|
xmlQuoteAttributes: "double",
|
|
xmlSelfClosingSpace: true,
|
|
xmlSortAttributesByKey: true,
|
|
xmlWhitespaceSensitivity: "strict",
|
|
},
|
|
};
|
|
|
|
export const configClassique: Readonly<Config> = {
|
|
arrowParens: "avoid",
|
|
bracketSameLine: false,
|
|
bracketSpacing: true,
|
|
embeddedLanguageFormatting: "auto",
|
|
endOfLine: "lf",
|
|
experimentalOperatorPosition: "start",
|
|
experimentalTernaries: true,
|
|
htmlWhitespaceSensitivity: "ignore",
|
|
iniSpaceAroundEquals: false,
|
|
jsdocPreferCodeFences: true,
|
|
jsdocVerticalAlignment: true,
|
|
overrides: [configIni, ...configJson],
|
|
plugins: ["prettier-plugin-curly", "prettier-plugin-ini", "prettier-plugin-jsdoc", "prettier-plugin-sh"],
|
|
printWidth: 120,
|
|
proseWrap: "never",
|
|
quoteProps: "as-needed",
|
|
semi: true,
|
|
singleAttributePerLine: true,
|
|
singleQuote: false,
|
|
tabWidth: 2,
|
|
trailingComma: "all",
|
|
tsdoc: true,
|
|
useTabs: false,
|
|
};
|
|
|
|
export const configWordPress: Readonly<Config> = {
|
|
...configClassique,
|
|
overrides: [...(configClassique.overrides ?? []), configIni, ...configJson, configPhp, configXml],
|
|
};
|