@salesforce-ux/slds-linter 0.0.12-alpha.6 → 0.0.13-alpha.0
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/build/commands/emit.d.ts +2 -0
- package/build/commands/emit.js +50 -0
- package/build/commands/lint-components.js +2 -2
- package/build/commands/lint-styles.js +2 -2
- package/build/commands/lint.js +4 -4
- package/build/commands/report.js +2 -2
- package/build/index.js +4 -0
- package/build/utils/nodeVersionUtil.d.ts +11 -0
- package/build/utils/nodeVersionUtil.js +20 -0
- package/package.json +4 -3
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// src/commands/emit.ts
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import { Logger } from "../utils/logger.js";
|
|
4
|
+
import { normalizeCliOptions } from "../utils/cli-args.js";
|
|
5
|
+
import {
|
|
6
|
+
DEFAULT_ESLINT_CONFIG_PATH,
|
|
7
|
+
DEFAULT_STYLELINT_CONFIG_PATH
|
|
8
|
+
} from "../services/config.resolver.js";
|
|
9
|
+
import path from "path";
|
|
10
|
+
import { execSync } from "child_process";
|
|
11
|
+
function registerEmitCommand(program) {
|
|
12
|
+
program.command("emit").description("Emits the configuration files used by slds-linter cli").option(
|
|
13
|
+
"-d, --directory <path>",
|
|
14
|
+
"Target directory to emit (defaults to current directory)"
|
|
15
|
+
).action(async (options) => {
|
|
16
|
+
try {
|
|
17
|
+
Logger.info(chalk.blue("Emitting configuration files..."));
|
|
18
|
+
const normalizedOptions = normalizeCliOptions(options, {
|
|
19
|
+
configStyle: DEFAULT_STYLELINT_CONFIG_PATH,
|
|
20
|
+
configEslint: DEFAULT_ESLINT_CONFIG_PATH
|
|
21
|
+
});
|
|
22
|
+
const destStyleConfigPath = path.join(
|
|
23
|
+
normalizedOptions.directory,
|
|
24
|
+
path.basename(normalizedOptions.configStyle)
|
|
25
|
+
);
|
|
26
|
+
execSync(`cp ${normalizedOptions.configStyle} ${destStyleConfigPath}`);
|
|
27
|
+
Logger.success(chalk.green(`Stylelint configuration created at:
|
|
28
|
+
${destStyleConfigPath}
|
|
29
|
+
`));
|
|
30
|
+
const destESLintConfigPath = path.join(
|
|
31
|
+
normalizedOptions.directory,
|
|
32
|
+
path.basename(normalizedOptions.configEslint)
|
|
33
|
+
);
|
|
34
|
+
execSync(
|
|
35
|
+
`cp ${normalizedOptions.configEslint} ${destESLintConfigPath}`
|
|
36
|
+
);
|
|
37
|
+
Logger.success(chalk.green(`ESLint configuration created at:
|
|
38
|
+
${destESLintConfigPath}
|
|
39
|
+
`));
|
|
40
|
+
} catch (error) {
|
|
41
|
+
Logger.error(
|
|
42
|
+
chalk.red(`Failed to emit configuration: ${error.message}`)
|
|
43
|
+
);
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
export {
|
|
49
|
+
registerEmitCommand
|
|
50
|
+
};
|
|
@@ -24,8 +24,8 @@ function registerLintComponentsCommand(program) {
|
|
|
24
24
|
Logger.info(chalk.blue(`Scanned ${totalFiles} file(s).`));
|
|
25
25
|
Logger.info(chalk.blue("Running linting..."));
|
|
26
26
|
const results = await LintRunner.runLinting(fileBatches, "component", {
|
|
27
|
-
fix:
|
|
28
|
-
configPath:
|
|
27
|
+
fix: normalizedOptions.fix,
|
|
28
|
+
configPath: normalizedOptions.config
|
|
29
29
|
});
|
|
30
30
|
printLintResults(results, normalizedOptions.editor);
|
|
31
31
|
const errorCount = results.reduce((sum, r) => sum + r.errors.length, 0);
|
|
@@ -24,8 +24,8 @@ function registerLintStylesCommand(program) {
|
|
|
24
24
|
Logger.info(chalk.blue(`Scanned ${totalFiles} file(s).`));
|
|
25
25
|
Logger.info(chalk.blue("Running stylelint..."));
|
|
26
26
|
const results = await LintRunner.runLinting(fileBatches, "style", {
|
|
27
|
-
fix:
|
|
28
|
-
configPath:
|
|
27
|
+
fix: normalizedOptions.fix,
|
|
28
|
+
configPath: normalizedOptions.config
|
|
29
29
|
});
|
|
30
30
|
printLintResults(results, normalizedOptions.editor);
|
|
31
31
|
const errorCount = results.reduce((sum, r) => sum + r.errors.length, 0);
|
package/build/commands/lint.js
CHANGED
|
@@ -27,8 +27,8 @@ function registerLintCommand(program) {
|
|
|
27
27
|
Logger.info(chalk.blue(`Found ${totalStyleFiles} style file(s). Running stylelint...
|
|
28
28
|
`));
|
|
29
29
|
const styleResults = await LintRunner.runLinting(styleFileBatches, "style", {
|
|
30
|
-
fix:
|
|
31
|
-
configPath:
|
|
30
|
+
fix: normalizedOptions.fix,
|
|
31
|
+
configPath: normalizedOptions.configStyle
|
|
32
32
|
});
|
|
33
33
|
styleResults.forEach((result) => {
|
|
34
34
|
const hasErrors = result.errors?.length > 0;
|
|
@@ -62,8 +62,8 @@ ${chalk.bold(relativeFile)}`);
|
|
|
62
62
|
Logger.info(chalk.blue(`Found ${totalComponentFiles} component file(s). Running eslint...
|
|
63
63
|
`));
|
|
64
64
|
const componentResults = await LintRunner.runLinting(componentFileBatches, "component", {
|
|
65
|
-
fix:
|
|
66
|
-
configPath:
|
|
65
|
+
fix: normalizedOptions.fix,
|
|
66
|
+
configPath: normalizedOptions.configEslint
|
|
67
67
|
});
|
|
68
68
|
printLintResults(componentResults, normalizedOptions.editor);
|
|
69
69
|
const componentErrorCount = componentResults.reduce((sum, r) => sum + r.errors.length, 0);
|
package/build/commands/report.js
CHANGED
|
@@ -22,7 +22,7 @@ function registerReportCommand(program) {
|
|
|
22
22
|
batchSize: 100
|
|
23
23
|
});
|
|
24
24
|
const styleResults = await LintRunner.runLinting(styleFileBatches, "style", {
|
|
25
|
-
configPath:
|
|
25
|
+
configPath: normalizedOptions.configStyle
|
|
26
26
|
});
|
|
27
27
|
spinner.text = "Running components linting...";
|
|
28
28
|
const componentFileBatches = await FileScanner.scanFiles(normalizedOptions.directory, {
|
|
@@ -30,7 +30,7 @@ function registerReportCommand(program) {
|
|
|
30
30
|
batchSize: 100
|
|
31
31
|
});
|
|
32
32
|
const componentResults = await LintRunner.runLinting(componentFileBatches, "component", {
|
|
33
|
-
configPath:
|
|
33
|
+
configPath: normalizedOptions.configEslint
|
|
34
34
|
});
|
|
35
35
|
spinner.text = "Generating combined report...";
|
|
36
36
|
const combinedReportPath = path.join(normalizedOptions.output, "slds-linter-report.sarif");
|
package/build/index.js
CHANGED
|
@@ -6,8 +6,11 @@ import { registerLintStylesCommand } from "./commands/lint-styles.js";
|
|
|
6
6
|
import { registerLintComponentsCommand } from "./commands/lint-components.js";
|
|
7
7
|
import { registerLintCommand } from "./commands/lint.js";
|
|
8
8
|
import { registerReportCommand } from "./commands/report.js";
|
|
9
|
+
import { registerEmitCommand } from "./commands/emit.js";
|
|
9
10
|
import { Logger } from "./utils/logger.js";
|
|
11
|
+
import { validateNodeVersion } from "./utils/nodeVersionUtil.js";
|
|
10
12
|
import pkg from "../package.json" with { type: "json" };
|
|
13
|
+
validateNodeVersion();
|
|
11
14
|
process.on("unhandledRejection", (error) => {
|
|
12
15
|
Logger.error(`Unhandled rejection: ${error}`);
|
|
13
16
|
process.exit(1);
|
|
@@ -22,4 +25,5 @@ registerLintStylesCommand(program);
|
|
|
22
25
|
registerLintComponentsCommand(program);
|
|
23
26
|
registerLintCommand(program);
|
|
24
27
|
registerReportCommand(program);
|
|
28
|
+
registerEmitCommand(program);
|
|
25
29
|
program.parse(process.argv);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const REQUIRED_NODE_VERSION = "20.18.3";
|
|
2
|
+
/**
|
|
3
|
+
* Checks if the current Node.js version meets the required version.
|
|
4
|
+
* @param {string} requiredVersion - The required Node.js version.
|
|
5
|
+
* @returns {boolean} - Returns true if the current version is valid.
|
|
6
|
+
*/
|
|
7
|
+
export declare function checkNodeVersion(requiredVersion: any): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Validates the Node.js version and exits if it does not meet the requirement.
|
|
10
|
+
*/
|
|
11
|
+
export declare function validateNodeVersion(): void;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// src/utils/nodeVersionUtil.ts
|
|
2
|
+
import semver from "semver";
|
|
3
|
+
import { Logger } from "./logger.js";
|
|
4
|
+
var REQUIRED_NODE_VERSION = "20.18.3";
|
|
5
|
+
function checkNodeVersion(requiredVersion) {
|
|
6
|
+
return semver.gte(process.version, requiredVersion);
|
|
7
|
+
}
|
|
8
|
+
function validateNodeVersion() {
|
|
9
|
+
if (!checkNodeVersion(REQUIRED_NODE_VERSION)) {
|
|
10
|
+
Logger.error(
|
|
11
|
+
`Node.js version ${process.version} is not supported. Please upgrade to ${REQUIRED_NODE_VERSION} or later.`
|
|
12
|
+
);
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
REQUIRED_NODE_VERSION,
|
|
18
|
+
checkNodeVersion,
|
|
19
|
+
validateNodeVersion
|
|
20
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce-ux/slds-linter",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13-alpha.0",
|
|
4
4
|
"description": "SLDS CLI tool for linting styles and components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lint",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"slds-linter": "./build/index.js"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@salesforce-ux/eslint-plugin-slds": "0.0.
|
|
26
|
-
"@salesforce-ux/stylelint-plugin-slds": "0.0.
|
|
25
|
+
"@salesforce-ux/eslint-plugin-slds": "0.0.13-alpha.0",
|
|
26
|
+
"@salesforce-ux/stylelint-plugin-slds": "0.0.13-alpha.0",
|
|
27
27
|
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
|
28
28
|
"@typescript-eslint/parser": "^5.0.0",
|
|
29
29
|
"chalk": "^4.1.2",
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"json-stream-stringify": "^3.1.6",
|
|
34
34
|
"node-sarif-builder": "^3.2.0",
|
|
35
35
|
"ora": "^5.4.1",
|
|
36
|
+
"semver": "^7.7.1",
|
|
36
37
|
"stylelint": "^16.10.0"
|
|
37
38
|
},
|
|
38
39
|
"license": "ISC",
|