update diagnostic name
parent
2942881928
commit
15fd935c57
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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}'`,
|
||||
|
|
|
@ -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<AugmentedDiagnostic[]> {
|
||||
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)
|
||||
: []),
|
||||
]
|
||||
: []
|
||||
|
|
|
@ -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<IncorrectVariantOrderDiagnostic[]> {
|
||||
): Promise<RecommendedVariantOrderDiagnostic[]> {
|
||||
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),
|
||||
],
|
|
@ -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
|
||||
|
|
|
@ -48,7 +48,7 @@ export type Settings = {
|
|||
invalidVariant: DiagnosticSeveritySetting
|
||||
invalidConfigPath: DiagnosticSeveritySetting
|
||||
invalidTailwindDirective: DiagnosticSeveritySetting
|
||||
incorrectVariantOrder: DiagnosticSeveritySetting
|
||||
recommendedVariantOrder: DiagnosticSeveritySetting
|
||||
}
|
||||
experimental: {
|
||||
classRegex: string[]
|
||||
|
|
Loading…
Reference in New Issue