@postxl/generator 1.0.3 → 1.0.4
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/utils/lint.d.ts +7 -0
- package/dist/utils/lint.js +25 -1
- package/package.json +1 -1
package/dist/utils/lint.d.ts
CHANGED
|
@@ -39,6 +39,13 @@ export type LintOptions = {
|
|
|
39
39
|
* Default: false
|
|
40
40
|
*/
|
|
41
41
|
verbose: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Base path to use for ESLint config resolution.
|
|
44
|
+
* If not provided, will auto-detect based on workspace structure.
|
|
45
|
+
*
|
|
46
|
+
* Default: auto-detected
|
|
47
|
+
*/
|
|
48
|
+
basePath?: string;
|
|
42
49
|
logger?: Logger;
|
|
43
50
|
};
|
|
44
51
|
export declare function lint(vfs: VirtualFileSystem, options?: Partial<LintOptions>): Promise<LintResults>;
|
package/dist/utils/lint.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.lint = lint;
|
|
4
4
|
exports.logLintResults = logLintResults;
|
|
5
|
+
const fs_1 = require("fs");
|
|
5
6
|
const path_1 = require("path");
|
|
6
7
|
const process_1 = require("process");
|
|
7
8
|
const eslint_1 = require("eslint");
|
|
@@ -26,6 +27,27 @@ function ignoreMessage(message) {
|
|
|
26
27
|
}
|
|
27
28
|
return false;
|
|
28
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Detects the base path for ESLint config resolution.
|
|
32
|
+
* Looks for pnpm-workspace.yaml to determine if we're in a monorepo workspace.
|
|
33
|
+
* If in a workspace, returns the workspace root (../../ from packages/generator).
|
|
34
|
+
* Otherwise, returns the current working directory.
|
|
35
|
+
*/
|
|
36
|
+
function detectBasePath() {
|
|
37
|
+
const currentDir = (0, process_1.cwd)();
|
|
38
|
+
// Try to find workspace root by looking for pnpm-workspace.yaml
|
|
39
|
+
// Check current directory and up to 3 levels up
|
|
40
|
+
const dirsToCheck = [currentDir, (0, path_1.join)(currentDir, '..'), (0, path_1.join)(currentDir, '../..'), (0, path_1.join)(currentDir, '../../..')];
|
|
41
|
+
for (const dir of dirsToCheck) {
|
|
42
|
+
const workspaceFile = (0, path_1.join)(dir, 'pnpm-workspace.yaml');
|
|
43
|
+
if ((0, fs_1.existsSync)(workspaceFile)) {
|
|
44
|
+
// Found workspace root
|
|
45
|
+
return dir;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
// Not in a workspace, use current directory
|
|
49
|
+
return currentDir;
|
|
50
|
+
}
|
|
29
51
|
async function lint(vfs, options = {}) {
|
|
30
52
|
const opts = { ...defaultOptions, ...options };
|
|
31
53
|
const logger = opts.logger ?? new logger_class_1.Logger();
|
|
@@ -38,8 +60,10 @@ async function lint(vfs, options = {}) {
|
|
|
38
60
|
if (opts.skipLint) {
|
|
39
61
|
return results;
|
|
40
62
|
}
|
|
63
|
+
// Use provided basePath or auto-detect
|
|
64
|
+
const basePath = opts.basePath ?? detectBasePath();
|
|
41
65
|
const linter = new eslint_1.ESLint({
|
|
42
|
-
cwd:
|
|
66
|
+
cwd: basePath,
|
|
43
67
|
fix: opts.noFix ? false : (m) => !ignoreMessage(m),
|
|
44
68
|
warnIgnored: false,
|
|
45
69
|
});
|