Skip to content

Commit 2c5faf0

Browse files
committed
chore: wip
1 parent 1db0349 commit 2c5faf0

File tree

5 files changed

+13
-6
lines changed

5 files changed

+13
-6
lines changed

eslint.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ const config: ESLintConfig = stacks({
1212
yaml: true,
1313
ignores: [
1414
'fixtures/**',
15+
'docs/**',
16+
'packages/*/docs/**',
1517
],
1618
})
1719

packages/headwind/src/parser.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ export function parseClass(className: string): ParsedClass {
238238
}
239239

240240
// Regular negative value
241-
const match = positiveUtility.match(/^([a-z-]+?)(?:-(.+))?$/)
241+
const match = positiveUtility.match(/^([a-z]+(?:-[a-z]+)*)(?:-(.+))?$/)
242242
if (match) {
243243
return {
244244
raw: className,
@@ -253,7 +253,7 @@ export function parseClass(className: string): ParsedClass {
253253

254254
// Check for color opacity modifiers: bg-blue-500/50, text-red-500/75
255255
// Must come before fractional values to avoid conflict
256-
const opacityMatch = utility.match(/^([a-z-]+?)-(.+?)\/(\d+)$/)
256+
const opacityMatch = utility.match(/^([a-z]+(?:-[a-z]+)*)-(.+?)\/(\d+)$/)
257257
if (opacityMatch && ['bg', 'text', 'border', 'ring', 'placeholder', 'divide'].includes(opacityMatch[1])) {
258258
return {
259259
raw: className,
@@ -266,7 +266,7 @@ export function parseClass(className: string): ParsedClass {
266266
}
267267

268268
// Check for fractional values: w-1/2, h-3/4
269-
const fractionMatch = utility.match(/^([a-z-]+?)-(\d+)\/(\d+)$/)
269+
const fractionMatch = utility.match(/^([a-z-]+)-(\d+)\/(\d+)$/)
270270
if (fractionMatch) {
271271
return {
272272
raw: className,
@@ -279,7 +279,7 @@ export function parseClass(className: string): ParsedClass {
279279
}
280280

281281
// Regular parsing - split on last dash
282-
const match = utility.match(/^([a-z-]+?)(?:-(.+))?$/)
282+
const match = utility.match(/^([a-z]+(?:-[a-z]+)*)(?:-(.+))?$/)
283283
if (!match) {
284284
return {
285285
raw: className,
@@ -316,6 +316,7 @@ export function extractClasses(content: string): Set<string> {
316316

317317
for (const pattern of patterns) {
318318
let match
319+
// eslint-disable-next-line no-cond-assign
319320
while ((match = pattern.exec(content)) !== null) {
320321
const classStr = match[1]
321322
// Extract all quoted strings from the class string (handles template literals with expressions)

packages/headwind/src/transformer-compile-class.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export function extractCompileClasses(
5050
const classRegex = /(?:class|className)=["']([^"']*)["']/g
5151
let match: RegExpExecArray | null
5252

53+
// eslint-disable-next-line no-cond-assign
5354
while ((match = classRegex.exec(content)) !== null) {
5455
const fullClass = match[1]
5556

@@ -92,6 +93,7 @@ export function transformContent(
9293
// We need to replace in reverse order to maintain string positions
9394
const replacements: Array<{ start: number, end: number, replacement: string }> = []
9495

96+
// eslint-disable-next-line no-cond-assign
9597
while ((match = classRegex.exec(content)) !== null) {
9698
const fullClass = match[1]
9799

packages/headwind/test/parser.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,8 @@ describe('extractClasses - Edge Cases', () => {
391391
})
392392

393393
it('should handle template literal with expressions', () => {
394-
const jsx = '<div className={`flex $\{isActive ? "active" : ""} p-4`}></div>'
394+
// eslint-disable-next-line no-template-curly-in-string
395+
const jsx = '<div className={`flex ${isActive ? "active" : ""} p-4`}></div>'
395396
const result = extractClasses(jsx)
396397
expect(result.has('flex')).toBe(true)
397398
expect(result.has('p-4')).toBe(true)

packages/headwind/test/scanner.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ describe('Scanner', () => {
2222

2323
await writeFile(
2424
join(TEST_DIR, 'test3.jsx'),
25-
'<div className={`text-center $\{active ? "font-bold" : ""}`}>Text</div>',
25+
// eslint-disable-next-line no-template-curly-in-string
26+
'<div className={`text-center ${active ? "font-bold" : ""}`}>Text</div>',
2627
)
2728
})
2829

0 commit comments

Comments
 (0)