Disable variant order linting and sorting for tailwindcss v3
parent
ddabfe9390
commit
4e8918ad8c
|
@ -123,13 +123,19 @@ export function completionsFromClassList(
|
|||
let items: CompletionItem[] = []
|
||||
|
||||
if (!important) {
|
||||
let shouldSortVariants = !semver.gte(state.version, '2.99.0')
|
||||
|
||||
items.push(
|
||||
...Object.entries(state.variants)
|
||||
.filter(([variant]) => !existingVariants.includes(variant))
|
||||
.map(([variant, definition], index) => {
|
||||
let resultingVariants = [...existingVariants, variant].sort(
|
||||
(a, b) => allVariants.indexOf(b) - allVariants.indexOf(a)
|
||||
)
|
||||
let resultingVariants = [...existingVariants, variant]
|
||||
|
||||
if (shouldSortVariants) {
|
||||
resultingVariants = resultingVariants.sort(
|
||||
(a, b) => allVariants.indexOf(b) - allVariants.indexOf(a)
|
||||
)
|
||||
}
|
||||
|
||||
return {
|
||||
label: variant + sep,
|
||||
|
@ -146,7 +152,7 @@ export function completionsFromClassList(
|
|||
range: replacementRange,
|
||||
},
|
||||
additionalTextEdits:
|
||||
resultingVariants.length > 1
|
||||
shouldSortVariants && resultingVariants.length > 1
|
||||
? [
|
||||
{
|
||||
newText:
|
||||
|
|
|
@ -5,6 +5,7 @@ import { findClassListsInDocument, getClassNamesInClassList } from '../util/find
|
|||
import * as jit from '../util/jit'
|
||||
import { getVariantsFromClassName } from '../util/getVariantsFromClassName'
|
||||
import { equalExact } from '../util/array'
|
||||
import semver from 'semver'
|
||||
|
||||
export async function getRecommendedVariantOrderDiagnostics(
|
||||
state: State,
|
||||
|
@ -13,6 +14,8 @@ export async function getRecommendedVariantOrderDiagnostics(
|
|||
): Promise<RecommendedVariantOrderDiagnostic[]> {
|
||||
if (!state.jit) return []
|
||||
|
||||
if (semver.gte(state.version, '2.99.0')) return []
|
||||
|
||||
let severity = settings.tailwindCSS.lint.recommendedVariantOrder
|
||||
if (severity === 'ignore') return []
|
||||
|
||||
|
|
Loading…
Reference in New Issue