diff --git a/src/config/editorconfig/index.js b/src/config/editorconfig/index.js index 7a5384a33..6b3537867 100644 --- a/src/config/editorconfig/index.js +++ b/src/config/editorconfig/index.js @@ -6,6 +6,13 @@ import { } from "../find-project-root.js"; import editorConfigToPrettier from "./editorconfig-to-prettier.js"; +/** +@typedef {ReturnType} EditorConfig +*/ + +/** +@type {Map>} +*/ const editorconfigCache = new Map(); function clearEditorconfigCache() { @@ -22,9 +29,9 @@ async function loadEditorconfigInternal(file, { shouldCache }) { } /** - * @param {string} file - * @param {{shouldCache?: boolean}} options - */ +@param {string} file +@param {{shouldCache?: boolean}} options +*/ function loadEditorconfig(file, { shouldCache }) { file = path.resolve(file); diff --git a/src/config/resolve-config.js b/src/config/resolve-config.js index d817c6f82..44fb6017c 100644 --- a/src/config/resolve-config.js +++ b/src/config/resolve-config.js @@ -17,6 +17,13 @@ function clearCache() { clearEditorconfigCache(); } +/** +@param {string} file +@param {{ + editorconfig?: boolean, + useCache?: boolean, +}} options +*/ function loadEditorconfig(file, options) { if (!file || !options.editorconfig) { return; @@ -26,6 +33,17 @@ function loadEditorconfig(file, options) { return loadEditorconfigForFile(file, { shouldCache }); } +/** +@param {string} file +@param {{ + useCache?: boolean, + config?: string | URL +}} options +@returns {{ + config: any, + configFile: string, +} | void} +*/ async function loadPrettierConfig(file, options) { const shouldCache = options.useCache; let configFile = options.config; @@ -45,6 +63,10 @@ async function loadPrettierConfig(file, options) { return { config, configFile }; } +/** +@param {string | URL} fileUrlOrPath +@param {*} options +*/ async function resolveConfig(fileUrlOrPath, options) { options = { useCache: true, ...options }; const filePath = toPath(fileUrlOrPath); @@ -74,6 +96,9 @@ async function resolveConfig(fileUrlOrPath, options) { return merged; } +/** +@param {string | URL} fileUrlOrPath +*/ async function resolveConfigFile(fileUrlOrPath) { const directory = fileUrlOrPath ? path.dirname(path.resolve(toPath(fileUrlOrPath)))