@salesforce-ux/slds-linter 0.3.1-internal-beta.1 → 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/README.md CHANGED
@@ -28,7 +28,7 @@ Install these items if they aren't installed already.
28
28
  - [VS Code](https://code.visualstudio.com/)
29
29
  - [SARIF Viewer](https://marketplace.visualstudio.com/items?itemName=MS-SarifVSCode.sarif-viewer) VS Code extension. This extension enables you to view SLDS Linter violation reports.
30
30
  - [Node.js](https://nodejs.org/)
31
- - The minimum supported version is **v18.4.0**
31
+ - The minimum supported version is **v18.18.0**
32
32
  - We recommend using the latest [Active LTS](https://nodejs.org/en/about/previous-releases) version of Node.js.
33
33
 
34
34
  ## Install SLDS Linter
@@ -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);
@@ -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);
@@ -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, {}, true);
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 lintOptions = {
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
- ...lintOptions,
28
- configPath: normalizedConfig.configStylelint
27
+ fix,
28
+ configPath: configStylelint
29
29
  });
30
30
  const componentResults = await LintRunner.runLinting(componentFiles, "component", {
31
- ...lintOptions,
32
- configPath: normalizedConfig.configEslint
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, {}, true);
46
- const format = normalizedConfig.format || "sarif";
47
- const lintResults = results || await lint({
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.1");
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);
@@ -1,11 +1,11 @@
1
1
  // src/services/config.resolver.ts
2
2
  import { ruleMetadata } from "@salesforce-ux/stylelint-plugin-slds";
3
3
  import { resolvePath } from "../utils/nodeVersionUtil.js";
4
- var DEFAULT_ESLINT_CONFIG_PATH = resolvePath("@salesforce-ux/eslint-plugin-slds/.eslintrc.yml", import.meta);
5
- var DEFAULT_STYLELINT_CONFIG_PATH = resolvePath("@salesforce-ux/stylelint-plugin-slds/.stylelintrc.yml", import.meta);
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.mjs", import.meta);
6
6
  var STYLELINT_VERSION = "16.14.1";
7
- var ESLINT_VERSION = "8.57.1";
8
- var LINTER_CLI_VERSION = "0.3.1-internal-beta.1";
7
+ var ESLINT_VERSION = "9.30.1";
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?: LintOptions): Promise<LintResult[]>;
6
+ static runLinting(fileBatches: string[][], workerType: 'style' | 'component', options?: LintRunnerOptions): Promise<LintResult[]>;
13
7
  /**
14
8
  * Process and normalize worker results
15
9
  */
@@ -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>, isNodeApi?: boolean): 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 = {}, isNodeApi = false) {
35
+ function normalizeCliOptions(options, defaultOptions = {}) {
37
36
  const baseDefaults = {
38
37
  files: [],
39
- configStylelint: isNodeApi ? DEFAULT_STYLELINT_CONFIG_PATH : "",
40
- configEslint: isNodeApi ? DEFAULT_ESLINT_CONFIG_PATH : ""
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;
@@ -1,10 +1,10 @@
1
- export declare const REQUIRED_NODE_VERSION = ">=18.4.0";
1
+ export declare const REQUIRED_NODE_VERSION = ">=18.18.0";
2
2
  /**
3
3
  * Checks if the current Node.js version meets the required version.
4
4
  * @param {string} requiredVersion - The required Node.js version.
5
5
  * @returns {boolean} - Returns true if the current version is valid.
6
6
  */
7
- export declare function checkNodeVersion(requiredVersion: any): boolean;
7
+ export declare function checkNodeVersion(requiredVersion: any): any;
8
8
  /**
9
9
  * Validates the Node.js version and exits if it does not meet the requirement.
10
10
  */
@@ -4,7 +4,7 @@ import { fileURLToPath } from "url";
4
4
  import { dirname } from "path";
5
5
  import { resolve } from "import-meta-resolve";
6
6
  import { Logger } from "./logger.js";
7
- var REQUIRED_NODE_VERSION = ">=18.4.0";
7
+ var REQUIRED_NODE_VERSION = ">=18.18.0";
8
8
  function checkNodeVersion(requiredVersion) {
9
9
  return semver.satisfies(process.version, requiredVersion);
10
10
  }
@@ -6,9 +6,8 @@ var ESLintWorker = class extends BaseWorker {
6
6
  constructor() {
7
7
  super();
8
8
  this.eslint = new ESLint({
9
- useEslintrc: false,
10
- fix: this.task.config.fix,
11
- overrideConfigFile: this.task.config.configPath
9
+ overrideConfigFile: this.task.config.configPath,
10
+ fix: this.task.config.fix
12
11
  });
13
12
  }
14
13
  async processFile(filePath) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce-ux/slds-linter",
3
- "version": "0.3.1-internal-beta.1",
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,13 +29,13 @@
29
29
  ],
30
30
  "bin": "build/index.js",
31
31
  "dependencies": {
32
- "@salesforce-ux/eslint-plugin-slds": "0.3.1-internal-beta.1",
33
- "@salesforce-ux/stylelint-plugin-slds": "0.3.1-internal-beta.1",
34
- "@typescript-eslint/eslint-plugin": "^5.0.0",
35
- "@typescript-eslint/parser": "^5.0.0",
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
+ "@typescript-eslint/eslint-plugin": "^8.36.0",
35
+ "@typescript-eslint/parser": "^8.36.0",
36
36
  "chalk": "^4.1.2",
37
37
  "commander": "^13.1.0",
38
- "eslint": "8.57.1",
38
+ "eslint": "^9.0.0",
39
39
  "export-to-csv": "^1.4.0",
40
40
  "globby": "^14.1.0",
41
41
  "import-meta-resolve": "^4.1.0",
@@ -45,6 +45,9 @@
45
45
  "semver": "^7.7.1",
46
46
  "stylelint": "16.14.1"
47
47
  },
48
+ "engines": {
49
+ "node": ">=18.18.0"
50
+ },
48
51
  "license": "ISC",
49
52
  "repository": {
50
53
  "type": "git",