Skip to content

Commit 8ccf4d0

Browse files
committed
Add diagnostic for @tailwind base / preflight
1 parent b93d8da commit 8ccf4d0

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,4 +314,34 @@ withFixture('v4/basic', (c) => {
314314
},
315315
],
316316
})
317+
318+
testMatch('Old Tailwind directives warn when used in a v4 project', {
319+
language: 'css',
320+
code: `
321+
@tailwind base;
322+
@tailwind preflight;
323+
`,
324+
expected: [
325+
{
326+
code: 'invalidTailwindDirective',
327+
message:
328+
"'@tailwind base' is no longer available in v4. Use '@import \"tailwindcss/base\"' instead.",
329+
range: {
330+
start: { line: 1, character: 16 },
331+
end: { line: 1, character: 20 },
332+
},
333+
severity: 1,
334+
},
335+
{
336+
code: 'invalidTailwindDirective',
337+
message:
338+
"'@tailwind preflight' is no longer available in v4. Use '@import \"tailwindcss/base\"' instead.",
339+
range: {
340+
start: { line: 2, character: 16 },
341+
end: { line: 2, character: 25 },
342+
},
343+
severity: 1,
344+
},
345+
],
346+
})
317347
})

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,14 @@ function validateLayerName(
8181
return null
8282
}
8383

84+
// `@tailwind base | preflight` do not exist in v4
85+
if (layerName === 'base' || layerName === 'preflight') {
86+
return {
87+
message: `'@tailwind ${layerName}' is no longer available in v4. Use '@import "tailwindcss/base"' instead.`,
88+
suggestions: [],
89+
}
90+
}
91+
8492
let parts = layerName.split(/\s+/)
8593

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

0 commit comments

Comments
 (0)