Skip to content

Commit 93874bf

Browse files
authored
fix: added support for mts and cts (#288)
1 parent d3f36f4 commit 93874bf

3 files changed

Lines changed: 25 additions & 1 deletion

File tree

docs/capabilities.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import { MY_KEY } from '$env/static/public';
3232
MY_KEY
3333
```
3434

35-
Default scanned file types: .ts, .js, jsx, tsx, vue, .mjs, .cjs, .svelte
35+
Default scanned file types: .ts, .js, jsx, tsx, vue, .mjs, .mts, .cjs, .cts, .svelte
3636

3737
## What It Checks For
3838

src/core/scan/patterns.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ export const DEFAULT_INCLUDE_EXTENSIONS = [
120120
'.vue',
121121
'.svelte',
122122
'.mjs',
123+
'.mts',
123124
'.cjs',
125+
'.cts',
124126
];
125127

126128
// Default patterns to exclude from scans

test/unit/core/scan/patterns.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { describe, it, expect } from 'vitest';
22
import { scanFile } from '../../../../src/core/scan/scanFile';
3+
import { DEFAULT_INCLUDE_EXTENSIONS } from '../../../../src/core/scan/patterns';
34
import type { ScanOptions } from '../../../../src/config/types';
45

56
describe('scanFile - Pattern Detection', () => {
@@ -158,4 +159,25 @@ describe('scanFile - Pattern Detection', () => {
158159
});
159160
});
160161
});
162+
163+
describe('Default include extensions', () => {
164+
it('includes .mts in default scan extensions', () => {
165+
expect(DEFAULT_INCLUDE_EXTENSIONS).toContain('.mts');
166+
});
167+
168+
it('includes .cts in default scan extensions', () => {
169+
expect(DEFAULT_INCLUDE_EXTENSIONS).toContain('.cts');
170+
});
171+
172+
it('will detect patterns in .mts files', () => {
173+
const code = 'const val = process.env.MY_KEY;';
174+
const result = scanFile('test.mts', code, baseOpts);
175+
176+
expect(result).toHaveLength(1);
177+
expect(result[0]).toMatchObject({
178+
variable: 'MY_KEY',
179+
pattern: 'process.env',
180+
});
181+
});
182+
});
161183
});

0 commit comments

Comments
 (0)