Skip to content

Commit 111492c

Browse files
committed
feat(tests): add tests for Sass deprecation warnings and file type validation
- Created `import-deprecation-test.vue` to test Sass @import deprecation warnings. - Created `mixed-decls-fix-test.vue` to test Sass mixed-declarations deprecation warnings. - Added `file-type-validation.test.ts` to validate file type detection and processing for JavaScript and Vue files. - Implemented `sass-mixed-decls.test.ts` to ensure Sass compiles without mixed-decls warnings and handles modern features. - Added `unplugin-filter.test.ts` to test node_modules filtering logic in unplugin.
1 parent a7cbcb9 commit 111492c

17 files changed

+2535
-75
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@
106106
"@unocss/core": "^0.50.8",
107107
"@unocss/preset-uno": "^0.50.8",
108108
"@vue/babel-plugin-jsx": "^1.4.0",
109-
"@vue/compiler-sfc": "^3.5.17",
109+
"@vue/compiler-sfc": "^3.5.18",
110110
"fast-glob": "^3.3.3",
111111
"node-html-parser": "^7.0.1",
112-
"transform-to-unocss-core": "^0.0.68",
112+
"transform-to-unocss-core": "^0.0.69",
113113
"unplugin": "^2.3.5"
114114
},
115115
"devDependencies": {

patches/@[email protected]

Lines changed: 0 additions & 26 deletions
This file was deleted.

patches/@[email protected]

Lines changed: 0 additions & 13 deletions
This file was deleted.

pnpm-lock.yaml

Lines changed: 85 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/compilerCss.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,26 @@ export function compilerCss(
1212
globalCss?: string,
1313
debug?: boolean,
1414
) {
15+
// 添加输入验证
16+
if (typeof css !== 'string') {
17+
if (debug) {
18+
console.warn(
19+
`[transform-to-unocss] compilerCss received non-string CSS input: ${typeof css}, filepath: ${filepath}`,
20+
)
21+
}
22+
return String(css || '')
23+
}
24+
25+
// 验证语言类型
26+
if (!['stylus', 'less', 'scss', 'css'].includes(lang)) {
27+
if (debug) {
28+
console.warn(
29+
`[transform-to-unocss] compilerCss received unknown language: ${lang}, filepath: ${filepath}`,
30+
)
31+
}
32+
return css
33+
}
34+
1535
switch (lang) {
1636
case 'stylus':
1737
return stylusCompiler(css, filepath, globalCss, debug)

0 commit comments

Comments
 (0)