Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/oxlint-tailwindcss/tests/e2e/cache-dir.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,14 @@ describe('E2E: editing a local @plugin invalidates the cached design system', ()
if (PLUGIN_DIR) rmSync(PLUGIN_DIR, { recursive: true, force: true })
})

// Two cold precomputes, each allowed the 120 s `run` gives oxlint: vitest's
// default 60 s for the whole test ran out inside a loaded full suite.
it('reports the class the edited plugin no longer defines', () => {
const cache = join(PLUGIN_DIR, '.cache')
expect(diagnostics(run(cache))).toEqual([])
writeFileSync(resolve(PLUGIN_DIR, 'src/my-plugin.cjs'), plugin('foo-baz'))
expect(diagnostics(run(cache))).toEqual([
'tailwindcss(no-unknown-classes) "foo-bar" is not a valid Tailwind class. Did you mean "foo-baz"?',
])
})
}, 240_000)
})
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ function fixInOrder(classes: string, ...stages: Rules[]): string {

const SHORTHAND: Rules = { 'tailwindcss/enforce-shorthand': 'warn' }

// An allOrders() is 15 `oxlint --fix` runs in a row, and a test makes up to
// three: about 5 s alone, but well past vitest's default 60 s inside a loaded
// full suite, where each run can take seconds.
const RUNS_TIMEOUT = 180_000

/** Every order the two fixes can land in: together, either one first. */
function allOrders(classes: string, directional: Rules): string[] {
const both = { ...directional, ...SHORTHAND }
Expand All @@ -77,29 +82,41 @@ function allOrders(classes: string, directional: Rules): string[] {
}

describe('E2E: directional rules and enforce-shorthand converge', () => {
it('enforce-logical: a block-axis pair ends as the shorthand', () => {
const logical = { 'tailwindcss/enforce-logical': 'warn' }
expect(allOrders('mt-2 mb-2', logical)).toEqual(['my-2', 'my-2', 'my-2'])
expect(allOrders('top-0 bottom-0', logical)).toEqual(['inset-y-0', 'inset-y-0', 'inset-y-0'])
expect(allOrders('left-0 right-0', logical)).toEqual(['inset-x-0', 'inset-x-0', 'inset-x-0'])
})
it(
'enforce-logical: a block-axis pair ends as the shorthand',
() => {
const logical = { 'tailwindcss/enforce-logical': 'warn' }
expect(allOrders('mt-2 mb-2', logical)).toEqual(['my-2', 'my-2', 'my-2'])
expect(allOrders('top-0 bottom-0', logical)).toEqual(['inset-y-0', 'inset-y-0', 'inset-y-0'])
expect(allOrders('left-0 right-0', logical)).toEqual(['inset-x-0', 'inset-x-0', 'inset-x-0'])
},
RUNS_TIMEOUT,
)

it('enforce-logical with sizing: a width and a height end as the logical pair', () => {
const sizing = { 'tailwindcss/enforce-logical': ['warn', { sizing: true }] }
expect(allOrders('w-4 h-4', sizing)).toEqual([
'inline-4 block-4',
'inline-4 block-4',
'inline-4 block-4',
])
})
it(
'enforce-logical with sizing: a width and a height end as the logical pair',
() => {
const sizing = { 'tailwindcss/enforce-logical': ['warn', { sizing: true }] }
expect(allOrders('w-4 h-4', sizing)).toEqual([
'inline-4 block-4',
'inline-4 block-4',
'inline-4 block-4',
])
},
RUNS_TIMEOUT,
)

it('enforce-physical: a logical block pair ends as the shorthand', () => {
const physical = { 'tailwindcss/enforce-physical': 'warn' }
expect(allOrders('mbs-2 mbe-2', physical)).toEqual(['my-2', 'my-2', 'my-2'])
expect(allOrders('inset-s-0 inset-e-0', physical)).toEqual([
'inset-x-0',
'inset-x-0',
'inset-x-0',
])
})
it(
'enforce-physical: a logical block pair ends as the shorthand',
() => {
const physical = { 'tailwindcss/enforce-physical': 'warn' }
expect(allOrders('mbs-2 mbe-2', physical)).toEqual(['my-2', 'my-2', 'my-2'])
expect(allOrders('inset-s-0 inset-e-0', physical)).toEqual([
'inset-x-0',
'inset-x-0',
'inset-x-0',
])
},
RUNS_TIMEOUT,
)
})
Loading