Skip to content

Commit a8fd8cb

Browse files
appano1ota-meshi
andauthored
feat: Support glob pattern in options.project (#84)
* feat: Support glob pattern in options.project * Create slow-jobs-confess.md --------- Co-authored-by: Yosuke Ota <[email protected]>
1 parent 7cbd9b5 commit a8fd8cb

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

Diff for: .changeset/slow-jobs-confess.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"typescript-eslint-parser-for-extra-files": minor
3+
---
4+
5+
feat: Support glob pattern in `options.project`

Diff for: 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",

Diff for: 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)