MCPcopy
hub / github.com/shufo/vscode-blade-formatter / readRuntimeConfig

Function readRuntimeConfig

src/runtimeConfig.ts:39–81  ·  view source on GitHub ↗
(filePath: string)

Source from the content-addressed store, hash-verified

37const configFileNames = [".bladeformatterrc.json", ".bladeformatterrc"];
38
39export function readRuntimeConfig(filePath: string): RuntimeConfig | undefined {
40 const configFilePath: string | null = findConfigFile(filePath);
41
42 if (configFilePath === null) {
43 return undefined;
44 }
45
46 const configFileContent = fs.readFileSync(configFilePath).toString();
47 const schema: JTDSchemaType<RuntimeConfig> = {
48 optionalProperties: {
49 indentSize: { type: "int32" },
50 indentInnerHtml: { type: "boolean" },
51 wrapLineLength: { type: "int32" },
52 wrapAttributes: {
53 enum: [
54 "auto",
55 "force",
56 "force-aligned ",
57 "force-expand-multiline",
58 "aligned-multiple",
59 "preserve",
60 "preserve-aligned",
61 ],
62 },
63 wrapAttributesMinAttrs: { type: "int32" },
64 endWithNewline: { type: "boolean" },
65 useTabs: { type: "boolean" },
66 sortTailwindcssClasses: { type: "boolean" },
67 sortHtmlAttributes: { type: "string" },
68 customHtmlAttributesOrder: { type: "string" },
69 tailwindcssConfigPath: { type: "string" },
70 noMultipleEmptyLines: { type: "boolean" },
71 noPhpSyntaxCheck: { type: "boolean" },
72 noSingleQuote: { type: "boolean" },
73 noTrailingCommaPhp: { type: "boolean" },
74 componentPrefix: { elements: { type: "string" } },
75 phpVersion: { type: "string" },
76 },
77 additionalProperties: true,
78 };
79 const parse = ajv.compileParser(schema);
80 return parse(configFileContent);
81}
82
83export function findConfigFile(filePath: string): string | null {
84 for (let i = 0; i < configFileNames.length; i++) {

Callers 2

formatFromCommandFunction · 0.90

Calls 1

findConfigFileFunction · 0.85

Tested by

no test coverage detected