@salesforce-ux/slds-linter 0.0.1
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 +74 -0
- package/build/.eslintrc.yml +31 -0
- package/build/.stylelintrc.yml +52 -0
- package/build/index.d.ts +1 -0
- package/build/setup.d.ts +1 -0
- package/build/setup.js +38 -0
- package/package.json +34 -0
package/README.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# SDS Linter
|
|
2
|
+
|
|
3
|
+
## Features
|
|
4
|
+
|
|
5
|
+
* Component Linting:
|
|
6
|
+
The utility supports linting for two types of Salesforce Lightning components:
|
|
7
|
+
|
|
8
|
+
* LWC and Aura components.
|
|
9
|
+
LWC Components (.html): Linting is applied to Lightning Web Components.
|
|
10
|
+
* Aura Components (.cmp): Linting is applied to Aura Components.
|
|
11
|
+
|
|
12
|
+
- Stylelint for CSS FilesStylelint rules are applied to .css files associated with the components. This ensures consistent styling practices are followed throughout the project.
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
To install the SDS Linter Utility in your project, you can use npm:
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
npm install @salesforce-ux/sds-linter --save-dev
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Usage
|
|
23
|
+
|
|
24
|
+
After installing the package, you need to add a few commands to your `package.json` to allow running the commands needed for linting.
|
|
25
|
+
|
|
26
|
+
You need to add the below in "scripts" item in `package.json`
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
"lint:styles": "stylelint ./**/*.css --config=.stylelintrc.yml",
|
|
30
|
+
"lint:components": "eslint ./**/*.{html,cmp} --ext .html,.cmp --config=.eslintrc.yml",
|
|
31
|
+
"lint": "npm run lint:components; npm run lint:styles",
|
|
32
|
+
"fix": "stylelint ./**/*.css -c .stylelintrc.yml --fix ",
|
|
33
|
+
"report": "node node_modules/@salesforce-ux/stylelint-sds/build/report.js force-app/ -c .stylelintrc.yml",
|
|
34
|
+
"setup-lint": "node ./node_modules/@salesforce-ux/sds-linter/build/setup.js"
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
once the above scripts are added. You can setup the configuration by running
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
npm run setup-lint
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
which will inturn create `.eslintrc.yml` & `.stylelintrc.yml` in the root folder.
|
|
44
|
+
|
|
45
|
+
NOTE: If the project root already containing `.eslintrc.yml` & `.stylelintrc.yml`, we don't overwrite those files and the use needs to merge those files manually. You can find the configuration files in this repostory in the root folder.
|
|
46
|
+
|
|
47
|
+
### Command-Line Interface (CLI)
|
|
48
|
+
|
|
49
|
+
* To lint all components and styles in your project:
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
npm run lint:components
|
|
53
|
+
npm run lint:styles
|
|
54
|
+
```
|
|
55
|
+
* To auto-fix some of the most confident fixes automatically.
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
npm run fix
|
|
59
|
+
```
|
|
60
|
+
* To run a report in .sarif format
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
npm run report
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Contribution
|
|
67
|
+
|
|
68
|
+
We welcome contributions to improve this utility. If you have any suggestions, bug reports, or want to contribute code, please open an issue or pull request.
|
|
69
|
+
|
|
70
|
+
### License
|
|
71
|
+
|
|
72
|
+
This project is licensed under the MIT License - see the LICENSE file for details.
|
|
73
|
+
|
|
74
|
+
For any questions or issues, feel free to reach out to the maintainers or open an issue in the repository.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
root: true
|
|
2
|
+
env:
|
|
3
|
+
es2021: true
|
|
4
|
+
node: true
|
|
5
|
+
parserOptions:
|
|
6
|
+
ecmaVersion: 2021
|
|
7
|
+
sourceType: module
|
|
8
|
+
ignorePatterns:
|
|
9
|
+
- "node_modules/"
|
|
10
|
+
overrides:
|
|
11
|
+
- files:
|
|
12
|
+
- "*.html"
|
|
13
|
+
- "*.cmp"
|
|
14
|
+
parser: "@html-eslint/parser"
|
|
15
|
+
plugins:
|
|
16
|
+
- "@salesforce-ux/sf-sds"
|
|
17
|
+
rules:
|
|
18
|
+
"@salesforce-ux/sf-sds/no-bem-class":
|
|
19
|
+
- "error"
|
|
20
|
+
"@salesforce-ux/sf-sds/no-deprecated-slds-classes":
|
|
21
|
+
- "error"
|
|
22
|
+
|
|
23
|
+
- files:
|
|
24
|
+
- "*.js"
|
|
25
|
+
- "*.json"
|
|
26
|
+
excludedFiles: "*.js"
|
|
27
|
+
rules:
|
|
28
|
+
"@salesforce-ux/no-bem-class":
|
|
29
|
+
- "error"
|
|
30
|
+
"@salesforce-ux/sf-sds/no-deprecated-slds-classes":
|
|
31
|
+
- "error"
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
plugins:
|
|
2
|
+
- "@salesforce-ux/stylelint-sds"
|
|
3
|
+
|
|
4
|
+
overrides:
|
|
5
|
+
- files:
|
|
6
|
+
- "**/*.css"
|
|
7
|
+
- "**/*.scss"
|
|
8
|
+
customSyntax: "postcss"
|
|
9
|
+
rules:
|
|
10
|
+
sf-sds/no-slds-class-overrides:
|
|
11
|
+
- true
|
|
12
|
+
- severity: warning
|
|
13
|
+
sf-sds/no-important-tag:
|
|
14
|
+
- true
|
|
15
|
+
- severity: warning
|
|
16
|
+
# sf-sds/no-hardcoded-values:
|
|
17
|
+
# - true
|
|
18
|
+
# - severity: error
|
|
19
|
+
sf-sds/no-hardcoded-values-slds2:
|
|
20
|
+
- true
|
|
21
|
+
- severity: error
|
|
22
|
+
sf-sds/enforce-utility-classes:
|
|
23
|
+
- true
|
|
24
|
+
sf-sds/no-aura-tokens:
|
|
25
|
+
- true
|
|
26
|
+
sf-sds/lwc-to-slds-token:
|
|
27
|
+
- true
|
|
28
|
+
sf-sds/enforce-bem-usage:
|
|
29
|
+
- true
|
|
30
|
+
sf-sds/no-deprecated-slds-classes:
|
|
31
|
+
- true
|
|
32
|
+
sf-sds/no-deprecated-slds-hooks:
|
|
33
|
+
- true
|
|
34
|
+
sf-sds/no-lwc-custom-properties:
|
|
35
|
+
- true
|
|
36
|
+
sf-sds/no-sds-custom-properties:
|
|
37
|
+
- true
|
|
38
|
+
sf-sds/no-slds-private-var:
|
|
39
|
+
- true
|
|
40
|
+
# sf-sds/do-not-use-calc-function:
|
|
41
|
+
# - true
|
|
42
|
+
sf-sds/enforce-sds-to-slds-hooks:
|
|
43
|
+
- true
|
|
44
|
+
- severity: error
|
|
45
|
+
|
|
46
|
+
sourceMap:
|
|
47
|
+
- false
|
|
48
|
+
|
|
49
|
+
- files:
|
|
50
|
+
- "**/*.html"
|
|
51
|
+
customSyntax: "postcss-html"
|
|
52
|
+
rules: {}
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function exampleFunction(filePath: string): string;
|
package/build/setup.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/build/setup.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
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 config = [
|
|
9
|
+
{
|
|
10
|
+
"sourcePath": "./.eslintrc.yml",
|
|
11
|
+
"destinationPath": ".eslintrc.yml"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"sourcePath": "./.stylelintrc.yml",
|
|
15
|
+
"destinationPath": ".stylelintrc.yml"
|
|
16
|
+
}
|
|
17
|
+
];
|
|
18
|
+
function setupStylelintConfig() {
|
|
19
|
+
config.forEach(({ sourcePath, destinationPath }) => {
|
|
20
|
+
const source = path.resolve(__dirname, sourcePath);
|
|
21
|
+
const destination = path.resolve(process.cwd(), destinationPath);
|
|
22
|
+
// Check if the destination file already exists
|
|
23
|
+
if (!fs.existsSync(destination)) {
|
|
24
|
+
try {
|
|
25
|
+
// Copy the source file to the destination
|
|
26
|
+
fs.copyFileSync(source, destination);
|
|
27
|
+
console.log(`${destinationPath} has been successfully created.`);
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
console.error(`Error copying ${destinationPath}:`, error);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
console.log(`${destinationPath} already exists. Merge configurations manually if needed.`);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
setupStylelintConfig();
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@salesforce-ux/slds-linter",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "SLDS Linter with both stylelint and eslint together",
|
|
5
|
+
"main": "index.mjs",
|
|
6
|
+
"workspaces": [
|
|
7
|
+
"packages/*"
|
|
8
|
+
],
|
|
9
|
+
"access": "public",
|
|
10
|
+
"files": [
|
|
11
|
+
"build/",
|
|
12
|
+
"README.md"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "rollup --config rollup.config.js",
|
|
16
|
+
"setup-lint": "node ./build/setup.js"
|
|
17
|
+
},
|
|
18
|
+
"type": "module",
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@salesforce-ux/eslint-plugin-sf-sds": "latest",
|
|
21
|
+
"@salesforce-ux/stylelint-sds": "latest"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"eslint SDS",
|
|
25
|
+
"stylelint SDS",
|
|
26
|
+
"salesforce",
|
|
27
|
+
"sds linter"
|
|
28
|
+
],
|
|
29
|
+
"author": "Kishore Nemalipuri",
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@rollup/plugin-typescript": "^12.1.2"
|
|
33
|
+
}
|
|
34
|
+
}
|