@simplysm/sd-cli 13.0.68 → 13.0.70
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/README.md +10 -957
- package/dist/builders/BaseBuilder.d.ts +23 -23
- package/dist/builders/BaseBuilder.d.ts.map +1 -1
- package/dist/builders/BaseBuilder.js +15 -15
- package/dist/builders/DtsBuilder.d.ts +4 -4
- package/dist/builders/DtsBuilder.js +1 -1
- package/dist/builders/LibraryBuilder.d.ts +3 -3
- package/dist/builders/types.d.ts +10 -10
- package/dist/capacitor/capacitor.d.ts +36 -36
- package/dist/capacitor/capacitor.js +63 -63
- package/dist/capacitor/capacitor.js.map +1 -1
- package/dist/commands/add-client.d.ts +8 -8
- package/dist/commands/add-client.js +15 -15
- package/dist/commands/add-client.js.map +1 -1
- package/dist/commands/add-server.d.ts +9 -9
- package/dist/commands/add-server.js +13 -13
- package/dist/commands/add-server.js.map +1 -1
- package/dist/commands/build.d.ts +9 -9
- package/dist/commands/check.js +3 -3
- package/dist/commands/check.js.map +1 -1
- package/dist/commands/dev.d.ts +9 -9
- package/dist/commands/device.d.ts +9 -9
- package/dist/commands/device.d.ts.map +1 -1
- package/dist/commands/device.js +17 -17
- package/dist/commands/device.js.map +1 -1
- package/dist/commands/init.d.ts +6 -6
- package/dist/commands/init.js +12 -12
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/lint.d.ts +23 -23
- package/dist/commands/lint.d.ts.map +1 -1
- package/dist/commands/lint.js +25 -25
- package/dist/commands/lint.js.map +1 -1
- package/dist/commands/publish.d.ts +13 -13
- package/dist/commands/publish.d.ts.map +1 -1
- package/dist/commands/publish.js +61 -61
- package/dist/commands/publish.js.map +1 -1
- package/dist/commands/replace-deps.d.ts +3 -3
- package/dist/commands/replace-deps.d.ts.map +1 -1
- package/dist/commands/replace-deps.js +1 -1
- package/dist/commands/replace-deps.js.map +1 -1
- package/dist/commands/typecheck.d.ts +20 -20
- package/dist/commands/typecheck.d.ts.map +1 -1
- package/dist/commands/typecheck.js +20 -20
- package/dist/commands/typecheck.js.map +1 -1
- package/dist/commands/watch.d.ts +7 -7
- package/dist/electron/electron.d.ts +27 -27
- package/dist/electron/electron.js +32 -32
- package/dist/electron/electron.js.map +1 -1
- package/dist/infra/ResultCollector.d.ts +9 -9
- package/dist/infra/ResultCollector.js +5 -5
- package/dist/infra/SignalHandler.d.ts +7 -7
- package/dist/infra/SignalHandler.js +4 -4
- package/dist/infra/WorkerManager.d.ts +14 -14
- package/dist/infra/WorkerManager.js +11 -11
- package/dist/orchestrators/BuildOrchestrator.d.ts +19 -19
- package/dist/orchestrators/BuildOrchestrator.d.ts.map +1 -1
- package/dist/orchestrators/BuildOrchestrator.js +26 -26
- package/dist/orchestrators/BuildOrchestrator.js.map +1 -1
- package/dist/orchestrators/DevOrchestrator.d.ts +25 -25
- package/dist/orchestrators/DevOrchestrator.d.ts.map +1 -1
- package/dist/orchestrators/DevOrchestrator.js +30 -30
- package/dist/orchestrators/DevOrchestrator.js.map +1 -1
- package/dist/orchestrators/WatchOrchestrator.d.ts +13 -13
- package/dist/orchestrators/WatchOrchestrator.js +17 -17
- package/dist/orchestrators/WatchOrchestrator.js.map +1 -1
- package/dist/sd-cli-entry.d.ts +2 -2
- package/dist/sd-cli-entry.js +38 -38
- package/dist/sd-cli-entry.js.map +1 -1
- package/dist/sd-cli.d.ts +2 -2
- package/dist/sd-cli.js +1 -1
- package/dist/sd-cli.js.map +1 -1
- package/dist/sd-config.types.d.ts +84 -84
- package/dist/sd-config.types.d.ts.map +1 -1
- package/dist/utils/build-env.d.ts +1 -1
- package/dist/utils/config-editor.d.ts +5 -5
- package/dist/utils/config-editor.js +2 -2
- package/dist/utils/config-editor.js.map +1 -1
- package/dist/utils/copy-public.d.ts +9 -9
- package/dist/utils/copy-src.d.ts +9 -9
- package/dist/utils/esbuild-config.d.ts +30 -30
- package/dist/utils/esbuild-config.d.ts.map +1 -1
- package/dist/utils/output-utils.d.ts +6 -6
- package/dist/utils/package-utils.d.ts +6 -6
- package/dist/utils/package-utils.js +1 -1
- package/dist/utils/package-utils.js.map +1 -1
- package/dist/utils/rebuild-manager.js +3 -3
- package/dist/utils/rebuild-manager.js.map +1 -1
- package/dist/utils/replace-deps.d.ts +25 -25
- package/dist/utils/replace-deps.js +3 -3
- package/dist/utils/replace-deps.js.map +1 -1
- package/dist/utils/sd-config.d.ts +3 -3
- package/dist/utils/sd-config.js +3 -3
- package/dist/utils/sd-config.js.map +1 -1
- package/dist/utils/tailwind-config-deps.d.ts +3 -3
- package/dist/utils/template.d.ts +8 -8
- package/dist/utils/tsconfig.d.ts +16 -16
- package/dist/utils/tsconfig.js +2 -2
- package/dist/utils/tsconfig.js.map +1 -1
- package/dist/utils/typecheck-serialization.d.ts +8 -8
- package/dist/utils/vite-config.d.ts +8 -8
- package/dist/utils/vite-config.d.ts.map +1 -1
- package/dist/utils/vite-config.js +3 -3
- package/dist/utils/worker-events.d.ts +12 -12
- package/dist/utils/worker-events.d.ts.map +1 -1
- package/dist/utils/worker-utils.d.ts +3 -3
- package/dist/utils/worker-utils.js +2 -2
- package/dist/utils/worker-utils.js.map +1 -1
- package/dist/workers/client.worker.d.ts +14 -14
- package/dist/workers/client.worker.d.ts.map +1 -1
- package/dist/workers/client.worker.js +1 -1
- package/dist/workers/client.worker.js.map +1 -1
- package/dist/workers/dts.worker.d.ts +13 -13
- package/dist/workers/dts.worker.d.ts.map +1 -1
- package/dist/workers/dts.worker.js +3 -3
- package/dist/workers/dts.worker.js.map +1 -1
- package/dist/workers/library.worker.d.ts +12 -12
- package/dist/workers/library.worker.js +1 -1
- package/dist/workers/library.worker.js.map +1 -1
- package/dist/workers/lint.worker.d.ts +1 -1
- package/dist/workers/server-runtime.worker.d.ts +6 -6
- package/dist/workers/server-runtime.worker.js +6 -6
- package/dist/workers/server-runtime.worker.js.map +1 -1
- package/dist/workers/server.worker.d.ts +20 -20
- package/dist/workers/server.worker.d.ts.map +1 -1
- package/dist/workers/server.worker.js +6 -6
- package/dist/workers/server.worker.js.map +1 -1
- package/package.json +8 -7
- package/src/builders/BaseBuilder.ts +33 -33
- package/src/builders/DtsBuilder.ts +5 -5
- package/src/builders/LibraryBuilder.ts +9 -9
- package/src/builders/types.ts +10 -10
- package/src/capacitor/capacitor.ts +119 -119
- package/src/commands/add-client.ts +31 -31
- package/src/commands/add-server.ts +34 -34
- package/src/commands/build.ts +9 -9
- package/src/commands/check.ts +5 -5
- package/src/commands/dev.ts +9 -9
- package/src/commands/device.ts +30 -30
- package/src/commands/init.ts +25 -25
- package/src/commands/lint.ts +64 -64
- package/src/commands/publish.ts +139 -139
- package/src/commands/replace-deps.ts +4 -4
- package/src/commands/typecheck.ts +74 -74
- package/src/commands/watch.ts +7 -7
- package/src/electron/electron.ts +51 -51
- package/src/infra/ResultCollector.ts +9 -9
- package/src/infra/SignalHandler.ts +7 -7
- package/src/infra/WorkerManager.ts +14 -14
- package/src/orchestrators/BuildOrchestrator.ts +76 -76
- package/src/orchestrators/DevOrchestrator.ts +88 -88
- package/src/orchestrators/WatchOrchestrator.ts +39 -39
- package/src/sd-cli-entry.ts +43 -43
- package/src/sd-cli.ts +15 -15
- package/src/sd-config.types.ts +85 -85
- package/src/utils/build-env.ts +1 -1
- package/src/utils/config-editor.ts +19 -19
- package/src/utils/copy-public.ts +17 -17
- package/src/utils/copy-src.ts +11 -11
- package/src/utils/esbuild-config.ts +33 -33
- package/src/utils/output-utils.ts +11 -11
- package/src/utils/package-utils.ts +12 -12
- package/src/utils/rebuild-manager.ts +3 -3
- package/src/utils/replace-deps.ts +361 -361
- package/src/utils/sd-config.ts +44 -44
- package/src/utils/tailwind-config-deps.ts +98 -98
- package/src/utils/template.ts +56 -56
- package/src/utils/tsconfig.ts +127 -127
- package/src/utils/typecheck-serialization.ts +86 -86
- package/src/utils/vite-config.ts +341 -341
- package/src/utils/worker-events.ts +16 -16
- package/src/utils/worker-utils.ts +45 -45
- package/src/workers/client.worker.ts +34 -34
- package/src/workers/dts.worker.ts +467 -467
- package/src/workers/library.worker.ts +314 -314
- package/src/workers/lint.worker.ts +16 -16
- package/src/workers/server-runtime.worker.ts +157 -157
- package/src/workers/server.worker.ts +572 -572
- package/templates/add-client/__CLIENT__/package.json.hbs +1 -1
- package/templates/add-server/__SERVER__/package.json.hbs +2 -2
- package/templates/init/package.json.hbs +3 -3
- package/tests/config-editor.spec.ts +160 -0
- package/tests/copy-src.spec.ts +50 -0
- package/tests/get-compiler-options-for-package.spec.ts +139 -0
- package/tests/get-package-source-files.spec.ts +181 -0
- package/tests/get-types-from-package-json.spec.ts +107 -0
- package/tests/infra/ResultCollector.spec.ts +39 -0
- package/tests/infra/SignalHandler.spec.ts +38 -0
- package/tests/infra/WorkerManager.spec.ts +97 -0
- package/tests/load-ignore-patterns.spec.ts +188 -0
- package/tests/load-sd-config.spec.ts +137 -0
- package/tests/package-utils.spec.ts +188 -0
- package/tests/parse-root-tsconfig.spec.ts +89 -0
- package/tests/replace-deps.spec.ts +308 -0
- package/tests/run-lint.spec.ts +415 -0
- package/tests/run-typecheck.spec.ts +653 -0
- package/tests/run-watch.spec.ts +75 -0
- package/tests/sd-cli.spec.ts +330 -0
- package/tests/tailwind-config-deps.spec.ts +30 -0
- package/tests/template.spec.ts +70 -0
- package/tests/utils/rebuild-manager.spec.ts +43 -0
- package/tests/write-changed-output-files.spec.ts +97 -0
package/src/commands/lint.ts
CHANGED
|
@@ -10,28 +10,28 @@ import stylelint from "stylelint";
|
|
|
10
10
|
//#region Types
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* ESLint
|
|
13
|
+
* ESLint execution options
|
|
14
14
|
*/
|
|
15
15
|
export interface LintOptions {
|
|
16
|
-
/**
|
|
16
|
+
/** Path filter for linting (e.g., `packages/core-common`). Empty array targets everything */
|
|
17
17
|
targets: string[];
|
|
18
|
-
/**
|
|
18
|
+
/** Enable auto-fix */
|
|
19
19
|
fix: boolean;
|
|
20
|
-
/**
|
|
20
|
+
/** Enable execution time measurement per ESLint rule (sets TIMING environment variable) */
|
|
21
21
|
timing: boolean;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
|
-
* executeLint()
|
|
25
|
+
* Return type of executeLint()
|
|
26
26
|
*/
|
|
27
27
|
export interface LintResult {
|
|
28
|
-
/**
|
|
28
|
+
/** true if there are no lint errors */
|
|
29
29
|
success: boolean;
|
|
30
|
-
/** ESLint + Stylelint
|
|
30
|
+
/** Total error count from ESLint + Stylelint */
|
|
31
31
|
errorCount: number;
|
|
32
|
-
/** ESLint + Stylelint
|
|
32
|
+
/** Total warning count from ESLint + Stylelint */
|
|
33
33
|
warningCount: number;
|
|
34
|
-
/**
|
|
34
|
+
/** Formatter output string (content to write to stdout) */
|
|
35
35
|
formattedOutput: string;
|
|
36
36
|
}
|
|
37
37
|
|
|
@@ -39,7 +39,7 @@ export interface LintResult {
|
|
|
39
39
|
|
|
40
40
|
//#region Utilities
|
|
41
41
|
|
|
42
|
-
/** ESLint
|
|
42
|
+
/** ESLint config file search order */
|
|
43
43
|
const ESLINT_CONFIG_FILES = [
|
|
44
44
|
"eslint.config.ts",
|
|
45
45
|
"eslint.config.mts",
|
|
@@ -47,7 +47,7 @@ const ESLINT_CONFIG_FILES = [
|
|
|
47
47
|
"eslint.config.mjs",
|
|
48
48
|
] as const;
|
|
49
49
|
|
|
50
|
-
/** Stylelint
|
|
50
|
+
/** Stylelint config file search order */
|
|
51
51
|
const STYLELINT_CONFIG_FILES = [
|
|
52
52
|
"stylelint.config.ts",
|
|
53
53
|
"stylelint.config.mts",
|
|
@@ -58,21 +58,21 @@ const STYLELINT_CONFIG_FILES = [
|
|
|
58
58
|
] as const;
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
|
-
*
|
|
61
|
+
* Type guard to check if an ESLint config object has only ignores property
|
|
62
62
|
*/
|
|
63
63
|
function isGlobalIgnoresConfig(item: unknown): item is { ignores: string[] } {
|
|
64
64
|
if (item == null || typeof item !== "object") return false;
|
|
65
65
|
if (!("ignores" in item)) return false;
|
|
66
|
-
if ("files" in item) return false; // files
|
|
66
|
+
if ("files" in item) return false; // if files exists, it's not globalIgnores
|
|
67
67
|
const ignores = (item as { ignores: unknown }).ignores;
|
|
68
68
|
if (!Array.isArray(ignores)) return false;
|
|
69
69
|
return ignores.every((i) => typeof i === "string");
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
|
-
* eslint.config.ts/js
|
|
74
|
-
*
|
|
75
|
-
* @internal
|
|
73
|
+
* Extract globalIgnores patterns from eslint.config.ts/js.
|
|
74
|
+
* A config object with only ignores (no files) is a globalIgnores.
|
|
75
|
+
* @internal exported for testing
|
|
76
76
|
*/
|
|
77
77
|
export async function loadIgnorePatterns(cwd: string): Promise<string[]> {
|
|
78
78
|
let configPath: string | undefined;
|
|
@@ -86,7 +86,7 @@ export async function loadIgnorePatterns(cwd: string): Promise<string[]> {
|
|
|
86
86
|
|
|
87
87
|
if (configPath == null) {
|
|
88
88
|
throw new SdError(
|
|
89
|
-
`
|
|
89
|
+
`Cannot find ESLint config file (cwd: ${cwd}): ${ESLINT_CONFIG_FILES.join(", ")}`,
|
|
90
90
|
);
|
|
91
91
|
}
|
|
92
92
|
|
|
@@ -105,18 +105,18 @@ export async function loadIgnorePatterns(cwd: string): Promise<string[]> {
|
|
|
105
105
|
) {
|
|
106
106
|
configs = configModule.default;
|
|
107
107
|
} else {
|
|
108
|
-
throw new SdError(`ESLint
|
|
108
|
+
throw new SdError(`ESLint config file is not in correct format: ${configPath}`);
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
if (!Array.isArray(configs)) {
|
|
112
|
-
throw new SdError(`ESLint
|
|
112
|
+
throw new SdError(`ESLint config is not an array: ${configPath}`);
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
return configs.filter(isGlobalIgnoresConfig).flatMap((item) => item.ignores);
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
/**
|
|
119
|
-
* Stylelint
|
|
119
|
+
* Check if Stylelint config file exists.
|
|
120
120
|
*/
|
|
121
121
|
async function hasStylelintConfig(cwd: string): Promise<boolean> {
|
|
122
122
|
for (const f of STYLELINT_CONFIG_FILES) {
|
|
@@ -130,36 +130,36 @@ async function hasStylelintConfig(cwd: string): Promise<boolean> {
|
|
|
130
130
|
//#region Main
|
|
131
131
|
|
|
132
132
|
/**
|
|
133
|
-
* ESLint/Stylelint
|
|
133
|
+
* Run ESLint/Stylelint and return results.
|
|
134
134
|
*
|
|
135
|
-
* - `eslint.config.ts/js
|
|
136
|
-
* -
|
|
137
|
-
* -
|
|
138
|
-
* - stdout
|
|
135
|
+
* - Extract globalIgnores patterns from `eslint.config.ts/js` and apply to glob filtering
|
|
136
|
+
* - Show progress using consola
|
|
137
|
+
* - Enable cache (saved to `.cache/eslint.cache`, auto invalidated on config changes)
|
|
138
|
+
* - No stdout output or process.exitCode setting (caller decides)
|
|
139
139
|
*
|
|
140
|
-
* @param options -
|
|
141
|
-
* @returns
|
|
140
|
+
* @param options - lint execution options
|
|
141
|
+
* @returns lint result (success status, error/warning counts, formatter output)
|
|
142
142
|
*/
|
|
143
143
|
export async function executeLint(options: LintOptions): Promise<LintResult> {
|
|
144
144
|
const { targets, fix, timing } = options;
|
|
145
145
|
const cwd = process.cwd();
|
|
146
146
|
const logger = consola.withTag("sd:cli:lint");
|
|
147
147
|
|
|
148
|
-
logger.debug("
|
|
148
|
+
logger.debug("start lint", { targets, fix, timing });
|
|
149
149
|
|
|
150
|
-
// TIMING
|
|
150
|
+
// Set TIMING environment variable
|
|
151
151
|
if (timing) {
|
|
152
152
|
process.env["TIMING"] = "1";
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
-
// ESLint
|
|
156
|
-
logger.start("ESLint
|
|
155
|
+
// Load ESLint configuration
|
|
156
|
+
logger.start("loading ESLint config");
|
|
157
157
|
const ignorePatterns = await loadIgnorePatterns(cwd);
|
|
158
|
-
logger.debug("ignore
|
|
159
|
-
logger.success(`ESLint
|
|
158
|
+
logger.debug("ignore patterns loaded", { ignorePatternCount: ignorePatterns.length });
|
|
159
|
+
logger.success(`loaded ESLint config (${ignorePatterns.length} ignore patterns)`);
|
|
160
160
|
|
|
161
|
-
//
|
|
162
|
-
logger.start("
|
|
161
|
+
// Collect lint target files
|
|
162
|
+
logger.start("collecting lint target files");
|
|
163
163
|
let files = await fsGlob("**/*.{ts,tsx,js,jsx}", {
|
|
164
164
|
cwd,
|
|
165
165
|
ignore: ignorePatterns,
|
|
@@ -167,14 +167,14 @@ export async function executeLint(options: LintOptions): Promise<LintResult> {
|
|
|
167
167
|
absolute: true,
|
|
168
168
|
});
|
|
169
169
|
files = pathFilterByTargets(files, targets, cwd);
|
|
170
|
-
logger.debug("
|
|
171
|
-
logger.success(
|
|
170
|
+
logger.debug("file collection complete", { fileCount: files.length });
|
|
171
|
+
logger.success(`collected lint target files (${files.length} files)`);
|
|
172
172
|
|
|
173
|
-
//
|
|
173
|
+
// Run lint
|
|
174
174
|
let eslint: ESLint | undefined;
|
|
175
175
|
let eslintResults: ESLint.LintResult[] | undefined;
|
|
176
176
|
if (files.length > 0) {
|
|
177
|
-
logger.start(
|
|
177
|
+
logger.start(`running lint... (${files.length} files)`);
|
|
178
178
|
eslint = new ESLint({
|
|
179
179
|
cwd,
|
|
180
180
|
fix,
|
|
@@ -182,13 +182,13 @@ export async function executeLint(options: LintOptions): Promise<LintResult> {
|
|
|
182
182
|
cacheLocation: path.join(cwd, ".cache", "eslint.cache"),
|
|
183
183
|
});
|
|
184
184
|
eslintResults = await eslint.lintFiles(files);
|
|
185
|
-
logger.success("
|
|
185
|
+
logger.success("lint complete");
|
|
186
186
|
|
|
187
|
-
//
|
|
187
|
+
// Apply auto-fix
|
|
188
188
|
if (fix) {
|
|
189
|
-
logger.debug("
|
|
189
|
+
logger.debug("applying auto-fix...");
|
|
190
190
|
await ESLint.outputFixes(eslintResults);
|
|
191
|
-
logger.debug("
|
|
191
|
+
logger.debug("auto-fix applied");
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
194
|
|
|
@@ -196,7 +196,7 @@ export async function executeLint(options: LintOptions): Promise<LintResult> {
|
|
|
196
196
|
const hasStylelintCfg = await hasStylelintConfig(cwd);
|
|
197
197
|
let stylelintResult: stylelint.LinterResult | undefined;
|
|
198
198
|
if (hasStylelintCfg) {
|
|
199
|
-
logger.start("CSS
|
|
199
|
+
logger.start("collecting CSS files");
|
|
200
200
|
let cssFiles = await fsGlob("**/*.css", {
|
|
201
201
|
cwd,
|
|
202
202
|
ignore: ignorePatterns,
|
|
@@ -204,10 +204,10 @@ export async function executeLint(options: LintOptions): Promise<LintResult> {
|
|
|
204
204
|
absolute: true,
|
|
205
205
|
});
|
|
206
206
|
cssFiles = pathFilterByTargets(cssFiles, targets, cwd);
|
|
207
|
-
logger.success(`CSS
|
|
207
|
+
logger.success(`collected CSS files (${cssFiles.length} files)`);
|
|
208
208
|
|
|
209
209
|
if (cssFiles.length > 0) {
|
|
210
|
-
logger.start(`Stylelint
|
|
210
|
+
logger.start(`running Stylelint... (${cssFiles.length} files)`);
|
|
211
211
|
let configFile: string | undefined;
|
|
212
212
|
for (const f of STYLELINT_CONFIG_FILES) {
|
|
213
213
|
const configPath = path.join(cwd, f);
|
|
@@ -217,7 +217,7 @@ export async function executeLint(options: LintOptions): Promise<LintResult> {
|
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
219
|
|
|
220
|
-
// TypeScript
|
|
220
|
+
// Support TypeScript config files: load with jiti, pass as config object
|
|
221
221
|
let stylelintOptions: stylelint.LinterOptions;
|
|
222
222
|
if (configFile != null && /\.ts$/.test(configFile)) {
|
|
223
223
|
const jiti = createJiti(import.meta.url);
|
|
@@ -241,29 +241,29 @@ export async function executeLint(options: LintOptions): Promise<LintResult> {
|
|
|
241
241
|
};
|
|
242
242
|
}
|
|
243
243
|
stylelintResult = await stylelint.lint(stylelintOptions);
|
|
244
|
-
logger.success("Stylelint
|
|
244
|
+
logger.success("Stylelint execution complete");
|
|
245
245
|
}
|
|
246
246
|
}
|
|
247
247
|
|
|
248
|
-
//
|
|
248
|
+
// Return success result if no files or lint was not executed
|
|
249
249
|
if (files.length === 0 || eslintResults == null || eslint == null) {
|
|
250
|
-
logger.info("
|
|
250
|
+
logger.info("no files to lint");
|
|
251
251
|
return { success: true, errorCount: 0, warningCount: 0, formattedOutput: "" };
|
|
252
252
|
}
|
|
253
253
|
|
|
254
|
-
//
|
|
254
|
+
// Aggregate results
|
|
255
255
|
let errorCount = eslintResults.sum((r) => r.errorCount);
|
|
256
256
|
let warningCount = eslintResults.sum((r) => r.warningCount);
|
|
257
257
|
|
|
258
258
|
if (errorCount > 0) {
|
|
259
|
-
logger.error("
|
|
259
|
+
logger.error("lint errors occurred", { errorCount, warningCount });
|
|
260
260
|
} else if (warningCount > 0) {
|
|
261
|
-
logger.info("
|
|
261
|
+
logger.info("lint complete (warnings present)", { errorCount, warningCount });
|
|
262
262
|
} else {
|
|
263
|
-
logger.info("
|
|
263
|
+
logger.info("lint complete", { errorCount, warningCount });
|
|
264
264
|
}
|
|
265
265
|
|
|
266
|
-
//
|
|
266
|
+
// Collect formatter output
|
|
267
267
|
let formattedOutput = "";
|
|
268
268
|
const formatter = await eslint.loadFormatter("stylish");
|
|
269
269
|
const resultText = await formatter.format(eslintResults);
|
|
@@ -271,7 +271,7 @@ export async function executeLint(options: LintOptions): Promise<LintResult> {
|
|
|
271
271
|
formattedOutput += resultText;
|
|
272
272
|
}
|
|
273
273
|
|
|
274
|
-
// Stylelint
|
|
274
|
+
// Collect Stylelint results
|
|
275
275
|
if (stylelintResult != null && stylelintResult.results.length > 0) {
|
|
276
276
|
const stylelintErrorCount = stylelintResult.results.sum(
|
|
277
277
|
(r) => r.warnings.filter((w) => w.severity === "error").length,
|
|
@@ -284,23 +284,23 @@ export async function executeLint(options: LintOptions): Promise<LintResult> {
|
|
|
284
284
|
warningCount += stylelintWarningCount;
|
|
285
285
|
|
|
286
286
|
if (stylelintErrorCount > 0) {
|
|
287
|
-
logger.error("Stylelint
|
|
287
|
+
logger.error("Stylelint errors occurred", {
|
|
288
288
|
errorCount: stylelintErrorCount,
|
|
289
289
|
warningCount: stylelintWarningCount,
|
|
290
290
|
});
|
|
291
291
|
} else if (stylelintWarningCount > 0) {
|
|
292
|
-
logger.info("Stylelint
|
|
292
|
+
logger.info("Stylelint complete (warnings present)", {
|
|
293
293
|
errorCount: stylelintErrorCount,
|
|
294
294
|
warningCount: stylelintWarningCount,
|
|
295
295
|
});
|
|
296
296
|
} else {
|
|
297
|
-
logger.info("Stylelint
|
|
297
|
+
logger.info("Stylelint complete", {
|
|
298
298
|
errorCount: stylelintErrorCount,
|
|
299
299
|
warningCount: stylelintWarningCount,
|
|
300
300
|
});
|
|
301
301
|
}
|
|
302
302
|
|
|
303
|
-
// Stylelint formatter
|
|
303
|
+
// Stylelint formatter output
|
|
304
304
|
const stylelintFormatter = await stylelint.formatters.string;
|
|
305
305
|
const stylelintOutput = stylelintFormatter(stylelintResult.results, stylelintResult);
|
|
306
306
|
if (stylelintOutput) {
|
|
@@ -317,12 +317,12 @@ export async function executeLint(options: LintOptions): Promise<LintResult> {
|
|
|
317
317
|
}
|
|
318
318
|
|
|
319
319
|
/**
|
|
320
|
-
* ESLint
|
|
320
|
+
* Run ESLint.
|
|
321
321
|
*
|
|
322
|
-
* executeLint()
|
|
322
|
+
* Wrapper that calls executeLint(), outputs results to stdout, and sets exitCode.
|
|
323
323
|
*
|
|
324
|
-
* @param options -
|
|
325
|
-
* @returns
|
|
324
|
+
* @param options - lint execution options
|
|
325
|
+
* @returns resolves when complete. If errors are found, sets `process.exitCode` to 1 and resolves (does not throw)
|
|
326
326
|
*/
|
|
327
327
|
export async function runLint(options: LintOptions): Promise<void> {
|
|
328
328
|
const result = await executeLint(options);
|