UNPKG

eslint-plugin-better-tailwindcss

Version:

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

35 lines 1.47 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getCustomComponentClasses = getCustomComponentClasses; const node_fs_1 = require("node:fs"); const css_tree_1 = require("@eslint/css-tree"); const tailwind_csstree_1 = require("tailwind-csstree"); const { findAll, generate, parse } = (0, css_tree_1.fork)(tailwind_csstree_1.tailwind4); function getCustomComponentClasses({ configPath }) { const entryFile = (0, node_fs_1.readFileSync)(configPath, "utf-8"); const ast = parse(entryFile); return getCustomComponentUtilities(ast); } function getCustomComponentUtilities(ast) { const customComponentUtilities = []; const componentLayers = findAll(ast, node => { return node.type === "Atrule" && node.name === "layer" && node.prelude?.type === "AtrulePrelude" && generate(node.prelude).trim() === "components"; }); for (const layer of componentLayers) { const classSelectors = findAll(layer, node => node.type === "ClassSelector"); for (const classNode of classSelectors) { if (classNode.type !== "ClassSelector") { continue; } if (customComponentUtilities.includes(classNode.name)) { continue; } customComponentUtilities.push(classNode.name); } } return customComponentUtilities; } //# sourceMappingURL=custom-component-classes.async.v4.js.map