Skip to content

Commit 1d5a53f

Browse files
committed
move to more appropriate location, give function a more appropriate name
1 parent c107f14 commit 1d5a53f

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

packages/kit/src/exports/vite/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import {
3737
import { import_peer } from '../../utils/import.js';
3838
import { compact } from '../../utils/array.js';
3939
import { 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

4242
const 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 =

packages/kit/src/exports/vite/comment_utils.js renamed to packages/kit/src/exports/vite/static_analysis/utils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
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;

packages/kit/src/exports/vite/comment_utils.spec.js renamed to packages/kit/src/exports/vite/static_analysis/utils.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { expect, test, vi } from 'vitest';
22
import 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
66
vi.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
}

0 commit comments

Comments
 (0)