@salesforce-ux/slds-linter 0.0.12-alpha → 0.0.12-alpha.6
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 +54 -32
- package/build/commands/lint-components.d.ts +2 -0
- package/build/commands/lint-components.js +52 -0
- package/build/commands/lint-styles.d.ts +2 -0
- package/build/commands/lint-styles.js +52 -0
- package/build/commands/lint.d.ts +2 -0
- package/build/commands/lint.js +89 -0
- package/build/commands/report.d.ts +2 -0
- package/build/commands/report.js +53 -0
- package/build/index.d.ts +2 -1
- package/build/index.js +25 -0
- package/build/services/__tests__/file-scanner.test.js +47 -0
- package/build/services/batch-processor.d.ts +29 -0
- package/build/services/batch-processor.js +84 -0
- package/build/services/config.resolver.d.ts +6 -0
- package/build/services/config.resolver.js +23 -0
- package/build/services/file-patterns.d.ts +3 -0
- package/build/services/file-patterns.js +33 -0
- package/build/services/file-scanner.d.ts +26 -0
- package/build/services/file-scanner.js +69 -0
- package/build/services/lint-runner.d.ts +17 -0
- package/build/services/lint-runner.js +68 -0
- package/build/services/report-generator.d.ts +20 -0
- package/build/services/report-generator.js +119 -0
- package/build/types/index.d.ts +51 -0
- package/build/types/index.js +0 -0
- package/build/utils/cli-args.d.ts +3 -0
- package/build/utils/cli-args.js +31 -0
- package/build/utils/editorLinkUtil.d.ts +21 -0
- package/build/utils/editorLinkUtil.js +21 -0
- package/build/utils/lintResultsUtil.d.ts +7 -0
- package/build/utils/lintResultsUtil.js +43 -0
- package/build/utils/logger.d.ts +7 -0
- package/build/utils/logger.js +24 -0
- package/build/workers/base.worker.d.ts +15 -0
- package/build/workers/base.worker.js +44 -0
- package/build/workers/eslint.worker.js +50 -0
- package/build/workers/stylelint.worker.d.ts +1 -0
- package/build/workers/stylelint.worker.js +40 -0
- package/package.json +40 -32
- package/bin/slds-linter.js +0 -119
- package/build/setup.js +0 -42
- /package/build/{setup.d.ts → workers/eslint.worker.d.ts} +0 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// src/workers/stylelint.worker.ts
|
|
2
|
+
import stylelint from "stylelint";
|
|
3
|
+
import { BaseWorker } from "./base.worker.js";
|
|
4
|
+
var StylelintWorker = class extends BaseWorker {
|
|
5
|
+
async processFile(filePath) {
|
|
6
|
+
try {
|
|
7
|
+
const options = {
|
|
8
|
+
files: filePath,
|
|
9
|
+
fix: this.task.config.fix
|
|
10
|
+
};
|
|
11
|
+
if (this.task.config.configPath) {
|
|
12
|
+
options.configFile = this.task.config.configPath;
|
|
13
|
+
}
|
|
14
|
+
const result = await stylelint.lint(options);
|
|
15
|
+
const fileResult = result.results[0];
|
|
16
|
+
return {
|
|
17
|
+
file: filePath,
|
|
18
|
+
warnings: fileResult.warnings.map((warning) => ({
|
|
19
|
+
line: warning.line,
|
|
20
|
+
column: warning.column,
|
|
21
|
+
endColumn: warning.endColumn,
|
|
22
|
+
message: warning.text,
|
|
23
|
+
ruleId: warning.rule
|
|
24
|
+
})),
|
|
25
|
+
errors: []
|
|
26
|
+
// Stylelint doesn't differentiate between warnings and errors
|
|
27
|
+
};
|
|
28
|
+
} catch (error) {
|
|
29
|
+
return {
|
|
30
|
+
file: filePath,
|
|
31
|
+
error: error.message
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
var worker = new StylelintWorker();
|
|
37
|
+
worker.process().catch((error) => {
|
|
38
|
+
console.error("Worker failed:", error);
|
|
39
|
+
process.exit(1);
|
|
40
|
+
});
|
package/package.json
CHANGED
|
@@ -1,42 +1,50 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce-ux/slds-linter",
|
|
3
|
-
"version": "0.0.12-alpha",
|
|
4
|
-
"description": "SLDS
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"
|
|
3
|
+
"version": "0.0.12-alpha.6",
|
|
4
|
+
"description": "SLDS CLI tool for linting styles and components",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"lint",
|
|
7
|
+
"eslint",
|
|
8
|
+
"stylelint",
|
|
9
|
+
"cli",
|
|
10
|
+
"sarif",
|
|
11
|
+
"parallel",
|
|
12
|
+
"performance"
|
|
11
13
|
],
|
|
12
|
-
"
|
|
14
|
+
"author": "UXF Tooling Team",
|
|
15
|
+
"type": "module",
|
|
16
|
+
"main": "build/index.js",
|
|
13
17
|
"files": [
|
|
14
|
-
"build
|
|
15
|
-
"bin/",
|
|
18
|
+
"build/**",
|
|
16
19
|
"README.md"
|
|
17
20
|
],
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"clean": "rm -rf build package-lock.json",
|
|
21
|
-
"test": "echo 'Not implemented!'",
|
|
22
|
-
"setup-lint": "node ./build/setup.js"
|
|
21
|
+
"bin": {
|
|
22
|
+
"slds-linter": "./build/index.js"
|
|
23
23
|
},
|
|
24
|
-
"type": "module",
|
|
25
24
|
"dependencies": {
|
|
26
|
-
"@salesforce-ux/eslint-plugin-slds": "
|
|
27
|
-
"@salesforce-ux/stylelint-plugin-slds": "
|
|
28
|
-
"
|
|
29
|
-
"
|
|
25
|
+
"@salesforce-ux/eslint-plugin-slds": "0.0.12-alpha.6",
|
|
26
|
+
"@salesforce-ux/stylelint-plugin-slds": "0.0.12-alpha.6",
|
|
27
|
+
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
|
28
|
+
"@typescript-eslint/parser": "^5.0.0",
|
|
29
|
+
"chalk": "^4.1.2",
|
|
30
|
+
"commander": "^13.1.0",
|
|
31
|
+
"eslint": "^8.0.0",
|
|
32
|
+
"glob": "^11.0.0",
|
|
33
|
+
"json-stream-stringify": "^3.1.6",
|
|
34
|
+
"node-sarif-builder": "^3.2.0",
|
|
35
|
+
"ora": "^5.4.1",
|
|
36
|
+
"stylelint": "^16.10.0"
|
|
30
37
|
},
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"
|
|
40
|
-
|
|
38
|
+
"license": "ISC",
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "git+https://github.com/yourusername/linting-cli.git"
|
|
42
|
+
},
|
|
43
|
+
"bugs": {
|
|
44
|
+
"url": "https://github.com/yourusername/linting-cli/issues"
|
|
45
|
+
},
|
|
46
|
+
"homepage": "https://github.com/yourusername/linting-cli#readme",
|
|
47
|
+
"publishConfig": {
|
|
48
|
+
"registry": "https://registry.npmjs.org"
|
|
41
49
|
}
|
|
42
|
-
}
|
|
50
|
+
}
|
package/bin/slds-linter.js
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { execSync } from 'child_process';
|
|
4
|
-
import path from 'path';
|
|
5
|
-
import { fileURLToPath } from 'url';
|
|
6
|
-
import chalk from 'chalk';
|
|
7
|
-
import yargs from 'yargs';
|
|
8
|
-
import { hideBin } from 'yargs/helpers';
|
|
9
|
-
|
|
10
|
-
const eslintConfigPath = fileURLToPath(await import.meta.resolve('@salesforce-ux/eslint-plugin-slds/build/.eslintrc.yml'));
|
|
11
|
-
const stylelintConfigPath = fileURLToPath(await import.meta.resolve('@salesforce-ux/stylelint-plugin-slds/build/.stylelintrc.yml'));
|
|
12
|
-
const reportExecuterPath = fileURLToPath(await import.meta.resolve('@salesforce-ux/stylelint-plugin-slds/build/report.js'));
|
|
13
|
-
|
|
14
|
-
// ✅ Define CLI Commands using `yargs`
|
|
15
|
-
yargs(hideBin(process.argv))
|
|
16
|
-
.scriptName('')
|
|
17
|
-
.usage('Usage: npx @salesforce-ux/slds-linter [command]')
|
|
18
|
-
.command(
|
|
19
|
-
'lint',
|
|
20
|
-
'Run both ESLint and Stylelint',
|
|
21
|
-
() => {},
|
|
22
|
-
() => {
|
|
23
|
-
console.log(chalk.cyan('🔍 Running ESLint and Stylelint...'));
|
|
24
|
-
try {
|
|
25
|
-
execSync(`eslint **/*.{html,cmp} --config ${eslintConfigPath} --ext .html,.cmp`, { stdio: 'inherit' });
|
|
26
|
-
console.log(chalk.green('✅ Linting components completed successfully!'));
|
|
27
|
-
} catch (error) {
|
|
28
|
-
console.error(chalk.red('❌ Linting components failed. Please fix the errors and try again.'));
|
|
29
|
-
//process.exit(1);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
try {
|
|
33
|
-
execSync(`stylelint ./**/*.css --config ${stylelintConfigPath}`, { stdio: 'inherit' });
|
|
34
|
-
console.log(chalk.green('✅ Linting styles completed successfully!'));
|
|
35
|
-
} catch (error) {
|
|
36
|
-
console.error(chalk.red('❌ Linting styles failed. Please fix the errors and try again.'));
|
|
37
|
-
//process.exit(1);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
)
|
|
42
|
-
.command(
|
|
43
|
-
'lint:styles',
|
|
44
|
-
'Run only Stylelint',
|
|
45
|
-
() => {},
|
|
46
|
-
() => {
|
|
47
|
-
console.log(chalk.cyan('🎨 Running Stylelint...'));
|
|
48
|
-
try {
|
|
49
|
-
execSync(`stylelint ./**/*.css --config ${stylelintConfigPath}`, { stdio: 'inherit' });
|
|
50
|
-
console.log(chalk.green('✅ Stylelint completed successfully!'));
|
|
51
|
-
} catch (error) {
|
|
52
|
-
console.error(chalk.red('❌ Stylelint failed. Please fix the errors and try again.'));
|
|
53
|
-
process.exit(1);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
)
|
|
57
|
-
.command(
|
|
58
|
-
'lint:components',
|
|
59
|
-
'Run only ESLint',
|
|
60
|
-
() => {},
|
|
61
|
-
() => {
|
|
62
|
-
console.log(chalk.cyan('🛠️ Running ESLint...'));
|
|
63
|
-
try {
|
|
64
|
-
execSync(`eslint **/*.{html,cmp} --config ${eslintConfigPath} --ext .html,.cmp`, { stdio: 'inherit' });
|
|
65
|
-
console.log(chalk.green('✅ ESLint completed successfully!'));
|
|
66
|
-
} catch (error) {
|
|
67
|
-
console.error(chalk.red('❌ ESLint failed. Please fix the errors and try again.'));
|
|
68
|
-
process.exit(1);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
)
|
|
72
|
-
.command(
|
|
73
|
-
'fix',
|
|
74
|
-
'Fix auto-fixable issues',
|
|
75
|
-
() => {},
|
|
76
|
-
() => {
|
|
77
|
-
console.log(chalk.cyan('🔧 Running auto-fix for ESLint and Stylelint...'));
|
|
78
|
-
try {
|
|
79
|
-
execSync(`eslint **/*.{html,cmp} --config ${eslintConfigPath} --fix --ext .html,.cmp`, { stdio: 'inherit' });
|
|
80
|
-
console.log(chalk.green('✅ Auto-fix components applied successfully!'));
|
|
81
|
-
} catch (error) {
|
|
82
|
-
console.error(chalk.red('❌ Fixing components failed. Please check linting errors.'));
|
|
83
|
-
//process.exit(1);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
try {
|
|
87
|
-
execSync(`stylelint "**/*.css" -c ${stylelintConfigPath} --fix`, { stdio: 'inherit' });
|
|
88
|
-
console.log(chalk.green('✅ Auto-fix styles applied successfully!'));
|
|
89
|
-
} catch (error) {
|
|
90
|
-
console.error(chalk.red('❌ Fixing styles failed. Please check linting errors.'));
|
|
91
|
-
//process.exit(1);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
)
|
|
96
|
-
.command(
|
|
97
|
-
'report',
|
|
98
|
-
'Generate a linting report',
|
|
99
|
-
(yargs) => {
|
|
100
|
-
return yargs.option('dir', {
|
|
101
|
-
alias: 'd',
|
|
102
|
-
describe: 'Target directory for linting',
|
|
103
|
-
type: 'string',
|
|
104
|
-
default: 'force-app/'
|
|
105
|
-
});
|
|
106
|
-
},
|
|
107
|
-
(argv) => {
|
|
108
|
-
console.log(chalk.cyan(`📊 Generating linting report for ${argv.dir}...`));
|
|
109
|
-
try {
|
|
110
|
-
execSync(`node ${reportExecuterPath} ${argv.dir} -c ${stylelintConfigPath}`, { stdio: 'inherit' });
|
|
111
|
-
console.log(chalk.green('✅ Report generated successfully!'));
|
|
112
|
-
} catch (error) {
|
|
113
|
-
console.error(chalk.red('❌ Failed to generate the report.'));
|
|
114
|
-
process.exit(1);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
)
|
|
118
|
-
.help()
|
|
119
|
-
.argv;
|
package/build/setup.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { fileURLToPath } from 'url';
|
|
4
|
-
|
|
5
|
-
// Define __dirname for ES modules
|
|
6
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
-
const __dirname = path.dirname(__filename);
|
|
8
|
-
const eslintConfigPath = fileURLToPath(await import.meta.resolve('@salesforce-ux/eslint-plugin-slds/build/.eslintrc.yml'));
|
|
9
|
-
const stylelintConfigPath = fileURLToPath(await import.meta.resolve('@salesforce-ux/stylelint-plugin-slds/build/.stylelintrc.yml'));
|
|
10
|
-
// Define the destination path where you want to copy the file
|
|
11
|
-
path.resolve(__dirname, 'config-copy.json');
|
|
12
|
-
const config = [
|
|
13
|
-
{
|
|
14
|
-
"sourcePath": path.resolve(__dirname, eslintConfigPath),
|
|
15
|
-
"destinationPath": ".eslintrc.yml"
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
"sourcePath": path.resolve(__dirname, stylelintConfigPath),
|
|
19
|
-
"destinationPath": ".stylelintrc.yml"
|
|
20
|
-
}
|
|
21
|
-
];
|
|
22
|
-
function setupStylelintConfig() {
|
|
23
|
-
config.forEach(({ sourcePath, destinationPath }) => {
|
|
24
|
-
const source = path.resolve(__dirname, sourcePath);
|
|
25
|
-
const destination = path.resolve(process.cwd(), destinationPath);
|
|
26
|
-
// Check if the destination file already exists
|
|
27
|
-
if (!fs.existsSync(destination)) {
|
|
28
|
-
try {
|
|
29
|
-
// Copy the source file to the destination
|
|
30
|
-
fs.copyFileSync(source, destination);
|
|
31
|
-
console.log(`${destinationPath} has been successfully created.`);
|
|
32
|
-
}
|
|
33
|
-
catch (error) {
|
|
34
|
-
console.error(`Error copying ${destinationPath}:`, error);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
console.log(`${destinationPath} already exists. Merge configurations manually if needed.`);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
setupStylelintConfig();
|
|
File without changes
|