Skip to content

Commit adbcf19

Browse files
committed
feat(serve): exclude built-in components from checks
1 parent 96b21a5 commit adbcf19

3 files changed

Lines changed: 16 additions & 3 deletions

File tree

src/server/compatibility.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import safeParser from 'postcss-safe-parser'
55
import valueParser from 'postcss-value-parser'
66
import { Parser } from 'htmlparser2'
77
import { DomHandler, type ChildNode, type Element } from 'domhandler'
8-
import { parseSfcBlocks, findComponentTags, buildComponentMap, type SfcBlock } from './sfc-utils.ts'
8+
import { parseSfcBlocks, findComponentTags, buildComponentMap, isFrameworkComponent, type SfcBlock } from './sfc-utils.ts'
99
import { scanLint } from './linter.ts'
1010
import { tailwindcss as compileWithPipeline } from '../transformers/tailwindcss.ts'
1111
import type { MaizzleConfig } from '../types/index.ts'
@@ -915,6 +915,7 @@ export async function serveCompatibility(
915915
})
916916

917917
let issues: Issue[] = [...compatIssues, ...lintAsIssues]
918+
issues = issues.filter((i) => !isFrameworkComponent(i.file))
918919
if (checksCfg.level) issues = issues.filter((i) => passesLevelFilter(i, checksCfg.level))
919920
issues.sort((a, b) => {
920921
const c = CATEGORY_ORDER.indexOf(a.category) - CATEGORY_ORDER.indexOf(b.category)

src/server/linter.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { readFileSync } from 'node:fs'
22
import { resolve } from 'node:path'
3-
import { parseSfcBlocks, findComponentTags, buildComponentMap } from './sfc-utils.ts'
3+
import { parseSfcBlocks, findComponentTags, buildComponentMap, isFrameworkComponent } from './sfc-utils.ts'
44
import type { MaizzleConfig } from '../types/index.ts'
55
import type { NormalizedComponentSource } from '../utils/componentSources.ts'
66

@@ -67,7 +67,8 @@ export async function serveLint(url: string, res: any, config: MaizzleConfig, co
6767

6868
try {
6969
const absolutePath = resolve(filePath)
70-
const issues = await scanLint(absolutePath, config, componentDirs)
70+
const issues = (await scanLint(absolutePath, config, componentDirs))
71+
.filter(i => !isFrameworkComponent(i.file))
7172

7273
// Sort: errors first, then warnings, then by line
7374
issues.sort((a, b) => {

src/server/sfc-utils.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ import { componentNameFromPath, type NormalizedComponentSource } from '../utils/
66

77
const __dirname = dirname(fileURLToPath(import.meta.url))
88

9+
/**
10+
* Built-in framework components Maizzle ships internally. Issues raised
11+
* against these files are framework-owned, not the user's responsibility,
12+
* so the dev UI's Checks tab filters them out.
13+
*/
14+
const FRAMEWORK_COMPONENTS_DIR = resolve(__dirname, '../components').replace(/\\/g, '/') + '/'
15+
16+
export function isFrameworkComponent(file: string): boolean {
17+
return file.replace(/\\/g, '/').startsWith(FRAMEWORK_COMPONENTS_DIR)
18+
}
19+
920
export interface SfcBlock {
1021
content: string
1122
offset: number

0 commit comments

Comments
 (0)