Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show all potential class conflicts in v4 projects #1077

Merged
merged 3 commits into from
Nov 8, 2024
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 @@ -254,3 +254,64 @@ withFixture('v4/with-prefix', (c) => {
expected: [],
})
})

withFixture('v4/basic', (c) => {
function testMatch(name, { code, expected, language = 'html' }) {
test(name, async () => {
let promise = new Promise((resolve) => {
c.onNotification('textDocument/publishDiagnostics', ({ diagnostics }) => {
resolve(diagnostics)
})
})

let doc = await c.openDocument({ text: code, lang: language })
let diagnostics = await promise

expected = JSON.parse(JSON.stringify(expected).replaceAll('{{URI}}', doc.uri))

expect(diagnostics).toMatchObject(expected)
})
}

testMatch('conflicts show even when unknown classes are present', {
code: `<div class="foo max-w-4xl max-w-6xl hover:underline">testing</div>`,
expected: [
{
code: 'cssConflict',
message: "'max-w-4xl' applies the same CSS properties as 'max-w-6xl'.",
className: {
className: 'max-w-4xl',
classList: {
classList: 'foo max-w-4xl max-w-6xl hover:underline',
},
},
otherClassNames: [
{
className: 'max-w-6xl',
classList: {
classList: 'foo max-w-4xl max-w-6xl hover:underline',
},
},
],
},
{
code: 'cssConflict',
message: "'max-w-6xl' applies the same CSS properties as 'max-w-4xl'.",
className: {
className: 'max-w-6xl',
classList: {
classList: 'foo max-w-4xl max-w-6xl hover:underline',
},
},
otherClassNames: [
{
className: 'max-w-4xl',
classList: {
classList: 'foo max-w-4xl max-w-6xl hover:underline',
},
},
],
},
],
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ function* findConflicts(
conflictingClassNames.push(otherClassName)
}

if (conflictingClassNames.length === 0) return
if (conflictingClassNames.length === 0) continue

yield [className, conflictingClassNames]
}
Expand Down
1 change: 1 addition & 0 deletions packages/vscode-tailwindcss/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Properly validate `theme(…)` function paths in v4 ([#1074](https://github.com/tailwindlabs/tailwindcss-intellisense/pull/1074))
- Support loading TypeScript configs and plugins in v4 projects ([#1076](https://github.com/tailwindlabs/tailwindcss-intellisense/pull/1076))
- Show colors for logical border properties ([#1075](https://github.com/tailwindlabs/tailwindcss-intellisense/pull/1075))
- Show all potential class conflicts in v4 projects ([#1077](https://github.com/tailwindlabs/tailwindcss-intellisense/pull/1077))

## 0.12.12

Expand Down