UNPKG

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.15 kB
// runner.js import { resolve } from "node:path"; import { env } from "node:process"; import { createSyncFn, TsRunner } from "synckit"; import { getTailwindcssVersion, isSupportedVersion } from "../utils/version.js"; const workerPath = getWorkerPath(); const version = getTailwindcssVersion(); const workerOptions = getWorkerOptions(); const getClassOrderSync = createSyncFn(workerPath, workerOptions); export function getClassOrder(request) { if (!isSupportedVersion(version.major)) { throw new Error(`Unsupported Tailwind CSS version: ${version.major}`); } return getClassOrderSync(version.major, request); } function getWorkerPath() { return resolve(getCurrentDirectory(), "./class-order.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=class-order.sync.js.map