Skip to content

Commit 3476a69

Browse files
authored
Fix getFileInfo (#18081)
1 parent d6f7f14 commit 3476a69

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

src/cli/file-info.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ async function logFileInfoOrDie(context) {
1616
const fileInfo = await getFileInfo(path.resolve(file), {
1717
ignorePath,
1818
withNodeModules,
19-
plugins: plugins.length > 0 ? plugins : undefined,
19+
plugins,
2020
resolveConfig: config !== false,
2121
});
2222

src/common/get-file-info.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { resolveConfig } from "../config/resolve-config.js";
2-
import { loadBuiltinPlugins, loadPlugins } from "../main/plugins/index.js";
2+
import { loadPlugins } from "../main/plugins/index.js";
33
import { isIgnored } from "../utils/ignore.js";
44
import inferParser from "../utils/infer-parser.js";
55

@@ -54,10 +54,10 @@ async function getParser(file, options) {
5454
return config.parser;
5555
}
5656

57-
let plugins = options.plugins ?? config?.plugins ?? [];
58-
plugins = (
59-
await Promise.all([loadBuiltinPlugins(), loadPlugins(plugins)])
60-
).flat();
57+
const plugins = [
58+
...options.plugins,
59+
...(await loadPlugins(config?.plugins ?? [])),
60+
];
6161

6262
return inferParser({ plugins }, { physicalFile: file });
6363
}

src/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { closestMatch as closetLevenshteinMatch } from "leven";
1111
import picocolors from "picocolors";
1212
import * as vnopts from "vnopts";
1313
import * as errors from "./common/errors.js";
14+
import getFileInfoWithoutPlugins from "./common/get-file-info.js";
1415
import { mockable } from "./common/mockable.js";
1516
import {
1617
clearCache as clearConfigCache,
@@ -90,6 +91,8 @@ const inferParser = withPlugins((file, options) =>
9091
inferParserWithoutPlugins(options, { physicalFile: file }),
9192
);
9293

94+
const getFileInfo = withPlugins(getFileInfoWithoutPlugins);
95+
9396
// Internal shared with cli
9497
const sharedWithCli = {
9598
errors,
@@ -132,11 +135,11 @@ export {
132135
clearCache as clearConfigCache,
133136
format,
134137
formatWithCursor,
138+
getFileInfo,
135139
getSupportInfo,
136140
resolveConfig,
137141
resolveConfigFile,
138142
};
139-
export { default as getFileInfo } from "./common/get-file-info.js";
140143
export * as doc from "./document/public.js";
141144
export { default as version } from "./main/version.evaluate.js";
142145
export * as util from "./utils/public.js";

0 commit comments

Comments
 (0)