eslint-plugin-readable-tailwind
Version:
auto-wraps tailwind classes after a certain print width or class count into multiple lines to improve readability.
29 lines • 1.19 kB
JavaScript
// runner.js
import { resolve } from "node:path";
import { env } from "node:process";
import { createSyncFn, TsRunner } from "synckit";
import { getTailwindcssVersion, isTailwindcssVersion4 } from "../utils/version.js";
const workerPath = getWorkerPath();
const version = getTailwindcssVersion();
const workerOptions = getWorkerOptions();
const getConflictingClassesSync = createSyncFn(workerPath, workerOptions);
export function getConflictingClasses(request) {
if (!isTailwindcssVersion4(version.major)) {
throw new Error(`Unsupported Tailwind CSS version: ${version.major}`);
}
return getConflictingClassesSync(version.major, request);
}
function getWorkerPath() {
return resolve(getCurrentDirectory(), "./conflicting-classes.async.js");
}
function getWorkerOptions() {
if (env.NODE_ENV === "test") {
return { execArgv: ["--import", TsRunner.TSX] };
}
}
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=conflicting-classes.sync.js.map