Skip to content

Commit 341a9ff

Browse files
committed
Add diagnostic for @tailwind components / screens / variants
1 parent a3dd881 commit 341a9ff

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

packages/tailwindcss-language-server/tests/diagnostics/diagnostics.test.js

+33
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,9 @@ withFixture('v4/basic', (c) => {
320320
code: `
321321
@tailwind base;
322322
@tailwind preflight;
323+
@tailwind components;
324+
@tailwind screens;
325+
@tailwind variants;
323326
`,
324327
expected: [
325328
{
@@ -342,6 +345,36 @@ withFixture('v4/basic', (c) => {
342345
},
343346
severity: 1,
344347
},
348+
{
349+
code: 'invalidTailwindDirective',
350+
message:
351+
"'@tailwind components' is no longer available in v4. Use '@tailwind utilities' instead.",
352+
range: {
353+
start: { line: 3, character: 16 },
354+
end: { line: 3, character: 26 },
355+
},
356+
severity: 1,
357+
},
358+
{
359+
code: 'invalidTailwindDirective',
360+
message:
361+
"'@tailwind screens' is no longer available in v4. Use '@tailwind utilities' instead.",
362+
range: {
363+
start: { line: 4, character: 16 },
364+
end: { line: 4, character: 23 },
365+
},
366+
severity: 1,
367+
},
368+
{
369+
code: 'invalidTailwindDirective',
370+
message:
371+
"'@tailwind variants' is no longer available in v4. Use '@tailwind utilities' instead.",
372+
range: {
373+
start: { line: 5, character: 16 },
374+
end: { line: 5, character: 24 },
375+
},
376+
severity: 1,
377+
},
345378
],
346379
})
347380
})

packages/tailwindcss-language-service/src/diagnostics/getInvalidTailwindDirectiveDiagnostics.ts

+8
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,14 @@ function validateLayerName(
8989
}
9090
}
9191

92+
// `@tailwind components | screens | variants` do not exist in v4
93+
if (layerName === 'components' || layerName === 'screens' || layerName === 'variants') {
94+
return {
95+
message: `'@tailwind ${layerName}' is no longer available in v4. Use '@tailwind utilities' instead.`,
96+
suggestions: [],
97+
}
98+
}
99+
92100
let parts = layerName.split(/\s+/)
93101

94102
// `@tailwind utilities source(…)` is valid

0 commit comments

Comments
 (0)