@salesforce-ux/slds-linter 0.2.0-alpha.3 → 0.2.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -8
- package/build/executor/__tests__/executor.test.js.map +1 -1
- package/build/executor/index.d.ts +2 -2
- package/build/executor/index.js.map +1 -1
- package/build/index.d.ts +1 -2
- package/build/index.js +0 -2
- package/build/index.js.map +2 -2
- package/build/types/index.d.ts +0 -1
- package/build/workers/eslint.worker.js +2 -3
- package/build/workers/eslint.worker.js.map +2 -2
- package/build/workers/stylelint.worker.js +1 -2
- package/build/workers/stylelint.worker.js.map +2 -2
- package/package.json +4 -8
- package/build/utils/lintMessageUtils.d.ts +0 -4
- package/build/utils/lintMessageUtils.js +0 -15
- package/build/utils/lintMessageUtils.js.map +0 -7
package/README.md
CHANGED
|
@@ -215,14 +215,14 @@ reportStream.on('end', () => {
|
|
|
215
215
|
The Node.js API includes comprehensive TypeScript type definitions. You can import both the API functions and their associated types:
|
|
216
216
|
|
|
217
217
|
```typescript
|
|
218
|
-
// Import from the
|
|
219
|
-
import {
|
|
220
|
-
lint,
|
|
221
|
-
report,
|
|
222
|
-
LintConfig,
|
|
223
|
-
ReportConfig,
|
|
224
|
-
LintResult
|
|
225
|
-
} from '@salesforce-ux/slds-linter';
|
|
218
|
+
// Import from the executor entrypoint
|
|
219
|
+
import {
|
|
220
|
+
lint,
|
|
221
|
+
report,
|
|
222
|
+
type LintConfig,
|
|
223
|
+
type ReportConfig,
|
|
224
|
+
type LintResult
|
|
225
|
+
} from '@salesforce-ux/slds-linter/executor';
|
|
226
226
|
|
|
227
227
|
// Define configuration with typed interface
|
|
228
228
|
const config: LintConfig = {
|
|
@@ -234,6 +234,8 @@ const config: LintConfig = {
|
|
|
234
234
|
const results: LintResult[] = await lint(config);
|
|
235
235
|
```
|
|
236
236
|
|
|
237
|
+
All relevant types (such as `LintConfig`, `ReportConfig`, `LintResult`, etc.) are exported from the executor entrypoint for use in your TypeScript projects.
|
|
238
|
+
|
|
237
239
|
### API Reference
|
|
238
240
|
|
|
239
241
|
The Node.js API provides the following methods:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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
|
|
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
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;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;AAAA,MACV,WAAW;AAAA,IACb,CAAC;AAGD,UAAM,cAA2B;AAAA,MAC/B,KAAK,iBAAiB;AAAA,MACtB,YAAY,iBAAiB;AAAA,IAC/B;AAGA,UAAM,eAAe,MAAM,WAAW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AO,CAAC,aAAa,iBAAiB;AAAA,MACxC;AAEA,YAAMF,MAAK,MAAM;AAGjB,aAAOG,aAAY,SAAS,EAAE,IAAI,iBAAiB;AAGnD,aAAOD,YAAW,UAAU,EAAE,sBAAsB,CAAC;AAAA,IACvD,CAAC;AAAA,EACH,CAAC;AAED,WAAS,UAAU,MAAM;AACvB,OAAG,mCAAmC,YAAY;AAChD,YAAM,SAAuB;AAAA,QAC3B,WAAW;AAAA,QACX,QAAQ;AAAA,MACV;AAEA,YAAM,SAAS,MAAMD,QAAO,MAAM;AAElC,aAAO,MAAM,EAAE,eAAeG,SAAQ;AAAA,IACxC,CAAC;AAED,OAAG,gDAAgD,YAAY;AAE7D,YAAM,WAAW,KAAK,MAAM,mDAAqB,MAAM,EAAE,kBAAkB,CAAC,cAAc,CAAC;AAE3F,YAAM,SAAuB;AAAA,QAC3B,WAAW;AAAA,QACX,QAAQ;AAAA,MACV;AAEA,YAAMH,QAAO,MAAM;AAEnB,aAAO,QAAQ,EAAE,qBAAqB;AAAA,QACpC,WAAW;AAAA,QACX,iBAAiB,OAAO,IAAI,MAAM;AAAA,QAClC,cAAc,OAAO,IAAI,MAAM;AAAA,MACjC,CAAC;AAGD,eAAS,YAAY;AAAA,IACvB,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
6
|
"names": ["lint", "report", "LintRunner", "FileScanner", "Readable"]
|
|
7
7
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Readable } from 'stream';
|
|
2
|
-
import { LintResult, LintConfig, ReportConfig
|
|
2
|
+
import { LintResult, LintConfig, ReportConfig } from '../types';
|
|
3
3
|
/**
|
|
4
4
|
* Run linting on specified files or directory
|
|
5
5
|
*
|
|
@@ -17,4 +17,4 @@ export declare function lint(config: LintConfig): Promise<LintResult[]>;
|
|
|
17
17
|
* @throws Error if report generation fails
|
|
18
18
|
*/
|
|
19
19
|
export declare function report(config: ReportConfig, results?: LintResult[]): Promise<Readable>;
|
|
20
|
-
export type { LintResult, LintResultEntry, LintConfig, ReportConfig, ExitCode, WorkerResult, SarifResultEntry };
|
|
20
|
+
export type { LintResult, LintResultEntry, LintConfig, ReportConfig, ExitCode, WorkerResult, SarifResultEntry } from '../types';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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
|
|
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
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;AAAA,MACV,WAAW;AAAA,IACb,CAAC;AAGD,UAAM,cAA2B;AAAA,MAC/B,KAAK,iBAAiB;AAAA,MACtB,YAAY,iBAAiB;AAAA,IAC/B;AAGA,UAAM,eAAe,MAAM,WAAW,WAAW,YAAY,SAAS;AAAA,MACpE,GAAG;AAAA,MACH,YAAY,iBAAiB;AAAA,IAC/B,CAAC;AAGD,UAAM,mBAAmB,MAAM,WAAW,WAAW,gBAAgB,aAAa;AAAA,MAChF,GAAG;AAAA,MACH,YAAY,iBAAiB;AAAA,IAC/B,CAAC;AAGD,UAAM,kBAAkB,CAAC,GAAG,cAAc,GAAG,gBAAgB;AAE7D,WAAO;AAAA,EACT,SAAS,OAAY;AAEnB,UAAM,eAAe,mBAAmB,MAAM,OAAO;AACrD,WAAO,MAAM,YAAY;AACzB,UAAM,IAAI,MAAM,YAAY;AAAA,EAC9B;AACF;AAUA,eAAsB,OAAO,QAAsB,SAA2C;AAC5F,MAAI;AACF,WAAO,MAAM,0CAA0C;AAGvD,UAAM,mBAAmB,oBAAoB,QAAQ,CAAC,GAAG,IAAI;AAG7D,UAAM,SAAS,iBAAiB,UAAU;AAG1C,UAAM,cAAc,WAAW,MAAM,KAAK;AAAA,MACxC,WAAW,iBAAiB;AAAA,MAC5B,iBAAiB,iBAAiB;AAAA,MAClC,cAAc,iBAAiB;AAAA,IACjC,CAAC;AAGD,YAAQ,QAAQ;AAAA,MACd,KAAK;AAEH,eAAO,gBAAgB,0BAA0B,aAAa;AAAA,UAC5D,UAAU;AAAA,UACV,aAAa;AAAA,QACf,CAAC;AAAA,MAEH,KAAK;AAEH,cAAM,YAAY,mBAAmB,kBAAkB,WAAW;AAClE,cAAM,YAAY,IAAI,SAAS;AAC/B,kBAAU,KAAK,SAAS;AACxB,kBAAU,KAAK,IAAI;AACnB,eAAO;AAAA,MAET;AAEE,cAAM,eAAe,uBAAuB,MAAM;AAClD,eAAO,MAAM,YAAY;AACzB,cAAM,IAAI,MAAM,YAAY;AAAA,IAChC;AAAA,EACF,SAAS,OAAY;AAEnB,UAAM,eAAe,6BAA6B,MAAM,OAAO;AAC/D,WAAO,MAAM,YAAY;AACzB,UAAM,IAAI,MAAM,YAAY;AAAA,EAC9B;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/build/index.d.ts
CHANGED
package/build/index.js
CHANGED
|
@@ -7,8 +7,6 @@ import { registerReportCommand } from "./commands/report.js";
|
|
|
7
7
|
import { registerEmitCommand } from "./commands/emit.js";
|
|
8
8
|
import { Logger } from "./utils/logger.js";
|
|
9
9
|
import { validateNodeVersion } from "./utils/nodeVersionUtil.js";
|
|
10
|
-
export * from "./types/index.js";
|
|
11
|
-
export * from "./executor/index.js";
|
|
12
10
|
validateNodeVersion();
|
|
13
11
|
process.on("unhandledRejection", (error) => {
|
|
14
12
|
Logger.error(`Unhandled rejection: ${error}`);
|
package/build/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["#!/usr/bin/env node\n\nimport { Command } from 'commander';\nimport { registerLintCommand } from './commands/lint';\nimport { registerReportCommand } from './commands/report';\nimport { registerEmitCommand } from './commands/emit';\nimport { Logger } from './utils/logger';\nimport { validateNodeVersion } from './utils/nodeVersionUtil';\n\n// Validate Node.js version before proceeding\nvalidateNodeVersion();\n\nprocess.on('unhandledRejection', (error) => {\n Logger.error(`Unhandled rejection: ${error}`);\n process.exit(1);\n});\n\nprocess.on('uncaughtException', (error) => {\n Logger.error(`Uncaught exception: ${error}`);\n process.exit(1);\n});\n\nconst program = new Command();\n\nprogram\n .name('npx @salesforce-ux/slds-linter@latest')\n .showHelpAfterError();\n\nfunction registerVersion(){\n // resolving version and description from env props. check gulp file\n program.description(process.env.CLI_DESCRIPTION)\n .version(process.env.CLI_VERSION);\n}\n\nregisterLintCommand(program);\nregisterReportCommand(program);\nregisterEmitCommand(program);\nregisterVersion();\nprogram.configureHelp({ \n subcommandTerm:(cmd)=>{\n return cmd.name();\n },\n})\n\nprogram.parse(process.argv);
|
|
5
|
-
"mappings": ";;;AAEA,SAAS,eAAe;AACxB,SAAS,2BAA2B;AACpC,SAAS,6BAA6B;AACtC,SAAS,2BAA2B;AACpC,SAAS,cAAc;AACvB,SAAS,2BAA2B;
|
|
4
|
+
"sourcesContent": ["#!/usr/bin/env node\n\nimport { Command } from 'commander';\nimport { registerLintCommand } from './commands/lint';\nimport { registerReportCommand } from './commands/report';\nimport { registerEmitCommand } from './commands/emit';\nimport { Logger } from './utils/logger';\nimport { validateNodeVersion } from './utils/nodeVersionUtil';\n\n// Validate Node.js version before proceeding\nvalidateNodeVersion();\n\nprocess.on('unhandledRejection', (error) => {\n Logger.error(`Unhandled rejection: ${error}`);\n process.exit(1);\n});\n\nprocess.on('uncaughtException', (error) => {\n Logger.error(`Uncaught exception: ${error}`);\n process.exit(1);\n});\n\nconst program = new Command();\n\nprogram\n .name('npx @salesforce-ux/slds-linter@latest')\n .showHelpAfterError();\n\nfunction registerVersion(){\n // resolving version and description from env props. check gulp file\n program.description(process.env.CLI_DESCRIPTION)\n .version(process.env.CLI_VERSION);\n}\n\nregisterLintCommand(program);\nregisterReportCommand(program);\nregisterEmitCommand(program);\nregisterVersion();\nprogram.configureHelp({ \n subcommandTerm:(cmd)=>{\n return cmd.name();\n },\n})\n\nprogram.parse(process.argv); "],
|
|
5
|
+
"mappings": ";;;AAEA,SAAS,eAAe;AACxB,SAAS,2BAA2B;AACpC,SAAS,6BAA6B;AACtC,SAAS,2BAA2B;AACpC,SAAS,cAAc;AACvB,SAAS,2BAA2B;AAGpC,oBAAoB;AAEpB,QAAQ,GAAG,sBAAsB,CAAC,UAAU;AAC1C,SAAO,MAAM,wBAAwB,KAAK,EAAE;AAC5C,UAAQ,KAAK,CAAC;AAChB,CAAC;AAED,QAAQ,GAAG,qBAAqB,CAAC,UAAU;AACzC,SAAO,MAAM,uBAAuB,KAAK,EAAE;AAC3C,UAAQ,KAAK,CAAC;AAChB,CAAC;AAED,IAAM,UAAU,IAAI,QAAQ;AAE5B,QACG,KAAK,uCAAuC,EAC5C,mBAAmB;AAEtB,SAAS,kBAAiB;AAExB,UAAQ,YAAY,wDAA2B,EAC9C,QAAQ,eAAuB;AAClC;AAEA,oBAAoB,OAAO;AAC3B,sBAAsB,OAAO;AAC7B,oBAAoB,OAAO;AAC3B,gBAAgB;AAChB,QAAQ,cAAc;AAAA,EACpB,gBAAe,CAAC,QAAM;AACpB,WAAO,IAAI,KAAK;AAAA,EAClB;AACF,CAAC;AAED,QAAQ,MAAM,QAAQ,IAAI;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/build/types/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// src/workers/eslint.worker.ts
|
|
2
2
|
import { ESLint } from "eslint";
|
|
3
3
|
import { BaseWorker } from "./base.worker.js";
|
|
4
|
-
import { normalizeLintMessage } from "../utils/lintMessageUtils.js";
|
|
5
4
|
var ESLintWorker = class extends BaseWorker {
|
|
6
5
|
eslint;
|
|
7
6
|
constructor() {
|
|
@@ -25,14 +24,14 @@ var ESLintWorker = class extends BaseWorker {
|
|
|
25
24
|
line: warning.line,
|
|
26
25
|
column: warning.column,
|
|
27
26
|
endColumn: warning.endColumn,
|
|
28
|
-
|
|
27
|
+
message: warning.message,
|
|
29
28
|
ruleId: warning.ruleId || "unknown"
|
|
30
29
|
})),
|
|
31
30
|
errors: fileResult.messages.filter((msg) => msg.severity === 2).map((error) => ({
|
|
32
31
|
line: error.line,
|
|
33
32
|
column: error.column,
|
|
34
33
|
endColumn: error.endColumn,
|
|
35
|
-
|
|
34
|
+
message: error.message,
|
|
36
35
|
ruleId: error.ruleId || "unknown"
|
|
37
36
|
}))
|
|
38
37
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/workers/eslint.worker.ts"],
|
|
4
|
-
"sourcesContent": ["import { ESLint } from 'eslint';\nimport { BaseWorker } from './base.worker';\nimport { WorkerConfig, WorkerResult } from '../types';\
|
|
5
|
-
"mappings": ";AAAA,SAAS,cAAc;AACvB,SAAS,kBAAkB;
|
|
4
|
+
"sourcesContent": ["import { ESLint } from 'eslint';\nimport { BaseWorker } from './base.worker';\nimport { WorkerConfig, WorkerResult } from '../types';\n\nclass ESLintWorker extends BaseWorker<WorkerConfig, WorkerResult> {\n private eslint: ESLint;\n\n constructor() {\n super();\n this.eslint = new ESLint({\n useEslintrc: false,\n fix: this.task.config.fix,\n overrideConfigFile: this.task.config.configPath\n });\n }\n\n protected async processFile(filePath: string): Promise<WorkerResult> {\n try {\n const results = await this.eslint.lintFiles([filePath]);\n const fileResult = results[0];\n\n // Apply fixes if requested\n if (this.task.config.fix && fileResult.output) {\n await ESLint.outputFixes(results);\n }\n return {\n file: filePath,\n warnings: fileResult.messages\n .filter(msg => msg.severity === 1)\n .map(warning => ({\n line: warning.line,\n column: warning.column,\n endColumn: warning.endColumn,\n message: warning.message,\n ruleId: warning.ruleId || 'unknown'\n })),\n errors: fileResult.messages\n .filter(msg => msg.severity === 2)\n .map(error => ({\n line: error.line,\n column: error.column,\n endColumn: error.endColumn,\n message: error.message,\n ruleId: error.ruleId || 'unknown'\n }))\n };\n } catch (error: any) {\n return {\n file: filePath,\n error: error.message\n };\n }\n }\n}\n\n// Initialize and start the worker\nconst worker = new ESLintWorker();\nworker.process().catch(error => {\n console.error('Worker failed:', error);\n process.exit(1);\n}); "],
|
|
5
|
+
"mappings": ";AAAA,SAAS,cAAc;AACvB,SAAS,kBAAkB;AAG3B,IAAM,eAAN,cAA2B,WAAuC;AAAA,EACxD;AAAA,EAER,cAAc;AACZ,UAAM;AACN,SAAK,SAAS,IAAI,OAAO;AAAA,MACvB,aAAa;AAAA,MACb,KAAK,KAAK,KAAK,OAAO;AAAA,MACtB,oBAAoB,KAAK,KAAK,OAAO;AAAA,IACvC,CAAC;AAAA,EACH;AAAA,EAEA,MAAgB,YAAY,UAAyC;AACnE,QAAI;AACF,YAAM,UAAU,MAAM,KAAK,OAAO,UAAU,CAAC,QAAQ,CAAC;AACtD,YAAM,aAAa,QAAQ,CAAC;AAG5B,UAAI,KAAK,KAAK,OAAO,OAAO,WAAW,QAAQ;AAC7C,cAAM,OAAO,YAAY,OAAO;AAAA,MAClC;AACA,aAAO;AAAA,QACL,MAAM;AAAA,QACN,UAAU,WAAW,SAClB,OAAO,SAAO,IAAI,aAAa,CAAC,EAChC,IAAI,cAAY;AAAA,UACf,MAAM,QAAQ;AAAA,UACd,QAAQ,QAAQ;AAAA,UAChB,WAAW,QAAQ;AAAA,UACnB,SAAS,QAAQ;AAAA,UACjB,QAAQ,QAAQ,UAAU;AAAA,QAC5B,EAAE;AAAA,QACJ,QAAQ,WAAW,SAChB,OAAO,SAAO,IAAI,aAAa,CAAC,EAChC,IAAI,YAAU;AAAA,UACb,MAAM,MAAM;AAAA,UACZ,QAAQ,MAAM;AAAA,UACd,WAAW,MAAM;AAAA,UACjB,SAAS,MAAM;AAAA,UACf,QAAQ,MAAM,UAAU;AAAA,QAC1B,EAAE;AAAA,MACN;AAAA,IACF,SAAS,OAAY;AACnB,aAAO;AAAA,QACL,MAAM;AAAA,QACN,OAAO,MAAM;AAAA,MACf;AAAA,IACF;AAAA,EACF;AACF;AAGA,IAAM,SAAS,IAAI,aAAa;AAChC,OAAO,QAAQ,EAAE,MAAM,WAAS;AAC9B,UAAQ,MAAM,kBAAkB,KAAK;AACrC,UAAQ,KAAK,CAAC;AAChB,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// src/workers/stylelint.worker.ts
|
|
2
2
|
import stylelint from "stylelint";
|
|
3
3
|
import { BaseWorker } from "./base.worker.js";
|
|
4
|
-
import { normalizeLintMessage } from "../utils/lintMessageUtils.js";
|
|
5
4
|
var StylelintWorker = class extends BaseWorker {
|
|
6
5
|
async processFile(filePath) {
|
|
7
6
|
try {
|
|
@@ -20,7 +19,7 @@ var StylelintWorker = class extends BaseWorker {
|
|
|
20
19
|
line: warning.line,
|
|
21
20
|
column: warning.column,
|
|
22
21
|
endColumn: warning.endColumn,
|
|
23
|
-
|
|
22
|
+
message: warning.text,
|
|
24
23
|
ruleId: warning.rule
|
|
25
24
|
})),
|
|
26
25
|
errors: []
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/workers/stylelint.worker.ts"],
|
|
4
|
-
"sourcesContent": ["import stylelint from 'stylelint';\nimport { BaseWorker } from './base.worker';\nimport { WorkerConfig, WorkerResult } from '../types';\
|
|
5
|
-
"mappings": ";AAAA,OAAO,eAAe;AACtB,SAAS,kBAAkB;
|
|
4
|
+
"sourcesContent": ["import stylelint from 'stylelint';\nimport { BaseWorker } from './base.worker';\nimport { WorkerConfig, WorkerResult } from '../types';\n\nclass StylelintWorker extends BaseWorker<WorkerConfig, WorkerResult> {\n protected async processFile(filePath: string): Promise<WorkerResult> {\n try {\n const options: stylelint.LinterOptions = {\n files: filePath,\n fix: this.task.config.fix,\n };\n\n // Load custom config if provided\n if (this.task.config.configPath) {\n options.configFile = this.task.config.configPath;\n }\n\n const result = await stylelint.lint(options);\n const fileResult = result.results[0];\n\n // Convert stylelint results to our format\n return {\n file: filePath,\n warnings: fileResult.warnings.map(warning => ({\n line: warning.line,\n column: warning.column,\n endColumn: warning.endColumn,\n message: warning.text,\n ruleId: warning.rule\n })),\n errors: [] // Stylelint doesn't differentiate between warnings and errors\n };\n } catch (error: any) {\n return {\n file: filePath,\n error: error.message\n };\n }\n }\n}\n\n// Initialize and start the worker\nconst worker = new StylelintWorker();\nworker.process().catch(error => {\n console.error('Worker failed:', error);\n process.exit(1);\n}); "],
|
|
5
|
+
"mappings": ";AAAA,OAAO,eAAe;AACtB,SAAS,kBAAkB;AAG3B,IAAM,kBAAN,cAA8B,WAAuC;AAAA,EACnE,MAAgB,YAAY,UAAyC;AACnE,QAAI;AACF,YAAM,UAAmC;AAAA,QACvC,OAAO;AAAA,QACP,KAAK,KAAK,KAAK,OAAO;AAAA,MACxB;AAGA,UAAI,KAAK,KAAK,OAAO,YAAY;AAC/B,gBAAQ,aAAa,KAAK,KAAK,OAAO;AAAA,MACxC;AAEA,YAAM,SAAS,MAAM,UAAU,KAAK,OAAO;AAC3C,YAAM,aAAa,OAAO,QAAQ,CAAC;AAGnC,aAAO;AAAA,QACL,MAAM;AAAA,QACN,UAAU,WAAW,SAAS,IAAI,cAAY;AAAA,UAC5C,MAAM,QAAQ;AAAA,UACd,QAAQ,QAAQ;AAAA,UAChB,WAAW,QAAQ;AAAA,UACnB,SAAS,QAAQ;AAAA,UACjB,QAAQ,QAAQ;AAAA,QAClB,EAAE;AAAA,QACF,QAAQ,CAAC;AAAA;AAAA,MACX;AAAA,IACF,SAAS,OAAY;AACnB,aAAO;AAAA,QACL,MAAM;AAAA,QACN,OAAO,MAAM;AAAA,MACf;AAAA,IACF;AAAA,EACF;AACF;AAGA,IAAM,SAAS,IAAI,gBAAgB;AACnC,OAAO,QAAQ,EAAE,MAAM,WAAS;AAC9B,UAAQ,MAAM,kBAAkB,KAAK;AACrC,UAAQ,KAAK,CAAC;AAChB,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce-ux/slds-linter",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
3
|
+
"version": "0.2.0-alpha.4",
|
|
4
4
|
"description": "SLDS Linter CLI tool for linting styles and components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lightning design system linter",
|
|
@@ -12,12 +12,8 @@
|
|
|
12
12
|
"author": "UXF Tooling Team",
|
|
13
13
|
"type": "module",
|
|
14
14
|
"main": "build/index.js",
|
|
15
|
-
"types": "./build/index.d.ts",
|
|
16
15
|
"exports": {
|
|
17
|
-
".":
|
|
18
|
-
"types": "./build/index.d.ts",
|
|
19
|
-
"default": "./build/index.js"
|
|
20
|
-
},
|
|
16
|
+
".": "./build/index.js",
|
|
21
17
|
"./executor": {
|
|
22
18
|
"types": "./build/executor/index.d.ts",
|
|
23
19
|
"default": "./build/executor/index.js"
|
|
@@ -29,8 +25,8 @@
|
|
|
29
25
|
],
|
|
30
26
|
"bin": "./build/index.js",
|
|
31
27
|
"dependencies": {
|
|
32
|
-
"@salesforce-ux/eslint-plugin-slds": "0.2.0-alpha.
|
|
33
|
-
"@salesforce-ux/stylelint-plugin-slds": "0.2.0-alpha.
|
|
28
|
+
"@salesforce-ux/eslint-plugin-slds": "0.2.0-alpha.4",
|
|
29
|
+
"@salesforce-ux/stylelint-plugin-slds": "0.2.0-alpha.4",
|
|
34
30
|
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
|
35
31
|
"@typescript-eslint/parser": "^5.0.0",
|
|
36
32
|
"chalk": "^4.1.2",
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
// src/utils/lintMessageUtils.ts
|
|
2
|
-
function normalizeLintMessage(msg) {
|
|
3
|
-
try {
|
|
4
|
-
const parsed = JSON.parse(msg);
|
|
5
|
-
if (typeof parsed === "object" && parsed.message) {
|
|
6
|
-
return parsed;
|
|
7
|
-
}
|
|
8
|
-
} catch {
|
|
9
|
-
}
|
|
10
|
-
return { message: msg };
|
|
11
|
-
}
|
|
12
|
-
export {
|
|
13
|
-
normalizeLintMessage
|
|
14
|
-
};
|
|
15
|
-
//# sourceMappingURL=lintMessageUtils.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/utils/lintMessageUtils.ts"],
|
|
4
|
-
"sourcesContent": ["export function normalizeLintMessage(msg: string): { message: string, suggestions?: string[] } {\n try {\n const parsed = JSON.parse(msg);\n if (typeof parsed === 'object' && parsed.message) {\n return parsed;\n }\n } catch {}\n return { message: msg };\n} "],
|
|
5
|
-
"mappings": ";AAAO,SAAS,qBAAqB,KAA0D;AAC7F,MAAI;AACF,UAAM,SAAS,KAAK,MAAM,GAAG;AAC7B,QAAI,OAAO,WAAW,YAAY,OAAO,SAAS;AAChD,aAAO;AAAA,IACT;AAAA,EACF,QAAQ;AAAA,EAAC;AACT,SAAO,EAAE,SAAS,IAAI;AACxB;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|