Skip to content

Commit d0179b4

Browse files
authored
Merge branch 'main' into fix/v4-load-via-jiti
2 parents 78d34c4 + 5798007 commit d0179b4

File tree

33 files changed

+567
-179
lines changed

33 files changed

+567
-179
lines changed

packages/tailwindcss-language-server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@tailwindcss/language-server",
33
"description": "Tailwind CSS Language Server",
44
"license": "MIT",
5-
"version": "0.0.25",
5+
"version": "0.0.26",
66
"repository": {
77
"type": "git",
88
"url": "git+https://github.com/tailwindlabs/tailwindcss-intellisense.git",

packages/tailwindcss-language-server/src/oxide.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,21 @@ export async function scan(options: ScanOptions): Promise<ScanResult | null> {
131131
}
132132

133133
// V3
134+
if (lte(options.oxideVersion, '4.0.0-alpha.30')) {
135+
let scanner = new oxide.Scanner({
136+
detectSources: { base: options.basePath },
137+
sources: options.sources,
138+
})
139+
140+
return {
141+
files: scanner.files,
142+
globs: scanner.globs,
143+
}
144+
}
145+
146+
// V4
134147
let scanner = new oxide.Scanner({
135-
detectSources: { base: options.basePath },
136-
sources: options.sources,
148+
sources: [{ base: options.basePath, pattern: '**/*' }, ...options.sources],
137149
})
138150

139151
return {

packages/tailwindcss-language-server/tests/colors/colors.test.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { test } from 'vitest'
1+
import { test, expect } from 'vitest'
22
import { withFixture } from '../common'
33

44
withFixture('basic', (c) => {
@@ -169,9 +169,9 @@ withFixture('v4/basic', (c) => {
169169
{
170170
range: { start: { line: 0, character: 12 }, end: { line: 0, character: 22 } },
171171
color: {
172-
red: 0.9372549019607843,
173-
green: 0.26666666666666666,
174-
blue: 0.26666666666666666,
172+
red: expect.closeTo(0.98, 0.01),
173+
green: expect.closeTo(0.172, 0.01),
174+
blue: expect.closeTo(0.21, 0.01),
175175
alpha: 1,
176176
},
177177
},
@@ -184,9 +184,9 @@ withFixture('v4/basic', (c) => {
184184
{
185185
range: { start: { line: 0, character: 12 }, end: { line: 0, character: 25 } },
186186
color: {
187-
red: 0.9372549019607843,
188-
green: 0.26666666666666666,
189-
blue: 0.26666666666666666,
187+
red: expect.closeTo(0.98, 0.01),
188+
green: expect.closeTo(0.172, 0.01),
189+
blue: expect.closeTo(0.21, 0.01),
190190
alpha: 0.2,
191191
},
192192
},

packages/tailwindcss-language-server/tests/completions/completions.test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,8 @@ withFixture('v4/basic', (c) => {
310310
let result = await completion({ lang, text, position, settings })
311311
let textEdit = expect.objectContaining({ range: { start: position, end: position } })
312312

313-
expect(result.items.length).toBe(12398)
314-
expect(result.items.filter((item) => item.label.endsWith(':')).length).toBe(224)
313+
expect(result.items.length).toBe(12492)
314+
expect(result.items.filter((item) => item.label.endsWith(':')).length).toBe(270)
315315
expect(result).toEqual({
316316
isIncomplete: false,
317317
items: expect.arrayContaining([
@@ -553,11 +553,11 @@ withFixture('v4/basic', (c) => {
553553
expect(resolved).toEqual({
554554
...item,
555555
detail:
556-
'font-size: var(--font-size-sm, 0.875rem /* 8.75px */); line-height: var(--font-size-sm--line-height, 1.25rem /* 12.5px */);',
556+
'font-size: var(--font-size-sm, 0.875rem /* 8.75px */); line-height: var(--tw-leading, var(--font-size-sm--line-height, 1.25rem /* 12.5px */));',
557557
documentation: {
558558
kind: 'markdown',
559559
value:
560-
'```css\n.text-sm {\n font-size: var(--font-size-sm, 0.875rem /* 8.75px */);\n line-height: var(--font-size-sm--line-height, 1.25rem /* 12.5px */);\n}\n```',
560+
'```css\n.text-sm {\n font-size: var(--font-size-sm, 0.875rem /* 8.75px */);\n line-height: var(--tw-leading, var(--font-size-sm--line-height, 1.25rem /* 12.5px */));\n}\n```',
561561
},
562562
})
563563
})
@@ -579,8 +579,8 @@ withFixture('v4/basic', (c) => {
579579

580580
expect(resolved).toEqual({
581581
...item,
582-
detail: 'background-color: var(--color-red-500, #ef4444);',
583-
documentation: '#ef4444',
582+
detail: 'background-color: var(--color-red-500, oklch(0.637 0.237 25.331));',
583+
documentation: '#fb2c36',
584584
})
585585
})
586586
})

packages/tailwindcss-language-server/tests/diagnostics/diagnostics.test.js

Lines changed: 184 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,23 @@ withFixture('v4/basic', (c) => {
5959
})
6060
}
6161

62+
function testInline(fixture, { code, expected, language = 'html' }) {
63+
test(fixture, async () => {
64+
let promise = new Promise((resolve) => {
65+
c.onNotification('textDocument/publishDiagnostics', ({ diagnostics }) => {
66+
resolve(diagnostics)
67+
})
68+
})
69+
70+
let doc = await c.openDocument({ text: code, lang: language })
71+
let diagnostics = await promise
72+
73+
expected = JSON.parse(JSON.stringify(expected).replaceAll('{{URI}}', doc.uri))
74+
75+
expect(diagnostics).toEqual(expected)
76+
})
77+
}
78+
6279
testFixture('css-conflict/simple')
6380
testFixture('css-conflict/variants-negative')
6481
testFixture('css-conflict/variants-positive')
@@ -69,5 +86,171 @@ withFixture('v4/basic', (c) => {
6986
// testFixture('css-conflict/css-multi-rule')
7087
// testFixture('css-conflict/css-multi-prop')
7188
// testFixture('invalid-screen/simple')
72-
// testFixture('invalid-theme/simple')
89+
90+
testInline('simple typos in theme keys (in key)', {
91+
code: '.test { color: theme(--color-red-901) }',
92+
language: 'css',
93+
expected: [
94+
{
95+
code: 'invalidConfigPath',
96+
range: { start: { line: 0, character: 21 }, end: { line: 0, character: 36 } },
97+
severity: 1,
98+
message: "'--color-red-901' does not exist in your theme. Did you mean '--color-red-900'?",
99+
suggestions: ['--color-red-900'],
100+
},
101+
],
102+
})
103+
104+
testInline('simple typos in theme keys (in namespace)', {
105+
code: '.test { color: theme(--colors-red-901) }',
106+
language: 'css',
107+
expected: [
108+
{
109+
code: 'invalidConfigPath',
110+
range: { start: { line: 0, character: 21 }, end: { line: 0, character: 37 } },
111+
severity: 1,
112+
message: "'--colors-red-901' does not exist in your theme. Did you mean '--color-red-900'?",
113+
suggestions: ['--color-red-900'],
114+
},
115+
],
116+
})
117+
118+
testInline('No similar theme key exists', {
119+
code: '.test { color: theme(--font-obliqueness-90) }',
120+
language: 'css',
121+
expected: [
122+
{
123+
code: 'invalidConfigPath',
124+
range: { start: { line: 0, character: 21 }, end: { line: 0, character: 42 } },
125+
severity: 1,
126+
message: "'--font-obliqueness-90' does not exist in your theme.",
127+
suggestions: [],
128+
},
129+
],
130+
})
131+
132+
testInline('valid theme keys dont issue diagnostics', {
133+
code: '.test { color: theme(--color-red-900) }',
134+
language: 'css',
135+
expected: [],
136+
})
137+
138+
testInline('types in legacy theme config paths', {
139+
code: '.test { color: theme(colors.red.901) }',
140+
language: 'css',
141+
expected: [
142+
{
143+
code: 'invalidConfigPath',
144+
range: { start: { line: 0, character: 21 }, end: { line: 0, character: 35 } },
145+
severity: 1,
146+
message: "'colors.red.901' does not exist in your theme config.",
147+
suggestions: [],
148+
},
149+
],
150+
})
151+
152+
testInline('valid legacy theme config paths', {
153+
code: '.test { color: theme(colors.red.900) }',
154+
language: 'css',
155+
expected: [],
156+
})
157+
})
158+
159+
withFixture('v4/with-prefix', (c) => {
160+
function testInline(fixture, { code, expected, language = 'html' }) {
161+
test(fixture, async () => {
162+
let promise = new Promise((resolve) => {
163+
c.onNotification('textDocument/publishDiagnostics', ({ diagnostics }) => {
164+
resolve(diagnostics)
165+
})
166+
})
167+
168+
let doc = await c.openDocument({ text: code, lang: language })
169+
let diagnostics = await promise
170+
171+
expected = JSON.parse(JSON.stringify(expected).replaceAll('{{URI}}', doc.uri))
172+
173+
expect(diagnostics).toEqual(expected)
174+
})
175+
}
176+
177+
// testFixture('css-conflict/simple')
178+
// testFixture('css-conflict/variants-negative')
179+
// testFixture('css-conflict/variants-positive')
180+
// testFixture('css-conflict/jsx-concat-negative')
181+
// testFixture('css-conflict/jsx-concat-positive')
182+
// testFixture('css-conflict/vue-style-lang-sass')
183+
184+
// testFixture('css-conflict/css')
185+
// testFixture('css-conflict/css-multi-rule')
186+
// testFixture('css-conflict/css-multi-prop')
187+
// testFixture('invalid-screen/simple')
188+
189+
testInline('simple typos in theme keys (in key)', {
190+
code: '.test { color: theme(--color-red-901) }',
191+
language: 'css',
192+
expected: [
193+
{
194+
code: 'invalidConfigPath',
195+
range: { start: { line: 0, character: 21 }, end: { line: 0, character: 36 } },
196+
severity: 1,
197+
message: "'--color-red-901' does not exist in your theme. Did you mean '--color-red-900'?",
198+
suggestions: ['--color-red-900'],
199+
},
200+
],
201+
})
202+
203+
testInline('simple typos in theme keys (in namespace)', {
204+
code: '.test { color: theme(--colors-red-901) }',
205+
language: 'css',
206+
expected: [
207+
{
208+
code: 'invalidConfigPath',
209+
range: { start: { line: 0, character: 21 }, end: { line: 0, character: 37 } },
210+
severity: 1,
211+
message: "'--colors-red-901' does not exist in your theme. Did you mean '--color-red-900'?",
212+
suggestions: ['--color-red-900'],
213+
},
214+
],
215+
})
216+
217+
testInline('No similar theme key exists', {
218+
code: '.test { color: theme(--font-obliqueness-90) }',
219+
language: 'css',
220+
expected: [
221+
{
222+
code: 'invalidConfigPath',
223+
range: { start: { line: 0, character: 21 }, end: { line: 0, character: 42 } },
224+
severity: 1,
225+
message: "'--font-obliqueness-90' does not exist in your theme.",
226+
suggestions: [],
227+
},
228+
],
229+
})
230+
231+
testInline('valid theme keys dont issue diagnostics', {
232+
code: '.test { color: theme(--color-red-900) }',
233+
language: 'css',
234+
expected: [],
235+
})
236+
237+
testInline('types in legacy theme config paths', {
238+
code: '.test { color: theme(colors.red.901) }',
239+
language: 'css',
240+
expected: [
241+
{
242+
code: 'invalidConfigPath',
243+
range: { start: { line: 0, character: 21 }, end: { line: 0, character: 35 } },
244+
severity: 1,
245+
message: "'colors.red.901' does not exist in your theme config.",
246+
suggestions: [],
247+
},
248+
],
249+
})
250+
251+
testInline('valid legacy theme config paths', {
252+
code: '.test { color: theme(colors.red.900) }',
253+
language: 'css',
254+
expected: [],
255+
})
73256
})

0 commit comments

Comments
 (0)