xo 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/handle-ts-files.js +0 -1
- package/dist/lib/xo.d.ts +7 -1
- package/dist/lib/xo.js +22 -1
- package/package.json +1 -1
|
@@ -28,7 +28,6 @@ export async function handleTsconfig({ cwd, files }) {
|
|
|
28
28
|
tsConfig.files = unincludedFiles;
|
|
29
29
|
if (unincludedFiles.length > 0) {
|
|
30
30
|
try {
|
|
31
|
-
await fs.mkdir(path.dirname(fallbackTsConfigPath), { recursive: true });
|
|
32
31
|
await fs.writeFile(fallbackTsConfigPath, JSON.stringify(tsConfig, null, 2));
|
|
33
32
|
}
|
|
34
33
|
catch (error) {
|
package/dist/lib/xo.d.ts
CHANGED
|
@@ -48,7 +48,7 @@ export declare class Xo {
|
|
|
48
48
|
*/
|
|
49
49
|
flatConfigPath?: string | undefined;
|
|
50
50
|
/**
|
|
51
|
-
If any user configs
|
|
51
|
+
If any user configs contain Prettier, we will need to fetch the Prettier config.
|
|
52
52
|
*/
|
|
53
53
|
prettier?: boolean;
|
|
54
54
|
/**
|
|
@@ -85,6 +85,12 @@ export declare class Xo {
|
|
|
85
85
|
*/
|
|
86
86
|
setIgnores(): void;
|
|
87
87
|
/**
|
|
88
|
+
Ensures the cache directory exists. This needs to run once before both tsconfig handling and running ESLint occur.
|
|
89
|
+
|
|
90
|
+
@private
|
|
91
|
+
*/
|
|
92
|
+
ensureCacheDirectory(): Promise<void>;
|
|
93
|
+
/**
|
|
88
94
|
Checks every TS file to ensure its included in the tsconfig and any that are not included are added to a generated tsconfig for type aware linting.
|
|
89
95
|
|
|
90
96
|
@param files - The TypeScript files being linted.
|
package/dist/lib/xo.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import os from 'node:os';
|
|
3
|
+
import fs from 'node:fs/promises';
|
|
3
4
|
import process from 'node:process';
|
|
4
5
|
import { ESLint } from 'eslint';
|
|
5
6
|
import findCacheDirectory from 'find-cache-directory';
|
|
@@ -95,7 +96,7 @@ export class Xo {
|
|
|
95
96
|
*/
|
|
96
97
|
flatConfigPath;
|
|
97
98
|
/**
|
|
98
|
-
If any user configs
|
|
99
|
+
If any user configs contain Prettier, we will need to fetch the Prettier config.
|
|
99
100
|
*/
|
|
100
101
|
prettier;
|
|
101
102
|
/**
|
|
@@ -181,6 +182,25 @@ export class Xo {
|
|
|
181
182
|
this.xoConfig.push({ ignores });
|
|
182
183
|
}
|
|
183
184
|
/**
|
|
185
|
+
Ensures the cache directory exists. This needs to run once before both tsconfig handling and running ESLint occur.
|
|
186
|
+
|
|
187
|
+
@private
|
|
188
|
+
*/
|
|
189
|
+
async ensureCacheDirectory() {
|
|
190
|
+
try {
|
|
191
|
+
const cacheStats = await fs.stat(this.cacheLocation);
|
|
192
|
+
// If file, re-create as directory
|
|
193
|
+
if (cacheStats.isFile()) {
|
|
194
|
+
await fs.rm(this.cacheLocation, { recursive: true, force: true });
|
|
195
|
+
await fs.mkdir(this.cacheLocation, { recursive: true });
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
catch {
|
|
199
|
+
// If not exists, create the directory
|
|
200
|
+
await fs.mkdir(this.cacheLocation, { recursive: true });
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
184
204
|
Checks every TS file to ensure its included in the tsconfig and any that are not included are added to a generated tsconfig for type aware linting.
|
|
185
205
|
|
|
186
206
|
@param files - The TypeScript files being linted.
|
|
@@ -215,6 +235,7 @@ export class Xo {
|
|
|
215
235
|
async initEslint(files) {
|
|
216
236
|
await this.setXoConfig();
|
|
217
237
|
this.setIgnores();
|
|
238
|
+
await this.ensureCacheDirectory();
|
|
218
239
|
await this.handleUnincludedTsFiles(files);
|
|
219
240
|
this.setEslintConfig();
|
|
220
241
|
if (!this.xoConfig) {
|