update `@tailwind` completions and diagnostics

master
Brad Cornes 2021-06-16 19:37:35 +01:00
parent 0a62e0dbdf
commit c2345f0112
2 changed files with 26 additions and 12 deletions

View File

@ -632,7 +632,18 @@ function provideTailwindDirectiveCompletions(
)})`,
},
},
{
state.jit && semver.gte(state.version, '2.1.99')
? {
label: 'variants',
documentation: {
kind: 'markdown' as typeof MarkupKind.Markdown,
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(
state.version,
'just-in-time-mode#variants-are-inserted-at-tailwind-variants'
)})`,
},
}
: {
label: 'screens',
documentation: {
kind: 'markdown' as typeof MarkupKind.Markdown,

View File

@ -34,7 +34,7 @@ export function getInvalidTailwindDirectiveDiagnostics(
let valid = [
'utilities',
'components',
'screens',
state.jit && semver.gte(state.version, '2.1.99') ? 'variants' : 'screens',
semver.gte(state.version, '1.0.0-beta.1') ? 'base' : 'preflight',
]
@ -43,12 +43,15 @@ export function getInvalidTailwindDirectiveDiagnostics(
return null
}
let message = `'${match.groups.value}' is not a valid group.`
let message = `'${match.groups.value}' is not a valid value.`
let suggestions: string[] = []
if (match.groups.value === 'preflight') {
suggestions.push('base')
message += ` Did you mean 'base'?`
} else if (match.groups.value === 'screens') {
suggestions.push('variants')
message += ` Did you mean 'variants'?`
} else {
let suggestion = closest(match.groups.value, valid)
if (suggestion) {