@salesforce-ux/slds-linter 0.0.8 → 0.0.11
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/bin/slds-linter.js +100 -0
- package/package.json +10 -5
|
@@ -0,0 +1,100 @@
|
|
|
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
|
+
|
|
13
|
+
// ✅ Define CLI Commands using `yargs`
|
|
14
|
+
yargs(hideBin(process.argv))
|
|
15
|
+
.command(
|
|
16
|
+
'lint',
|
|
17
|
+
'Run both ESLint and Stylelint',
|
|
18
|
+
() => {},
|
|
19
|
+
() => {
|
|
20
|
+
console.log(chalk.cyan('🔍 Running ESLint and Stylelint...'));
|
|
21
|
+
try {
|
|
22
|
+
execSync(`eslint **/*.{html,cmp} --config ${eslintConfigPath} --ext .html,.cmp`, { stdio: 'inherit' });
|
|
23
|
+
execSync(`stylelint ./**/*.css --config ${stylelintConfigPath}`, { stdio: 'inherit' });
|
|
24
|
+
console.log(chalk.green('✅ Linting completed successfully!'));
|
|
25
|
+
} catch (error) {
|
|
26
|
+
console.error(chalk.red('❌ Linting failed. Please fix the errors and try again.'));
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
)
|
|
31
|
+
.command(
|
|
32
|
+
'lint:styles',
|
|
33
|
+
'Run only Stylelint',
|
|
34
|
+
() => {},
|
|
35
|
+
() => {
|
|
36
|
+
console.log(chalk.cyan('🎨 Running Stylelint...'));
|
|
37
|
+
try {
|
|
38
|
+
execSync(`stylelint ./**/*.css --config ${stylelintConfigPath}`, { stdio: 'inherit' });
|
|
39
|
+
console.log(chalk.green('✅ Stylelint completed successfully!'));
|
|
40
|
+
} catch (error) {
|
|
41
|
+
console.error(chalk.red('❌ Stylelint failed. Please fix the errors and try again.'));
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
)
|
|
46
|
+
.command(
|
|
47
|
+
'lint:components',
|
|
48
|
+
'Run only ESLint',
|
|
49
|
+
() => {},
|
|
50
|
+
() => {
|
|
51
|
+
console.log(chalk.cyan('🛠️ Running ESLint...'));
|
|
52
|
+
try {
|
|
53
|
+
execSync(`eslint **/*.{html,cmp} --config ${eslintConfigPath} --ext .html,.cmp`, { stdio: 'inherit' });
|
|
54
|
+
console.log(chalk.green('✅ ESLint completed successfully!'));
|
|
55
|
+
} catch (error) {
|
|
56
|
+
console.error(chalk.red('❌ ESLint failed. Please fix the errors and try again.'));
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
)
|
|
61
|
+
.command(
|
|
62
|
+
'fix',
|
|
63
|
+
'Fix auto-fixable issues',
|
|
64
|
+
() => {},
|
|
65
|
+
() => {
|
|
66
|
+
console.log(chalk.cyan('🔧 Running auto-fix for ESLint and Stylelint...'));
|
|
67
|
+
try {
|
|
68
|
+
execSync(`eslint **/*.{html,cmp} --config ${eslintConfigPath} --fix --ext .html,.cmp`, { stdio: 'inherit' });
|
|
69
|
+
execSync(`stylelint "**/*.css" -c ${stylelintConfigPath} --fix`, { stdio: 'inherit' });
|
|
70
|
+
console.log(chalk.green('✅ Auto-fix applied successfully!'));
|
|
71
|
+
} catch (error) {
|
|
72
|
+
console.error(chalk.red('❌ Fixing failed. Please check linting errors.'));
|
|
73
|
+
process.exit(1);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
)
|
|
77
|
+
.command(
|
|
78
|
+
'report',
|
|
79
|
+
'Generate a linting report',
|
|
80
|
+
(yargs) => {
|
|
81
|
+
return yargs.option('dir', {
|
|
82
|
+
alias: 'd',
|
|
83
|
+
describe: 'Target directory for linting',
|
|
84
|
+
type: 'string',
|
|
85
|
+
default: 'force-app/'
|
|
86
|
+
});
|
|
87
|
+
},
|
|
88
|
+
(argv) => {
|
|
89
|
+
console.log(chalk.cyan(`📊 Generating linting report for ${argv.dir}...`));
|
|
90
|
+
try {
|
|
91
|
+
execSync(`node node_modules/@salesforce-ux/stylelint-plugin-slds/build/report.js ${argv.dir} -c ${stylelintConfigPath}`, { stdio: 'inherit' });
|
|
92
|
+
console.log(chalk.green('✅ Report generated successfully!'));
|
|
93
|
+
} catch (error) {
|
|
94
|
+
console.error(chalk.red('❌ Failed to generate the report.'));
|
|
95
|
+
process.exit(1);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
)
|
|
99
|
+
.help()
|
|
100
|
+
.argv;
|
package/package.json
CHANGED
|
@@ -1,27 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce-ux/slds-linter",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"description": "SLDS Linter with both stylelint and eslint together",
|
|
5
5
|
"main": "index.mjs",
|
|
6
|
+
"bin": {
|
|
7
|
+
"slds-linter": "./bin/slds-linter.js"
|
|
8
|
+
},
|
|
6
9
|
"workspaces": [
|
|
7
10
|
"packages/*"
|
|
8
11
|
],
|
|
9
12
|
"access": "public",
|
|
10
13
|
"files": [
|
|
11
14
|
"build/",
|
|
15
|
+
"bin/",
|
|
12
16
|
"README.md"
|
|
13
17
|
],
|
|
14
18
|
"scripts": {
|
|
15
19
|
"build": "rollup --config rollup.config.js",
|
|
16
20
|
"clean": "rm -rf build package-lock.json",
|
|
17
21
|
"test": "echo 'Not implemented!'",
|
|
18
|
-
"setup-lint": "node ./build/setup.js"
|
|
19
|
-
"postinstall": "npm run setup-lint"
|
|
22
|
+
"setup-lint": "node ./build/setup.js"
|
|
20
23
|
},
|
|
21
24
|
"type": "module",
|
|
22
25
|
"dependencies": {
|
|
23
|
-
"@salesforce-ux/eslint-plugin-slds": "
|
|
24
|
-
"@salesforce-ux/stylelint-plugin-slds": "
|
|
26
|
+
"@salesforce-ux/eslint-plugin-slds": "0.0.11",
|
|
27
|
+
"@salesforce-ux/stylelint-plugin-slds": "0.0.11",
|
|
28
|
+
"chalk": "^5.3.0",
|
|
29
|
+
"yargs": "^17.7.2"
|
|
25
30
|
},
|
|
26
31
|
"keywords": [
|
|
27
32
|
"eslint SDS",
|