@salesforce-ux/slds-linter 0.1.4-alpha.3 → 0.1.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/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.1.4-alpha.3");
22
+ program.description("SLDS Linter CLI tool for linting styles and components").version("0.1.4");
23
23
  }
24
24
  registerLintCommand(program);
25
25
  registerReportCommand(program);
@@ -5,7 +5,7 @@ var DEFAULT_ESLINT_CONFIG_PATH = resolvePath("@salesforce-ux/eslint-plugin-slds/
5
5
  var DEFAULT_STYLELINT_CONFIG_PATH = resolvePath("@salesforce-ux/stylelint-plugin-slds/.stylelintrc.yml", import.meta);
6
6
  var STYLELINT_VERSION = "16.14.1";
7
7
  var ESLINT_VERSION = "8.57.1";
8
- var LINTER_CLI_VERSION = "0.1.4-alpha.3";
8
+ var LINTER_CLI_VERSION = "0.1.4";
9
9
  var getRuleDescription = (ruleId) => {
10
10
  const ruleIdWithoutNameSpace = `${ruleId}`.replace(/\@salesforce-ux\//, "");
11
11
  return ruleMetadata(ruleIdWithoutNameSpace)?.ruleDesc || "--";
@@ -6,7 +6,7 @@ import { SarifBuilder, SarifRunBuilder, SarifResultBuilder, SarifRuleBuilder } f
6
6
  import { createWriteStream } from "fs";
7
7
  import { JsonStreamStringify } from "json-stream-stringify";
8
8
  import { getRuleDescription } from "./config.resolver.js";
9
- import { replaceNamespaceinRules } from "../utils/lintResultsUtil.js";
9
+ import { parseText, replaceNamespaceinRules } from "../utils/lintResultsUtil.js";
10
10
  var ReportGenerator = class {
11
11
  /**
12
12
  * Generate SARIF report from lint results
@@ -82,7 +82,7 @@ var ReportGenerator = class {
82
82
  const resultBuilder = new SarifResultBuilder().initSimple({
83
83
  ruleId: replaceNamespaceinRules(error.ruleId),
84
84
  level: "error",
85
- messageText: error.message,
85
+ messageText: parseText(error.message),
86
86
  fileUri: path.relative(process.cwd(), lintResult.filePath),
87
87
  startLine: error.line,
88
88
  startColumn: error.column,
@@ -95,7 +95,7 @@ var ReportGenerator = class {
95
95
  const resultBuilder = new SarifResultBuilder().initSimple({
96
96
  ruleId: replaceNamespaceinRules(warning.ruleId),
97
97
  level: "warning",
98
- messageText: warning.message,
98
+ messageText: parseText(warning.message),
99
99
  fileUri: path.relative(process.cwd(), lintResult.filePath),
100
100
  startLine: warning.line,
101
101
  startColumn: warning.column,
@@ -122,7 +122,7 @@ var CsvReportGenerator = class {
122
122
  (result) => [
123
123
  ...result.errors.map((error) => ({
124
124
  "File Path": path.relative(cwd, result.filePath),
125
- "Message": error.message,
125
+ "Message": parseText(error.message),
126
126
  "Severity": "error",
127
127
  "Rule ID": replaceNamespaceinRules(error.ruleId || "N/A"),
128
128
  "Start Line": error.line,
@@ -134,7 +134,7 @@ var CsvReportGenerator = class {
134
134
  })),
135
135
  ...result.warnings.map((warning) => ({
136
136
  "File Path": path.relative(cwd, result.filePath),
137
- "Message": warning.message,
137
+ "Message": parseText(warning.message),
138
138
  "Severity": "warning",
139
139
  "Rule ID": replaceNamespaceinRules(warning.ruleId || "N/A"),
140
140
  "Start Line": warning.line,
@@ -5,6 +5,12 @@ import { LintResult } from '../types';
5
5
  * @returns updated Rule id without the namespace @salesforce-ux
6
6
  */
7
7
  export declare function replaceNamespaceinRules(id: string): string;
8
+ /**
9
+ *
10
+ * @param text - The input text that could either be a plain string or a stringified JSON object.
11
+ * @returns The parsed message or the original string if parsing fails.
12
+ */
13
+ export declare function parseText(text: string): string;
8
14
  /**
9
15
  * Prints detailed lint results for each file that has issues.
10
16
  *
@@ -6,6 +6,14 @@ import { Logger } from "../utils/logger.js";
6
6
  function replaceNamespaceinRules(id) {
7
7
  return id.includes("@salesforce-ux/") ? id.replace("@salesforce-ux/", "") : id;
8
8
  }
9
+ function parseText(text) {
10
+ try {
11
+ const parsed = JSON.parse(text);
12
+ return parsed.message || JSON.stringify(parsed);
13
+ } catch (error) {
14
+ return text;
15
+ }
16
+ }
9
17
  function printLintResults(results, editor) {
10
18
  results.forEach((result) => {
11
19
  const hasErrors = result.errors && result.errors.length > 0;
@@ -20,9 +28,9 @@ function printLintResults(results, editor) {
20
28
  const lineCol = `${error.line}:${error.column}`;
21
29
  const clickable = createClickableLineCol(lineCol, absolutePath, error.line, error.column, editor);
22
30
  const ruleId = error.ruleId ? chalk.dim(replaceNamespaceinRules(error.ruleId)) : "";
23
- Logger.error(` ${clickable} ${error.message} ${ruleId}`);
31
+ Logger.error(` ${clickable} ${parseText(error.message)} ${ruleId}`);
24
32
  } else {
25
- Logger.error(` ${chalk.red("Error:")} ${error.message}`);
33
+ Logger.error(` ${chalk.red("Error:")} ${parseText(error.message)}`);
26
34
  }
27
35
  });
28
36
  }
@@ -32,15 +40,16 @@ function printLintResults(results, editor) {
32
40
  const lineCol = `${warn.line}:${warn.column}`;
33
41
  const clickable = createClickableLineCol(lineCol, absolutePath, warn.line, warn.column, editor);
34
42
  const ruleId = warn.ruleId ? chalk.dim(replaceNamespaceinRules(warn.ruleId)) : "";
35
- Logger.warning(` ${clickable} ${warn.message} ${ruleId}`);
43
+ Logger.warning(` ${clickable} ${parseText(warn.message)} ${ruleId}`);
36
44
  } else {
37
- Logger.warning(` ${chalk.yellow("Warning:")} ${warn.message}`);
45
+ Logger.warning(` ${chalk.yellow("Warning:")} ${parseText(warn.message)}`);
38
46
  }
39
47
  });
40
48
  }
41
49
  });
42
50
  }
43
51
  export {
52
+ parseText,
44
53
  printLintResults,
45
54
  replaceNamespaceinRules
46
55
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce-ux/slds-linter",
3
- "version": "0.1.4-alpha.3",
3
+ "version": "0.1.4",
4
4
  "description": "SLDS Linter CLI tool for linting styles and components",
5
5
  "keywords": [
6
6
  "lightning design system linter",
@@ -20,8 +20,8 @@
20
20
  "slds-linter": "./build/index.js"
21
21
  },
22
22
  "dependencies": {
23
- "@salesforce-ux/eslint-plugin-slds": "0.1.4-alpha.3",
24
- "@salesforce-ux/stylelint-plugin-slds": "0.1.4-alpha.3",
23
+ "@salesforce-ux/eslint-plugin-slds": "0.1.4",
24
+ "@salesforce-ux/stylelint-plugin-slds": "0.1.4",
25
25
  "@typescript-eslint/eslint-plugin": "^5.0.0",
26
26
  "@typescript-eslint/parser": "^5.0.0",
27
27
  "chalk": "^4.1.2",