Skip to content

Commit cf4fb50

Browse files
committed
fix: support mts/cts file extensions for TypeScript
1 parent 5fab143 commit cf4fb50

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/typescript.cts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import makeSynchronous from "make-synchronous"
55
import { findOneFile } from "./utils.cjs"
66
import type { GlobifiedEntry } from "globify-gitignore"
77

8-
const tsFiles = ["**/*.tsx", "**/*.ts"]
8+
const tsFiles = ["**/*.tsx", "**/*.ts", "**/*.mts", "**/*.cts"]
99
const project = ["**/tsconfig.json", "!**/node_modules/**/tsconfig.json"]
1010

1111
function globifyGitIgnoreFileWithDeps(cwd: string, include: boolean) {
@@ -20,9 +20,11 @@ const globifyGitIgnoreFileSync = makeSynchronous(globifyGitIgnoreFileWithDeps) a
2020

2121
/** Check if there are any tsconfig.json files */
2222
function disableProjectBasedRules() {
23+
const cwd = process.cwd()
24+
2325
// get all the files that are ignored by git
2426
const ignore =
25-
globifyGitIgnoreFileSync(".", true)?.map((entry) => {
27+
globifyGitIgnoreFileSync(cwd, true)?.map((entry) => {
2628
if (entry.included) {
2729
return `!${entry.glob}`
2830
}
@@ -38,13 +40,15 @@ function disableProjectBasedRules() {
3840
)
3941

4042
// check if there are any ts files
41-
const hasTsFile = findOneFile(process.cwd(), tsFiles, ignore)
43+
const hasTsFile = findOneFile(cwd, tsFiles, ignore)
44+
45+
// return if there are no ts files
4246
if (!hasTsFile) {
4347
return true
4448
}
4549

4650
// check if there is a tsconfig.json file
47-
const hasTsConfig = findOneFile(process.cwd(), project, ignore)
51+
const hasTsConfig = findOneFile(cwd, project, ignore)
4852

4953
// if there is no tsconfig.json file, but there are ts files, disable the project-based rules
5054
const disable = !hasTsConfig && hasTsFile

0 commit comments

Comments
 (0)