Skip to content

Commit 21459bc

Browse files
committed
fix: include .d.mts and .d.cts and .ts
1 parent 95d1976 commit 21459bc

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

src/configs/typescript.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import process from 'node:process'
2-
import { GLOB_TS, GLOB_TSX } from '../constants/glob'
2+
import { GLOB_ASTRO_TS, GLOB_MARKDOWN, GLOB_TS, GLOB_TSX } from '../constants/glob'
33
import { pluginAntfu } from '../plugins'
44
import { interopDefault, renameRules, toArray } from '../shared'
55
import type {
@@ -27,6 +27,10 @@ export async function typescript(
2727
]
2828

2929
const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX]
30+
const ignoresTypeAware = options.ignoresTypeAware ?? [
31+
`${GLOB_MARKDOWN}/**`,
32+
GLOB_ASTRO_TS,
33+
]
3034

3135
const tsconfigPath = options?.tsconfigPath
3236
? toArray(options.tsconfigPath)
@@ -99,7 +103,7 @@ export async function typescript(
99103
// assign type-aware parser for type-aware files and type-unaware parser for the rest
100104
...(isTypeAware
101105
? [
102-
makeParser(true, filesTypeAware),
106+
makeParser(true, filesTypeAware, ignoresTypeAware),
103107
makeParser(false, files, filesTypeAware),
104108
]
105109
: [makeParser(false, files)]),
@@ -156,6 +160,7 @@ export async function typescript(
156160
? [
157161
{
158162
files: filesTypeAware,
163+
ignores: ignoresTypeAware,
159164
name: 'coderwyd/typescript/rules-type-aware',
160165
rules: {
161166
...(tsconfigPath ? typeAwareRules : {}),
@@ -165,7 +170,7 @@ export async function typescript(
165170
]
166171
: []),
167172
{
168-
files: ['**/*.d.ts'],
173+
files: [GLOB_TS],
169174
name: 'coderwyd/typescript/disables/dts',
170175
rules: {
171176
'eslint-comments/no-unlimited-disable': 'off',

src/constants/glob.ts

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export const GLOB_TSX = '**/*.?([cm])tsx'
99

1010
export const GLOB_VUE = '**/*.vue'
1111
export const GLOB_ASTRO = '**/*.astro'
12+
export const GLOB_ASTRO_TS = '**/*.astro/*.ts'
1213
export const GLOB_SVELTE = '**/*.svelte'
1314

1415
export const GLOB_HTML = '**/*.htm?(l)'

src/types/index.ts

+6
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ export interface OptionsTypeScriptParserOptions {
8383
* @default ['**\/*.{ts,tsx}']
8484
*/
8585
filesTypeAware?: string[]
86+
87+
/**
88+
* Glob patterns for files that should not be type aware.
89+
* @default ['**\/*.md\/**', '**\/*.astro/*.ts']
90+
*/
91+
ignoresTypeAware?: string[]
8692
}
8793

8894
export interface OptionsTypeScriptWithTypes {

0 commit comments

Comments
 (0)