Skip to content

Commit 03ad23d

Browse files
Update default file exclusions (#1336)
IntelliSense, by default, ignores files for: - Version control (`.git`, `.hg`, `.svn`) - NPM (`node_modules`) I'm adding three more groups to this: - Python virtual environment folders (`.venv`, `venv`) - Yarn v2+ metadata & caches (`.yarn`) - *some* build caches (`.next`, `.turbo`, `.parcel-cache`, `__pycache__`) Discovered that we should update these when triaging #1312 (that one was specifically about python virtual envs)
1 parent f432c77 commit 03ad23d

File tree

3 files changed

+148
-1
lines changed

3 files changed

+148
-1
lines changed
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
import { expect } from 'vitest'
2+
import { css, defineTest } from '../../src/testing'
3+
import { createClient } from '../utils/client'
4+
import dedent from 'dedent'
5+
6+
let ignored = css`
7+
@import 'tailwindcss';
8+
@theme {
9+
--color-primary: #c0ffee;
10+
}
11+
`
12+
13+
let found = css`
14+
@import 'tailwindcss';
15+
@theme {
16+
--color-primary: rebeccapurple;
17+
}
18+
`
19+
20+
defineTest({
21+
name: 'various build folders and caches are ignored by default',
22+
fs: {
23+
// All of these should be ignored
24+
'aaa/.git/app.css': ignored,
25+
'aaa/.hg/app.css': ignored,
26+
'aaa/.svn/app.css': ignored,
27+
'aaa/node_modules/app.css': ignored,
28+
'aaa/.yarn/app.css': ignored,
29+
'aaa/.venv/app.css': ignored,
30+
'aaa/venv/app.css': ignored,
31+
'aaa/.next/app.css': ignored,
32+
'aaa/.parcel-cache/app.css': ignored,
33+
'aaa/.svelte-kit/app.css': ignored,
34+
'aaa/.turbo/app.css': ignored,
35+
'aaa/__pycache__/app.css': ignored,
36+
37+
// But this one should not be
38+
'zzz/app.css': found,
39+
},
40+
41+
prepare: async ({ root }) => ({ client: await createClient({ root }) }),
42+
handle: async ({ client }) => {
43+
let doc = await client.open({
44+
lang: 'html',
45+
text: '<div class="bg-primary">',
46+
})
47+
48+
// <div class="bg-primary">
49+
// ^
50+
let hover = await doc.hover({ line: 0, character: 13 })
51+
expect(hover).toEqual({
52+
contents: {
53+
language: 'css',
54+
value: dedent`
55+
.bg-primary {
56+
background-color: var(--color-primary) /* rebeccapurple = #663399 */;
57+
}
58+
`,
59+
},
60+
range: {
61+
start: { line: 0, character: 12 },
62+
end: { line: 0, character: 22 },
63+
},
64+
})
65+
},
66+
})
67+
68+
defineTest({
69+
name: 'ignores can be overridden',
70+
fs: {
71+
'aaa/app.css': ignored,
72+
'bbb/.git/app.css': found,
73+
},
74+
75+
prepare: async ({ root }) => ({
76+
client: await createClient({
77+
root,
78+
settings: {
79+
tailwindCSS: {
80+
files: {
81+
exclude: ['**/aaa/**'],
82+
},
83+
},
84+
},
85+
}),
86+
}),
87+
handle: async ({ client }) => {
88+
let doc = await client.open({
89+
lang: 'html',
90+
text: '<div class="bg-primary">',
91+
})
92+
93+
// <div class="bg-primary">
94+
// ^
95+
let hover = await doc.hover({ line: 0, character: 13 })
96+
expect(hover).toEqual({
97+
contents: {
98+
language: 'css',
99+
value: dedent`
100+
.bg-primary {
101+
background-color: var(--color-primary) /* rebeccapurple = #663399 */;
102+
}
103+
`,
104+
},
105+
range: {
106+
start: { line: 0, character: 12 },
107+
end: { line: 0, character: 22 },
108+
},
109+
})
110+
},
111+
})

packages/tailwindcss-language-service/src/util/state.ts

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,40 @@ export function getDefaultTailwindSettings(): Settings {
208208
},
209209
showPixelEquivalents: true,
210210
includeLanguages: {},
211-
files: { exclude: ['**/.git/**', '**/node_modules/**', '**/.hg/**', '**/.svn/**'] },
211+
files: {
212+
exclude: [
213+
// These paths need to be universally ignorable. This means that we
214+
// should only consider hidden folders with a commonly understood
215+
// meaning unless there is a very good reason to do otherwise.
216+
//
217+
// This means that things like `build`, `target`, `cache`, etc… are
218+
// not appropriate to include even though _in many cases_ they might
219+
// be ignorable. The names are too general and ignoring them could
220+
// cause us to ignore actual project files.
221+
222+
// Version Control
223+
'**/.git/**',
224+
'**/.hg/**',
225+
'**/.svn/**',
226+
227+
// NPM
228+
'**/node_modules/**',
229+
230+
// Yarn v2+ metadata & caches
231+
'**/.yarn/**',
232+
233+
// Python Virtual Environments
234+
'**/.venv/**',
235+
'**/venv/**',
236+
237+
// Build caches
238+
'**/.next/**',
239+
'**/.parcel-cache/**',
240+
'**/.svelte-kit/**',
241+
'**/.turbo/**',
242+
'**/__pycache__/**',
243+
],
244+
},
212245
experimental: {
213246
classRegex: [],
214247
configFile: null,

packages/vscode-tailwindcss/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
## Prerelease
44

55
- Improve dynamic capability registration in the language server ([#1327](https://github.com/tailwindlabs/tailwindcss-intellisense/pull/1327))
6+
- Ignore Python virtual env directories by default ([#1336](https://github.com/tailwindlabs/tailwindcss-intellisense/pull/1336))
7+
- Ignore Yarn v2+ metadata & cache directories by default ([#1336](https://github.com/tailwindlabs/tailwindcss-intellisense/pull/1336))
8+
- Ignore some build caches by default ([#1336](https://github.com/tailwindlabs/tailwindcss-intellisense/pull/1336))
69

710
# 0.14.16
811

0 commit comments

Comments
 (0)