@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
@@ -1,187 +0,0 @@
1
- // src/services/report-generator.ts
2
- import path from "path";
3
- import fs, { writeFile } from "fs/promises";
4
- import { mkConfig, generateCsv, asString } from "export-to-csv";
5
- import { SarifBuilder, SarifRunBuilder, SarifResultBuilder, SarifRuleBuilder } from "node-sarif-builder";
6
- import { createWriteStream } from "fs";
7
- import { JsonStreamStringify } from "json-stream-stringify";
8
- import { getRuleDescription } from "./config.resolver.js";
9
- import { parseText, replaceNamespaceinRules, transformedResults } from "../utils/lintResultsUtil.js";
10
- import { processArtifacts } from "./artifact-processor.js";
11
- var ReportGenerator = class {
12
- /**
13
- * Generate SARIF report from lint results with file output
14
- */
15
- static async generateSarifReport(results, options) {
16
- if (!options.outputPath) {
17
- return;
18
- }
19
- const sarifReport = await this.buildSarifReport(results, options);
20
- for (const run of sarifReport.runs) {
21
- await processArtifacts(run.artifacts);
22
- }
23
- const outputDir = path.dirname(options.outputPath);
24
- await fs.mkdir(outputDir, { recursive: true });
25
- const writeStream = createWriteStream(options.outputPath);
26
- const jsonStream = new JsonStreamStringify(sarifReport, null, 2);
27
- await new Promise((resolve, reject) => {
28
- jsonStream.pipe(writeStream).on("finish", resolve).on("error", reject);
29
- });
30
- }
31
- /**
32
- * Generate SARIF report as a stream without creating a file
33
- */
34
- static async generateSarifReportStream(results, options) {
35
- const sarifReport = await this.buildSarifReport(results, options);
36
- return new JsonStreamStringify(sarifReport, null, 2);
37
- }
38
- /**
39
- * Build SARIF report data in memory
40
- */
41
- static async buildSarifReport(results, options) {
42
- const builder = new SarifBuilder();
43
- const runBuilder = new SarifRunBuilder({
44
- defaultSourceLanguage: "html"
45
- }).initSimple({
46
- toolDriverName: options.toolName,
47
- toolDriverVersion: options.toolVersion,
48
- url: "https://github.com/salesforce-ux/slds-linter"
49
- });
50
- runBuilder.run.properties = {
51
- id: Number(Math.random().toString(10).substring(2, 10)),
52
- version: options.toolVersion,
53
- submissionDate: (/* @__PURE__ */ new Date()).toISOString().split("T")[0],
54
- language: "html",
55
- status: "accepted",
56
- type: "source code"
57
- };
58
- runBuilder.run.tool.driver.organization = "Salesforce";
59
- const rules = this.extractRules(results);
60
- for (const rule of rules) {
61
- const ruleBuilder = new SarifRuleBuilder().initSimple({
62
- ruleId: replaceNamespaceinRules(rule.id),
63
- shortDescriptionText: rule.shortDescription?.text
64
- });
65
- runBuilder.addRule(ruleBuilder);
66
- }
67
- for (const result of results) {
68
- this.addResultsToSarif(runBuilder, result);
69
- }
70
- builder.addRun(runBuilder);
71
- return builder.buildSarifOutput();
72
- }
73
- /**
74
- * Extract unique rules from results
75
- */
76
- static extractRules(results) {
77
- const rules = /* @__PURE__ */ new Map();
78
- for (const result of results) {
79
- for (const error of result.errors) {
80
- if (!rules.has(error.ruleId)) {
81
- rules.set(error.ruleId, {
82
- id: replaceNamespaceinRules(error.ruleId),
83
- shortDescription: {
84
- text: getRuleDescription(replaceNamespaceinRules(error.ruleId))
85
- },
86
- properties: {
87
- category: "Style"
88
- }
89
- });
90
- }
91
- }
92
- for (const warning of result.warnings) {
93
- if (!rules.has(warning.ruleId)) {
94
- rules.set(warning.ruleId, {
95
- id: replaceNamespaceinRules(warning.ruleId),
96
- shortDescription: {
97
- text: getRuleDescription(replaceNamespaceinRules(warning.ruleId))
98
- },
99
- properties: {
100
- category: "Style"
101
- }
102
- });
103
- }
104
- }
105
- }
106
- return Array.from(rules.values());
107
- }
108
- /**
109
- * Add lint results to SARIF report
110
- */
111
- static addResultsToSarif(runBuilder, lintResult) {
112
- lintResult.errors.forEach((error) => {
113
- const resultBuilder = new SarifResultBuilder().initSimple(transformedResults(lintResult, error, "error"));
114
- runBuilder.addResult(resultBuilder);
115
- });
116
- lintResult.warnings.forEach((warning) => {
117
- const resultBuilder = new SarifResultBuilder().initSimple(transformedResults(lintResult, warning, "warning"));
118
- runBuilder.addResult(resultBuilder);
119
- });
120
- }
121
- };
122
- var CsvReportGenerator = class {
123
- /**
124
- * Generate CSV report and write to file
125
- */
126
- static async generate(results) {
127
- const csvString = this.generateCsvString(results);
128
- const csvReportPath = path.join(process.cwd(), "slds-linter-report.csv");
129
- await writeFile(csvReportPath, csvString);
130
- return csvReportPath;
131
- }
132
- /**
133
- * Generate CSV string from lint results
134
- */
135
- static generateCsvString(results) {
136
- const csvData = this.convertResultsToCsvData(results);
137
- return asString(csvData);
138
- }
139
- /**
140
- * Convert lint results to CSV-compatible data format
141
- */
142
- static convertResultsToCsvData(results) {
143
- const cwd = process.cwd();
144
- const csvConfig = mkConfig({
145
- fieldSeparator: ",",
146
- quoteStrings: true,
147
- decimalSeparator: ".",
148
- useTextFile: false,
149
- useBom: true,
150
- useKeysAsHeaders: true
151
- });
152
- const transformedResults2 = results.flatMap(
153
- (result) => [
154
- ...result.errors.map((error) => ({
155
- "File Path": path.relative(cwd, result.filePath),
156
- "Message": parseText(error.message),
157
- "Severity": "error",
158
- "Rule ID": replaceNamespaceinRules(error.ruleId || "N/A"),
159
- "Start Line": error.line,
160
- "Start Column": error.column,
161
- "End Line": error.endLine || error.line,
162
- // Default to start line if missing
163
- "End Column": error.endColumn || error.column
164
- // Default to start column if missing
165
- })),
166
- ...result.warnings.map((warning) => ({
167
- "File Path": path.relative(cwd, result.filePath),
168
- "Message": parseText(warning.message),
169
- "Severity": "warning",
170
- "Rule ID": replaceNamespaceinRules(warning.ruleId || "N/A"),
171
- "Start Line": warning.line,
172
- "Start Column": warning.column,
173
- "End Line": warning.endLine || warning.line,
174
- // Default to start line if missing
175
- "End Column": warning.endColumn || warning.column
176
- // Default to start column if missing
177
- }))
178
- ]
179
- );
180
- return generateCsv(csvConfig)(transformedResults2);
181
- }
182
- };
183
- export {
184
- CsvReportGenerator,
185
- ReportGenerator
186
- };
187
- //# sourceMappingURL=report-generator.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/services/report-generator.ts"],
4
- "sourcesContent": ["import path from 'path';\nimport fs, { writeFile } from 'fs/promises';\nimport { mkConfig, generateCsv, asString } from 'export-to-csv';\nimport { LintResult, LintResultEntry, SarifResultEntry } from '../types';\nimport { SarifBuilder, SarifRunBuilder, SarifResultBuilder, SarifRuleBuilder } from 'node-sarif-builder';\nimport { createWriteStream } from 'fs';\nimport { JsonStreamStringify } from 'json-stream-stringify';\nimport {getRuleDescription} from \"./config.resolver\";\nimport { parseText, replaceNamespaceinRules, transformedResults } from '../utils/lintResultsUtil';\nimport { Readable } from 'stream';\nimport { processArtifacts } from './artifact-processor';\n\n\nexport interface ReportOptions {\n outputPath?: string;\n toolName: string;\n toolVersion: string;\n}\n\nexport class ReportGenerator {\n /**\n * Generate SARIF report from lint results with file output\n */\n static async generateSarifReport(\n results: LintResult[],\n options: ReportOptions\n ): Promise<void> {\n // If no outputPath, we're just building the report in memory\n if (!options.outputPath) {\n return;\n }\n \n // Build SARIF report data\n const sarifReport = await this.buildSarifReport(results, options);\n \n // Process artifacts and add file content properties\n for (const run of sarifReport.runs) {\n await processArtifacts(run.artifacts);\n }\n \n // Ensure output directory exists\n const outputDir = path.dirname(options.outputPath);\n await fs.mkdir(outputDir, { recursive: true });\n\n // Use JsonStreamStringify to write large JSON efficiently\n const writeStream = createWriteStream(options.outputPath);\n const jsonStream = new JsonStreamStringify(sarifReport, null, 2); // pretty print with 2 spaces\n \n // Write the report\n await new Promise<void>((resolve, reject) => {\n jsonStream\n .pipe(writeStream)\n .on('finish', resolve)\n .on('error', reject);\n }); \n }\n \n /**\n * Generate SARIF report as a stream without creating a file\n */\n static async generateSarifReportStream(\n results: LintResult[],\n options: ReportOptions\n ): Promise<Readable> {\n // Create SARIF report\n const sarifReport = await this.buildSarifReport(results, options);\n \n // Return JsonStreamStringify as a readable stream\n return new JsonStreamStringify(sarifReport, null, 2);\n }\n\n /**\n * Build SARIF report data in memory\n */\n static async buildSarifReport(\n results: LintResult[],\n options: ReportOptions\n ): Promise<any> {\n const builder = new SarifBuilder();\n const runBuilder = new SarifRunBuilder({\n defaultSourceLanguage: 'html'\n }).initSimple({\n toolDriverName: options.toolName,\n toolDriverVersion: options.toolVersion,\n url: 'https://github.com/salesforce-ux/slds-linter'\n });\n\n // Add additional properties for better SARIF compatibility\n runBuilder.run.properties = {\n id: Number(Math.random().toString(10).substring(2, 10)),\n version: options.toolVersion,\n submissionDate: new Date().toISOString().split('T')[0],\n language: 'html',\n status: 'accepted',\n type: 'source code'\n };\n\n runBuilder.run.tool.driver.organization = \"Salesforce\";\n\n // Add rules\n const rules = this.extractRules(results);\n for (const rule of rules) {\n const ruleBuilder = new SarifRuleBuilder().initSimple({\n ruleId: replaceNamespaceinRules(rule.id),\n shortDescriptionText: rule.shortDescription?.text,\n });\n runBuilder.addRule(ruleBuilder);\n }\n\n // Add results\n for (const result of results) {\n this.addResultsToSarif(runBuilder, result);\n }\n\n // Add run to builder\n builder.addRun(runBuilder);\n\n // Return the report data\n return builder.buildSarifOutput();\n }\n\n /**\n * Extract unique rules from results\n */\n private static extractRules(results: LintResult[]): any[] {\n const rules = new Map();\n\n for (const result of results) {\n // Process errors\n for (const error of result.errors) {\n if (!rules.has(error.ruleId)) {\n \n rules.set(error.ruleId, {\n id: replaceNamespaceinRules(error.ruleId),\n shortDescription: {\n text: getRuleDescription(replaceNamespaceinRules(error.ruleId))\n },\n properties: {\n category: 'Style'\n }\n });\n }\n }\n\n // Process warnings\n for (const warning of result.warnings) {\n if (!rules.has(warning.ruleId)) { \n rules.set(warning.ruleId, {\n id: replaceNamespaceinRules(warning.ruleId),\n shortDescription: {\n text: getRuleDescription(replaceNamespaceinRules(warning.ruleId))\n },\n properties: {\n category: 'Style'\n }\n });\n }\n }\n }\n\n return Array.from(rules.values());\n }\n\n /**\n * Add lint results to SARIF report\n */\n private static addResultsToSarif(\n runBuilder: SarifRunBuilder,\n lintResult: LintResult\n ): void {\n lintResult.errors.forEach(error => {\n const resultBuilder = new SarifResultBuilder().initSimple(transformedResults(lintResult, error, 'error'));\n runBuilder.addResult(resultBuilder);\n });\n\n lintResult.warnings.forEach(warning => {\n const resultBuilder = new SarifResultBuilder().initSimple(transformedResults(lintResult, warning, 'warning'));\n runBuilder.addResult(resultBuilder);\n });\n }\n}\n\nexport class CsvReportGenerator {\n /**\n * Generate CSV report and write to file\n */\n static async generate(results: any[]): Promise<string> {\n // Generate CSV string using the shared method\n const csvString = this.generateCsvString(results);\n \n // Define the output path\n const csvReportPath = path.join(process.cwd(), 'slds-linter-report.csv');\n\n // Write to file\n await writeFile(csvReportPath, csvString);\n return csvReportPath;\n }\n \n /**\n * Generate CSV string from lint results\n */\n static generateCsvString(results: any[]): string {\n const csvData = this.convertResultsToCsvData(results);\n return asString(csvData);\n }\n \n /**\n * Convert lint results to CSV-compatible data format\n */\n private static convertResultsToCsvData(results: any[]): any {\n const cwd = process.cwd();\n \n // Create CSV config inline instead of using a separate method\n const csvConfig = mkConfig({\n fieldSeparator: ',',\n quoteStrings: true,\n decimalSeparator: '.',\n useTextFile: false,\n useBom: true,\n useKeysAsHeaders: true,\n });\n\n const transformedResults = results.flatMap((result: { errors: any[]; filePath: string; warnings: any[]; }) =>\n [\n ...result.errors.map((error: { message: any; ruleId: any; line: any; column: any; endLine: any; endColumn: any; }) => ({\n \"File Path\": path.relative(cwd, result.filePath),\n \"Message\": parseText(error.message),\n \"Severity\": 'error',\n \"Rule ID\": replaceNamespaceinRules(error.ruleId || 'N/A'),\n \"Start Line\": error.line,\n \"Start Column\": error.column,\n \"End Line\": error.endLine || error.line, // Default to start line if missing\n \"End Column\": error.endColumn || error.column // Default to start column if missing\n })),\n ...result.warnings.map((warning: { message: any; ruleId: any; line: any; column: any; endLine: any; endColumn: any; }) => ({\n \"File Path\": path.relative(cwd, result.filePath),\n \"Message\": parseText(warning.message),\n \"Severity\": 'warning',\n \"Rule ID\": replaceNamespaceinRules(warning.ruleId || 'N/A'),\n \"Start Line\": warning.line,\n \"Start Column\": warning.column,\n \"End Line\": warning.endLine || warning.line, // Default to start line if missing\n \"End Column\": warning.endColumn || warning.column // Default to start column if missing\n }))\n ]\n );\n\n return generateCsv(csvConfig)(transformedResults);\n }\n}"],
5
- "mappings": ";AAAA,OAAO,UAAU;AACjB,OAAO,MAAM,iBAAiB;AAC9B,SAAS,UAAU,aAAa,gBAAgB;AAEhD,SAAS,cAAc,iBAAiB,oBAAoB,wBAAwB;AACpF,SAAS,yBAAyB;AAClC,SAAS,2BAA2B;AACpC,SAAQ,0BAAyB;AACjC,SAAS,WAAW,yBAAyB,0BAA0B;AAEvE,SAAS,wBAAwB;AAS1B,IAAM,kBAAN,MAAsB;AAAA;AAAA;AAAA;AAAA,EAI3B,aAAa,oBACX,SACA,SACe;AAEb,QAAI,CAAC,QAAQ,YAAY;AACvB;AAAA,IACF;AAG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;AAAA;AAAA,UACnC,cAAc,MAAM,aAAa,MAAM;AAAA;AAAA,QACzC,EAAE;AAAA,QACF,GAAG,OAAO,SAAS,IAAI,CAAC,aAAmG;AAAA,UACzH,aAAa,KAAK,SAAS,KAAK,OAAO,QAAQ;AAAA,UAC/C,WAAW,UAAU,QAAQ,OAAO;AAAA,UACpC,YAAY;AAAA,UACZ,WAAW,wBAAwB,QAAQ,UAAU,KAAK;AAAA,UAC1D,cAAc,QAAQ;AAAA,UACtB,gBAAgB,QAAQ;AAAA,UACxB,YAAY,QAAQ,WAAW,QAAQ;AAAA;AAAA,UACvC,cAAc,QAAQ,aAAa,QAAQ;AAAA;AAAA,QAC7C,EAAE;AAAA,MACJ;AAAA,IACF;AAEA,WAAO,YAAY,SAAS,EAAEA,mBAAkB;AAAA,EAClD;AACF;",
6
- "names": ["transformedResults"]
7
- }
@@ -1,75 +0,0 @@
1
- export interface BaseConfig {
2
- directory?: string;
3
- files?: string[];
4
- configStylelint?: string;
5
- configEslint?: string;
6
- }
7
- /**
8
- * CLI options interface extends BaseConfig for shared properties
9
- */
10
- export interface CliOptions extends BaseConfig {
11
- output?: string;
12
- fix?: boolean;
13
- editor?: string;
14
- format?: string;
15
- }
16
- /**
17
- * Configuration for linting operation in the Node API
18
- * Extends the common base configuration
19
- */
20
- export interface LintConfig extends BaseConfig {
21
- fix?: boolean;
22
- }
23
- /**
24
- * Configuration for report generation in the Node API
25
- * Extends the common base configuration
26
- */
27
- export interface ReportConfig extends BaseConfig {
28
- format?: 'sarif' | 'csv';
29
- }
30
- export interface LintResultEntry {
31
- line: number;
32
- column: number;
33
- endColumn: number;
34
- message: string;
35
- ruleId: string;
36
- severity: number;
37
- }
38
- export interface LintResult {
39
- filePath: string;
40
- errors: Array<LintResultEntry>;
41
- warnings: Array<LintResultEntry>;
42
- }
43
- export type ExitCode = 0 | 1 | 2;
44
- export interface WorkerConfig {
45
- configPath?: string;
46
- fix?: boolean;
47
- }
48
- export interface WorkerResult {
49
- file: string;
50
- error?: string;
51
- warnings?: Array<{
52
- line: number;
53
- column: number;
54
- endColumn: number;
55
- message: string;
56
- ruleId: string;
57
- }>;
58
- errors?: Array<{
59
- line: number;
60
- column: number;
61
- endColumn: number;
62
- message: string;
63
- ruleId: string;
64
- }>;
65
- }
66
- export interface SarifResultEntry {
67
- level: any;
68
- messageText: string;
69
- ruleId: string;
70
- fileUri?: string;
71
- startLine?: number;
72
- startColumn?: number;
73
- endLine?: number;
74
- endColumn?: number;
75
- }
@@ -1 +0,0 @@
1
- //# sourceMappingURL=index.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": [],
4
- "sourcesContent": [],
5
- "mappings": "",
6
- "names": []
7
- }
@@ -1,33 +0,0 @@
1
- import { LintConfig, ReportConfig, CliOptions } from '../types';
2
- /**
3
- * Normalize and validate a file path
4
- * This function ensures that the provided path exists and is accessible
5
- * If no path is provided, it defaults to the current working directory
6
- *
7
- * @param inputPath Input file path or undefined
8
- * @returns Normalized and validated absolute path
9
- * @throws Error if the path is invalid or inaccessible
10
- */
11
- export declare function normalizeAndValidatePath(inputPath?: string): string;
12
- /**
13
- * Normalize directory path with special handling for glob patterns
14
- * This function preserves glob patterns and resolves regular paths to absolute paths
15
- * If no directory is provided, it defaults to the current working directory
16
- *
17
- * @param directory Input directory or glob pattern or undefined
18
- * @returns Normalized directory path
19
- */
20
- export declare function normalizeDirectoryPath(directory?: string): string;
21
- /**
22
- * Normalize configuration with appropriate defaults
23
- * This function ensures all required options have valid values
24
- * It applies provided defaults, then user-provided options, then normalizes paths
25
- * Used by both CLI commands and Node API functions
26
- *
27
- * @param options Options to normalize
28
- * @param defaultOptions Default options to apply
29
- * @param isNodeApi Whether this is being called from the Node API
30
- * @returns Normalized options with appropriate defaults
31
- */
32
- export declare function normalizeCliOptions<T extends CliOptions | LintConfig | ReportConfig>(options: T, defaultOptions?: Partial<T>, isNodeApi?: boolean): T;
33
- export declare const normalizeConfig: typeof normalizeCliOptions;
@@ -1,69 +0,0 @@
1
- // src/utils/config-utils.ts
2
- import path from "path";
3
- import { DEFAULT_ESLINT_CONFIG_PATH, DEFAULT_STYLELINT_CONFIG_PATH } from "../services/config.resolver.js";
4
- import { isDynamicPattern } from "globby";
5
- import { accessSync } from "fs";
6
- import { Logger } from "./logger.js";
7
- function normalizeAndValidatePath(inputPath) {
8
- if (!inputPath) {
9
- Logger.debug("No path provided, using current working directory");
10
- return process.cwd();
11
- }
12
- const normalizedPath = path.resolve(inputPath);
13
- Logger.debug(`Normalized path: ${normalizedPath}`);
14
- try {
15
- accessSync(normalizedPath);
16
- return normalizedPath;
17
- } catch (error) {
18
- const errorMessage = `Invalid path: ${inputPath}`;
19
- Logger.error(errorMessage);
20
- throw new Error(errorMessage);
21
- }
22
- }
23
- function normalizeDirectoryPath(directory) {
24
- if (!directory) {
25
- Logger.debug("No directory provided, using current working directory");
26
- return process.cwd();
27
- }
28
- if (isDynamicPattern(directory)) {
29
- Logger.debug(`Detected glob pattern: ${directory}`);
30
- return directory;
31
- }
32
- Logger.debug(`Normalizing directory path: ${directory}`);
33
- return path.resolve(directory);
34
- }
35
- function normalizeCliOptions(options, defaultOptions = {}, isNodeApi = false) {
36
- const baseDefaults = {
37
- files: [],
38
- configStylelint: isNodeApi ? DEFAULT_STYLELINT_CONFIG_PATH : "",
39
- configEslint: isNodeApi ? DEFAULT_ESLINT_CONFIG_PATH : ""
40
- };
41
- if (!isNodeApi) {
42
- Object.assign(baseDefaults, {
43
- fix: false,
44
- editor: "vscode",
45
- format: "sarif"
46
- });
47
- }
48
- const normalizedOptions = {
49
- ...baseDefaults,
50
- ...defaultOptions,
51
- ...options,
52
- directory: normalizeDirectoryPath(options.directory)
53
- };
54
- if (!isNodeApi) {
55
- normalizedOptions.output = options.output ? normalizeAndValidatePath(options.output) : process.cwd();
56
- }
57
- if ("format" in options && !options.format && isNodeApi) {
58
- normalizedOptions.format = "sarif";
59
- }
60
- return normalizedOptions;
61
- }
62
- var normalizeConfig = normalizeCliOptions;
63
- export {
64
- normalizeAndValidatePath,
65
- normalizeCliOptions,
66
- normalizeConfig,
67
- normalizeDirectoryPath
68
- };
69
- //# sourceMappingURL=config-utils.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/utils/config-utils.ts"],
4
- "sourcesContent": ["/**\n * Config utilities for SLDS Linter\n * \n * Note: This file replaces the earlier cli-args.ts and consolidates configuration \n * handling for both CLI and Node API into a single place\n */\nimport path from 'path';\nimport { LintConfig, ReportConfig, CliOptions } from '../types';\nimport { DEFAULT_ESLINT_CONFIG_PATH, DEFAULT_STYLELINT_CONFIG_PATH } from '../services/config.resolver';\nimport { isDynamicPattern } from 'globby';\nimport { accessSync } from 'fs';\nimport { Logger } from './logger';\n\n/**\n * Normalize and validate a file path\n * This function ensures that the provided path exists and is accessible\n * If no path is provided, it defaults to the current working directory\n * \n * @param inputPath Input file path or undefined\n * @returns Normalized and validated absolute path\n * @throws Error if the path is invalid or inaccessible\n */\nexport function normalizeAndValidatePath(inputPath?: string): string {\n // Default to current working directory if no path provided\n if (!inputPath) {\n Logger.debug('No path provided, using current working directory');\n return process.cwd();\n }\n\n // Resolve to absolute path\n const normalizedPath = path.resolve(inputPath);\n Logger.debug(`Normalized path: ${normalizedPath}`);\n\n try {\n // Check if path exists and is accessible\n accessSync(normalizedPath);\n return normalizedPath;\n } catch (error) {\n // Throw descriptive error if path is invalid\n const errorMessage = `Invalid path: ${inputPath}`;\n Logger.error(errorMessage);\n throw new Error(errorMessage);\n }\n}\n\n/**\n * Normalize directory path with special handling for glob patterns\n * This function preserves glob patterns and resolves regular paths to absolute paths\n * If no directory is provided, it defaults to the current working directory\n * \n * @param directory Input directory or glob pattern or undefined\n * @returns Normalized directory path\n */\nexport function normalizeDirectoryPath(directory?: string): string {\n // Default to current working directory if no directory provided\n if (!directory) {\n Logger.debug('No directory provided, using current working directory');\n return process.cwd();\n }\n \n // If it's a glob pattern, return as-is to preserve pattern matching\n if (isDynamicPattern(directory)) {\n Logger.debug(`Detected glob pattern: ${directory}`);\n return directory;\n }\n \n // For regular directories, resolve to absolute path\n Logger.debug(`Normalizing directory path: ${directory}`);\n return path.resolve(directory);\n}\n\n/**\n * Normalize configuration with appropriate defaults\n * This function ensures all required options have valid values\n * It applies provided defaults, then user-provided options, then normalizes paths\n * Used by both CLI commands and Node API functions\n * \n * @param options Options to normalize\n * @param defaultOptions Default options to apply\n * @param isNodeApi Whether this is being called from the Node API\n * @returns Normalized options with appropriate defaults\n */\nexport function normalizeCliOptions<T extends CliOptions | LintConfig | ReportConfig>(\n options: T,\n defaultOptions: Partial<T> = {},\n isNodeApi = false\n): T {\n // Set up defaults based on context\n const baseDefaults: Partial<CliOptions> = {\n files: [],\n configStylelint: isNodeApi ? DEFAULT_STYLELINT_CONFIG_PATH : \"\",\n configEslint: isNodeApi ? DEFAULT_ESLINT_CONFIG_PATH : \"\",\n };\n \n // Add CLI-specific defaults\n if (!isNodeApi) {\n Object.assign(baseDefaults, {\n fix: false,\n editor: \"vscode\",\n format: \"sarif\",\n });\n }\n \n // Create normalized options with proper precedence\n const normalizedOptions = {\n ...baseDefaults,\n ...defaultOptions,\n ...options,\n directory: normalizeDirectoryPath(options.directory),\n };\n \n // Handle output path for CLI options\n if (!isNodeApi) {\n (normalizedOptions as any).output = (options as any).output \n ? normalizeAndValidatePath((options as any).output)\n : process.cwd();\n }\n \n // Handle ReportConfig specific fields\n if ('format' in options && !options.format && isNodeApi) {\n (normalizedOptions as any).format = 'sarif';\n }\n \n return normalizedOptions as T;\n}\n\n// For backward compatibility with imports, but deprecate in future versions\nexport const normalizeConfig = normalizeCliOptions; "],
5
- "mappings": ";AAMA,OAAO,UAAU;AAEjB,SAAS,4BAA4B,qCAAqC;AAC1E,SAAS,wBAAwB;AACjC,SAAS,kBAAkB;AAC3B,SAAS,cAAc;AAWhB,SAAS,yBAAyB,WAA4B;AAEnE,MAAI,CAAC,WAAW;AACd,WAAO,MAAM,mDAAmD;AAChE,WAAO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AkB;",
6
- "names": []
7
- }
@@ -1,21 +0,0 @@
1
- /**
2
- * Returns an editor-specific link for opening a file at a given line and column.
3
- *
4
- * @param editor - The editor to use (e.g., 'vscode', 'atom', 'sublime').
5
- * @param absolutePath - The absolute path to the file.
6
- * @param line - The line number in the file.
7
- * @param column - The column number in the file.
8
- * @returns A URL string that can be used to open the file in the specified editor.
9
- */
10
- export declare function getEditorLink(editor: string, absolutePath: string, line: number, column: number): string;
11
- /**
12
- * Creates an ANSI hyperlink (if supported) for the line:column text.
13
- *
14
- * @param lineCol - The line:column string (e.g., "10:5").
15
- * @param absolutePath - The absolute path to the file.
16
- * @param line - The line number in the file.
17
- * @param column - The column number in the file.
18
- * @param editor - The editor to use (e.g., 'vscode', 'atom', 'sublime').
19
- * @returns A string with ANSI escape sequences to create a clickable hyperlink.
20
- */
21
- export declare function createClickableLineCol(lineCol: string, absolutePath: string, line: number, column: number, editor: string): string;
@@ -1,22 +0,0 @@
1
- // src/utils/editorLinkUtil.ts
2
- import chalk from "chalk";
3
- function getEditorLink(editor, absolutePath, line, column) {
4
- if (editor === "vscode") {
5
- return `vscode://file/${absolutePath}:${line}:${column}`;
6
- } else if (editor === "atom") {
7
- return `atom://core/open/file?filename=${absolutePath}&line=${line}&column=${column}`;
8
- } else if (editor === "sublime") {
9
- return `file://${absolutePath}:${line}:${column}`;
10
- } else {
11
- return `file://${absolutePath}:${line}:${column}`;
12
- }
13
- }
14
- function createClickableLineCol(lineCol, absolutePath, line, column, editor) {
15
- const link = getEditorLink(editor, absolutePath, line, column);
16
- return `\x1B]8;;${link}\x07${chalk.blueBright(lineCol)}\x1B]8;;\x07`;
17
- }
18
- export {
19
- createClickableLineCol,
20
- getEditorLink
21
- };
22
- //# sourceMappingURL=editorLinkUtil.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/utils/editorLinkUtil.ts"],
4
- "sourcesContent": ["// src/utils/editorLinkUtil.ts\n\nimport chalk from 'chalk';\n\n/**\n * Returns an editor-specific link for opening a file at a given line and column.\n *\n * @param editor - The editor to use (e.g., 'vscode', 'atom', 'sublime').\n * @param absolutePath - The absolute path to the file.\n * @param line - The line number in the file.\n * @param column - The column number in the file.\n * @returns A URL string that can be used to open the file in the specified editor.\n */\nexport function getEditorLink(\n editor: string,\n absolutePath: string,\n line: number,\n column: number\n): string {\n if (editor === 'vscode') {\n return `vscode://file/${absolutePath}:${line}:${column}`;\n } else if (editor === 'atom') {\n return `atom://core/open/file?filename=${absolutePath}&line=${line}&column=${column}`;\n } else if (editor === 'sublime') {\n // Sublime Text does not have a standard URL scheme.\n return `file://${absolutePath}:${line}:${column}`;\n } else {\n // Fallback to a standard file URL.\n return `file://${absolutePath}:${line}:${column}`;\n }\n}\n\n/**\n * Creates an ANSI hyperlink (if supported) for the line:column text.\n *\n * @param lineCol - The line:column string (e.g., \"10:5\").\n * @param absolutePath - The absolute path to the file.\n * @param line - The line number in the file.\n * @param column - The column number in the file.\n * @param editor - The editor to use (e.g., 'vscode', 'atom', 'sublime').\n * @returns A string with ANSI escape sequences to create a clickable hyperlink.\n */\nexport function createClickableLineCol(\n lineCol: string,\n absolutePath: string,\n line: number,\n column: number,\n editor: string\n): string {\n const link = getEditorLink(editor, absolutePath, line, column);\n return `\\u001b]8;;${link}\\u0007${chalk.blueBright(lineCol)}\\u001b]8;;\\u0007`;\n}\n"],
5
- "mappings": ";AAEA,OAAO,WAAW;AAWX,SAAS,cACd,QACA,cACA,MACA,QACQ;AACR,MAAI,WAAW,UAAU;AACvB,WAAO,iBAAiB,YAAY,IAAI,IAAI,IAAI,MAAM;AAAA,EACxD,WAAW,WAAW,QAAQ;AAC5B,WAAO,kCAAkC,YAAY,SAAS,IAAI,WAAW,MAAM;AAAA,EACrF,WAAW,WAAW,WAAW;AAE/B,WAAO,UAAU,YAAY,IAAI,IAAI,IAAI,MAAM;AAAA,EACjD,OAAO;AAEL,WAAO,UAAU,YAAY,IAAI,IAAI,IAAI,MAAM;AAAA,EACjD;AACF;AAYO,SAAS,uBACd,SACA,cACA,MACA,QACA,QACQ;AACR,QAAM,OAAO,cAAc,QAAQ,cAAc,MAAM,MAAM;AAC7D,SAAO,WAAa,IAAI,OAAS,MAAM,WAAW,OAAO,CAAC;AAC5D;",
6
- "names": []
7
- }
@@ -1,21 +0,0 @@
1
- import { LintResult, LintResultEntry, SarifResultEntry } from '../types';
2
- /**
3
- *
4
- * @param id - Rule id
5
- * @returns updated Rule id without the namespace @salesforce-ux
6
- */
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;
14
- /**
15
- * Prints detailed lint results for each file that has issues.
16
- *
17
- * @param results - Array of lint results.
18
- * @param editor - The chosen editor for clickable links (e.g., "vscode", "atom", "sublime").
19
- */
20
- export declare function printLintResults(results: LintResult[], editor: string): void;
21
- export declare function transformedResults(lintResult: LintResult, entry: LintResultEntry, level: 'error' | 'warning'): SarifResultEntry;
@@ -1,71 +0,0 @@
1
- // src/utils/lintResultsUtil.ts
2
- import chalk from "chalk";
3
- import path from "path";
4
- import { createClickableLineCol } from "./editorLinkUtil.js";
5
- import { Logger } from "../utils/logger.js";
6
- function replaceNamespaceinRules(id) {
7
- return id.includes("@salesforce-ux/") ? id.replace("@salesforce-ux/", "") : id;
8
- }
9
- function parseText(text) {
10
- let safeText = text;
11
- try {
12
- const parsed = JSON.parse(text);
13
- safeText = parsed.message || JSON.stringify(parsed);
14
- } catch (error) {
15
- safeText = text;
16
- }
17
- return safeText.endsWith(".") ? safeText : `${safeText}.`;
18
- }
19
- function printLintResults(results, editor) {
20
- results.forEach((result) => {
21
- const hasErrors = result.errors && result.errors.length > 0;
22
- const hasWarnings = result.warnings && result.warnings.length > 0;
23
- if (!hasErrors && !hasWarnings) return;
24
- const absolutePath = result.filePath || "";
25
- const relativeFile = path.relative(process.cwd(), absolutePath) || "Unknown file";
26
- Logger.newLine().info(`${chalk.bold(relativeFile)}`);
27
- if (hasErrors) {
28
- result.errors.forEach((error) => {
29
- if (error.line && error.column && absolutePath) {
30
- const lineCol = `${error.line}:${error.column}`;
31
- const clickable = createClickableLineCol(lineCol, absolutePath, error.line, error.column, editor);
32
- const ruleId = error.ruleId ? chalk.dim(replaceNamespaceinRules(error.ruleId)) : "";
33
- Logger.error(` ${clickable} ${parseText(error.message)} ${ruleId}`);
34
- } else {
35
- Logger.error(` ${chalk.red("Error:")} ${parseText(error.message)}`);
36
- }
37
- });
38
- }
39
- if (hasWarnings) {
40
- result.warnings.forEach((warn) => {
41
- if (warn.line && warn.column && absolutePath) {
42
- const lineCol = `${warn.line}:${warn.column}`;
43
- const clickable = createClickableLineCol(lineCol, absolutePath, warn.line, warn.column, editor);
44
- const ruleId = warn.ruleId ? chalk.dim(replaceNamespaceinRules(warn.ruleId)) : "";
45
- Logger.warning(` ${clickable} ${parseText(warn.message)} ${ruleId}`);
46
- } else {
47
- Logger.warning(` ${chalk.yellow("Warning:")} ${parseText(warn.message)}`);
48
- }
49
- });
50
- }
51
- });
52
- }
53
- function transformedResults(lintResult, entry, level) {
54
- return {
55
- ruleId: replaceNamespaceinRules(entry.ruleId),
56
- level,
57
- messageText: parseText(entry.message),
58
- fileUri: path.relative(process.cwd(), lintResult.filePath),
59
- startLine: entry.line,
60
- startColumn: entry.column,
61
- endLine: entry.line,
62
- endColumn: entry.endColumn
63
- };
64
- }
65
- export {
66
- parseText,
67
- printLintResults,
68
- replaceNamespaceinRules,
69
- transformedResults
70
- };
71
- //# sourceMappingURL=lintResultsUtil.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/utils/lintResultsUtil.ts"],
4
- "sourcesContent": ["// src/utils/lintResultsUtil.ts\n\nimport chalk from 'chalk';\nimport path from 'path';\nimport { createClickableLineCol } from './editorLinkUtil';\nimport { Logger } from '../utils/logger';\nimport { LintResult, LintResultEntry, SarifResultEntry } from '../types';\n\n/**\n * \n * @param id - Rule id\n * @returns updated Rule id without the namespace @salesforce-ux\n */\nexport function replaceNamespaceinRules(id: string) {\n return id.includes(\"@salesforce-ux/\")\n ? id.replace(\"@salesforce-ux/\", \"\")\n : id;\n}\n/**\n * \n * @param text - The input text that could either be a plain string or a stringified JSON object.\n * @returns The parsed message or the original string if parsing fails.\n */\nexport function parseText(text: string): string {\n let safeText = text;\n try {\n // Try to parse the text as JSON\n const parsed = JSON.parse(text);\n // If successful, return the message property or the whole object if no message\n safeText = parsed.message || JSON.stringify(parsed);\n } catch (error) {\n // If JSON parsing fails, return the original string\n safeText = text;\n }\n return safeText.endsWith('.') ? safeText : `${safeText}.`;\n}\n\n/**\n * Prints detailed lint results for each file that has issues.\n *\n * @param results - Array of lint results.\n * @param editor - The chosen editor for clickable links (e.g., \"vscode\", \"atom\", \"sublime\").\n */\nexport function printLintResults(results: LintResult[], editor: string): void {\n results.forEach(result => {\n const hasErrors = result.errors && result.errors.length > 0;\n const hasWarnings = result.warnings && result.warnings.length > 0;\n if (!hasErrors && !hasWarnings) return;\n\n const absolutePath = result.filePath || '';\n const relativeFile = path.relative(process.cwd(), absolutePath) || 'Unknown file';\n // Print file name with a preceding new line for spacing.\n Logger.newLine().info(`${chalk.bold(relativeFile)}`);\n\n if (hasErrors) {\n result.errors.forEach((error: any) => {\n if (error.line && error.column && absolutePath) {\n const lineCol = `${error.line}:${error.column}`;\n const clickable = createClickableLineCol(lineCol, absolutePath, error.line, error.column, editor);\n const ruleId = error.ruleId ? chalk.dim(replaceNamespaceinRules(error.ruleId)) : '';\n Logger.error(` ${clickable} ${parseText(error.message)} ${ruleId}`);\n } else {\n Logger.error(` ${chalk.red('Error:')} ${parseText(error.message)}`);\n }\n });\n }\n\n if (hasWarnings) {\n result.warnings.forEach((warn: any) => {\n if (warn.line && warn.column && absolutePath) {\n const lineCol = `${warn.line}:${warn.column}`;\n const clickable = createClickableLineCol(lineCol, absolutePath, warn.line, warn.column, editor);\n const ruleId = warn.ruleId ? chalk.dim(replaceNamespaceinRules(warn.ruleId)) : '';\n Logger.warning(` ${clickable} ${parseText(warn.message)} ${ruleId}`);\n } else {\n Logger.warning(` ${chalk.yellow('Warning:')} ${parseText(warn.message)}`);\n }\n });\n }\n });\n}\n\nexport function transformedResults(lintResult: LintResult, entry: LintResultEntry, level: 'error' | 'warning'): SarifResultEntry {\n return {\n ruleId: replaceNamespaceinRules(entry.ruleId),\n level,\n messageText: parseText(entry.message),\n fileUri: path.relative(process.cwd(), lintResult.filePath),\n startLine: entry.line,\n startColumn: entry.column,\n endLine: entry.line,\n endColumn: entry.endColumn\n }\n}"],
5
- "mappings": ";AAEA,OAAO,WAAW;AAClB,OAAO,UAAU;AACjB,SAAS,8BAA8B;AACvC,SAAS,cAAc;AAQhB,SAAS,wBAAwB,IAAY;AAClD,SAAO,GAAG,SAAS,iBAAiB,IAChC,GAAG,QAAQ,mBAAmB,EAAE,IAChC;AACN;AAMO,SAAS,UAAU,MAAsB;AAC9C,MAAI,WAAW;AACf,MAAI;AAEF,UAAM,SAAS,KAAK,MAAM,IAAI;AAE9B,eAAW,OAAO,WAAW,KAAK,UAAU,MAAM;AAAA,EACpD,SAAS,OAAO;AAEd,eAAW;AAAA,EACb;AACA,SAAO,SAAS,SAAS,GAAG,IAAI,WAAW,GAAG,QAAQ;AACxD;AAQO,SAAS,iBAAiB,SAAuB,QAAsB;AAC5E,UAAQ,QAAQ,YAAU;AACxB,UAAM,YAAY,OAAO,UAAU,OAAO,OAAO,SAAS;AAC1D,UAAM,cAAc,OAAO,YAAY,OAAO,SAAS,SAAS;AAChE,QAAI,CAAC,aAAa,CAAC,YAAa;AAEhC,UAAM,eAAe,OAAO,YAAY;AACxC,UAAM,eAAe,KAAK,SAAS,QAAQ,IAAI,GAAG,YAAY,KAAK;AAEnE,WAAO,QAAQ,EAAE,KAAK,GAAG,MAAM,KAAK,YAAY,CAAC,EAAE;AAEnD,QAAI,WAAW;AACb,aAAO,OAAO,QAAQ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QAAQ;AAAA,IACzD,WAAW,MAAM;AAAA,IACjB,aAAa,MAAM;AAAA,IACnB,SAAS,MAAM;AAAA,IACf,WAAW,MAAM;AAAA,EACnB;AACF;",
6
- "names": []
7
- }
@@ -1,8 +0,0 @@
1
- export declare class Logger {
2
- static newLine(): typeof Logger;
3
- static info(message: string): void;
4
- static success(message: string): void;
5
- static warning(message: string): void;
6
- static error(message: string): void;
7
- static debug(message: string): void;
8
- }
@@ -1,29 +0,0 @@
1
- // src/utils/logger.ts
2
- import chalk from "chalk";
3
- var Logger = class {
4
- static newLine() {
5
- console.log("\n");
6
- return this;
7
- }
8
- static info(message) {
9
- console.log(chalk.blue("\u2139"), message);
10
- }
11
- static success(message) {
12
- console.log(chalk.green("\u2713"), message);
13
- }
14
- static warning(message) {
15
- console.warn(chalk.yellow("\u26A0"), message);
16
- }
17
- static error(message) {
18
- console.error(chalk.red("\u2716"), message);
19
- }
20
- static debug(message) {
21
- if (process.env.DEBUG) {
22
- console.debug(chalk.gray("\u{1F50D}"), message);
23
- }
24
- }
25
- };
26
- export {
27
- Logger
28
- };
29
- //# sourceMappingURL=logger.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/utils/logger.ts"],
4
- "sourcesContent": ["import chalk from 'chalk';\n\nexport class Logger {\n static newLine(){\n console.log('\\n');\n return this;\n }\n static info(message: string): void {\n console.log(chalk.blue('\u2139'), message);\n }\n\n static success(message: string): void {\n console.log(chalk.green('\u2713'), message);\n }\n\n static warning(message: string): void {\n console.warn(chalk.yellow('\u26A0'), message);\n }\n\n static error(message: string): void {\n console.error(chalk.red('\u2716'), message);\n }\n\n static debug(message: string): void {\n if (process.env.DEBUG) {\n console.debug(chalk.gray('\uD83D\uDD0D'), message);\n }\n }\n} "],
5
- "mappings": ";AAAA,OAAO,WAAW;AAEX,IAAM,SAAN,MAAa;AAAA,EAClB,OAAO,UAAS;AACd,YAAQ,IAAI,IAAI;AAChB,WAAO;AAAA,EACT;AAAA,EACA,OAAO,KAAK,SAAuB;AACjC,YAAQ,IAAI,MAAM,KAAK,QAAG,GAAG,OAAO;AAAA,EACtC;AAAA,EAEA,OAAO,QAAQ,SAAuB;AACpC,YAAQ,IAAI,MAAM,MAAM,QAAG,GAAG,OAAO;AAAA,EACvC;AAAA,EAEA,OAAO,QAAQ,SAAuB;AACpC,YAAQ,KAAK,MAAM,OAAO,QAAG,GAAG,OAAO;AAAA,EACzC;AAAA,EAEA,OAAO,MAAM,SAAuB;AAClC,YAAQ,MAAM,MAAM,IAAI,QAAG,GAAG,OAAO;AAAA,EACvC;AAAA,EAEA,OAAO,MAAM,SAAuB;AAClC,QAAI,QAAQ,IAAI,OAAO;AACrB,cAAQ,MAAM,MAAM,KAAK,WAAI,GAAG,OAAO;AAAA,IACzC;AAAA,EACF;AACF;",
6
- "names": []
7
- }