MCPcopy
hub / github.com/tailwindlabs/prettier-plugin-tailwindcss / findClosestJsConfig

Function findClosestJsConfig

src/sorter.ts:255–282  ·  view source on GitHub ↗
(inputDir: string)

Source from the content-addressed store, hash-verified

253let configPathCache = new Map<string, string | null>()
254
255function findClosestJsConfig(inputDir: string): string | null {
256 // Check cache for this directory
257 let cached = configPathCache.get(inputDir)
258 if (cached !== undefined) {
259 return cached
260 }
261
262 // Resolve
263 let configPath: string | null = null
264 try {
265 let foundPath = escalade(inputDir, (_, names) => {
266 if (names.includes('tailwind.config.js')) return 'tailwind.config.js'
267 if (names.includes('tailwind.config.cjs')) return 'tailwind.config.cjs'
268 if (names.includes('tailwind.config.mjs')) return 'tailwind.config.mjs'
269 if (names.includes('tailwind.config.ts')) return 'tailwind.config.ts'
270 })
271 configPath = foundPath ?? null
272 } catch {}
273
274 // Cache all directories from inputDir up to config location
275 if (configPath) {
276 cacheForDirs(configPathCache, inputDir, configPath, path.dirname(configPath))
277 } else {
278 configPathCache.set(inputDir, null)
279 }
280
281 return configPath
282}
283
284function resolveStylesheet(stylesheetPath: string | null, base: string): string | null {
285 if (!stylesheetPath) return null

Callers 1

getTailwindConfigFunction · 0.85

Calls 3

cacheForDirsFunction · 0.85
getMethod · 0.80
setMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…