@salesforce-ux/slds-linter 0.3.1-internal-beta.2 → 0.3.1-internal-beta.3
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/lint.js +1 -6
- package/build/commands/report.js +4 -7
- package/build/executor/index.js +15 -16
- package/build/index.js +1 -1
- package/build/services/config.resolver.js +2 -2
- package/build/services/lint-runner.d.ts +2 -8
- package/build/types/index.d.ts +6 -0
- package/build/utils/config-utils.d.ts +1 -2
- package/build/utils/config-utils.js +6 -17
- package/package.json +3 -3
package/build/commands/lint.js
CHANGED
|
@@ -27,12 +27,7 @@ function registerLintCommand(program) {
|
|
|
27
27
|
Example: npx @salesforce-ux/slds-linter lint ${options.directory}`
|
|
28
28
|
));
|
|
29
29
|
}
|
|
30
|
-
const lintResults = await lint(
|
|
31
|
-
directory: normalizedOptions.directory,
|
|
32
|
-
fix: normalizedOptions.fix,
|
|
33
|
-
configStylelint: normalizedOptions.configStylelint,
|
|
34
|
-
configEslint: normalizedOptions.configEslint
|
|
35
|
-
});
|
|
30
|
+
const lintResults = await lint(normalizedOptions);
|
|
36
31
|
printLintResults(lintResults, normalizedOptions.editor);
|
|
37
32
|
const errorCount = lintResults.reduce((sum, r) => sum + r.errors.length, 0);
|
|
38
33
|
const warningCount = lintResults.reduce((sum, r) => sum + r.warnings.length, 0);
|
package/build/commands/report.js
CHANGED
|
@@ -4,7 +4,7 @@ import path from "path";
|
|
|
4
4
|
import ora from "ora";
|
|
5
5
|
import chalk from "chalk";
|
|
6
6
|
import fs from "fs";
|
|
7
|
-
import { normalizeCliOptions, normalizeDirectoryPath } from "../utils/config-utils.js";
|
|
7
|
+
import { normalizeAndValidatePath, normalizeCliOptions, normalizeDirectoryPath } from "../utils/config-utils.js";
|
|
8
8
|
import { Logger } from "../utils/logger.js";
|
|
9
9
|
import { DEFAULT_ESLINT_CONFIG_PATH, DEFAULT_STYLELINT_CONFIG_PATH } from "../services/config.resolver.js";
|
|
10
10
|
import { report, lint } from "../executor/index.js";
|
|
@@ -14,7 +14,8 @@ function registerReportCommand(program) {
|
|
|
14
14
|
try {
|
|
15
15
|
const normalizedOptions = normalizeCliOptions(options, {
|
|
16
16
|
configStylelint: DEFAULT_STYLELINT_CONFIG_PATH,
|
|
17
|
-
configEslint: DEFAULT_ESLINT_CONFIG_PATH
|
|
17
|
+
configEslint: DEFAULT_ESLINT_CONFIG_PATH,
|
|
18
|
+
output: normalizeAndValidatePath(options.output)
|
|
18
19
|
});
|
|
19
20
|
if (directory) {
|
|
20
21
|
normalizedOptions.directory = normalizeDirectoryPath(directory);
|
|
@@ -26,11 +27,7 @@ function registerReportCommand(program) {
|
|
|
26
27
|
}
|
|
27
28
|
spinner.start();
|
|
28
29
|
const reportFormat = normalizedOptions.format?.toLowerCase() || "sarif";
|
|
29
|
-
const lintResults = await lint(
|
|
30
|
-
directory: normalizedOptions.directory,
|
|
31
|
-
configStylelint: normalizedOptions.configStylelint,
|
|
32
|
-
configEslint: normalizedOptions.configEslint
|
|
33
|
-
});
|
|
30
|
+
const lintResults = await lint(normalizedOptions);
|
|
34
31
|
const reportStream = await report({
|
|
35
32
|
format: reportFormat
|
|
36
33
|
}, lintResults);
|
package/build/executor/index.js
CHANGED
|
@@ -4,13 +4,16 @@ import { FileScanner } from "../services/file-scanner.js";
|
|
|
4
4
|
import { LintRunner } from "../services/lint-runner.js";
|
|
5
5
|
import { StyleFilePatterns, ComponentFilePatterns } from "../services/file-patterns.js";
|
|
6
6
|
import { ReportGenerator, CsvReportGenerator } from "../services/report-generator.js";
|
|
7
|
-
import { LINTER_CLI_VERSION } from "../services/config.resolver.js";
|
|
7
|
+
import { DEFAULT_ESLINT_CONFIG_PATH, DEFAULT_STYLELINT_CONFIG_PATH, LINTER_CLI_VERSION } from "../services/config.resolver.js";
|
|
8
8
|
import { normalizeCliOptions } from "../utils/config-utils.js";
|
|
9
9
|
import { Logger } from "../utils/logger.js";
|
|
10
10
|
async function lint(config) {
|
|
11
11
|
try {
|
|
12
12
|
Logger.debug("Starting linting with Node API");
|
|
13
|
-
const normalizedConfig = normalizeCliOptions(config, {
|
|
13
|
+
const normalizedConfig = normalizeCliOptions(config, {
|
|
14
|
+
configEslint: DEFAULT_ESLINT_CONFIG_PATH,
|
|
15
|
+
configStylelint: DEFAULT_STYLELINT_CONFIG_PATH
|
|
16
|
+
});
|
|
14
17
|
const styleFiles = await FileScanner.scanFiles(normalizedConfig.directory, {
|
|
15
18
|
patterns: StyleFilePatterns,
|
|
16
19
|
batchSize: 100
|
|
@@ -19,17 +22,14 @@ async function lint(config) {
|
|
|
19
22
|
patterns: ComponentFilePatterns,
|
|
20
23
|
batchSize: 100
|
|
21
24
|
});
|
|
22
|
-
const
|
|
23
|
-
fix: normalizedConfig.fix,
|
|
24
|
-
configPath: normalizedConfig.configStylelint
|
|
25
|
-
};
|
|
25
|
+
const { fix, configStylelint, configEslint } = normalizedConfig;
|
|
26
26
|
const styleResults = await LintRunner.runLinting(styleFiles, "style", {
|
|
27
|
-
|
|
28
|
-
configPath:
|
|
27
|
+
fix,
|
|
28
|
+
configPath: configStylelint
|
|
29
29
|
});
|
|
30
30
|
const componentResults = await LintRunner.runLinting(componentFiles, "component", {
|
|
31
|
-
|
|
32
|
-
configPath:
|
|
31
|
+
fix,
|
|
32
|
+
configPath: configEslint
|
|
33
33
|
});
|
|
34
34
|
const combinedResults = [...styleResults, ...componentResults];
|
|
35
35
|
return standardizeLintMessages(combinedResults);
|
|
@@ -42,13 +42,12 @@ async function lint(config) {
|
|
|
42
42
|
async function report(config, results) {
|
|
43
43
|
try {
|
|
44
44
|
Logger.debug("Starting report generation with Node API");
|
|
45
|
-
const normalizedConfig = normalizeCliOptions(config, {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
directory: normalizedConfig.directory,
|
|
49
|
-
configStylelint: normalizedConfig.configStylelint,
|
|
50
|
-
configEslint: normalizedConfig.configEslint
|
|
45
|
+
const normalizedConfig = normalizeCliOptions(config, {
|
|
46
|
+
configStylelint: DEFAULT_STYLELINT_CONFIG_PATH,
|
|
47
|
+
configEslint: DEFAULT_ESLINT_CONFIG_PATH
|
|
51
48
|
});
|
|
49
|
+
const format = normalizedConfig.format || "sarif";
|
|
50
|
+
const lintResults = results || await lint(normalizedConfig);
|
|
52
51
|
switch (format) {
|
|
53
52
|
case "sarif":
|
|
54
53
|
return ReportGenerator.generateSarifReportStream(lintResults, {
|
package/build/index.js
CHANGED
|
@@ -19,7 +19,7 @@ process.on("uncaughtException", (error) => {
|
|
|
19
19
|
var program = new Command();
|
|
20
20
|
program.name("npx @salesforce-ux/slds-linter@latest").showHelpAfterError();
|
|
21
21
|
function registerVersion() {
|
|
22
|
-
program.description("SLDS Linter CLI tool for linting styles and components").version("0.3.1-internal-beta.
|
|
22
|
+
program.description("SLDS Linter CLI tool for linting styles and components").version("0.3.1-internal-beta.3");
|
|
23
23
|
}
|
|
24
24
|
registerLintCommand(program);
|
|
25
25
|
registerReportCommand(program);
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import { ruleMetadata } from "@salesforce-ux/stylelint-plugin-slds";
|
|
3
3
|
import { resolvePath } from "../utils/nodeVersionUtil.js";
|
|
4
4
|
var DEFAULT_ESLINT_CONFIG_PATH = resolvePath("@salesforce-ux/eslint-plugin-slds/config", import.meta);
|
|
5
|
-
var DEFAULT_STYLELINT_CONFIG_PATH = resolvePath("@salesforce-ux/stylelint-plugin-slds/.stylelintrc.
|
|
5
|
+
var DEFAULT_STYLELINT_CONFIG_PATH = resolvePath("@salesforce-ux/stylelint-plugin-slds/.stylelintrc.mjs", import.meta);
|
|
6
6
|
var STYLELINT_VERSION = "16.14.1";
|
|
7
7
|
var ESLINT_VERSION = "9.30.1";
|
|
8
|
-
var LINTER_CLI_VERSION = "0.3.1-internal-beta.
|
|
8
|
+
var LINTER_CLI_VERSION = "0.3.1-internal-beta.3";
|
|
9
9
|
var getRuleDescription = (ruleId) => {
|
|
10
10
|
const ruleIdWithoutNameSpace = `${ruleId}`.replace(/\@salesforce-ux\//, "");
|
|
11
11
|
return ruleMetadata(ruleIdWithoutNameSpace)?.ruleDesc || "--";
|
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
import { LintResult } from '../types';
|
|
2
|
-
export interface LintOptions {
|
|
3
|
-
fix?: boolean;
|
|
4
|
-
configPath?: string;
|
|
5
|
-
maxWorkers?: number;
|
|
6
|
-
timeoutMs?: number;
|
|
7
|
-
}
|
|
1
|
+
import { LintResult, LintRunnerOptions } from '../types';
|
|
8
2
|
export declare class LintRunner {
|
|
9
3
|
/**
|
|
10
4
|
* Run linting on batches of files
|
|
11
5
|
*/
|
|
12
|
-
static runLinting(fileBatches: string[][], workerType: 'style' | 'component', options?:
|
|
6
|
+
static runLinting(fileBatches: string[][], workerType: 'style' | 'component', options?: LintRunnerOptions): Promise<LintResult[]>;
|
|
13
7
|
/**
|
|
14
8
|
* Process and normalize worker results
|
|
15
9
|
*/
|
package/build/types/index.d.ts
CHANGED
|
@@ -27,6 +27,12 @@ export interface LintConfig extends BaseConfig {
|
|
|
27
27
|
export interface ReportConfig extends BaseConfig {
|
|
28
28
|
format?: 'sarif' | 'csv';
|
|
29
29
|
}
|
|
30
|
+
export interface LintRunnerOptions {
|
|
31
|
+
fix?: boolean;
|
|
32
|
+
configPath?: string;
|
|
33
|
+
maxWorkers?: number;
|
|
34
|
+
timeoutMs?: number;
|
|
35
|
+
}
|
|
30
36
|
export interface LintResultEntry {
|
|
31
37
|
line: number;
|
|
32
38
|
column: number;
|
|
@@ -26,8 +26,7 @@ export declare function normalizeDirectoryPath(directory?: string): string;
|
|
|
26
26
|
*
|
|
27
27
|
* @param options Options to normalize
|
|
28
28
|
* @param defaultOptions Default options to apply
|
|
29
|
-
* @param isNodeApi Whether this is being called from the Node API
|
|
30
29
|
* @returns Normalized options with appropriate defaults
|
|
31
30
|
*/
|
|
32
|
-
export declare function normalizeCliOptions<T extends CliOptions | LintConfig | ReportConfig>(options: T, defaultOptions?: Partial<T
|
|
31
|
+
export declare function normalizeCliOptions<T extends CliOptions | LintConfig | ReportConfig>(options: T, defaultOptions?: Partial<T>): T;
|
|
33
32
|
export declare const normalizeConfig: typeof normalizeCliOptions;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// src/utils/config-utils.ts
|
|
2
2
|
import path from "path";
|
|
3
|
-
import { DEFAULT_ESLINT_CONFIG_PATH, DEFAULT_STYLELINT_CONFIG_PATH } from "../services/config.resolver.js";
|
|
4
3
|
import { isDynamicPattern } from "globby";
|
|
5
4
|
import { accessSync } from "fs";
|
|
6
5
|
import { Logger } from "./logger.js";
|
|
@@ -33,31 +32,21 @@ function normalizeDirectoryPath(directory) {
|
|
|
33
32
|
Logger.debug(`Normalizing directory path: ${directory}`);
|
|
34
33
|
return path.resolve(directory);
|
|
35
34
|
}
|
|
36
|
-
function normalizeCliOptions(options, defaultOptions = {}
|
|
35
|
+
function normalizeCliOptions(options, defaultOptions = {}) {
|
|
37
36
|
const baseDefaults = {
|
|
38
37
|
files: [],
|
|
39
|
-
configStylelint:
|
|
40
|
-
configEslint:
|
|
38
|
+
configStylelint: "",
|
|
39
|
+
configEslint: "",
|
|
40
|
+
fix: false,
|
|
41
|
+
editor: detectCurrentEditor(),
|
|
42
|
+
format: "sarif"
|
|
41
43
|
};
|
|
42
|
-
if (!isNodeApi) {
|
|
43
|
-
Object.assign(baseDefaults, {
|
|
44
|
-
fix: false,
|
|
45
|
-
editor: detectCurrentEditor(),
|
|
46
|
-
format: "sarif"
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
44
|
const normalizedOptions = {
|
|
50
45
|
...baseDefaults,
|
|
51
46
|
...defaultOptions,
|
|
52
47
|
...options,
|
|
53
48
|
directory: normalizeDirectoryPath(options.directory)
|
|
54
49
|
};
|
|
55
|
-
if (!isNodeApi) {
|
|
56
|
-
normalizedOptions.output = options.output ? normalizeAndValidatePath(options.output) : process.cwd();
|
|
57
|
-
}
|
|
58
|
-
if ("format" in options && !options.format && isNodeApi) {
|
|
59
|
-
normalizedOptions.format = "sarif";
|
|
60
|
-
}
|
|
61
50
|
return normalizedOptions;
|
|
62
51
|
}
|
|
63
52
|
var normalizeConfig = normalizeCliOptions;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce-ux/slds-linter",
|
|
3
|
-
"version": "0.3.1-internal-beta.
|
|
3
|
+
"version": "0.3.1-internal-beta.3",
|
|
4
4
|
"description": "SLDS Linter CLI tool for linting styles and components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lightning design system linter",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
],
|
|
30
30
|
"bin": "build/index.js",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@salesforce-ux/eslint-plugin-slds": "0.3.1-internal-beta.
|
|
33
|
-
"@salesforce-ux/stylelint-plugin-slds": "0.3.1-internal-beta.
|
|
32
|
+
"@salesforce-ux/eslint-plugin-slds": "0.3.1-internal-beta.3",
|
|
33
|
+
"@salesforce-ux/stylelint-plugin-slds": "0.3.1-internal-beta.3",
|
|
34
34
|
"@typescript-eslint/eslint-plugin": "^8.36.0",
|
|
35
35
|
"@typescript-eslint/parser": "^8.36.0",
|
|
36
36
|
"chalk": "^4.1.2",
|