-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: update dependency to eslint v9 @W-17448473 (#141)
* feat!: update dependency to eslint v9 @W-17448473 BREAKING CHANGE: dropping support for ESLint v7 and v8. The only supported option is ESLint v9
- Loading branch information
1 parent
9508645
commit be4ee1c
Showing
24 changed files
with
939 additions
and
938 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,70 +12,100 @@ Note that `@lwc/eslint-plugin-lwc`, `@salesforce/eslint-plugin-lightning`, `esli | |
|
||
## Usage | ||
|
||
Add the appropriate [configuration](#Configurations) to the `extends` field in your configuration. | ||
> [!IMPORTANT] | ||
> Starting with v4.0.0, @salesforce/eslint-config-lwc only supports `eslint@v9`. Use `@salesforce/[email protected]` for older versions of eslint. | ||
This repo exports the configurations as an array of config objects. [Apply](https://eslint.org/docs/latest/use/configure/combine-configs#apply-a-config-array) the appropriate [configuration](#Configurations) into your configuration using the spread operator. | ||
|
||
Example of `eslint.config.js`: | ||
|
||
Example of `.eslintrc`: | ||
```js | ||
const lwcConfig = require('@salesforce/eslint-config-lwc'); | ||
|
||
```json | ||
{ | ||
"extends": ["@salesforce/eslint-config-lwc/recommended"] | ||
} | ||
module.exports = [...lwcConfig.configs.recommended]; | ||
``` | ||
|
||
For more details about configuration, please refer to the dedicated section in the ESLint documentation: https://eslint.org/docs/user-guide/configuring#using-a-shareable-configuration-package | ||
|
||
### [Experimental] Usage with TypeScript | ||
|
||
To enable working with TypeScript projects, install `@babel/preset-typescript` as a dependency, and extend any of the TypeScript-enabled [configurations](#configurations) (any config ending in `-ts`). | ||
To enable working with TypeScript projects, install `@babel/preset-typescript` as a dependency, and apply any of the TypeScript-enabled [configurations](#configurations) (any config ending in `Ts`). | ||
|
||
Note that these configs use [@babel/eslint-parser](https://www.npmjs.com/package/@babel/eslint-parser), and compatibility with [@typescript-eslint/parser](https://npmjs.com/package/@typescript-eslint/parser) is not guaranteed. | ||
|
||
> [!IMPORTANT] | ||
> While these configs are capable of parsing TypeScript files, not all rules support all TypeScript language features. For example, using type assertions (`variable as Type`) will break many rules. | ||
Example `.eslintrc`: | ||
Example `eslint.config.js`: | ||
|
||
```json | ||
{ | ||
"extends": ["@salesforce/eslint-config-lwc/recommended-ts"] | ||
} | ||
```js | ||
const lwcConfig = require('@salesforce/eslint-config-lwc'); | ||
|
||
module.exports = [...lwcConfig.configs.recommendedTs]; | ||
``` | ||
|
||
## Configurations | ||
|
||
This package exposes multiple configurations for your usage. Each configuration listed below is available for both JavaScript projects and TypeScript projects (when using `-ts` suffix). | ||
This package exposes multiple configurations for your usage. Each configuration listed below is available for both JavaScript projects and TypeScript projects (when using `Ts` suffix). | ||
|
||
### `@salesforce/eslint-config-lwc/base` | ||
### Base | ||
|
||
**Goal:** | ||
Prevent common pitfalls with LWC, and enforce other Salesforce platform restrictions. | ||
|
||
**Rules:** | ||
[_LWC specific rules_](https://github.com/salesforce/eslint-plugin-lwc/blob/master/README.md#lwc) only. | ||
|
||
**TypeScript:** Use `@salesforce/eslint-config-lwc/base-ts` to use this config in TypeScript projects. | ||
**Usage:** | ||
|
||
```js | ||
// eslint.config.js | ||
const lwcConfig = require('@salesforce/eslint-config-lwc'); | ||
|
||
module.exports = [...lwcConfig.configs.base]; | ||
``` | ||
|
||
### `@salesforce/eslint-config-lwc/recommended` | ||
**TypeScript:** Use `configs.baseTs` to use this config in TypeScript projects. | ||
|
||
### Recommended`@salesforce/eslint-config-lwc/recommended` | ||
|
||
**Goal:** | ||
Prevent common Javascript pitfalls and enforce all best practices. | ||
|
||
**Rules:** | ||
`@salesforce/eslint-config-lwc/base` rules + Most of the base [_Potential errors_](https://eslint.org/docs/rules/#possible-errors) rules + Some of the [_Best Practices_](https://eslint.org/docs/rules/#best-practices) rules + [_LWC Best Practices_](https://github.com/salesforce/eslint-plugin-lwc/blob/master/README.md#best-practices). | ||
Base rules + Most of the base [_Potential errors_](https://eslint.org/docs/rules/#possible-errors) rules + Some of the [_Best Practices_](https://eslint.org/docs/rules/#best-practices) rules + [_LWC Best Practices_](https://github.com/salesforce/eslint-plugin-lwc/blob/master/README.md#best-practices). | ||
|
||
**Usage:** | ||
|
||
```js | ||
// eslint.config.js | ||
const lwcConfig = require('@salesforce/eslint-config-lwc'); | ||
|
||
**TypeScript:** Use `@salesforce/eslint-config-lwc/recommended-ts` to use this config in TypeScript projects. | ||
module.exports = [...lwcConfig.configs.recommended]; | ||
``` | ||
|
||
### `@salesforce/eslint-config-lwc/extended` | ||
**TypeScript:** Use `configs.recommendedTs` to use this config in TypeScript projects. | ||
|
||
### Extended | ||
|
||
**Goal:** | ||
Restrict usage of some Javascript language features known to be slow after the _COMPAT_ transformation. LWC runs in _COMPAT_ mode on older browsers (eg. IE11). To support new Javascript syntax and language features on older browser the LWC compiler transforms LWC modules. This linting configuration targets patterns known to be slow in _COMPAT_ mode. | ||
|
||
**Rules:** | ||
`@salesforce/eslint-config-lwc/recommended` rules + restrict usage of some slow patterns in [_COMPAT_](https://github.com/salesforce/eslint-plugin-lwc/blob/master/README.md#compat-performance). | ||
Recommended rules + restrict usage of some slow patterns in [_COMPAT_](https://github.com/salesforce/eslint-plugin-lwc/blob/master/README.md#compat-performance). | ||
|
||
**Usage:** | ||
|
||
```js | ||
// eslint.config.js | ||
const lwcConfig = require('@salesforce/eslint-config-lwc'); | ||
|
||
**TypeScript:** Use `@salesforce/eslint-config-lwc/extended-ts` to use this config in TypeScript projects. | ||
module.exports = [...lwcConfig.configs.extended]; | ||
``` | ||
|
||
### `@salesforce/eslint-config-lwc/i18n` | ||
**TypeScript:** Use `configs.extendedTs` to use this config in TypeScript projects. | ||
|
||
### i18n `@salesforce/eslint-config-lwc/i18n` | ||
|
||
**Goal:** | ||
Promote usage of `@salesforce/i18n-service` over 3rd parties, promote internationalization (I18N) best practices. | ||
|
@@ -85,17 +115,18 @@ Promote usage of `@salesforce/i18n-service` over 3rd parties, promote internatio | |
|
||
**Usage:** | ||
|
||
Add the `i18n` configuration to the `extends` field in your `.eslintrc` configuration file, for example: | ||
Add the `i18n` configuration to the `extends` field in your `eslint.config.js` configuration file, for example: | ||
|
||
```js | ||
// eslint.config.js | ||
const lwcConfig = require('@salesforce/eslint-config-lwc'); | ||
|
||
```json | ||
{ | ||
"extends": ["@salesforce/eslint-config-lwc/recommended", "@salesforce/eslint-config-lwc/i18n"] | ||
} | ||
module.exports = [...lwcConfig.configs.recommended, ...lwcConfig.configs.i18n]; | ||
``` | ||
|
||
**TypeScript:** Use `@salesforce/eslint-config-lwc/i18n-ts` to use this config in TypeScript projects. | ||
**TypeScript:** Use `configs.i18nTs` to use this config in TypeScript projects. | ||
|
||
### `@salesforce/eslint-config-lwc/ssr` | ||
### Ssr | ||
|
||
**Goal:** | ||
Promote writing server-side-rendering friendly components. We only recommend using this configuration if your components are running in experiences supporting LWC server-side-rendering. | ||
|
@@ -105,12 +136,11 @@ Promote writing server-side-rendering friendly components. We only recommend usi | |
|
||
**Usage:** | ||
|
||
Add the `ssr` configuration to the `extends` field in your `.eslintrc` configuration file, for example: | ||
```js | ||
// eslint.config.js | ||
const lwcConfig = require('@salesforce/eslint-config-lwc'); | ||
|
||
```json | ||
{ | ||
"extends": ["@salesforce/eslint-config-lwc/recommended", "@salesforce/eslint-config-lwc/ssr"] | ||
} | ||
module.exports = [...lwcConfig.configs.ssr]; | ||
``` | ||
|
||
**TypeScript:** Use `@salesforce/eslint-config-lwc/ssr-ts` to use this config in TypeScript projects. | ||
**TypeScript:** Use `configs.ssrTs` to use this config in TypeScript projects. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
'use strict'; | ||
const globals = require('globals'); | ||
const js = require('@eslint/js'); | ||
module.exports = [ | ||
js.configs.recommended, | ||
{ | ||
languageOptions: { | ||
globals: { | ||
...globals.mocha, | ||
...globals.node, | ||
}, | ||
sourceType: 'commonjs', | ||
}, | ||
rules: { | ||
strict: ['error', 'global'], | ||
}, | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.