File tree Expand file tree Collapse file tree 3 files changed +6
-6
lines changed
packages/kit/src/exports/vite Expand file tree Collapse file tree 3 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ import {
3737import { import_peer } from '../../utils/import.js' ;
3838import { compact } from '../../utils/array.js' ;
3939import { build_remotes , treeshake_prerendered_remotes } from './build/build_remote.js' ;
40- import { is_within_comment } from './comment_utils .js' ;
40+ import { should_ignore } from './static_analysis/utils .js' ;
4141
4242const cwd = process . cwd ( ) ;
4343
@@ -91,7 +91,7 @@ const warning_preprocessor = {
9191 const basename = path . basename ( filename ) ;
9292 if ( basename . startsWith ( '+page.' ) || basename . startsWith ( '+layout.' ) ) {
9393 const match = content . match ( options_regex ) ;
94- if ( match && match . index !== undefined && ! is_within_comment ( content , match . index ) ) {
94+ if ( match && match . index !== undefined && ! should_ignore ( content , match . index ) ) {
9595 const fixed = basename . replace ( '.svelte' , '(.server).js/ts' ) ;
9696
9797 const message =
Original file line number Diff line number Diff line change 11/**
2- * Check if a match position is within a comment, accounting for strings and escaped characters
2+ * Check if a match position is within a comment or a string
33 * @param {string } content - The full content
44 * @param {number } match_index - The index where the match starts
55 * @returns {boolean } - True if the match is within a comment
66 */
7- export function is_within_comment ( content , match_index ) {
7+ export function should_ignore ( content , match_index ) {
88 // Track if we're inside different types of quotes and comments
99 let in_single_quote = false ;
1010 let in_double_quote = false ;
Original file line number Diff line number Diff line change 11import { expect , test , vi } from 'vitest' ;
22import path from 'node:path' ;
3- import { is_within_comment } from './comment_utils .js' ;
3+ import { should_ignore } from './utils .js' ;
44
55// Mock the colors module to avoid issues in tests
66vi . mock ( 'kleur' , ( ) => ( {
@@ -21,7 +21,7 @@ function should_warn_for_content(content, filename) {
2121 const basename = path . basename ( filename ) ;
2222 if ( basename . startsWith ( '+page.' ) || basename . startsWith ( '+layout.' ) ) {
2323 const match = content . match ( options_regex ) ;
24- return match && match . index !== undefined && ! is_within_comment ( content , match . index ) ;
24+ return match && match . index !== undefined && ! should_ignore ( content , match . index ) ;
2525 }
2626 return false ;
2727}
You can’t perform that action at this time.
0 commit comments