Skip to content

Commit c2345f0

Browse files
committed
update @tailwind completions and diagnostics
1 parent 0a62e0d commit c2345f0

File tree

2 files changed

+26
-12
lines changed

2 files changed

+26
-12
lines changed

packages/tailwindcss-language-service/src/completionProvider.ts

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -632,16 +632,27 @@ function provideTailwindDirectiveCompletions(
632632
)})`,
633633
},
634634
},
635-
{
636-
label: 'screens',
637-
documentation: {
638-
kind: 'markdown' as typeof MarkupKind.Markdown,
639-
value: `Use this directive to control where Tailwind injects the responsive variations of each utility.\n\nIf omitted, Tailwind will append these classes to the very end of your stylesheet by default.\n\n[Tailwind CSS Documentation](${docsUrl(
640-
state.version,
641-
'functions-and-directives/#tailwind'
642-
)})`,
643-
},
644-
},
635+
state.jit && semver.gte(state.version, '2.1.99')
636+
? {
637+
label: 'variants',
638+
documentation: {
639+
kind: 'markdown' as typeof MarkupKind.Markdown,
640+
value: `Use this directive to control where Tailwind injects the utility variants.\n\nThis directive is considered an advanced escape hatch and it is recommended to omit it whenever possible. If omitted, Tailwind will append these classes to the very end of your stylesheet by default.\n\n[Tailwind CSS Documentation](${docsUrl(
641+
state.version,
642+
'just-in-time-mode#variants-are-inserted-at-tailwind-variants'
643+
)})`,
644+
},
645+
}
646+
: {
647+
label: 'screens',
648+
documentation: {
649+
kind: 'markdown' as typeof MarkupKind.Markdown,
650+
value: `Use this directive to control where Tailwind injects the responsive variations of each utility.\n\nIf omitted, Tailwind will append these classes to the very end of your stylesheet by default.\n\n[Tailwind CSS Documentation](${docsUrl(
651+
state.version,
652+
'functions-and-directives/#tailwind'
653+
)})`,
654+
},
655+
},
645656
].map((item) => ({
646657
...item,
647658
kind: 21,

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export function getInvalidTailwindDirectiveDiagnostics(
3434
let valid = [
3535
'utilities',
3636
'components',
37-
'screens',
37+
state.jit && semver.gte(state.version, '2.1.99') ? 'variants' : 'screens',
3838
semver.gte(state.version, '1.0.0-beta.1') ? 'base' : 'preflight',
3939
]
4040

@@ -43,12 +43,15 @@ export function getInvalidTailwindDirectiveDiagnostics(
4343
return null
4444
}
4545

46-
let message = `'${match.groups.value}' is not a valid group.`
46+
let message = `'${match.groups.value}' is not a valid value.`
4747
let suggestions: string[] = []
4848

4949
if (match.groups.value === 'preflight') {
5050
suggestions.push('base')
5151
message += ` Did you mean 'base'?`
52+
} else if (match.groups.value === 'screens') {
53+
suggestions.push('variants')
54+
message += ` Did you mean 'variants'?`
5255
} else {
5356
let suggestion = closest(match.groups.value, valid)
5457
if (suggestion) {

0 commit comments

Comments
 (0)