Skip to content

Commit dbab175

Browse files
committed
feat: Support glob pattern in options.project
1 parent fb11abe commit dbab175

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
"eslint-plugin-svelte": "^2.11.0",
9797
"eslint-plugin-vue": "^9.6.0",
9898
"eslint-plugin-yml": "^1.2.0",
99+
"glob": "^10.3.10",
99100
"mocha": "^10.0.0",
100101
"mocha-chai-jest-snapshot": "^1.1.3",
101102
"nyc": "^15.1.0",

src/utils/get-project-config-files.ts

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
11
import type { ParserOptions } from "@typescript-eslint/parser";
22
import fs from "fs";
3+
import { glob } from "glob";
34
import path from "path";
45

6+
function syncWithGlob(pattern: string, cwd: string): string[] {
7+
return glob
8+
.sync(pattern, { cwd })
9+
.map((filePath) => path.resolve(cwd, filePath));
10+
}
11+
512
export function getProjectConfigFiles(options: ParserOptions): string[] {
613
const tsconfigRootDir =
714
typeof options.tsconfigRootDir === "string"
815
? options.tsconfigRootDir
916
: process.cwd();
17+
1018
if (options.project !== true) {
1119
return Array.isArray(options.project)
12-
? options.project
13-
: [options.project!];
20+
? options.project.flatMap((projectPattern: string) =>
21+
syncWithGlob(projectPattern, tsconfigRootDir),
22+
)
23+
: syncWithGlob(options.project!, tsconfigRootDir);
1424
}
1525

1626
let directory = path.dirname(options.filePath!);

0 commit comments

Comments
 (0)