Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ defineTest({
'package.json': json`
{
"dependencies": {
"tailwindcss": "0.0.0-insiders.efe084b"
"tailwindcss": "0.0.0-insiders.249bed0"
}
}
`,
Expand All @@ -447,14 +447,15 @@ defineTest({
settings: {
tailwindCSS: {
lint: { suggestCanonicalClasses: 'warning' },
rootFontSize: 16,
},
},
}),
}),
handle: async ({ client }) => {
let doc = await client.open({
lang: 'html',
text: '<div class="[@media_print]:flex [color:red]/50">',
text: '<div class="[@media_print]:flex [color:red]/50 mt-[16px]">',
})

let diagnostics = await doc.diagnostics()
Expand All @@ -480,6 +481,16 @@ defineTest({
severity: 2,
suggestions: ['text-[red]/50'],
},
{
code: 'suggestCanonicalClasses',
message: 'The class `mt-[16px]` can be written as `mt-4`',
range: {
start: { line: 0, character: 47 },
end: { line: 0, character: 56 },
},
severity: 2,
suggestions: ['mt-4'],
},
])
},
})
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ export async function getSuggestCanonicalClassesDiagnostics(
// diagnostics in a given class list.

for (let className of classNames) {
let canonicalized = state.designSystem.canonicalizeCandidates([className.className])[0]
let canonicalized = state.designSystem.canonicalizeCandidates([className.className], {
rem: settings.tailwindCSS.rootFontSize,
})[0]
let isCanonical = canonicalized === className.className

if (isCanonical) continue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ export interface ThemeEntry {
name: string
}

export interface CanonicalizeOptions {
rem?: number
}

export interface DesignSystem {
theme: Theme
variants: Map<string, VariantFn>
Expand All @@ -45,7 +49,7 @@ export interface DesignSystem {
invalidCandidates?: Set<string>

// Added in v4.1.15
canonicalizeCandidates?(classes: string[]): string[]
canonicalizeCandidates?(classes: string[], options?: CanonicalizeOptions): string[]
}

export interface DesignSystem {
Expand Down