@salesforce-ux/slds-linter 0.2.0-alpha.6 → 0.2.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.
Files changed (68) hide show
  1. package/package.json +7 -3
  2. package/build/commands/emit.d.ts +0 -2
  3. package/build/commands/emit.js +0 -49
  4. package/build/commands/emit.js.map +0 -7
  5. package/build/commands/lint.d.ts +0 -2
  6. package/build/commands/lint.js +0 -56
  7. package/build/commands/lint.js.map +0 -7
  8. package/build/commands/report.d.ts +0 -2
  9. package/build/commands/report.js +0 -67
  10. package/build/commands/report.js.map +0 -7
  11. package/build/executor/__tests__/executor.test.js +0 -190
  12. package/build/executor/__tests__/executor.test.js.map +0 -7
  13. package/build/executor/index.d.ts +0 -20
  14. package/build/executor/index.js +0 -79
  15. package/build/executor/index.js.map +0 -7
  16. package/build/index.d.ts +0 -2
  17. package/build/index.js +0 -34
  18. package/build/index.js.map +0 -7
  19. package/build/services/__tests__/file-scanner.test.js +0 -48
  20. package/build/services/__tests__/file-scanner.test.js.map +0 -7
  21. package/build/services/artifact-processor.d.ts +0 -6
  22. package/build/services/artifact-processor.js +0 -38
  23. package/build/services/artifact-processor.js.map +0 -7
  24. package/build/services/batch-processor.d.ts +0 -29
  25. package/build/services/batch-processor.js +0 -85
  26. package/build/services/batch-processor.js.map +0 -7
  27. package/build/services/config.resolver.d.ts +0 -6
  28. package/build/services/config.resolver.js +0 -21
  29. package/build/services/config.resolver.js.map +0 -7
  30. package/build/services/file-patterns.d.ts +0 -3
  31. package/build/services/file-patterns.js +0 -22
  32. package/build/services/file-patterns.js.map +0 -7
  33. package/build/services/file-scanner.d.ts +0 -26
  34. package/build/services/file-scanner.js +0 -72
  35. package/build/services/file-scanner.js.map +0 -7
  36. package/build/services/lint-runner.d.ts +0 -17
  37. package/build/services/lint-runner.js +0 -70
  38. package/build/services/lint-runner.js.map +0 -7
  39. package/build/services/report-generator.d.ts +0 -43
  40. package/build/services/report-generator.js +0 -187
  41. package/build/services/report-generator.js.map +0 -7
  42. package/build/types/index.d.ts +0 -75
  43. package/build/types/index.js +0 -1
  44. package/build/types/index.js.map +0 -7
  45. package/build/utils/config-utils.d.ts +0 -33
  46. package/build/utils/config-utils.js +0 -69
  47. package/build/utils/config-utils.js.map +0 -7
  48. package/build/utils/editorLinkUtil.d.ts +0 -21
  49. package/build/utils/editorLinkUtil.js +0 -22
  50. package/build/utils/editorLinkUtil.js.map +0 -7
  51. package/build/utils/lintResultsUtil.d.ts +0 -21
  52. package/build/utils/lintResultsUtil.js +0 -71
  53. package/build/utils/lintResultsUtil.js.map +0 -7
  54. package/build/utils/logger.d.ts +0 -8
  55. package/build/utils/logger.js +0 -29
  56. package/build/utils/logger.js.map +0 -7
  57. package/build/utils/nodeVersionUtil.d.ts +0 -19
  58. package/build/utils/nodeVersionUtil.js +0 -43
  59. package/build/utils/nodeVersionUtil.js.map +0 -7
  60. package/build/workers/base.worker.d.ts +0 -15
  61. package/build/workers/base.worker.js +0 -45
  62. package/build/workers/base.worker.js.map +0 -7
  63. package/build/workers/eslint.worker.d.ts +0 -1
  64. package/build/workers/eslint.worker.js +0 -51
  65. package/build/workers/eslint.worker.js.map +0 -7
  66. package/build/workers/stylelint.worker.d.ts +0 -1
  67. package/build/workers/stylelint.worker.js +0 -41
  68. package/build/workers/stylelint.worker.js.map +0 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce-ux/slds-linter",
3
- "version": "0.2.0-alpha.6",
3
+ "version": "0.2.0",
4
4
  "description": "SLDS Linter CLI tool for linting styles and components",
5
5
  "keywords": [
6
6
  "lightning design system linter",
@@ -17,6 +17,10 @@
17
17
  "./executor": {
18
18
  "types": "./build/executor/index.d.ts",
19
19
  "default": "./build/executor/index.js"
20
+ },
21
+ "./utils": {
22
+ "types": "./build/utils/index.d.ts",
23
+ "default": "./build/utils/index.js"
20
24
  }
21
25
  },
22
26
  "files": [
@@ -25,8 +29,8 @@
25
29
  ],
26
30
  "bin": "./build/index.js",
27
31
  "dependencies": {
28
- "@salesforce-ux/eslint-plugin-slds": "0.2.0-alpha.6",
29
- "@salesforce-ux/stylelint-plugin-slds": "0.2.0-alpha.6",
32
+ "@salesforce-ux/eslint-plugin-slds": "0.2.0",
33
+ "@salesforce-ux/stylelint-plugin-slds": "0.2.0",
30
34
  "@typescript-eslint/eslint-plugin": "^5.0.0",
31
35
  "@typescript-eslint/parser": "^5.0.0",
32
36
  "chalk": "^4.1.2",
@@ -1,2 +0,0 @@
1
- import { Command } from "commander";
2
- export declare function registerEmitCommand(program: Command): void;
@@ -1,49 +0,0 @@
1
- // src/commands/emit.ts
2
- import chalk from "chalk";
3
- import { Logger } from "../utils/logger.js";
4
- import { normalizeCliOptions } from "../utils/config-utils.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 { copyFile } from "fs/promises";
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). Support glob patterns"
15
- ).action(async (options) => {
16
- try {
17
- Logger.info(chalk.blue("Emitting configuration files..."));
18
- const normalizedOptions = normalizeCliOptions(options, {
19
- configStylelint: DEFAULT_STYLELINT_CONFIG_PATH,
20
- configEslint: DEFAULT_ESLINT_CONFIG_PATH
21
- });
22
- const destStyleConfigPath = path.join(
23
- normalizedOptions.directory,
24
- path.basename(normalizedOptions.configStylelint)
25
- );
26
- await copyFile(normalizedOptions.configStylelint, 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
- await copyFile(normalizedOptions.configEslint, destESLintConfigPath);
35
- Logger.success(chalk.green(`ESLint configuration created at:
36
- ${destESLintConfigPath}
37
- `));
38
- } catch (error) {
39
- Logger.error(
40
- chalk.red(`Failed to emit configuration: ${error.message}`)
41
- );
42
- process.exit(1);
43
- }
44
- });
45
- }
46
- export {
47
- registerEmitCommand
48
- };
49
- //# sourceMappingURL=emit.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/commands/emit.ts"],
4
- "sourcesContent": ["import { Command } from \"commander\";\nimport chalk from \"chalk\";\nimport { CliOptions } from \"../types\";\nimport { Logger } from \"../utils/logger\";\nimport { normalizeCliOptions } from '../utils/config-utils';\nimport {\n DEFAULT_ESLINT_CONFIG_PATH,\n DEFAULT_STYLELINT_CONFIG_PATH,\n} from \"../services/config.resolver\";\nimport path from \"path\";\nimport { copyFile } from 'fs/promises';\n\nexport function registerEmitCommand(program: Command): void {\n program\n .command(\"emit\")\n .description(\"Emits the configuration files used by slds-linter cli\")\n .option(\n \"-d, --directory <path>\",\n \"Target directory to emit (defaults to current directory). Support glob patterns\"\n )\n .action(async (options: CliOptions) => {\n try {\n Logger.info(chalk.blue(\"Emitting configuration files...\"));\n const normalizedOptions = normalizeCliOptions(options, {\n configStylelint: DEFAULT_STYLELINT_CONFIG_PATH,\n configEslint: DEFAULT_ESLINT_CONFIG_PATH,\n });\n\n const destStyleConfigPath = path.join(\n normalizedOptions.directory,\n path.basename(normalizedOptions.configStylelint)\n );\n await copyFile(normalizedOptions.configStylelint, destStyleConfigPath);\n Logger.success(chalk.green(`Stylelint configuration created at:\\n${destStyleConfigPath}\\n`));\n\n const destESLintConfigPath = path.join(\n normalizedOptions.directory,\n path.basename(normalizedOptions.configEslint)\n );\n await copyFile(normalizedOptions.configEslint, destESLintConfigPath);\n Logger.success(chalk.green(`ESLint configuration created at:\\n${destESLintConfigPath}\\n`));\n } catch (error: any) {\n Logger.error(\n chalk.red(`Failed to emit configuration: ${error.message}`)\n );\n process.exit(1);\n }\n });\n}\n"],
5
- "mappings": ";AACA,OAAO,WAAW;AAElB,SAAS,cAAc;AACvB,SAAS,2BAA2B;AACpC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,OAAO,UAAU;AACjB,SAAS,gBAAgB;AAElB,SAAS,oBAAoB,SAAwB;AAC1D,UACG,QAAQ,MAAM,EACd,YAAY,uDAAuD,EACnE;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC,OAAO,OAAO,YAAwB;AACrC,QAAI;AACF,aAAO,KAAK,MAAM,KAAK,iCAAiC,CAAC;AACzD,YAAM,oBAAoB,oBAAoB,SAAS;AAAA,QACrD,iBAAiB;AAAA,QACjB,cAAc;AAAA,MAChB,CAAC;AAED,YAAM,sBAAsB,KAAK;AAAA,QAC/B,kBAAkB;AAAA,QAClB,KAAK,SAAS,kBAAkB,eAAe;AAAA,MACjD;AACA,YAAM,SAAS,kBAAkB,iBAAiB,mBAAmB;AACrE,aAAO,QAAQ,MAAM,MAAM;AAAA,EAAwC,mBAAmB;AAAA,CAAI,CAAC;AAE3F,YAAM,uBAAuB,KAAK;AAAA,QAChC,kBAAkB;AAAA,QAClB,KAAK,SAAS,kBAAkB,YAAY;AAAA,MAC9C;AACA,YAAM,SAAS,kBAAkB,cAAc,oBAAoB;AACnE,aAAO,QAAQ,MAAM,MAAM;AAAA,EAAqC,oBAAoB;AAAA,CAAI,CAAC;AAAA,IAC3F,SAAS,OAAY;AACnB,aAAO;AAAA,QACL,MAAM,IAAI,iCAAiC,MAAM,OAAO,EAAE;AAAA,MAC5D;AACA,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF,CAAC;AACL;",
6
- "names": []
7
- }
@@ -1,2 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare function registerLintCommand(program: Command): void;
@@ -1,56 +0,0 @@
1
- // src/commands/lint.ts
2
- import { Option } from "commander";
3
- import chalk from "chalk";
4
- import { printLintResults } from "../utils/lintResultsUtil.js";
5
- import { normalizeCliOptions, normalizeDirectoryPath } from "../utils/config-utils.js";
6
- import { Logger } from "../utils/logger.js";
7
- import { DEFAULT_ESLINT_CONFIG_PATH, DEFAULT_STYLELINT_CONFIG_PATH } from "../services/config.resolver.js";
8
- import { lint } from "../executor/index.js";
9
- function registerLintCommand(program) {
10
- program.command("lint").aliases(["lint:styles", "lint:components"]).configureHelp({
11
- commandUsage: () => {
12
- return `${program.name()} lint [directory] [options]`;
13
- }
14
- }).description("Run both style and component linting").argument("[directory]", "Target directory to scan (defaults to current directory). Support glob patterns").addOption(new Option("-d, --directory <path>", "Target directory to scan (defaults to current directory). Support glob patterns").hideHelp()).option("--fix", "Automatically fix problems").option("--config-stylelint <path>", "Path to stylelint config file").option("--config-eslint <path>", "Path to eslint config file").option("--editor <editor>", "Editor to open files with (e.g., vscode, atom, sublime). Defaults to vscode", "vscode").action(async (directory, options) => {
15
- const startTime = Date.now();
16
- try {
17
- Logger.info(chalk.blue("Starting lint process..."));
18
- const normalizedOptions = normalizeCliOptions(options, {
19
- configStylelint: DEFAULT_STYLELINT_CONFIG_PATH,
20
- configEslint: DEFAULT_ESLINT_CONFIG_PATH
21
- });
22
- if (directory) {
23
- normalizedOptions.directory = normalizeDirectoryPath(directory);
24
- } else if (options.directory) {
25
- Logger.newLine().warning(chalk.yellow(
26
- `WARNING: --directory, -d option is deprecated. Supply as argument instead.
27
- Example: npx @salesforce-ux/slds-linter lint ${options.directory}`
28
- ));
29
- }
30
- const lintResults = await lint({
31
- directory: normalizedOptions.directory,
32
- fix: normalizedOptions.fix,
33
- configStylelint: normalizedOptions.configStylelint,
34
- configEslint: normalizedOptions.configEslint
35
- });
36
- printLintResults(lintResults, normalizedOptions.editor);
37
- const errorCount = lintResults.reduce((sum, r) => sum + r.errors.length, 0);
38
- const warningCount = lintResults.reduce((sum, r) => sum + r.warnings.length, 0);
39
- Logger.info(
40
- `
41
- ${chalk.red(`${errorCount} error${errorCount !== 1 ? "s" : ""}`)} ${chalk.yellow(`${warningCount} warning${warningCount !== 1 ? "s" : ""}`)}`
42
- );
43
- const elapsedTime = ((Date.now() - startTime) / 1e3).toFixed(2);
44
- Logger.success(chalk.green(`
45
- Linting completed in ${elapsedTime} seconds.`));
46
- process.exit(errorCount > 0 ? 1 : 0);
47
- } catch (error) {
48
- Logger.error(chalk.red(`Failed to complete linting: ${error.message}`));
49
- process.exit(1);
50
- }
51
- });
52
- }
53
- export {
54
- registerLintCommand
55
- };
56
- //# sourceMappingURL=lint.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/commands/lint.ts"],
4
- "sourcesContent": ["import { Command, Option } from 'commander';\nimport chalk from 'chalk';\nimport { CliOptions } from '../types';\nimport { printLintResults } from '../utils/lintResultsUtil';\nimport { normalizeCliOptions, normalizeDirectoryPath } from '../utils/config-utils';\nimport { Logger } from '../utils/logger';\nimport { DEFAULT_ESLINT_CONFIG_PATH, DEFAULT_STYLELINT_CONFIG_PATH } from '../services/config.resolver';\nimport { lint } from '../executor';\n\nexport function registerLintCommand(program: Command): void {\n program\n .command('lint')\n .aliases(['lint:styles', 'lint:components'])\n .configureHelp({\n commandUsage: ()=>{\n return `${program.name()} lint [directory] [options]`\n }\n })\n .description('Run both style and component linting')\n .argument('[directory]', 'Target directory to scan (defaults to current directory). Support glob patterns')\n .addOption(new Option('-d, --directory <path>', 'Target directory to scan (defaults to current directory). Support glob patterns').hideHelp())\n .option('--fix', 'Automatically fix problems')\n .option('--config-stylelint <path>', 'Path to stylelint config file')\n .option('--config-eslint <path>', 'Path to eslint config file')\n .option('--editor <editor>', 'Editor to open files with (e.g., vscode, atom, sublime). Defaults to vscode', 'vscode')\n .action(async (directory:string, options: CliOptions) => {\n const startTime = Date.now();\n try {\n Logger.info(chalk.blue('Starting lint process...'));\n // Parse CLI options with appropriate defaults\n const normalizedOptions = normalizeCliOptions(options, {\n configStylelint: DEFAULT_STYLELINT_CONFIG_PATH,\n configEslint: DEFAULT_ESLINT_CONFIG_PATH,\n });\n\n if(directory){ // If argument is passed, ignore -d, --directory option\n normalizedOptions.directory = normalizeDirectoryPath(directory);\n } else if(options.directory){\n // If -d, --directory option is passed, prompt deprecation warning\n Logger.newLine().warning(chalk.yellow(\n `WARNING: --directory, -d option is deprecated. Supply as argument instead.\n Example: npx @salesforce-ux/slds-linter lint ${options.directory}`\n ));\n }\n\n // Use Node API to perform the linting\n const lintResults = await lint({\n directory: normalizedOptions.directory,\n fix: normalizedOptions.fix,\n configStylelint: normalizedOptions.configStylelint,\n configEslint: normalizedOptions.configEslint\n });\n\n // Print detailed lint results only for files with issues\n printLintResults(lintResults, normalizedOptions.editor);\n\n // Calculate statistics\n const errorCount = lintResults.reduce((sum, r) => sum + r.errors.length, 0);\n const warningCount = lintResults.reduce((sum, r) => sum + r.warnings.length, 0);\n\n // Final summary\n Logger.info(\n `\\n${chalk.red(`${errorCount} error${errorCount !== 1 ? 's' : ''}`)}` +\n ` ${chalk.yellow(`${warningCount} warning${warningCount !== 1 ? 's' : ''}`)}`\n );\n \n const elapsedTime = ((Date.now() - startTime) / 1000).toFixed(2);\n Logger.success(chalk.green(`\\nLinting completed in ${elapsedTime} seconds.`));\n process.exit(errorCount > 0 ? 1 : 0);\n } catch (error: any) {\n Logger.error(chalk.red(`Failed to complete linting: ${error.message}`));\n process.exit(1);\n }\n });\n}\n"],
5
- "mappings": ";AAAA,SAAkB,cAAc;AAChC,OAAO,WAAW;AAElB,SAAS,wBAAwB;AACjC,SAAS,qBAAqB,8BAA8B;AAC5D,SAAS,cAAc;AACvB,SAAS,4BAA4B,qCAAqC;AAC1E,SAAS,YAAY;AAEd,SAAS,oBAAoB,SAAwB;AAC1D,UACG,QAAQ,MAAM,EACd,QAAQ,CAAC,eAAe,iBAAiB,CAAC,EAC1C,cAAc;AAAA,IACb,cAAc,MAAI;AAChB,aAAO,GAAG,QAAQ,KAAK,CAAC;AAAA,IAC1B;AAAA,EACF,CAAC,EACA,YAAY,sCAAsC,EAClD,SAAS,eAAe,iFAAiF,EACzG,UAAU,IAAI,OAAO,0BAA0B,iFAAiF,EAAE,SAAS,CAAC,EAC5I,O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AAC;AAAA,IACrC,SAAS,OAAY;AACnB,aAAO,MAAM,MAAM,IAAI,+BAA+B,MAAM,OAAO,EAAE,CAAC;AACtE,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF,CAAC;AACL;",
6
- "names": []
7
- }
@@ -1,2 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare function registerReportCommand(program: Command): void;
@@ -1,67 +0,0 @@
1
- // src/commands/report.ts
2
- import { Option } from "commander";
3
- import path from "path";
4
- import ora from "ora";
5
- import chalk from "chalk";
6
- import fs from "fs";
7
- import { normalizeCliOptions, normalizeDirectoryPath } from "../utils/config-utils.js";
8
- import { Logger } from "../utils/logger.js";
9
- import { DEFAULT_ESLINT_CONFIG_PATH, DEFAULT_STYLELINT_CONFIG_PATH } from "../services/config.resolver.js";
10
- import { report, lint } from "../executor/index.js";
11
- function registerReportCommand(program) {
12
- program.command("report").description("Generate report from linting results").argument("[directory]", "Target directory to scan (defaults to current directory). Support glob patterns").addOption(new Option("-d, --directory <path>", "Target directory to scan (defaults to current directory). Support glob patterns").hideHelp()).option("-o, --output <path>", "Output directory for reports (defaults to current directory)").option("--config-stylelint <path>", "Path to stylelint config file").option("--config-eslint <path>", "Path to eslint config file").addOption(new Option("--format <type>", "Output format").choices(["sarif", "csv"]).default("sarif")).action(async (directory, options) => {
13
- const spinner = ora("Starting report generation...");
14
- try {
15
- const normalizedOptions = normalizeCliOptions(options, {
16
- configStylelint: DEFAULT_STYLELINT_CONFIG_PATH,
17
- configEslint: DEFAULT_ESLINT_CONFIG_PATH
18
- });
19
- if (directory) {
20
- normalizedOptions.directory = normalizeDirectoryPath(directory);
21
- } else if (options.directory) {
22
- Logger.newLine().warning(chalk.yellow(
23
- `WARNING: --directory, -d option is deprecated. Supply as argument instead.
24
- Example: npx @salesforce-ux/slds-linter report ${options.directory}`
25
- ));
26
- }
27
- spinner.start();
28
- const reportFormat = normalizedOptions.format?.toLowerCase() || "sarif";
29
- const lintResults = await lint({
30
- directory: normalizedOptions.directory,
31
- configStylelint: normalizedOptions.configStylelint,
32
- configEslint: normalizedOptions.configEslint
33
- });
34
- const reportStream = await report({
35
- format: reportFormat
36
- }, lintResults);
37
- let outputFilePath;
38
- if (reportFormat === "sarif") {
39
- spinner.text = "Saving SARIF report...";
40
- outputFilePath = path.join(normalizedOptions.output, "slds-linter-report.sarif");
41
- } else if (reportFormat === "csv") {
42
- spinner.text = "Saving CSV report...";
43
- outputFilePath = path.join(normalizedOptions.output, "slds-linter-report.csv");
44
- } else {
45
- throw new Error(`Invalid format: ${reportFormat}. Supported formats: sarif, csv`);
46
- }
47
- const writeStream = fs.createWriteStream(outputFilePath);
48
- reportStream.pipe(writeStream);
49
- await new Promise((resolve, reject) => {
50
- writeStream.on("finish", resolve);
51
- writeStream.on("error", reject);
52
- });
53
- Logger.success(`${reportFormat.toUpperCase()} report generated: ${outputFilePath}
54
- `);
55
- spinner.succeed("Report generation completed");
56
- process.exit(0);
57
- } catch (error) {
58
- spinner?.fail("Report generation failed");
59
- Logger.error(`Failed to generate report: ${error.message}`);
60
- process.exit(1);
61
- }
62
- });
63
- }
64
- export {
65
- registerReportCommand
66
- };
67
- //# sourceMappingURL=report.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/commands/report.ts"],
4
- "sourcesContent": ["import { Command, Option } from 'commander';\nimport path from 'path';\nimport ora from 'ora';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport { CliOptions } from '../types';\nimport { normalizeCliOptions, normalizeDirectoryPath } from '../utils/config-utils';\nimport { Logger } from '../utils/logger';\nimport { DEFAULT_ESLINT_CONFIG_PATH, DEFAULT_STYLELINT_CONFIG_PATH } from '../services/config.resolver';\nimport { report, lint } from '../executor';\n\nexport function registerReportCommand(program: Command): void {\n program\n .command('report')\n .description('Generate report from linting results')\n .argument('[directory]', 'Target directory to scan (defaults to current directory). Support glob patterns')\n .addOption(new Option('-d, --directory <path>', 'Target directory to scan (defaults to current directory). Support glob patterns').hideHelp()) \n .option('-o, --output <path>', 'Output directory for reports (defaults to current directory)')\n .option('--config-stylelint <path>', 'Path to stylelint config file')\n .option('--config-eslint <path>', 'Path to eslint config file')\n .addOption(new Option('--format <type>', 'Output format').choices(['sarif', 'csv']).default('sarif'))\n .action(async (directory: string, options: CliOptions) => {\n const spinner = ora('Starting report generation...');\n try { \n const normalizedOptions = normalizeCliOptions(options, {\n configStylelint: DEFAULT_STYLELINT_CONFIG_PATH,\n configEslint: DEFAULT_ESLINT_CONFIG_PATH\n });\n\n if(directory){ // If argument is passed, ignore -d, --directory option\n normalizedOptions.directory = normalizeDirectoryPath(directory);\n } else if(options.directory){\n // If -d, --directory option is passed, prompt deprecation warning\n Logger.newLine().warning(chalk.yellow(\n `WARNING: --directory, -d option is deprecated. Supply as argument instead.\n Example: npx @salesforce-ux/slds-linter report ${options.directory}`\n ));\n }\n spinner.start();\n \n // Generate report based on format using Node API\n const reportFormat = normalizedOptions.format?.toLowerCase() || 'sarif';\n \n // First run linting to get results\n const lintResults = await lint({\n directory: normalizedOptions.directory,\n configStylelint: normalizedOptions.configStylelint,\n configEslint: normalizedOptions.configEslint\n });\n \n // Generate report using the lint results\n const reportStream = await report({\n format: reportFormat as 'sarif' | 'csv'\n }, lintResults);\n \n // Save the report to a file\n let outputFilePath: string;\n if (reportFormat === 'sarif') {\n spinner.text = 'Saving SARIF report...';\n outputFilePath = path.join(normalizedOptions.output, 'slds-linter-report.sarif');\n } else if (reportFormat === 'csv') {\n spinner.text = 'Saving CSV report...';\n outputFilePath = path.join(normalizedOptions.output, 'slds-linter-report.csv');\n } else {\n throw new Error(`Invalid format: ${reportFormat}. Supported formats: sarif, csv`);\n }\n \n // Save stream to file\n const writeStream = fs.createWriteStream(outputFilePath);\n reportStream.pipe(writeStream);\n \n await new Promise<void>((resolve, reject) => {\n writeStream.on('finish', resolve);\n writeStream.on('error', reject);\n });\n \n Logger.success(`${reportFormat.toUpperCase()} report generated: ${outputFilePath}\\n`);\n spinner.succeed('Report generation completed');\n process.exit(0);\n } catch (error: any) {\n spinner?.fail('Report generation failed');\n Logger.error(`Failed to generate report: ${error.message}`);\n process.exit(1);\n }\n });\n}\n"],
5
- "mappings": ";AAAA,SAAkB,cAAc;AAChC,OAAO,UAAU;AACjB,OAAO,SAAS;AAChB,OAAO,WAAW;AAClB,OAAO,QAAQ;AAEf,SAAS,qBAAqB,8BAA8B;AAC5D,SAAS,cAAc;AACvB,SAAS,4BAA4B,qCAAqC;AAC1E,SAAS,QAAQ,YAAY;AAEtB,SAAS,sBAAsB,SAAwB;AAC5D,UACG,QAAQ,QAAQ,EAChB,YAAY,sCAAsC,EAClD,SAAS,eAAe,iFAAiF,EACzG,UAAU,IAAI,OAAO,0BAA0B,iFAAiF,EAAE,SAAS,CAAC,EAC5I,OAAO,uBAAuB,8DAA8D,EAC5F,OAAO,6BAA6B,+BAA+B,EACnE,OAAO,0BAA0B,4BAA4B,EAC7D,UAAU,IAAI,OAAO,mBAAmB,eAAe,EAAE,QAAQ,CAAC,SAAS,KAAK,CAAC,EAAE,QAAQ,OAAO,CAAC,EACnG,OAAO,OAAO,WAAmB,YAAwB;AACxD,UAAM,UAAU,IAAI,+BAA+B;AACnD,QAAI;AACF,YAAM,oBAAoB,oBAAoB,SAAS;AAAA,QACrD,iBAAiB;AAAA,QACjB,cAAc;AAAA,MAChB,CAAC;AAED,UAAG,WAAU;AACX,0BAAkB,YAAY,uBAAuB,SAAS;AAAA,MAChE,WAAU,QAAQ,WAAU;AAE1B,eAAO,QAAQ,EAAE,QAAQ,MAAM;AAAA,UAC7B;AAAA,6DACiD,QAAQ,SAAS;AAAA,QACpE,CAAC;AAAA,MACH;AACA,cAAQ,MAAM;AAGd,YAAM,eAAe,kBAAkB,QAAQ,YAAY,KAAK;AAGhE,YAAM,cAAc,MAAM,KAAK;AAAA,QAC7B,WAAW,kBAAkB;AAAA,QAC7B,iBAAiB,kBAAkB;AAAA,QACnC,cAAc,kBAAkB;AAAA,MAClC,CAAC;AAGD,YAAM,eAAe,MAAM,OAAO;AAAA,QAChC,QAAQ;AAAA,MACV,GAAG,WAAW;AAGd,UAAI;AACJ,UAAI,iBAAiB,SAAS;AAC5B,gBAAQ,OAAO;AACf,yBAAiB,KAAK,KAAK,kBAAkB,QAAQ,0BAA0B;AAAA,MACjF,WAAW,iBAAiB,OAAO;AACjC,gBAAQ,OAAO;AACf,yBAAiB,KAAK,KAAK,kBAAkB,QAAQ,wBAAwB;AAAA,MAC/E,OAAO;AACL,cAAM,IAAI,MAAM,mBAAmB,YAAY,iCAAiC;AAAA,MAClF;AAGA,YAAM,cAAc,GAAG,kBAAkB,cAAc;AACvD,mBAAa,KAAK,WAAW;AAE7B,YAAM,IAAI,QAAc,CAAC,SAAS,WAAW;AAC3C,oBAAY,GAAG,UAAU,OAAO;AAChC,oBAAY,GAAG,SAAS,MAAM;AAAA,MAChC,CAAC;AAED,aAAO,QAAQ,GAAG,aAAa,YAAY,CAAC,sBAAsB,cAAc;AAAA,CAAI;AACpF,cAAQ,QAAQ,6BAA6B;AAC7C,cAAQ,KAAK,CAAC;AAAA,IAChB,SAAS,OAAY;AACnB,eAAS,KAAK,0BAA0B;AACxC,aAAO,MAAM,8BAA8B,MAAM,OAAO,EAAE;AAC1D,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF,CAAC;AACL;",
6
- "names": []
7
- }
@@ -1,190 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __esm = (fn, res) => function __init() {
6
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
7
- };
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
-
22
- // src/executor/index.ts
23
- var executor_exports = {};
24
- __export(executor_exports, {
25
- lint: () => lint,
26
- report: () => report
27
- });
28
- import { Readable } from "stream";
29
- import { FileScanner } from "../services/file-scanner.js";
30
- import { LintRunner } from "../services/lint-runner.js";
31
- import { StyleFilePatterns, ComponentFilePatterns } from "../services/file-patterns.js";
32
- import { ReportGenerator, CsvReportGenerator } from "../services/report-generator.js";
33
- import { LINTER_CLI_VERSION } from "../services/config.resolver.js";
34
- import { normalizeCliOptions } from "../utils/config-utils.js";
35
- import { Logger } from "../utils/logger.js";
36
- async function lint(config) {
37
- try {
38
- Logger.debug("Starting linting with Node API");
39
- const normalizedConfig = normalizeCliOptions(config, {}, true);
40
- const styleFiles = await FileScanner.scanFiles(normalizedConfig.directory, {
41
- patterns: StyleFilePatterns,
42
- batchSize: 100
43
- });
44
- const componentFiles = await FileScanner.scanFiles(normalizedConfig.directory, {
45
- patterns: ComponentFilePatterns,
46
- batchSize: 100
47
- });
48
- const lintOptions = {
49
- fix: normalizedConfig.fix,
50
- configPath: normalizedConfig.configStylelint
51
- };
52
- const styleResults = await LintRunner.runLinting(styleFiles, "style", {
53
- ...lintOptions,
54
- configPath: normalizedConfig.configStylelint
55
- });
56
- const componentResults = await LintRunner.runLinting(componentFiles, "component", {
57
- ...lintOptions,
58
- configPath: normalizedConfig.configEslint
59
- });
60
- const combinedResults = [...styleResults, ...componentResults];
61
- return combinedResults;
62
- } catch (error) {
63
- const errorMessage = `Linting failed: ${error.message}`;
64
- Logger.error(errorMessage);
65
- throw new Error(errorMessage);
66
- }
67
- }
68
- async function report(config, results) {
69
- try {
70
- Logger.debug("Starting report generation with Node API");
71
- const normalizedConfig = normalizeCliOptions(config, {}, true);
72
- const format = normalizedConfig.format || "sarif";
73
- const lintResults = results || await lint({
74
- directory: normalizedConfig.directory,
75
- configStylelint: normalizedConfig.configStylelint,
76
- configEslint: normalizedConfig.configEslint
77
- });
78
- switch (format) {
79
- case "sarif":
80
- return ReportGenerator.generateSarifReportStream(lintResults, {
81
- toolName: "slds-linter",
82
- toolVersion: LINTER_CLI_VERSION
83
- });
84
- case "csv":
85
- const csvString = CsvReportGenerator.generateCsvString(lintResults);
86
- const csvStream = new Readable();
87
- csvStream.push(csvString);
88
- csvStream.push(null);
89
- return csvStream;
90
- default:
91
- const errorMessage = `Unsupported format: ${format}`;
92
- Logger.error(errorMessage);
93
- throw new Error(errorMessage);
94
- }
95
- } catch (error) {
96
- const errorMessage = `Report generation failed: ${error.message}`;
97
- Logger.error(errorMessage);
98
- throw new Error(errorMessage);
99
- }
100
- }
101
- var init_executor = __esm({
102
- "src/executor/index.ts"() {
103
- }
104
- });
105
-
106
- // src/executor/__tests__/executor.test.ts
107
- import { lint as lint2, report as report2 } from "../index.js";
108
- import { LintRunner as LintRunner2 } from "../../services/lint-runner.js";
109
- import { FileScanner as FileScanner2 } from "../../services/file-scanner.js";
110
- import { Readable as Readable2 } from "stream";
111
- import { jest } from "@jest/globals.js";
112
- var mockLintResult = {
113
- filePath: "file1.css",
114
- errors: [{ line: 1, column: 1, endColumn: 10, message: "Test error", ruleId: "test-rule", severity: 2 }],
115
- warnings: []
116
- };
117
- jest.mock("../../services/lint-runner", () => {
118
- return {
119
- LintRunner: {
120
- runLinting: jest.fn().mockImplementation(() => {
121
- return Promise.resolve([mockLintResult]);
122
- })
123
- }
124
- };
125
- });
126
- jest.mock("../../services/file-scanner", () => {
127
- return {
128
- FileScanner: {
129
- scanFiles: jest.fn().mockImplementation(() => {
130
- return Promise.resolve([["file1.css"]]);
131
- })
132
- }
133
- };
134
- });
135
- jest.mock("fs/promises");
136
- xdescribe("Executor functions", () => {
137
- beforeEach(() => {
138
- jest.clearAllMocks();
139
- });
140
- describe("lint", () => {
141
- it("should scan directory and run linting when no files are provided", async () => {
142
- const config = {
143
- directory: "./src",
144
- fix: true
145
- };
146
- const results = await lint2(config);
147
- expect(FileScanner2.scanFiles).toHaveBeenCalledTimes(2);
148
- expect(LintRunner2.runLinting).toHaveBeenCalledTimes(2);
149
- expect(results).toHaveLength(2);
150
- });
151
- it("should use provided files and skip scanning when files are provided", async () => {
152
- const config = {
153
- files: ["file1.css", "component1.html"]
154
- };
155
- await lint2(config);
156
- expect(FileScanner2.scanFiles).not.toHaveBeenCalled();
157
- expect(LintRunner2.runLinting).toHaveBeenCalledTimes(2);
158
- });
159
- });
160
- describe("report", () => {
161
- it("should return a readable stream", async () => {
162
- const config = {
163
- directory: "./src",
164
- format: "sarif"
165
- };
166
- const stream = await report2(config);
167
- expect(stream).toBeInstanceOf(Readable2);
168
- });
169
- it("should use lint results to generate a report", async () => {
170
- const lintMock = jest.spyOn((init_executor(), __toCommonJS(executor_exports)), "lint").mockResolvedValue([mockLintResult]);
171
- const config = {
172
- directory: "./src",
173
- format: "sarif"
174
- };
175
- await report2(config);
176
- expect(lintMock).toHaveBeenCalledWith({
177
- directory: "./src",
178
- configStylelint: expect.any(String),
179
- configEslint: expect.any(String)
180
- });
181
- lintMock.mockRestore();
182
- });
183
- });
184
- });
185
- describe("Executor placeholder tests", () => {
186
- it("should be implemented in the future", () => {
187
- expect(true).toBe(true);
188
- });
189
- });
190
- //# sourceMappingURL=executor.test.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/executor/index.ts", "../../../src/executor/__tests__/executor.test.ts"],
4
- "sourcesContent": ["import { Readable } from 'stream';\nimport { FileScanner } from '../services/file-scanner';\nimport { LintRunner, LintOptions } from '../services/lint-runner';\nimport { StyleFilePatterns, ComponentFilePatterns } from '../services/file-patterns';\nimport { ReportGenerator, CsvReportGenerator } from '../services/report-generator';\nimport { DEFAULT_ESLINT_CONFIG_PATH, DEFAULT_STYLELINT_CONFIG_PATH, LINTER_CLI_VERSION } from '../services/config.resolver';\nimport { LintResult, LintConfig, ReportConfig } from '../types';\nimport { normalizeCliOptions } from '../utils/config-utils';\nimport { Logger } from '../utils/logger';\n\n/**\n * Run linting on specified files or directory\n * \n * @param config Linting configuration options\n * @returns Promise resolving to an array of lint results\n * @throws Error if linting fails\n */\nexport async function lint(config: LintConfig): Promise<LintResult[]> {\n try {\n Logger.debug('Starting linting with Node API');\n \n // Normalize configuration to ensure all required fields have values\n const normalizedConfig = normalizeCliOptions(config, {}, true);\n \n // Scan directory for style files (CSS, SCSS, etc.)\n const styleFiles = await FileScanner.scanFiles(normalizedConfig.directory, {\n patterns: StyleFilePatterns,\n batchSize: 100,\n });\n \n // Scan directory for component files (HTML, etc.)\n const componentFiles = await FileScanner.scanFiles(normalizedConfig.directory, {\n patterns: ComponentFilePatterns,\n batchSize: 100,\n });\n \n // Configure linting options\n const lintOptions: LintOptions = {\n fix: normalizedConfig.fix,\n configPath: normalizedConfig.configStylelint,\n };\n \n // Run linting on style files\n const styleResults = await LintRunner.runLinting(styleFiles, 'style', {\n ...lintOptions,\n configPath: normalizedConfig.configStylelint,\n });\n \n // Run linting on component files\n const componentResults = await LintRunner.runLinting(componentFiles, 'component', {\n ...lintOptions,\n configPath: normalizedConfig.configEslint,\n });\n \n // Combine results from both linters\n const combinedResults = [...styleResults, ...componentResults];\n \n return combinedResults;\n } catch (error: any) {\n // Enhance error with context for better debugging\n const errorMessage = `Linting failed: ${error.message}`;\n Logger.error(errorMessage);\n throw new Error(errorMessage);\n }\n}\n\n/**\n * Generate a report from linting results\n * \n * @param config Report configuration options\n * @param results Optional lint results (if not provided, will run lint)\n * @returns A readable stream containing the report data\n * @throws Error if report generation fails\n */\nexport async function report(config: ReportConfig, results?: LintResult[]): Promise<Readable> {\n try {\n Logger.debug('Starting report generation with Node API');\n \n // Normalize configuration to ensure all required fields have values\n const normalizedConfig = normalizeCliOptions(config, {}, true);\n \n // Determine report format with default\n const format = normalizedConfig.format || 'sarif';\n \n // Get lint results either from provided results parameter or by running lint\n const lintResults = results || await lint({\n directory: normalizedConfig.directory,\n configStylelint: normalizedConfig.configStylelint,\n configEslint: normalizedConfig.configEslint,\n });\n \n // Process based on requested format\n switch (format) {\n case 'sarif':\n // Generate SARIF report as a stream\n return ReportGenerator.generateSarifReportStream(lintResults, {\n toolName: 'slds-linter',\n toolVersion: LINTER_CLI_VERSION\n });\n \n case 'csv':\n // Generate CSV data in memory and create a stream\n const csvString = CsvReportGenerator.generateCsvString(lintResults);\n const csvStream = new Readable();\n csvStream.push(csvString);\n csvStream.push(null); // End of stream\n return csvStream;\n \n default:\n // Throw error for unsupported formats\n const errorMessage = `Unsupported format: ${format}`;\n Logger.error(errorMessage);\n throw new Error(errorMessage);\n }\n } catch (error: any) {\n // Enhance error with context for better debugging\n const errorMessage = `Report generation failed: ${error.message}`;\n Logger.error(errorMessage);\n throw new Error(errorMessage);\n }\n}\n\nexport type { LintResult, LintResultEntry, LintConfig, ReportConfig, ExitCode, WorkerResult, SarifResultEntry } from '../types'; ", "/**\n * Tests for executor module functionality\n */\n\nimport { lint, report } from '../index';\nimport { LintConfig, ReportConfig, LintResult } from '../../types';\nimport { LintRunner } from '../../services/lint-runner';\nimport { FileScanner } from '../../services/file-scanner';\nimport { Readable } from 'stream';\nimport { jest } from '@jest/globals';\n\n// Create mock type-safe functions\nconst mockLintResult: LintResult = {\n filePath: 'file1.css',\n errors: [{ line: 1, column: 1, endColumn: 10, message: 'Test error', ruleId: 'test-rule', severity: 2 }],\n warnings: []\n};\n\n// Use an alternative approach without generic typing that was causing issues\njest.mock('../../services/lint-runner', () => {\n return {\n LintRunner: {\n runLinting: jest.fn().mockImplementation(() => {\n return Promise.resolve([mockLintResult]);\n })\n }\n };\n});\n\njest.mock('../../services/file-scanner', () => {\n return {\n FileScanner: {\n scanFiles: jest.fn().mockImplementation(() => {\n return Promise.resolve([['file1.css']]);\n })\n }\n };\n});\n\njest.mock('fs/promises');\n\n// Skip tests temporarily until TypeScript issues are resolved\nxdescribe('Executor functions', () => {\n beforeEach(() => {\n jest.clearAllMocks();\n });\n \n describe('lint', () => {\n it('should scan directory and run linting when no files are provided', async () => {\n const config: LintConfig = {\n directory: './src',\n fix: true\n };\n \n const results = await lint(config);\n \n // Check FileScanner was called with correct params\n expect(FileScanner.scanFiles).toHaveBeenCalledTimes(2);\n \n // Check LintRunner was called with correct params\n expect(LintRunner.runLinting).toHaveBeenCalledTimes(2);\n \n // Check results were combined correctly\n expect(results).toHaveLength(2);\n });\n \n it('should use provided files and skip scanning when files are provided', async () => {\n const config: LintConfig = {\n files: ['file1.css', 'component1.html']\n };\n \n await lint(config);\n \n // FileScanner should not be called when files are provided\n expect(FileScanner.scanFiles).not.toHaveBeenCalled();\n \n // LintRunner should still be called\n expect(LintRunner.runLinting).toHaveBeenCalledTimes(2);\n });\n });\n \n describe('report', () => {\n it('should return a readable stream', async () => {\n const config: ReportConfig = {\n directory: './src',\n format: 'sarif'\n };\n \n const stream = await report(config);\n \n expect(stream).toBeInstanceOf(Readable);\n });\n \n it('should use lint results to generate a report', async () => {\n // Create mock module for lint function to spy on\n const lintMock = jest.spyOn(require('../index'), 'lint').mockResolvedValue([mockLintResult]);\n \n const config: ReportConfig = {\n directory: './src',\n format: 'sarif'\n };\n \n await report(config);\n \n expect(lintMock).toHaveBeenCalledWith({\n directory: './src',\n configStylelint: expect.any(String),\n configEslint: expect.any(String)\n });\n \n // Restore the original implementation\n lintMock.mockRestore();\n });\n });\n});\n\ndescribe('Executor placeholder tests', () => {\n it('should be implemented in the future', () => {\n expect(true).toBe(true);\n });\n});"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAS,gBAAgB;AACzB,SAAS,mBAAmB;AAC5B,SAAS,kBAA+B;AACxC,SAAS,mBAAmB,6BAA6B;AACzD,SAAS,iBAAiB,0BAA0B;AACpD,SAAoE,0BAA0B;AAE9F,SAAS,2BAA2B;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B,CAAC;AAAA,EACH,CAAC;AACH,CAAC;AAED,SAAS,8BAA8B,MAAM;AAC3C,KAAG,uCAAuC,MAAM;AAC9C,WAAO,IAAI,EAAE,KAAK,IAAI;AAAA,EACxB,CAAC;AACH,CAAC;",
6
- "names": ["lint", "report", "LintRunner", "FileScanner", "Readable"]
7
- }
@@ -1,20 +0,0 @@
1
- import { Readable } from 'stream';
2
- import { LintResult, LintConfig, ReportConfig } from '../types';
3
- /**
4
- * Run linting on specified files or directory
5
- *
6
- * @param config Linting configuration options
7
- * @returns Promise resolving to an array of lint results
8
- * @throws Error if linting fails
9
- */
10
- export declare function lint(config: LintConfig): Promise<LintResult[]>;
11
- /**
12
- * Generate a report from linting results
13
- *
14
- * @param config Report configuration options
15
- * @param results Optional lint results (if not provided, will run lint)
16
- * @returns A readable stream containing the report data
17
- * @throws Error if report generation fails
18
- */
19
- export declare function report(config: ReportConfig, results?: LintResult[]): Promise<Readable>;
20
- export type { LintResult, LintResultEntry, LintConfig, ReportConfig, ExitCode, WorkerResult, SarifResultEntry } from '../types';
@@ -1,79 +0,0 @@
1
- // src/executor/index.ts
2
- import { Readable } from "stream";
3
- import { FileScanner } from "../services/file-scanner.js";
4
- import { LintRunner } from "../services/lint-runner.js";
5
- import { StyleFilePatterns, ComponentFilePatterns } from "../services/file-patterns.js";
6
- import { ReportGenerator, CsvReportGenerator } from "../services/report-generator.js";
7
- import { LINTER_CLI_VERSION } from "../services/config.resolver.js";
8
- import { normalizeCliOptions } from "../utils/config-utils.js";
9
- import { Logger } from "../utils/logger.js";
10
- async function lint(config) {
11
- try {
12
- Logger.debug("Starting linting with Node API");
13
- const normalizedConfig = normalizeCliOptions(config, {}, true);
14
- const styleFiles = await FileScanner.scanFiles(normalizedConfig.directory, {
15
- patterns: StyleFilePatterns,
16
- batchSize: 100
17
- });
18
- const componentFiles = await FileScanner.scanFiles(normalizedConfig.directory, {
19
- patterns: ComponentFilePatterns,
20
- batchSize: 100
21
- });
22
- const lintOptions = {
23
- fix: normalizedConfig.fix,
24
- configPath: normalizedConfig.configStylelint
25
- };
26
- const styleResults = await LintRunner.runLinting(styleFiles, "style", {
27
- ...lintOptions,
28
- configPath: normalizedConfig.configStylelint
29
- });
30
- const componentResults = await LintRunner.runLinting(componentFiles, "component", {
31
- ...lintOptions,
32
- configPath: normalizedConfig.configEslint
33
- });
34
- const combinedResults = [...styleResults, ...componentResults];
35
- return combinedResults;
36
- } catch (error) {
37
- const errorMessage = `Linting failed: ${error.message}`;
38
- Logger.error(errorMessage);
39
- throw new Error(errorMessage);
40
- }
41
- }
42
- async function report(config, results) {
43
- try {
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
51
- });
52
- switch (format) {
53
- case "sarif":
54
- return ReportGenerator.generateSarifReportStream(lintResults, {
55
- toolName: "slds-linter",
56
- toolVersion: LINTER_CLI_VERSION
57
- });
58
- case "csv":
59
- const csvString = CsvReportGenerator.generateCsvString(lintResults);
60
- const csvStream = new Readable();
61
- csvStream.push(csvString);
62
- csvStream.push(null);
63
- return csvStream;
64
- default:
65
- const errorMessage = `Unsupported format: ${format}`;
66
- Logger.error(errorMessage);
67
- throw new Error(errorMessage);
68
- }
69
- } catch (error) {
70
- const errorMessage = `Report generation failed: ${error.message}`;
71
- Logger.error(errorMessage);
72
- throw new Error(errorMessage);
73
- }
74
- }
75
- export {
76
- lint,
77
- report
78
- };
79
- //# sourceMappingURL=index.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/executor/index.ts"],
4
- "sourcesContent": ["import { Readable } from 'stream';\nimport { FileScanner } from '../services/file-scanner';\nimport { LintRunner, LintOptions } from '../services/lint-runner';\nimport { StyleFilePatterns, ComponentFilePatterns } from '../services/file-patterns';\nimport { ReportGenerator, CsvReportGenerator } from '../services/report-generator';\nimport { DEFAULT_ESLINT_CONFIG_PATH, DEFAULT_STYLELINT_CONFIG_PATH, LINTER_CLI_VERSION } from '../services/config.resolver';\nimport { LintResult, LintConfig, ReportConfig } from '../types';\nimport { normalizeCliOptions } from '../utils/config-utils';\nimport { Logger } from '../utils/logger';\n\n/**\n * Run linting on specified files or directory\n * \n * @param config Linting configuration options\n * @returns Promise resolving to an array of lint results\n * @throws Error if linting fails\n */\nexport async function lint(config: LintConfig): Promise<LintResult[]> {\n try {\n Logger.debug('Starting linting with Node API');\n \n // Normalize configuration to ensure all required fields have values\n const normalizedConfig = normalizeCliOptions(config, {}, true);\n \n // Scan directory for style files (CSS, SCSS, etc.)\n const styleFiles = await FileScanner.scanFiles(normalizedConfig.directory, {\n patterns: StyleFilePatterns,\n batchSize: 100,\n });\n \n // Scan directory for component files (HTML, etc.)\n const componentFiles = await FileScanner.scanFiles(normalizedConfig.directory, {\n patterns: ComponentFilePatterns,\n batchSize: 100,\n });\n \n // Configure linting options\n const lintOptions: LintOptions = {\n fix: normalizedConfig.fix,\n configPath: normalizedConfig.configStylelint,\n };\n \n // Run linting on style files\n const styleResults = await LintRunner.runLinting(styleFiles, 'style', {\n ...lintOptions,\n configPath: normalizedConfig.configStylelint,\n });\n \n // Run linting on component files\n const componentResults = await LintRunner.runLinting(componentFiles, 'component', {\n ...lintOptions,\n configPath: normalizedConfig.configEslint,\n });\n \n // Combine results from both linters\n const combinedResults = [...styleResults, ...componentResults];\n \n return combinedResults;\n } catch (error: any) {\n // Enhance error with context for better debugging\n const errorMessage = `Linting failed: ${error.message}`;\n Logger.error(errorMessage);\n throw new Error(errorMessage);\n }\n}\n\n/**\n * Generate a report from linting results\n * \n * @param config Report configuration options\n * @param results Optional lint results (if not provided, will run lint)\n * @returns A readable stream containing the report data\n * @throws Error if report generation fails\n */\nexport async function report(config: ReportConfig, results?: LintResult[]): Promise<Readable> {\n try {\n Logger.debug('Starting report generation with Node API');\n \n // Normalize configuration to ensure all required fields have values\n const normalizedConfig = normalizeCliOptions(config, {}, true);\n \n // Determine report format with default\n const format = normalizedConfig.format || 'sarif';\n \n // Get lint results either from provided results parameter or by running lint\n const lintResults = results || await lint({\n directory: normalizedConfig.directory,\n configStylelint: normalizedConfig.configStylelint,\n configEslint: normalizedConfig.configEslint,\n });\n \n // Process based on requested format\n switch (format) {\n case 'sarif':\n // Generate SARIF report as a stream\n return ReportGenerator.generateSarifReportStream(lintResults, {\n toolName: 'slds-linter',\n toolVersion: LINTER_CLI_VERSION\n });\n \n case 'csv':\n // Generate CSV data in memory and create a stream\n const csvString = CsvReportGenerator.generateCsvString(lintResults);\n const csvStream = new Readable();\n csvStream.push(csvString);\n csvStream.push(null); // End of stream\n return csvStream;\n \n default:\n // Throw error for unsupported formats\n const errorMessage = `Unsupported format: ${format}`;\n Logger.error(errorMessage);\n throw new Error(errorMessage);\n }\n } catch (error: any) {\n // Enhance error with context for better debugging\n const errorMessage = `Report generation failed: ${error.message}`;\n Logger.error(errorMessage);\n throw new Error(errorMessage);\n }\n}\n\nexport type { LintResult, LintResultEntry, LintConfig, ReportConfig, ExitCode, WorkerResult, SarifResultEntry } from '../types'; "],
5
- "mappings": ";AAAA,SAAS,gBAAgB;AACzB,SAAS,mBAAmB;AAC5B,SAAS,kBAA+B;AACxC,SAAS,mBAAmB,6BAA6B;AACzD,SAAS,iBAAiB,0BAA0B;AACpD,SAAoE,0BAA0B;AAE9F,SAAS,2BAA2B;AACpC,SAAS,cAAc;AASvB,eAAsB,KAAK,QAA2C;AACpE,MAAI;AACF,WAAO,MAAM,gCAAgC;AAG7C,UAAM,mBAAmB,oBAAoB,QAAQ,CAAC,GAAG,IAAI;AAG7D,UAAM,aAAa,MAAM,YAAY,UAAU,iBAAiB,WAAW;AAAA,MACzE,UAAU;AAAA,MACV,WAAW;AAAA,IACb,CAAC;AAGD,UAAM,iBAAiB,MAAM,YAAY,UAAU,iBAAiB,WAAW;AAAA,MAC7E,UAAU;A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