UNPKG

eslint-plugin-better-tailwindcss

Version:

auto-wraps tailwind classes after a certain print width or class count into multiple lines to improve readability.

47 lines 1.75 kB
import { resolve } from "node:path"; import { findTailwindConfigPath as findTailwindConfigPathV3 } from "./config.v3.js"; import { findDefaultConfigPath, findTailwindConfigPath as findTailwindConfigPathV4 } from "./config.v4.js"; import { withCache } from "../async-utils/cache.js"; import { getTailwindcssVersion, TailwindcssVersion } from "../async-utils/version.js"; export const getTailwindConfigPath = ({ configPath, cwd }) => withCache(configPath ?? "default", () => { const version = getTailwindcssVersion(); if (version.major === TailwindcssVersion.V3) { const foundConfigPath = findTailwindConfigPathV3(cwd, configPath); return { path: foundConfigPath ?? "default", warning: getConfigPathWarning(configPath, foundConfigPath) }; } else { const foundConfigPath = findTailwindConfigPathV4(cwd, configPath); return { path: foundConfigPath ?? findDefaultConfigPath(cwd), warning: getEntryPointWarning(configPath, foundConfigPath) }; } }); function getConfigPathWarning(configPath, foundConfigPath) { if (!configPath) { return; } if (foundConfigPath && resolve(configPath) === resolve(foundConfigPath)) { return; } return { option: "tailwindConfig", title: `No tailwind css config found at \`${configPath}\`` }; } function getEntryPointWarning(entryPoint, foundEntryPoint) { if (!entryPoint) { return; } if (foundEntryPoint && resolve(entryPoint) === resolve(foundEntryPoint)) { return; } return { option: "entryPoint", title: `No tailwind css entry point found at \`${entryPoint}\`` }; } //# sourceMappingURL=config.js.map