@salesforce-ux/slds-linter 1.0.0 → 1.0.2

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 CHANGED
@@ -2,33 +2,29 @@
2
2
 
3
3
  ## Overview
4
4
 
5
- SLDS Linter provides custom linting rules built for Salesforce Lightning Design System 2 (SLDS 2 beta). Lint your components against SLDS 2 best practices to ensure they adhere to the latest styling standards.
5
+ SLDS Linter is an installable npm package that analyzes your code against Salesforce Lightning Design System 2 (SLDS 2) rules and offers suggestions to better align your code with SLDS 2 guidelines. SLDS Linter can also apply the suggestions in bulk across your repository and automatically fix your code.
6
6
 
7
- SLDS Linter checks your Aura and Lightning web components' CSS and markup files to identify styling issues that you can fix for SLDS 2 compatibility. SLDS Linter helps you maintain consistent styling and identify common issues with custom Lightning components.
7
+ For detailed information about SLDS Linter, see the [SLDS Linter developer guide](https://developer.salesforce.com/docs/platform/slds-linter/overview).
8
8
 
9
9
  ## Features
10
10
 
11
- SLDS Linter is a custom-built linting solution based on open source [ESLint](https://eslint.org/) with CSS support. It supports linting for both types of Lightning components.
11
+ SLDS Linter is a custom-built linting solution based on open-source [ESLint](https://eslint.org/) projects. It supports linting for both types of Lightning components.
12
12
 
13
- SLDS Linter runs on these types of files.
13
+ - Lightning web components: HTML and Cascading Style Sheet (CSS) files
14
+ - Aura components: Component (CMP) and CSS files
14
15
 
15
- - Lightning web component *.html markup and Cascading Style Sheet (CSS) files
16
- - Aura component *.cmp markup and CSS files
16
+ Run SLDS Linter in a terminal window or in Visual Studio (VS) Code. We recommend running in VS Code.
17
17
 
18
- You can run SLDS Linter in a terminal window or in Visual Studio (VS) Code. We recommend running in VS Code.
19
-
20
- Follow these instructions to integrate SLDS Linter into your project.
18
+ Follow these steps to integrate SLDS Linter into your project.
21
19
 
22
20
  ---
23
21
 
24
22
  ## Prerequisites
25
23
 
26
- Install these items if they aren't installed already.
27
-
28
- - [VS Code](https://code.visualstudio.com/)
29
- - [SARIF Viewer](https://marketplace.visualstudio.com/items?itemName=MS-SarifVSCode.sarif-viewer) VS Code extension. This extension enables you to view SLDS Linter violation reports.
30
- - [Node.js](https://nodejs.org/)
31
- - The minimum supported version is **v18.18.0**
24
+ - Install [VS Code](https://code.visualstudio.com/)
25
+ - Install the [SARIF Viewer](https://marketplace.visualstudio.com/items?itemName=MS-SarifVSCode.sarif-viewer) VS Code extension. With this extension, you can view SLDS Linter violation reports.
26
+ - Install [Node.js](https://nodejs.org/)
27
+ - The minimum supported version is **v18.4.0**
32
28
  - We recommend using the latest [Active LTS](https://nodejs.org/en/about/previous-releases) version of Node.js.
33
29
 
34
30
  ## Install SLDS Linter
@@ -62,7 +58,7 @@ Commands:
62
58
 
63
59
  Run SLDS Linter against your project in the VS Code terminal to check for any violations and generate a SARIF report. This report helps you identify the components you need to update.
64
60
 
65
- In your project root directory, follow these steps.
61
+ In your project root directory, follow these instructions.
66
62
 
67
63
  1. In your project in VS Code, open Terminal.
68
64
  2. Run `npx @salesforce-ux/slds-linter lint`.
@@ -73,12 +69,12 @@ In your project root directory, follow these steps.
73
69
  5. Open the generated `.sarif` report file.
74
70
  6. Make a note of how many components SLDS Linter has identified that you must update.
75
71
  7. (Optional) To automatically fix validation errors in bulk, run the `lint` command with the `fix` option, `npx @salesforce-ux/slds-linter lint --fix`.
76
- 8. (Optional) To emit the configuration files used by `slds-linter`, run `npx @salesforce-ux/slds-linter emit` in your component source directory. Note that this command defaults to current working directory. These configuration files are discovered by your VS Code ESLint and Stylelint extensions to display squiggly lines in CSS and HTML files when opened in your code editor.
72
+ 8. (Optional) To emit the configuration files used by `slds-linter`, run `npx @salesforce-ux/slds-linter emit` in your component source directory. Note that this command defaults to current working directory. These configuration files are discovered by your VS Code ESLint extension to display squiggly lines in HTML, CSS and CMP files when opened in your code editor.
77
73
 
78
74
 
79
75
  ### Troubleshoot SARIF Viewer Navigation
80
76
 
81
- If the SARIF viewer doesn't automatically go to the line of code when you click on an error or warning, follow these steps.
77
+ If the SARIF viewer doesnt automatically go to the line of code when you click on an error or warning, follow these steps.
82
78
 
83
79
  1. In the SARIF viewer pop-up window, click Locate.
84
80
  2. In the file explorer or code editor, locate the file.
@@ -89,7 +85,7 @@ If the SARIF viewer doesn't automatically go to the line of code when you click
89
85
 
90
86
  Use these commands to run SLDS Linter rules. Review the output violations and fix any issues to uplift your code to SLDS best practices.
91
87
 
92
- - `npx @salesforce-ux/slds-linter lint`. Runs ESlint and Stylelint rules on HTML, CSS, and CMP files.
88
+ - `npx @salesforce-ux/slds-linter lint`. Runs ESLint rules on HTML, CSS, and CMP files.
93
89
  - `npx @salesforce-ux/slds-linter report`. Generates a SARIF report for static analysis.
94
90
  - `npx @salesforce-ux/slds-linter emit`. Emits the configuration files used by `slds-linter`. Defaults to current directory.
95
91
 
@@ -101,17 +97,16 @@ These options are available on SLDS Linter commands.
101
97
  | `-o, --output <path>` | Output directory for reports (defaults to current directory) | `report` |
102
98
  | `--fix` | Automatically fix problems | `lint` |
103
99
  | `--config-eslint <path>` | Path to eslint config file | `lint`, `report`|
104
- | `--editor <editor>` | Editor to open files with (e.g., vscode, atom, sublime). Auto-detects if not specified | `lint` |
105
- | `--format <type>` | Output format (sarif, csv). Defaults to sarif | `report` |
100
+ | `--editor <editor>` | Editor to open files with (e.g., vscode, atom, sublime). Defaults to vscode | `lint` |
106
101
 
107
102
  To view help for these options, add `--help` to each command. For example, run `npx @salesforce-ux/slds-linter lint --help` to see which options you can use with `lint`.
108
103
 
109
104
 
110
105
  ## Extensions
111
106
 
112
- To enhance your linting and error analysis experience, we recommend that you install these VS Code extensions. These extensions significantly improve your development workflow and make it easier to navigate and address linting issues.
107
+ To enhance your linting and error analysis experience, we recommend that you install these VS Code extensions. This extension significantly improves your development workflow and makes it easier to navigate and address linting issues.
113
108
 
114
- - *[ESLint Extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)*: Essential for JavaScript, TypeScript, HTML, and CSS linting, it checks your code and flags any violations of the ESLint rules with squiggly lines to show you what to fix.
109
+ - *[ESLint Extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)*: Essential for JavaScript, TypeScript, HTML, CMP, and CSS linting. It checks your code and highlights any violations of the ESLint rules with squiggly lines.
115
110
 
116
111
  ## Best Practices
117
112
 
@@ -166,119 +161,5 @@ Linting all `.html` and `.cmp` files:
166
161
  npx @salesforce-ux/slds-linter lint "**/*.{html,cmp}"
167
162
  ```
168
163
 
169
- For any questions or issues, open an issue in this repository.
170
-
171
- ## Node.js API
172
-
173
- The SLDS Linter provides a programmatic API for Node.js applications. This allows you to integrate the linter directly into your build process or other tools without relying on the command-line interface.
174
-
175
- ### Installation
176
-
177
- ```bash
178
- npm install @salesforce-ux/slds-linter
179
- ```
180
-
181
- ### Usage
182
-
183
- ```javascript
184
- import { lint, report } from '@salesforce-ux/slds-linter/executor';
185
-
186
- // Lint files in a directory
187
- const results = await lint({
188
- directory: './src',
189
- fix: false // Set to true to auto-fix issues where possible
190
- });
191
-
192
- console.log(`Found ${results.length} files with issues`);
193
-
194
- // Generate a report
195
- const reportStream = await report({
196
- directory: './src',
197
- format: 'sarif'
198
- }, results); // Pass the lint results as second parameter
199
-
200
- // Process the report stream
201
- let reportData = '';
202
- reportStream.on('data', chunk => {
203
- reportData += chunk;
204
- });
205
-
206
- reportStream.on('end', () => {
207
- console.log('Report:', reportData);
208
- });
209
- ```
210
-
211
- ### TypeScript Support
212
-
213
- The Node.js API includes comprehensive TypeScript type definitions. You can import both the API functions and their associated types:
214
-
215
- ```typescript
216
- // Import from the executor entrypoint
217
- import {
218
- lint,
219
- report,
220
- type LintConfig,
221
- type ReportConfig,
222
- type LintResult
223
- } from '@salesforce-ux/slds-linter/executor';
224
-
225
- // Define configuration with typed interface
226
- const config: LintConfig = {
227
- directory: './src',
228
- fix: false
229
- };
230
-
231
- // Results will be properly typed
232
- const results: LintResult[] = await lint(config);
233
- ```
234
-
235
- All relevant types (such as `LintConfig`, `ReportConfig`, `LintResult`, etc.) are exported from the executor entrypoint for use in your TypeScript projects.
236
-
237
- ### API Reference
238
-
239
- The Node.js API provides the following methods:
240
-
241
- #### `lint(options)`
242
-
243
- Lints files for SLDS compliance.
244
-
245
- **Options:**
246
- - `directory`: Path to directory to scan for files to lint
247
- - `fix`: Boolean indicating whether to automatically fix issues when possible
248
- - `configStylelint`: Path to custom stylelint configuration file
249
- - `configEslint`: Path to custom eslint configuration file
250
-
251
- **Returns:** Promise resolving to an array of result objects containing linting issues
252
-
253
- #### `report(options)`
254
-
255
- Generates a report of linting issues.
256
-
257
- **Options:**
258
- - `directory`: Path to directory to scan (if `results` is not provided)
259
- - `format`: Report format ('sarif' or 'csv')
260
- - `configStylelint`: Path to custom stylelint configuration file (if `directory` is used)
261
- - `configEslint`: Path to custom eslint configuration file (if `directory` is used)
262
-
263
- **Parameters:**
264
- - `options`: Configuration options as detailed above
265
- - `results`: Optional array of lint results (from `lint()`). If not provided, will run lint on the specified directory
266
-
267
- **Returns:** A readable stream containing the report data
268
-
269
- ### Utility Functions
270
-
271
- The package also provides utility functions to help with configuration:
272
-
273
- #### `normalizeConfig(options)`
274
-
275
- Normalizes configuration options with default values. Import from `@salesforce-ux/slds-linter/utils/config-utils`.
276
-
277
- **Options:** Same as the options for `lint()` or `report()`
278
-
279
- **Returns:** A normalized configuration object with default values applied
280
-
281
- ### Examples
282
-
283
- For complete examples, see the [examples directory](./examples/).
284
164
 
165
+ For any questions or issues, open an issue in this repository.
package/build/index.js CHANGED
@@ -19,7 +19,7 @@ process.on("uncaughtException", (error) => {
19
19
  var program = new Command();
20
20
  program.name("npx @salesforce-ux/slds-linter@latest").showHelpAfterError();
21
21
  function registerVersion() {
22
- program.description("SLDS Linter CLI tool for linting styles and components").version("1.0.0");
22
+ program.description("SLDS Linter CLI tool for linting styles and components").version("1.0.2");
23
23
  }
24
24
  registerLintCommand(program);
25
25
  registerReportCommand(program);
@@ -137,7 +137,7 @@ var rule_messages_default = {
137
137
  },
138
138
  "no-hardcoded-values-slds2": {
139
139
  "description": "Replace static values with SLDS 2 styling hooks. For more information, look up design tokens on lightningdesignsystem.com.",
140
- "url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-hardcoded-value",
140
+ "url": "https://developer.salesforce.com/docs/platform/slds-linter/guide/reference-rules.html#no-hardcoded-values-slds2",
141
141
  "type": "suggestion",
142
142
  "messages": {
143
143
  "hardcodedValue": "Consider replacing the {{oldValue}} static value with an SLDS 2 styling hook that has a similar value: {{newValue}}.",
@@ -156,10 +156,10 @@ var rule_messages_default = {
156
156
 
157
157
  // src/services/config.resolver.ts
158
158
  var DEFAULT_ESLINT_CONFIG_PATH = resolvePath("@salesforce-ux/eslint-plugin-slds/config", import.meta);
159
- var ESLINT_VERSION = "9.35.0";
160
- var LINTER_CLI_VERSION = "1.0.0";
159
+ var ESLINT_VERSION = "9.36.0";
160
+ var LINTER_CLI_VERSION = "1.0.2";
161
161
  var getRuleDescription = (ruleId) => {
162
- const ruleIdWithoutNameSpace = `${ruleId}`.replace(/\@salesforce-ux\//, "");
162
+ const ruleIdWithoutNameSpace = `${ruleId}`.replace(/\@salesforce-ux\//, "").replace(/^slds\//, "");
163
163
  return rule_messages_default[ruleIdWithoutNameSpace]?.description || "--";
164
164
  };
165
165
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce-ux/slds-linter",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "SLDS Linter CLI tool for linting styles and components",
5
5
  "keywords": [
6
6
  "lightning design system linter",
@@ -29,7 +29,7 @@
29
29
  ],
30
30
  "bin": "build/index.js",
31
31
  "dependencies": {
32
- "@salesforce-ux/eslint-plugin-slds": "1.0.0",
32
+ "@salesforce-ux/eslint-plugin-slds": "1.0.2",
33
33
  "@typescript-eslint/eslint-plugin": "^8.36.0",
34
34
  "@typescript-eslint/parser": "^8.36.0",
35
35
  "chalk": "^4.1.2",