Skip to content

Commit cfa1bed

Browse files
committed
Adding ESLint version-specific configuration docs
1 parent 981a313 commit cfa1bed

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

README.md

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,35 @@ $ npm install --save-dev @salesforce/eslint-plugin-lwc-graph-analyzer
2424

2525
## Configuration
2626

27-
Here's an example snippet of a `.eslintrc.json` configuration file, that will configure the `eslint-plugin-lwc-graph-analyzer` plugin. Extending the `plugin:@salesforce/lwc-graph-analyzer/recommended` ESLint configuration will enable static analysis on all `.js` and `.html` files used in your Lightning web components.
27+
ESLint version-specific configuration examples are provided below. Here are some additional considerations for configuring the plugin.
28+
29+
- In an SFDX project, you would most commonly add your configuration at the root of your LWC "tree"—which by default resides at `force-app/main/default/lwc/`—since the plugin's analysis applies specifically to Lightning web components.
30+
- Extending the appropriate `recommended` config based on your ESLint version will enable static analysis on all `.js` and `.html` files used in your Lightning web components.
31+
32+
### ESLint >= 9
33+
34+
The default configurations are now in the flat config format supported by ESLint 9 and beyond. Here's how to include the `recommended` config in your flat config:
35+
36+
```javascript
37+
// eslint.config.mjs
38+
import js from '@eslint/js';
39+
import lwcGraphAnalyzerPlugin from '@salesforce/eslint-plugin-lwc-graph-analyzer';
40+
41+
export default [
42+
{ plugins: { '@salesforce/lwc-graph-analyzer': lwcGraphAnalyzerPlugin } },
43+
js.configs.recommended,
44+
lwcGraphAnalyzerPlugin.configs.recommended
45+
];
46+
```
47+
48+
### ESLint < 9
49+
50+
Configurations for legacy ESLint have moved to `-legacy` extensions. Here's an `.eslintrc.json` configuration file that will configure the `eslint-plugin-lwc-graph-analyzer` plugin with the `recommended-legacy` config:
2851

2952
```json
3053
{
31-
"extends": ["eslint:recommended", "plugin:@salesforce/lwc-graph-analyzer/recommended"]
54+
"extends": ["eslint:recommended", "plugin:@salesforce/lwc-graph-analyzer/recommended-legacy"]
3255
}
3356
```
3457

35-
In an SFDX project, you would most commonly add this configuration at the root of your LWC "tree"—which by default resides at `force-app/main/default/lwc/`—since the plugin's analysis applies specifically to Lightning web components.
36-
3758
**Note:** If you have a `.eslintignore` configuration in your project, do _not_ add an entry to ignore HTML files. This will cause the plugin to skip linting on LWC bundles that include HTML templates. There are a number of Komaci-based static analysis rules that apply specifically to the HTML template of a Lightning web component bundle.

0 commit comments

Comments
 (0)