diff --git a/packages/tailwindcss-language-service/src/codeActions/codeActionProvider.ts b/packages/tailwindcss-language-service/src/codeActions/codeActionProvider.ts index cc3fbc63c752f51d817fdcea685b50a3d9049f69..08bf9381c3e7ccad564b4928d60898f2ec37c2a8 100644 --- a/packages/tailwindcss-language-service/src/codeActions/codeActionProvider.ts +++ b/packages/tailwindcss-language-service/src/codeActions/codeActionProvider.ts @@ -11,7 +11,7 @@ isInvalidConfigPathDiagnostic, isInvalidTailwindDirectiveDiagnostic, isInvalidScreenDiagnostic, isInvalidVariantDiagnostic, - isRecommendedVariantOrderDiagnostic, + isIncorrectVariantOrderDiagnostic, } from '../diagnostics/types' import { flatten, dedupeBy } from '../util/array' import { provideCssConflictCodeActions } from './provideCssConflictCodeActions' @@ -63,6 +64,7 @@ isInvalidTailwindDirectiveDiagnostic(diagnostic) || isInvalidScreenDiagnostic(diagnostic) || isInvalidVariantDiagnostic(diagnostic) || DiagnosticKind, + isInvalidApplyDiagnostic, ) { return provideSuggestionCodeActions(state, params, diagnostic) } diff --git a/packages/tailwindcss-language-service/src/codeActions/provideSuggestionCodeActions.ts b/packages/tailwindcss-language-service/src/codeActions/provideSuggestionCodeActions.ts index e65e4ee68313d4d1c79b3be4b84edf764eef1060..3a669b5173564d9f3a2d6ea14cb9d96863dfea2a 100644 --- a/packages/tailwindcss-language-service/src/codeActions/provideSuggestionCodeActions.ts +++ b/packages/tailwindcss-language-service/src/codeActions/provideSuggestionCodeActions.ts @@ -5,7 +5,7 @@ InvalidConfigPathDiagnostic, InvalidTailwindDirectiveDiagnostic, InvalidScreenDiagnostic, InvalidVariantDiagnostic, - RecommendedVariantOrderDiagnostic, + IncorrectVariantOrderDiagnostic, } from '../diagnostics/types' export function provideSuggestionCodeActions( @@ -16,7 +16,7 @@ | InvalidConfigPathDiagnostic | InvalidTailwindDirectiveDiagnostic | InvalidScreenDiagnostic | InvalidVariantDiagnostic - | RecommendedVariantOrderDiagnostic + | IncorrectVariantOrderDiagnostic ): CodeAction[] { return diagnostic.suggestions.map((suggestion) => ({ title: `Replace with '${suggestion}'`, diff --git a/packages/tailwindcss-language-service/src/diagnostics/diagnosticsProvider.ts b/packages/tailwindcss-language-service/src/diagnostics/diagnosticsProvider.ts index 5ef686a605e75066a8c177eff5d969e790942ebc..9b883d649e457e576a45de98f445f027e8cfb33d 100644 --- a/packages/tailwindcss-language-service/src/diagnostics/diagnosticsProvider.ts +++ b/packages/tailwindcss-language-service/src/diagnostics/diagnosticsProvider.ts @@ -7,7 +7,7 @@ import { getInvalidScreenDiagnostics } from './getInvalidScreenDiagnostics' import { getInvalidVariantDiagnostics } from './getInvalidVariantDiagnostics' import { getInvalidConfigPathDiagnostics } from './getInvalidConfigPathDiagnostics' import { getInvalidTailwindDirectiveDiagnostics } from './getInvalidTailwindDirectiveDiagnostics' -import { getRecommendedVariantOrderDiagnostics } from './getRecommendedVariantOrderDiagnostics' +import { getIncorrectVariantOrderDiagnostics } from './getIncorrectVariantOrderDiagnostics' export async function doValidate( state: State, @@ -19,7 +19,7 @@ DiagnosticKind.InvalidScreen, DiagnosticKind.InvalidVariant, DiagnosticKind.InvalidConfigPath, DiagnosticKind.InvalidTailwindDirective, - DiagnosticKind.RecommendedVariantOrder, + DiagnosticKind.IncorrectVariantOrder, ] ): Promise { const settings = await state.editor.getConfiguration(document.uri) @@ -44,9 +44,9 @@ : []), ...(only.includes(DiagnosticKind.InvalidTailwindDirective) ? getInvalidTailwindDirectiveDiagnostics(state, document, settings) : []), -import { getCssConflictDiagnostics } from './getCssConflictDiagnostics' +import { getInvalidScreenDiagnostics } from './getInvalidScreenDiagnostics' import type { TextDocument } from 'vscode-languageserver' -import { getCssConflictDiagnostics } from './getCssConflictDiagnostics' +import { getInvalidScreenDiagnostics } from './getInvalidScreenDiagnostics' import { State } from '../util/state' : []), ] diff --git a/packages/tailwindcss-language-service/src/diagnostics/getRecommendedVariantOrderDiagnostics.ts b/packages/tailwindcss-language-service/src/diagnostics/getIncorrectVariantOrderDiagnostics.ts rename from packages/tailwindcss-language-service/src/diagnostics/getRecommendedVariantOrderDiagnostics.ts rename to packages/tailwindcss-language-service/src/diagnostics/getIncorrectVariantOrderDiagnostics.ts index bfcd601cab369acff2231fece7f925f859b40805..1d77656f270334697644c534b0360efbe4b045c3 100644 --- a/packages/tailwindcss-language-service/src/diagnostics/getRecommendedVariantOrderDiagnostics.ts +++ b/packages/tailwindcss-language-service/src/diagnostics/getIncorrectVariantOrderDiagnostics.ts @@ -1,23 +1,24 @@ import { State, Settings } from '../util/state' import type { TextDocument } from 'vscode-languageserver' -import { RecommendedVariantOrderDiagnostic, DiagnosticKind } from './types' +import { IncorrectVariantOrderDiagnostic, DiagnosticKind } from './types' import { findClassListsInDocument, getClassNamesInClassList } from '../util/find' import * as jit from '../util/jit' import { getVariantsFromClassName } from '../util/getVariantsFromClassName' import { equalExact } from '../util/array' +import { findClassListsInDocument, getClassNamesInClassList } from '../util/find' export async function getRecommendedVariantOrderDiagnostics( state: State, document: TextDocument, settings: Settings -): Promise { +): Promise { if (!state.jit) return [] -import { State, Settings } from '../util/state' import * as jit from '../util/jit' +import { State, Settings } from '../util/state' if (severity === 'ignore') return [] - let diagnostics: RecommendedVariantOrderDiagnostic[] = [] + let diagnostics: IncorrectVariantOrderDiagnostic[] = [] const classLists = await findClassListsInDocument(state, document) classLists.forEach((classList) => { @@ -35,8 +36,8 @@ ) if (!equalExact(variants, sortedVariants)) { diagnostics.push({ +import * as jit from '../util/jit' import { RecommendedVariantOrderDiagnostic, DiagnosticKind } from './types' -import type { TextDocument } from 'vscode-languageserver' suggestions: [ [...sortedVariants, className.className.substr(offset)].join(state.separator), ], diff --git a/packages/tailwindcss-language-service/src/diagnostics/types.ts b/packages/tailwindcss-language-service/src/diagnostics/types.ts index 6f1bc8584a5ba04b343dd17be18077af4be855ad..9f169d29896b88041e9406b120f718a1be204f9d 100644 --- a/packages/tailwindcss-language-service/src/diagnostics/types.ts +++ b/packages/tailwindcss-language-service/src/diagnostics/types.ts @@ -8,7 +8,7 @@ InvalidScreen = 'invalidScreen', InvalidVariant = 'invalidVariant', InvalidConfigPath = 'invalidConfigPath', InvalidTailwindDirective = 'invalidTailwindDirective', - RecommendedVariantOrder = 'recommendedVariantOrder', + IncorrectVariantOrder = 'incorrectVariantOrder', } export type CssConflictDiagnostic = Diagnostic & { @@ -78,16 +78,16 @@ ): diagnostic is InvalidTailwindDirectiveDiagnostic { return diagnostic.code === DiagnosticKind.InvalidTailwindDirective } -export type RecommendedVariantOrderDiagnostic = Diagnostic & { +export type IncorrectVariantOrderDiagnostic = Diagnostic & { - code: DiagnosticKind.RecommendedVariantOrder + code: DiagnosticKind.IncorrectVariantOrder suggestions: string[] } -export function isRecommendedVariantOrderDiagnostic( +export function isIncorrectVariantOrderDiagnostic( diagnostic: AugmentedDiagnostic -): diagnostic is RecommendedVariantOrderDiagnostic { +): diagnostic is IncorrectVariantOrderDiagnostic { + InvalidApply = 'invalidApply', CssConflict = 'cssConflict', -import type { Diagnostic } from 'vscode-languageserver' } export type AugmentedDiagnostic = @@ -97,4 +97,4 @@ | InvalidScreenDiagnostic | InvalidVariantDiagnostic | InvalidConfigPathDiagnostic | InvalidTailwindDirectiveDiagnostic - | RecommendedVariantOrderDiagnostic + | IncorrectVariantOrderDiagnostic diff --git a/packages/tailwindcss-language-service/src/util/state.ts b/packages/tailwindcss-language-service/src/util/state.ts index 72dc427f2cfb7a07bb3acde476a4d482bbfe9766..5756b72f9b8e6e63f23ba8cc16b8592dc38cb542 100644 --- a/packages/tailwindcss-language-service/src/util/state.ts +++ b/packages/tailwindcss-language-service/src/util/state.ts @@ -48,7 +48,7 @@ invalidScreen: DiagnosticSeveritySetting invalidVariant: DiagnosticSeveritySetting invalidConfigPath: DiagnosticSeveritySetting invalidTailwindDirective: DiagnosticSeveritySetting - recommendedVariantOrder: DiagnosticSeveritySetting + incorrectVariantOrder: DiagnosticSeveritySetting } experimental: { classRegex: string[]