From 0cce870c1322eca9a4367c9930fa3f21ae3f2851 Mon Sep 17 00:00:00 2001 From: Brad Cornes Date: Tue, 3 Nov 2020 11:08:39 +0000 Subject: [PATCH] update for at-apply changes in v2 --- .../tailwindcss-language-service/src/completionProvider.ts | 2 +- .../src/diagnostics/getInvalidApplyDiagnostics.ts | 2 -- .../tailwindcss-language-service/src/util/validateApply.ts | 6 +++++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/tailwindcss-language-service/src/completionProvider.ts b/packages/tailwindcss-language-service/src/completionProvider.ts index 0c381a4..cef47b7 100644 --- a/packages/tailwindcss-language-service/src/completionProvider.ts +++ b/packages/tailwindcss-language-service/src/completionProvider.ts @@ -199,7 +199,7 @@ function provideAtApplyCompletions( }, (item) => { if (item.kind === 9) { - return flagEnabled(state, 'applyComplexClasses') + return semver.gte(state.version, '2.0.0-alpha.1') || flagEnabled(state, 'applyComplexClasses') } let validated = validateApply(state, item.data) return validated !== null && validated.isApplyable === true diff --git a/packages/tailwindcss-language-service/src/diagnostics/getInvalidApplyDiagnostics.ts b/packages/tailwindcss-language-service/src/diagnostics/getInvalidApplyDiagnostics.ts index 11d835d..3e6d03e 100644 --- a/packages/tailwindcss-language-service/src/diagnostics/getInvalidApplyDiagnostics.ts +++ b/packages/tailwindcss-language-service/src/diagnostics/getInvalidApplyDiagnostics.ts @@ -3,7 +3,6 @@ import { InvalidApplyDiagnostic, DiagnosticKind } from './types' import { Settings, State } from '../util/state' import type { TextDocument, DiagnosticSeverity } from 'vscode-languageserver' import { validateApply } from '../util/validateApply' -import { flagEnabled } from '../util/flagEnabled' export function getInvalidApplyDiagnostics( state: State, @@ -12,7 +11,6 @@ export function getInvalidApplyDiagnostics( ): InvalidApplyDiagnostic[] { let severity = settings.lint.invalidApply if (severity === 'ignore') return [] - if (flagEnabled(state, 'applyComplexClasses')) return [] const classNames = findClassNamesInRange(document, undefined, 'css') diff --git a/packages/tailwindcss-language-service/src/util/validateApply.ts b/packages/tailwindcss-language-service/src/util/validateApply.ts index 5a17956..e661c4c 100644 --- a/packages/tailwindcss-language-service/src/util/validateApply.ts +++ b/packages/tailwindcss-language-service/src/util/validateApply.ts @@ -1,6 +1,7 @@ import { State } from './state' import { getClassNameMeta } from './getClassNameMeta' import { flagEnabled } from './flagEnabled' +import semver from 'semver' export function validateApply( state: State, @@ -9,7 +10,10 @@ export function validateApply( const meta = getClassNameMeta(state, classNameOrParts) if (!meta) return null - if (flagEnabled(state, 'applyComplexClasses')) { + if ( + semver.gte(state.version, '2.0.0-alpha.1') || + flagEnabled(state, 'applyComplexClasses') + ) { return { isApplyable: true } }