You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/lexical-eslint-plugin/README.md
+87-3Lines changed: 87 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,8 @@
2
2
3
3
This ESLint plugin enforces the [Lexical $function convention](https://lexical.dev/docs/intro#reading-and-updating-editor-state).
4
4
5
+
**ESLint Compatibility:** This plugin supports ESLint 7, 8, 9, and 10+. Both legacy (`.eslintrc`) and flat config (`eslint.config.js`) formats are supported.
6
+
5
7
## Installation
6
8
7
9
Assuming you already have ESLint installed, run:
@@ -10,20 +12,54 @@ Assuming you already have ESLint installed, run:
10
12
npm install @lexical/eslint-plugin --save-dev
11
13
```
12
14
13
-
Then extend the recommended eslint config:
15
+
### ESLint 9+ (Flat Config)
16
+
17
+
If you're using ESLint 9 or later with the new flat config format (required in ESLint 10+), add this to your `eslint.config.js`:
18
+
19
+
```js
20
+
importlexicalfrom'@lexical/eslint-plugin';
21
+
22
+
exportdefault [
23
+
// ... other configs
24
+
lexical.configs['flat/recommended']
25
+
];
26
+
```
27
+
28
+
### ESLint 7-8 (Legacy Config)
29
+
30
+
For ESLint 7 or 8 with the legacy `.eslintrc` format, extend the recommended config:
14
31
15
32
```js
16
33
{
17
34
"extends": [
18
35
// ...
19
-
"plugin:@lexical/recommended"
36
+
"plugin:@lexical/legacy-recommended"
20
37
]
21
38
}
22
39
```
23
40
41
+
> **Note:** The `recommended` and `all` configs are currently aliases to `legacy-recommended` and `legacy-all`. `all` and `recommended` will be migrated to flat config in a future version.
42
+
24
43
### Custom Configuration
25
44
26
-
If you want more fine-grained configuration, you can instead add a snippet like this to your ESLint configuration file:
45
+
#### ESLint 9+ (Flat Config)
46
+
47
+
```js
48
+
importlexicalfrom'@lexical/eslint-plugin';
49
+
50
+
exportdefault [
51
+
{
52
+
plugins: {
53
+
'@lexical': lexical
54
+
},
55
+
rules: {
56
+
'@lexical/rules-of-lexical':'error'
57
+
}
58
+
}
59
+
];
60
+
```
61
+
62
+
#### ESLint 7-8 (Legacy Config)
27
63
28
64
```js
29
65
{
@@ -53,6 +89,39 @@ If the string begins with a `"^"` or `"("` then it is treated as a RegExp,
53
89
otherwise it will be an exact match. A string may also be used instead
54
90
of an array of strings.
55
91
92
+
#### ESLint 9+ (Flat Config)
93
+
94
+
```js
95
+
importlexicalfrom'@lexical/eslint-plugin';
96
+
97
+
exportdefault [
98
+
{
99
+
plugins: {
100
+
'@lexical': lexical
101
+
},
102
+
rules: {
103
+
'@lexical/rules-of-lexical': [
104
+
'error',
105
+
{
106
+
isDollarFunction: ['^\\$[a-z_]'],
107
+
isIgnoredFunction: [],
108
+
isLexicalProvider: [
109
+
'parseEditorState',
110
+
'read',
111
+
'registerCommand',
112
+
'registerNodeTransform',
113
+
'update'
114
+
],
115
+
isSafeDollarFunction: ['^\\$is']
116
+
}
117
+
]
118
+
}
119
+
}
120
+
];
121
+
```
122
+
123
+
#### ESLint 7-8 (Legacy Config)
124
+
56
125
```js
57
126
{
58
127
"plugins": [
@@ -111,6 +180,21 @@ These \$functions are considered safe to call from anywhere, generally
111
180
these functions are runtime type checks that do not depend on any other
112
181
state.
113
182
183
+
## Testing
184
+
185
+
To verify that the plugin works with different ESLint versions, run the integration tests:
0 commit comments