eslint-plugin-better-tailwindcss
Version:
auto-wraps tailwind classes after a certain print width or class count into multiple lines to improve readability.
21 lines • 1.08 kB
JavaScript
import { resolve } from "node:path";
import { createSyncFn } from "synckit";
import { getTailwindConfigPath } from "./config.js";
import { getTailwindcssVersion } from "../async-utils/version.js";
import { getWorkerOptions } from "../async-utils/worker.js";
export function getShorthandClasses({ classes, configPath, cwd }) {
const { path, warning } = getTailwindConfigPath({ configPath, cwd });
const shorthandClasses = getShorthandClassesSync({ classes, configPath: path });
return { shorthandClasses, warnings: [warning] };
}
const getShorthandClassesSync = createSyncFn(getWorkerPath(), getWorkerOptions());
function getWorkerPath() {
const { major } = getTailwindcssVersion();
return resolve(getCurrentDirectory(), `./shorthand-classes.async.worker.v${major}.js`);
}
function getCurrentDirectory() {
// eslint-disable-next-line eslint-plugin-typescript/prefer-ts-expect-error
// @ts-ignore - `import.meta` doesn't exist in CommonJS -> will be transformed in build step
return import.meta.dirname;
}
//# sourceMappingURL=shorthand-classes.js.map