From 15fd935c5737d0bdad1505af22c3c02a92144393 Mon Sep 17 00:00:00 2001 From: Brad Cornes Date: Wed, 5 May 2021 14:52:22 +0100 Subject: [PATCH] update diagnostic name --- .../src/codeActions/codeActionProvider.ts | 4 ++-- .../codeActions/provideSuggestionCodeActions.ts | 4 ++-- .../src/diagnostics/diagnosticsProvider.ts | 8 ++++---- ...ts => getRecommendedVariantOrderDiagnostics.ts} | 12 ++++++------ .../src/diagnostics/types.ts | 14 +++++++------- .../tailwindcss-language-service/src/util/state.ts | 2 +- 6 files changed, 22 insertions(+), 22 deletions(-) rename packages/tailwindcss-language-service/src/diagnostics/{getIncorrectVariantOrderDiagnostics.ts => getRecommendedVariantOrderDiagnostics.ts} (81%) diff --git a/packages/tailwindcss-language-service/src/codeActions/codeActionProvider.ts b/packages/tailwindcss-language-service/src/codeActions/codeActionProvider.ts index 08bf938..cc3fbc6 100644 --- a/packages/tailwindcss-language-service/src/codeActions/codeActionProvider.ts +++ b/packages/tailwindcss-language-service/src/codeActions/codeActionProvider.ts @@ -11,7 +11,7 @@ import { isInvalidTailwindDirectiveDiagnostic, isInvalidScreenDiagnostic, isInvalidVariantDiagnostic, - isIncorrectVariantOrderDiagnostic, + isRecommendedVariantOrderDiagnostic, } from '../diagnostics/types' import { flatten, dedupeBy } from '../util/array' import { provideCssConflictCodeActions } from './provideCssConflictCodeActions' @@ -63,7 +63,7 @@ export async function doCodeActions(state: State, params: CodeActionParams): Pro isInvalidTailwindDirectiveDiagnostic(diagnostic) || isInvalidScreenDiagnostic(diagnostic) || isInvalidVariantDiagnostic(diagnostic) || - isIncorrectVariantOrderDiagnostic(diagnostic) + isRecommendedVariantOrderDiagnostic(diagnostic) ) { 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 3a669b5..e65e4ee 100644 --- a/packages/tailwindcss-language-service/src/codeActions/provideSuggestionCodeActions.ts +++ b/packages/tailwindcss-language-service/src/codeActions/provideSuggestionCodeActions.ts @@ -5,7 +5,7 @@ import { InvalidTailwindDirectiveDiagnostic, InvalidScreenDiagnostic, InvalidVariantDiagnostic, - IncorrectVariantOrderDiagnostic, + RecommendedVariantOrderDiagnostic, } from '../diagnostics/types' export function provideSuggestionCodeActions( @@ -16,7 +16,7 @@ export function provideSuggestionCodeActions( | InvalidTailwindDirectiveDiagnostic | InvalidScreenDiagnostic | InvalidVariantDiagnostic - | IncorrectVariantOrderDiagnostic + | RecommendedVariantOrderDiagnostic ): 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 9b883d6..5ef686a 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 { getIncorrectVariantOrderDiagnostics } from './getIncorrectVariantOrderDiagnostics' +import { getRecommendedVariantOrderDiagnostics } from './getRecommendedVariantOrderDiagnostics' export async function doValidate( state: State, @@ -19,7 +19,7 @@ export async function doValidate( DiagnosticKind.InvalidVariant, DiagnosticKind.InvalidConfigPath, DiagnosticKind.InvalidTailwindDirective, - DiagnosticKind.IncorrectVariantOrder, + DiagnosticKind.RecommendedVariantOrder, ] ): Promise { const settings = await state.editor.getConfiguration(document.uri) @@ -44,8 +44,8 @@ export async function doValidate( ...(only.includes(DiagnosticKind.InvalidTailwindDirective) ? getInvalidTailwindDirectiveDiagnostics(state, document, settings) : []), - ...(only.includes(DiagnosticKind.IncorrectVariantOrder) - ? await getIncorrectVariantOrderDiagnostics(state, document, settings) + ...(only.includes(DiagnosticKind.RecommendedVariantOrder) + ? await getRecommendedVariantOrderDiagnostics(state, document, settings) : []), ] : [] diff --git a/packages/tailwindcss-language-service/src/diagnostics/getIncorrectVariantOrderDiagnostics.ts b/packages/tailwindcss-language-service/src/diagnostics/getRecommendedVariantOrderDiagnostics.ts similarity index 81% rename from packages/tailwindcss-language-service/src/diagnostics/getIncorrectVariantOrderDiagnostics.ts rename to packages/tailwindcss-language-service/src/diagnostics/getRecommendedVariantOrderDiagnostics.ts index 1d77656..bfcd601 100644 --- a/packages/tailwindcss-language-service/src/diagnostics/getIncorrectVariantOrderDiagnostics.ts +++ b/packages/tailwindcss-language-service/src/diagnostics/getRecommendedVariantOrderDiagnostics.ts @@ -1,22 +1,22 @@ import { State, Settings } from '../util/state' import type { TextDocument } from 'vscode-languageserver' -import { IncorrectVariantOrderDiagnostic, DiagnosticKind } from './types' +import { RecommendedVariantOrderDiagnostic, 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' -export async function getIncorrectVariantOrderDiagnostics( +export async function getRecommendedVariantOrderDiagnostics( state: State, document: TextDocument, settings: Settings -): Promise { +): Promise { if (!state.jit) return [] - let severity = settings.tailwindCSS.lint.incorrectVariantOrder + let severity = settings.tailwindCSS.lint.recommendedVariantOrder if (severity === 'ignore') return [] - let diagnostics: IncorrectVariantOrderDiagnostic[] = [] + let diagnostics: RecommendedVariantOrderDiagnostic[] = [] const classLists = await findClassListsInDocument(state, document) classLists.forEach((classList) => { @@ -34,7 +34,7 @@ export async function getIncorrectVariantOrderDiagnostics( if (!equalExact(variants, sortedVariants)) { diagnostics.push({ - code: DiagnosticKind.IncorrectVariantOrder, + code: DiagnosticKind.RecommendedVariantOrder, 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 9f169d2..6f1bc85 100644 --- a/packages/tailwindcss-language-service/src/diagnostics/types.ts +++ b/packages/tailwindcss-language-service/src/diagnostics/types.ts @@ -8,7 +8,7 @@ export enum DiagnosticKind { InvalidVariant = 'invalidVariant', InvalidConfigPath = 'invalidConfigPath', InvalidTailwindDirective = 'invalidTailwindDirective', - IncorrectVariantOrder = 'incorrectVariantOrder', + RecommendedVariantOrder = 'recommendedVariantOrder', } export type CssConflictDiagnostic = Diagnostic & { @@ -78,15 +78,15 @@ export function isInvalidTailwindDirectiveDiagnostic( return diagnostic.code === DiagnosticKind.InvalidTailwindDirective } -export type IncorrectVariantOrderDiagnostic = Diagnostic & { - code: DiagnosticKind.IncorrectVariantOrder +export type RecommendedVariantOrderDiagnostic = Diagnostic & { + code: DiagnosticKind.RecommendedVariantOrder suggestions: string[] } -export function isIncorrectVariantOrderDiagnostic( +export function isRecommendedVariantOrderDiagnostic( diagnostic: AugmentedDiagnostic -): diagnostic is IncorrectVariantOrderDiagnostic { - return diagnostic.code === DiagnosticKind.IncorrectVariantOrder +): diagnostic is RecommendedVariantOrderDiagnostic { + return diagnostic.code === DiagnosticKind.RecommendedVariantOrder } export type AugmentedDiagnostic = @@ -96,4 +96,4 @@ export type AugmentedDiagnostic = | InvalidVariantDiagnostic | InvalidConfigPathDiagnostic | InvalidTailwindDirectiveDiagnostic - | IncorrectVariantOrderDiagnostic + | RecommendedVariantOrderDiagnostic diff --git a/packages/tailwindcss-language-service/src/util/state.ts b/packages/tailwindcss-language-service/src/util/state.ts index 5756b72..72dc427 100644 --- a/packages/tailwindcss-language-service/src/util/state.ts +++ b/packages/tailwindcss-language-service/src/util/state.ts @@ -48,7 +48,7 @@ export type Settings = { invalidVariant: DiagnosticSeveritySetting invalidConfigPath: DiagnosticSeveritySetting invalidTailwindDirective: DiagnosticSeveritySetting - incorrectVariantOrder: DiagnosticSeveritySetting + recommendedVariantOrder: DiagnosticSeveritySetting } experimental: { classRegex: string[]