@qq99/eslint-plugin-solid 0.18.0-no-reactive-read-in-effect-callback.0
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/LICENSE +21 -0
- package/README.md +289 -0
- package/dist/chunk-4UZNJ5MS.mjs +32 -0
- package/dist/chunk-4UZNJ5MS.mjs.map +1 -0
- package/dist/chunk-EBU4C5NV.mjs +77 -0
- package/dist/chunk-EBU4C5NV.mjs.map +1 -0
- package/dist/chunk-LE6SW2M3.mjs +6231 -0
- package/dist/chunk-LE6SW2M3.mjs.map +1 -0
- package/dist/chunk-MHDQJMLE.mjs +39 -0
- package/dist/chunk-MHDQJMLE.mjs.map +1 -0
- package/dist/configs/recommended.d.mts +109 -0
- package/dist/configs/recommended.d.ts +109 -0
- package/dist/configs/recommended.js +5877 -0
- package/dist/configs/recommended.js.map +1 -0
- package/dist/configs/recommended.mjs +5 -0
- package/dist/configs/recommended.mjs.map +1 -0
- package/dist/configs/typescript.d.mts +103 -0
- package/dist/configs/typescript.d.ts +103 -0
- package/dist/configs/typescript.js +6246 -0
- package/dist/configs/typescript.js.map +1 -0
- package/dist/configs/typescript.mjs +6 -0
- package/dist/configs/typescript.mjs.map +1 -0
- package/dist/configs/v2-strict.d.mts +130 -0
- package/dist/configs/v2-strict.d.ts +130 -0
- package/dist/configs/v2-strict.js +6317 -0
- package/dist/configs/v2-strict.js.map +1 -0
- package/dist/configs/v2-strict.mjs +7 -0
- package/dist/configs/v2-strict.mjs.map +1 -0
- package/dist/configs/v2.d.mts +127 -0
- package/dist/configs/v2.d.ts +127 -0
- package/dist/configs/v2.js +6289 -0
- package/dist/configs/v2.js.map +1 -0
- package/dist/configs/v2.mjs +6 -0
- package/dist/configs/v2.mjs.map +1 -0
- package/dist/index.d.mts +740 -0
- package/dist/index.d.ts +740 -0
- package/dist/index.js +6365 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +42 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +109 -0
- package/src/compat.ts +53 -0
- package/src/configs/recommended.ts +48 -0
- package/src/configs/typescript.ts +21 -0
- package/src/configs/v2-strict.ts +28 -0
- package/src/configs/v2.ts +68 -0
- package/src/deps.d.ts +1 -0
- package/src/index.ts +29 -0
- package/src/plugin.ts +92 -0
- package/src/rules/components-return-once.ts +209 -0
- package/src/rules/event-handlers.ts +397 -0
- package/src/rules/imports.ts +338 -0
- package/src/rules/jsx-no-duplicate-props.ts +110 -0
- package/src/rules/jsx-no-script-url.ts +61 -0
- package/src/rules/jsx-no-undef.ts +230 -0
- package/src/rules/jsx-uses-vars.ts +66 -0
- package/src/rules/no-accessor-as-prop.ts +147 -0
- package/src/rules/no-array-handlers.ts +57 -0
- package/src/rules/no-boolean-enumerated-attribute.ts +209 -0
- package/src/rules/no-browser-globals-in-server-function.ts +108 -0
- package/src/rules/no-destructure.ts +245 -0
- package/src/rules/no-innerhtml.ts +143 -0
- package/src/rules/no-invalid-server-capture.ts +104 -0
- package/src/rules/no-module-scope-reactive-primitive.ts +69 -0
- package/src/rules/no-proxy-apis.ts +96 -0
- package/src/rules/no-react-deps.ts +68 -0
- package/src/rules/no-react-specific-props.ts +60 -0
- package/src/rules/no-reactive-read-in-effect-callback.ts +570 -0
- package/src/rules/no-restated-default-options.ts +96 -0
- package/src/rules/no-single-arg-create-effect.ts +56 -0
- package/src/rules/no-store-mutation-outside-setter.ts +137 -0
- package/src/rules/no-unknown-namespaces.ts +140 -0
- package/src/rules/no-unused-signal.ts +119 -0
- package/src/rules/no-write-in-pure-computation.ts +231 -0
- package/src/rules/prefer-classlist.ts +93 -0
- package/src/rules/prefer-for.ts +93 -0
- package/src/rules/prefer-onSettled-for-side-effects.ts +101 -0
- package/src/rules/prefer-show.ts +102 -0
- package/src/rules/prefer-structured-class.ts +117 -0
- package/src/rules/reactivity.ts +1730 -0
- package/src/rules/removed-api.ts +212 -0
- package/src/rules/require-async-server-function.ts +122 -0
- package/src/rules/self-closing-comp.ts +150 -0
- package/src/rules/style-prop.ts +140 -0
- package/src/rules/valid-use-server.ts +192 -0
- package/src/rules/validate-jsx-nesting.ts +1 -0
- package/src/utils/reactive-imports.ts +382 -0
- package/src/utils/reactive-types.ts +272 -0
- package/src/utils/reactive-values.ts +162 -0
- package/src/utils.ts +442 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Josh Wilson
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
<p>
|
|
2
|
+
<img width="100%" src="https://assets.solidjs.com/banner?type=ESLint%20Plugin&background=tiles&project=%20" alt="Solid ESLint Extension">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
# Solid ESLint Plugin
|
|
6
|
+
|
|
7
|
+
[](https://npmjs.com/package/eslint-plugin-solid)
|
|
8
|
+
[](https://github.com/solidjs-community/eslint-plugin-solid)
|
|
9
|
+

|
|
10
|
+
[](https://github.com/solidjs-community/eslint-plugin-solid/actions/workflows/ci.yml)
|
|
11
|
+
|
|
12
|
+
This package contains [Solid](https://www.solidjs.com/)-specific linting rules for ESLint. It can
|
|
13
|
+
ease Solid's learning curve by finding and fixing problems around Solid's reactivity system, and can
|
|
14
|
+
migrate some React patterns to Solid code.
|
|
15
|
+
|
|
16
|
+
It supports both Solid 1.x and Solid 2.0 APIs, requires ESLint v9 or v10 and Node.js 22+, and also
|
|
17
|
+
runs under [Oxlint](#oxlint) as a JS plugin.
|
|
18
|
+
|
|
19
|
+
<!-- doc-gen TOC -->
|
|
20
|
+
- [Solid ESLint Plugin](#solid-eslint-plugin)
|
|
21
|
+
- [Installation](#installation)
|
|
22
|
+
- [Configuration](#configuration)
|
|
23
|
+
- [TypeScript](#typescript)
|
|
24
|
+
- [Solid 2.0](#solid-20)
|
|
25
|
+
- [Manual Configuration](#manual-configuration)
|
|
26
|
+
- [Oxlint](#oxlint)
|
|
27
|
+
- [Rules](#rules)
|
|
28
|
+
- [Troubleshooting](#troubleshooting)
|
|
29
|
+
- [Versioning](#versioning)
|
|
30
|
+
<!-- end-doc-gen -->
|
|
31
|
+
|
|
32
|
+
## Installation
|
|
33
|
+
|
|
34
|
+
Install `eslint` and `eslint-plugin-solid` locally.
|
|
35
|
+
|
|
36
|
+
```sh
|
|
37
|
+
npm install --save-dev eslint eslint-plugin-solid
|
|
38
|
+
# or
|
|
39
|
+
pnpm add --save-dev eslint eslint-plugin-solid
|
|
40
|
+
yarn add --dev eslint eslint-plugin-solid
|
|
41
|
+
|
|
42
|
+
# optional, to create an ESLint config file
|
|
43
|
+
npx eslint --init
|
|
44
|
+
# or
|
|
45
|
+
pnpm eslint --init
|
|
46
|
+
yarn eslint --init
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
If you're using VSCode, you'll want to install the [ESLint
|
|
50
|
+
extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint). You're
|
|
51
|
+
encouraged to enable auto-fixing problems on save by adding the following to your `settings.json`
|
|
52
|
+
file.
|
|
53
|
+
|
|
54
|
+
```json
|
|
55
|
+
{
|
|
56
|
+
"editor.codeActionsOnSave": {
|
|
57
|
+
"source.fixAll": true
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
If you're using Vite, you may want to install
|
|
63
|
+
[vite-plugin-eslint](https://github.com/gxmari007/vite-plugin-eslint).
|
|
64
|
+
|
|
65
|
+
You may also want to check out
|
|
66
|
+
[eslint-plugin-jsx-a11y](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y), which provides
|
|
67
|
+
useful rules for writing accessible HTML.
|
|
68
|
+
|
|
69
|
+
## Configuration
|
|
70
|
+
|
|
71
|
+
Create an `eslint.config.js` file at the root of your project ([flat
|
|
72
|
+
config](https://eslint.org/docs/latest/use/configure/configuration-files) is the only configuration
|
|
73
|
+
system supported by ESLint v9+, and by this plugin as of v0.15.0), and use the `recommended`
|
|
74
|
+
configuration to get reasonable defaults as shown [below](#rules).
|
|
75
|
+
|
|
76
|
+
```js
|
|
77
|
+
import js from "@eslint/js";
|
|
78
|
+
import solid from "eslint-plugin-solid/configs/recommended";
|
|
79
|
+
|
|
80
|
+
export default [
|
|
81
|
+
js.configs.recommended, // replaces eslint:recommended
|
|
82
|
+
solid,
|
|
83
|
+
];
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### TypeScript
|
|
87
|
+
|
|
88
|
+
If you're using TypeScript, use the `typescript` configuration instead.
|
|
89
|
+
This disables some features that overlap with type checking.
|
|
90
|
+
|
|
91
|
+
```js
|
|
92
|
+
import js from "@eslint/js";
|
|
93
|
+
import solid from "eslint-plugin-solid/configs/typescript";
|
|
94
|
+
import * as tsParser from "@typescript-eslint/parser";
|
|
95
|
+
|
|
96
|
+
export default [
|
|
97
|
+
js.configs.recommended,
|
|
98
|
+
{
|
|
99
|
+
files: ["**/*.{ts,tsx}"],
|
|
100
|
+
...solid,
|
|
101
|
+
languageOptions: {
|
|
102
|
+
parser: tsParser,
|
|
103
|
+
parserOptions: {
|
|
104
|
+
project: "tsconfig.json",
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
];
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Solid 2.0
|
|
112
|
+
|
|
113
|
+
If your project targets Solid 2.0, use the `v2` configuration. It sets
|
|
114
|
+
`settings: { solid: { version: 2 } }`, which switches the version-aware rules (`reactivity`,
|
|
115
|
+
`imports`, `no-unknown-namespaces`, `event-handlers`, `jsx-no-undef`) to strict 2.0 semantics, and
|
|
116
|
+
enables the 2.0-specific rules: `removed-api`, `no-single-arg-create-effect`,
|
|
117
|
+
`no-accessor-as-prop`, `no-boolean-enumerated-attribute`, `no-store-mutation-outside-setter`,
|
|
118
|
+
`no-write-in-pure-computation`, `no-reactive-read-in-effect-callback`, and the server function rules (`valid-use-server`,
|
|
119
|
+
`require-async-server-function`, `no-invalid-server-capture`,
|
|
120
|
+
`no-browser-globals-in-server-function`) as errors, with `prefer-structured-class` and
|
|
121
|
+
`no-unused-signal` as warnings. This is the config the official Solid 2.0 templates ship
|
|
122
|
+
with.
|
|
123
|
+
|
|
124
|
+
```js
|
|
125
|
+
import js from "@eslint/js";
|
|
126
|
+
import solid from "eslint-plugin-solid/configs/v2";
|
|
127
|
+
|
|
128
|
+
export default [js.configs.recommended, solid];
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
There is also a `v2-strict` configuration with the plugin's strongest opinions: everything in `v2`
|
|
132
|
+
plus `no-module-scope-reactive-primitive` and `no-restated-default-options` as errors,
|
|
133
|
+
`prefer-onSettled-for-side-effects` as a warning, and `prefer-structured-class` and
|
|
134
|
+
`no-unused-signal` promoted to errors.
|
|
135
|
+
|
|
136
|
+
The `settings.solid.version` setting also works in any custom config; version-aware rules read it
|
|
137
|
+
directly, so you can opt individual rule configurations into 2.0 semantics without using the
|
|
138
|
+
presets.
|
|
139
|
+
|
|
140
|
+
If your project imports Solid's primitives from a custom renderer or a re-exporting wrapper module
|
|
141
|
+
instead of `solid-js`, add those module names to `settings.solid.moduleSources` (exact names,
|
|
142
|
+
matched whole) so the import-gated rules recognize them:
|
|
143
|
+
|
|
144
|
+
```js
|
|
145
|
+
{
|
|
146
|
+
settings: { solid: { moduleSources: ["my-custom-renderer"] } },
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
All configs are also available on the plugin's root export, as `solid.configs.recommended`,
|
|
151
|
+
`solid.configs.typescript`, `solid.configs.v2`, and `solid.configs["v2-strict"]`, after using
|
|
152
|
+
`import solid from 'eslint-plugin-solid'`. (The `configs["flat/recommended"]` and
|
|
153
|
+
`configs["flat/typescript"]` names from v0.14.x still work as aliases.)
|
|
154
|
+
|
|
155
|
+
These configurations do not configure global variables in ESLint. You can do this yourself manually
|
|
156
|
+
or with a package like [globals](https://www.npmjs.com/package/globals) by creating a configuration
|
|
157
|
+
with a `languageOptions.globals` object. We recommend setting up global variables for Browser APIs
|
|
158
|
+
as well as at least ES2015.
|
|
159
|
+
|
|
160
|
+
### Manual Configuration
|
|
161
|
+
|
|
162
|
+
If you don't want to use a preset, you can configure rules individually. Add the `solid` plugin,
|
|
163
|
+
enable JSX with the parser options (or use the equivalent options for `@typescript-eslint/parser` or
|
|
164
|
+
`@babel/eslint-parser`), and configure the rules you would like to use. Some rules have additional
|
|
165
|
+
options you can set.
|
|
166
|
+
|
|
167
|
+
```js
|
|
168
|
+
import solid from "eslint-plugin-solid";
|
|
169
|
+
|
|
170
|
+
export default [
|
|
171
|
+
{
|
|
172
|
+
plugins: { solid },
|
|
173
|
+
languageOptions: {
|
|
174
|
+
parserOptions: {
|
|
175
|
+
ecmaFeatures: { jsx: true },
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
rules: {
|
|
179
|
+
"solid/reactivity": "warn",
|
|
180
|
+
"solid/no-destructure": "warn",
|
|
181
|
+
"solid/jsx-no-undef": "error",
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
];
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Oxlint
|
|
188
|
+
|
|
189
|
+
The plugin's rules are AST-based, so they run under [Oxlint's JS
|
|
190
|
+
plugin support](https://oxc.rs/docs/guide/usage/linter/js-plugins.html) without modification. Add
|
|
191
|
+
the plugin to `jsPlugins` in your `.oxlintrc.json` and enable the rules you want:
|
|
192
|
+
|
|
193
|
+
```json
|
|
194
|
+
{
|
|
195
|
+
"jsPlugins": ["eslint-plugin-solid"],
|
|
196
|
+
"rules": {
|
|
197
|
+
"solid/reactivity": "warn",
|
|
198
|
+
"solid/no-destructure": "error",
|
|
199
|
+
"solid/jsx-no-undef": "error"
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
For Solid 2.0 projects, add `"settings": { "solid": { "version": 2 } }` to activate the
|
|
205
|
+
version-aware rule behavior, and enable the 2.0 rules (`solid/removed-api`,
|
|
206
|
+
`solid/no-single-arg-create-effect`, `solid/no-accessor-as-prop`,
|
|
207
|
+
`solid/no-store-mutation-outside-setter`, `solid/no-write-in-pure-computation`,
|
|
208
|
+
`solid/no-reactive-read-in-effect-callback`, `solid/no-unused-signal`, `solid/prefer-structured-class`, and the server function rules `solid/valid-use-server`,
|
|
209
|
+
`solid/require-async-server-function`, `solid/no-invalid-server-capture`, and
|
|
210
|
+
`solid/no-browser-globals-in-server-function`).
|
|
211
|
+
|
|
212
|
+
## Rules
|
|
213
|
+
|
|
214
|
+
✔: Enabled in the `recommended` configuration.
|
|
215
|
+
|
|
216
|
+
🔧: Fixable with [`eslint --fix`](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems)/IDE auto-fix.
|
|
217
|
+
|
|
218
|
+
<!-- doc-gen RULES -->
|
|
219
|
+
| ✔ | 🔧 | Rule | Description |
|
|
220
|
+
| :---: | :---: | :--- | :--- |
|
|
221
|
+
| ✔ | 🔧 | [solid/components-return-once](/packages/eslint-plugin-solid/docs/components-return-once.md) | Disallow early returns in components. Solid components only run once, and so conditionals should be inside JSX. |
|
|
222
|
+
| ✔ | 🔧 | [solid/event-handlers](/packages/eslint-plugin-solid/docs/event-handlers.md) | Enforce naming DOM element event handlers consistently and prevent Solid's analysis from misunderstanding whether a prop should be an event handler. |
|
|
223
|
+
| ✔ | 🔧 | [solid/imports](/packages/eslint-plugin-solid/docs/imports.md) | Enforce consistent imports from "solid-js", "solid-js/web", and "solid-js/store". |
|
|
224
|
+
| ✔ | | [solid/jsx-no-duplicate-props](/packages/eslint-plugin-solid/docs/jsx-no-duplicate-props.md) | Disallow passing the same prop twice in JSX. |
|
|
225
|
+
| ✔ | | [solid/jsx-no-script-url](/packages/eslint-plugin-solid/docs/jsx-no-script-url.md) | Disallow javascript: URLs. |
|
|
226
|
+
| ✔ | 🔧 | [solid/jsx-no-undef](/packages/eslint-plugin-solid/docs/jsx-no-undef.md) | Disallow references to undefined variables in JSX. Handles custom directives. |
|
|
227
|
+
| ✔ | | [solid/jsx-uses-vars](/packages/eslint-plugin-solid/docs/jsx-uses-vars.md) | Prevent variables used in JSX from being marked as unused. |
|
|
228
|
+
| | | [solid/no-accessor-as-prop](/packages/eslint-plugin-solid/docs/no-accessor-as-prop.md) | Disallow passing uncalled signal accessors or other functions as value-typed DOM element attributes. |
|
|
229
|
+
| | | [solid/no-array-handlers](/packages/eslint-plugin-solid/docs/no-array-handlers.md) | Disallow usage of type-unsafe event handlers. |
|
|
230
|
+
| | 🔧 | [solid/no-boolean-enumerated-attribute](/packages/eslint-plugin-solid/docs/no-boolean-enumerated-attribute.md) | Disallow boolean values on enumerated attributes like draggable and tristate aria-*, which take string tokens — a boolean false removes the attribute instead of writing "false". |
|
|
231
|
+
| | | [solid/no-browser-globals-in-server-function](/packages/eslint-plugin-solid/docs/no-browser-globals-in-server-function.md) | Disallow browser-only globals inside server functions, which run exclusively on the server. |
|
|
232
|
+
| ✔ | 🔧 | [solid/no-destructure](/packages/eslint-plugin-solid/docs/no-destructure.md) | Disallow destructuring props. In Solid, props must be used with property accesses (`props.foo`) to preserve reactivity. This rule only tracks destructuring in the parameter list. |
|
|
233
|
+
| ✔ | 🔧 | [solid/no-innerhtml](/packages/eslint-plugin-solid/docs/no-innerhtml.md) | Disallow usage of the innerHTML attribute, which can often lead to security vulnerabilities. |
|
|
234
|
+
| | | [solid/no-invalid-server-capture](/packages/eslint-plugin-solid/docs/no-invalid-server-capture.md) | Disallow server functions from capturing variables in enclosing non-module scopes, mirroring the compiler's build-time validation. |
|
|
235
|
+
| | | [solid/no-module-scope-reactive-primitive](/packages/eslint-plugin-solid/docs/no-module-scope-reactive-primitive.md) | Disallow reactive primitives at module scope, where state is shared across SSR requests. |
|
|
236
|
+
| | | [solid/no-proxy-apis](/packages/eslint-plugin-solid/docs/no-proxy-apis.md) | Disallow usage of APIs that use ES6 Proxies, only to target environments that don't support them. |
|
|
237
|
+
| ✔ | 🔧 | [solid/no-react-deps](/packages/eslint-plugin-solid/docs/no-react-deps.md) | Disallow usage of dependency arrays in `createEffect` and `createMemo`. |
|
|
238
|
+
| ✔ | 🔧 | [solid/no-react-specific-props](/packages/eslint-plugin-solid/docs/no-react-specific-props.md) | Disallow usage of React-specific `className`/`htmlFor` props, which were deprecated in v1.4.0. |
|
|
239
|
+
| | | [solid/no-reactive-read-in-effect-callback](/packages/eslint-plugin-solid/docs/no-reactive-read-in-effect-callback.md) | Disallow reading reactive values in the untracked apply callback of a Solid 2 split effect. |
|
|
240
|
+
| | 🔧 | [solid/no-restated-default-options](/packages/eslint-plugin-solid/docs/no-restated-default-options.md) | Disallow restating a prop or option value that is already the default. |
|
|
241
|
+
| | | [solid/no-single-arg-create-effect](/packages/eslint-plugin-solid/docs/no-single-arg-create-effect.md) | Require the two-argument `createEffect(compute, effect)` form used by Solid 2.0. |
|
|
242
|
+
| | | [solid/no-store-mutation-outside-setter](/packages/eslint-plugin-solid/docs/no-store-mutation-outside-setter.md) | Disallow mutating a store's read proxy; store state changes only through the setter's mutable draft. |
|
|
243
|
+
| ✔ | | [solid/no-unknown-namespaces](/packages/eslint-plugin-solid/docs/no-unknown-namespaces.md) | Enforce using only Solid-specific namespaced attribute names (i.e. `'on:'` in `<div on:click={...} />`). |
|
|
244
|
+
| | | [solid/no-unused-signal](/packages/eslint-plugin-solid/docs/no-unused-signal.md) | Disallow signals that are never written (use a plain value) or never read (dead state). |
|
|
245
|
+
| | | [solid/no-write-in-pure-computation](/packages/eslint-plugin-solid/docs/no-write-in-pure-computation.md) | Disallow writing signals or stores inside `createMemo`, the compute half of `createEffect`, or a component body, which are pure owned scopes. |
|
|
246
|
+
| | 🔧 | [solid/prefer-classlist](/packages/eslint-plugin-solid/docs/prefer-classlist.md) | Enforce using the classlist prop over importing a classnames helper. The classlist prop accepts an object `{ [class: string]: boolean }` just like classnames. |
|
|
247
|
+
| ✔ | 🔧 | [solid/prefer-for](/packages/eslint-plugin-solid/docs/prefer-for.md) | Enforce using Solid's `<For />` component for mapping an array to JSX elements. |
|
|
248
|
+
| | | [solid/prefer-onSettled-for-side-effects](/packages/eslint-plugin-solid/docs/prefer-onSettled-for-side-effects.md) | Enforce running side-effectful setup (timers, global listeners, observers) inside `onSettled` instead of the component body. |
|
|
249
|
+
| | 🔧 | [solid/prefer-show](/packages/eslint-plugin-solid/docs/prefer-show.md) | Enforce using Solid's `<Show />` component for conditionally showing content. Solid's compiler covers this case, so it's a stylistic rule only. |
|
|
250
|
+
| | | [solid/prefer-structured-class](/packages/eslint-plugin-solid/docs/prefer-structured-class.md) | Enforce using the structured array/object forms of the `class` prop over manually-built class strings. |
|
|
251
|
+
| ✔ | | [solid/reactivity](/packages/eslint-plugin-solid/docs/reactivity.md) | Enforce that reactivity (props, signals, memos, etc.) is properly used, so changes in those values will be tracked and update the view as expected. |
|
|
252
|
+
| | 🔧 | [solid/removed-api](/packages/eslint-plugin-solid/docs/removed-api.md) | Disallow Solid 1.x APIs that were removed or renamed in Solid 2.0, with migration guidance. |
|
|
253
|
+
| | 🔧 | [solid/require-async-server-function](/packages/eslint-plugin-solid/docs/require-async-server-function.md) | Require server functions to be async, matching their client-side contract. |
|
|
254
|
+
| ✔ | 🔧 | [solid/self-closing-comp](/packages/eslint-plugin-solid/docs/self-closing-comp.md) | Disallow extra closing tags for components without children. |
|
|
255
|
+
| ✔ | 🔧 | [solid/style-prop](/packages/eslint-plugin-solid/docs/style-prop.md) | Require CSS properties in the `style` prop to be valid and kebab-cased (ex. 'font-size'), not camel-cased (ex. 'fontSize') like in React, and that property values with dimensions are strings, not numbers with implicit 'px' units. |
|
|
256
|
+
| | | [solid/valid-use-server](/packages/eslint-plugin-solid/docs/valid-use-server.md) | Enforce that "use server" directives are placed where the compiler honors them, and that module-level directive files export working server functions. |
|
|
257
|
+
<!-- end-doc-gen -->
|
|
258
|
+
|
|
259
|
+
## Troubleshooting
|
|
260
|
+
|
|
261
|
+
The rules in this plugin provide sensible guidelines as well as possible, but there may be times
|
|
262
|
+
where you know better than the rule and want to ignore a warning. To do that, [add a
|
|
263
|
+
comment](https://eslint.org/docs/latest/user-guide/configuring/rules#disabling-rules) like the
|
|
264
|
+
following:
|
|
265
|
+
|
|
266
|
+
```jsx
|
|
267
|
+
// eslint-disable-next-line solid/reactivity
|
|
268
|
+
const [editedValue, setEditedValue] = createSignal(props.value);
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
_Please note_: there may also be times where a rule correctly warns about a subtle problem,
|
|
272
|
+
even if it looks like a false positive at first. With `solid/reactivity`, please look at the
|
|
273
|
+
[reactivity docs](https://github.com/solidjs-community/eslint-plugin-solid/blob/main/packages/eslint-plugin-solid/docs/reactivity.md#troubleshooting) before deciding to disable the rule.
|
|
274
|
+
|
|
275
|
+
When in doubt, feel free to [file an
|
|
276
|
+
issue](https://github.com/solidjs-community/eslint-plugin-solid/issues/new/choose).
|
|
277
|
+
|
|
278
|
+
## Versioning
|
|
279
|
+
|
|
280
|
+
Pre-1.0.0, the rules and the `recommended`, `typescript`, `v2`, and `v2-strict` configurations
|
|
281
|
+
will be stable across patch (`0.0.x`) versions, but may change across minor (`0.x`) versions.
|
|
282
|
+
If you want to pin a minor version, use a tilde in your `package.json`.
|
|
283
|
+
|
|
284
|
+
<!-- doc-gen TILDE -->
|
|
285
|
+
```diff
|
|
286
|
+
- "eslint-plugin-solid": "^0.18.0"
|
|
287
|
+
+ "eslint-plugin-solid": "~0.18.0"
|
|
288
|
+
```
|
|
289
|
+
<!-- end-doc-gen -->
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__commonJS,
|
|
3
|
+
__toESM,
|
|
4
|
+
require_recommended
|
|
5
|
+
} from "./chunk-LE6SW2M3.mjs";
|
|
6
|
+
|
|
7
|
+
// src/configs/typescript.ts
|
|
8
|
+
var require_typescript = __commonJS({
|
|
9
|
+
"src/configs/typescript.ts"(exports, module) {
|
|
10
|
+
var import_recommended = __toESM(require_recommended());
|
|
11
|
+
var typescript = {
|
|
12
|
+
// no files; either apply to all files, or let users spread in this config
|
|
13
|
+
// and specify matching patterns. This is eslint-plugin-react's take.
|
|
14
|
+
plugins: import_recommended.default.plugins,
|
|
15
|
+
// no languageOptions; ESLint's default parser can't parse TypeScript,
|
|
16
|
+
// and parsers are configured in languageOptions, so let the user handle
|
|
17
|
+
// this rather than cause potential conflicts
|
|
18
|
+
rules: {
|
|
19
|
+
...import_recommended.default.rules,
|
|
20
|
+
"solid/jsx-no-undef": [2, { typescriptEnabled: true }],
|
|
21
|
+
// namespaces taken care of by TS
|
|
22
|
+
"solid/no-unknown-namespaces": 0
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
module.exports = typescript;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export {
|
|
30
|
+
require_typescript
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=chunk-4UZNJ5MS.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/configs/typescript.ts"],"sourcesContent":["import type { TSESLint } from \"@typescript-eslint/utils\";\nimport type { Linter } from \"eslint\";\n\nimport recommended from \"./recommended\";\n\nconst typescript = {\n // no files; either apply to all files, or let users spread in this config\n // and specify matching patterns. This is eslint-plugin-react's take.\n plugins: recommended.plugins,\n // no languageOptions; ESLint's default parser can't parse TypeScript,\n // and parsers are configured in languageOptions, so let the user handle\n // this rather than cause potential conflicts\n rules: {\n ...recommended.rules,\n \"solid/jsx-no-undef\": [2, { typescriptEnabled: true }] satisfies Linter.RuleEntry,\n // namespaces taken care of by TS\n \"solid/no-unknown-namespaces\": 0,\n },\n} satisfies TSESLint.FlatConfig.Config;\n\nexport = typescript;\n"],"mappings":";;;;;;;AAAA;AAAA;AAGA,6BAAwB;AAExB,QAAM,aAAa;AAAA;AAAA;AAAA,MAGjB,SAAS,mBAAAA,QAAY;AAAA;AAAA;AAAA;AAAA,MAIrB,OAAO;AAAA,QACL,GAAG,mBAAAA,QAAY;AAAA,QACf,sBAAsB,CAAC,GAAG,EAAE,mBAAmB,KAAK,CAAC;AAAA;AAAA,QAErD,+BAA+B;AAAA,MACjC;AAAA,IACF;AAEA,qBAAS;AAAA;AAAA;","names":["recommended"]}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__commonJS,
|
|
3
|
+
__toESM,
|
|
4
|
+
init_plugin,
|
|
5
|
+
plugin,
|
|
6
|
+
require_recommended
|
|
7
|
+
} from "./chunk-LE6SW2M3.mjs";
|
|
8
|
+
|
|
9
|
+
// src/configs/v2.ts
|
|
10
|
+
var require_v2 = __commonJS({
|
|
11
|
+
"src/configs/v2.ts"(exports, module) {
|
|
12
|
+
init_plugin();
|
|
13
|
+
var import_recommended = __toESM(require_recommended());
|
|
14
|
+
var v2 = {
|
|
15
|
+
plugins: {
|
|
16
|
+
solid: plugin
|
|
17
|
+
},
|
|
18
|
+
languageOptions: {
|
|
19
|
+
sourceType: "module",
|
|
20
|
+
parserOptions: {
|
|
21
|
+
ecmaFeatures: {
|
|
22
|
+
jsx: true
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
settings: {
|
|
27
|
+
solid: { version: 2 }
|
|
28
|
+
},
|
|
29
|
+
rules: {
|
|
30
|
+
...import_recommended.default.rules,
|
|
31
|
+
// 1.x APIs that no longer exist; prescriptive migration guidance
|
|
32
|
+
"solid/removed-api": 2,
|
|
33
|
+
// 2.0 requires the split createEffect(compute, effect) form
|
|
34
|
+
"solid/no-single-arg-create-effect": 2,
|
|
35
|
+
// the store read proxy is read-only; mutations go through the setter's draft
|
|
36
|
+
"solid/no-store-mutation-outside-setter": 2,
|
|
37
|
+
// writes inside memos/compute halves create cycles and throw in 2.0 dev
|
|
38
|
+
"solid/no-write-in-pure-computation": 2,
|
|
39
|
+
// the apply half receives a value outside tracking; reads must happen in compute
|
|
40
|
+
"solid/no-reactive-read-in-effect-callback": 2,
|
|
41
|
+
// signals that are never written (or never read) aren't being used as signals
|
|
42
|
+
"solid/no-unused-signal": 1,
|
|
43
|
+
// uncalled accessors as DOM attributes render stringified functions
|
|
44
|
+
"solid/no-accessor-as-prop": 2,
|
|
45
|
+
// enumerated attributes (draggable, tristate aria-*) want string tokens;
|
|
46
|
+
// boolean false removes the attribute, a different state than "false"
|
|
47
|
+
"solid/no-boolean-enumerated-attribute": 2,
|
|
48
|
+
// manual class-string building works but defeats granular class toggling
|
|
49
|
+
"solid/prefer-structured-class": 1,
|
|
50
|
+
// graduated from style to correctness in 2.0: only camelCase `onClick` is
|
|
51
|
+
// an event handler; lowercase forms are literal attributes
|
|
52
|
+
"solid/event-handlers": 2,
|
|
53
|
+
// className/htmlFor pass through as literal attributes the DOM ignores
|
|
54
|
+
"solid/no-react-specific-props": 2,
|
|
55
|
+
// server functions are core in 2.0; misplaced/ignored "use server"
|
|
56
|
+
// directives and broken module-level directive files are silent failures
|
|
57
|
+
"solid/valid-use-server": 2,
|
|
58
|
+
// a sync server function returns T during SSR but Promise<T> on the client
|
|
59
|
+
"solid/require-async-server-function": 2,
|
|
60
|
+
// editor-time mirror of the compiler's closure-capture validation
|
|
61
|
+
"solid/no-invalid-server-capture": 2,
|
|
62
|
+
// server functions never run where browser globals exist
|
|
63
|
+
"solid/no-browser-globals-in-server-function": 2,
|
|
64
|
+
// premise no longer exists in 2.0 (rule also self-gates on version)
|
|
65
|
+
"solid/no-react-deps": 0,
|
|
66
|
+
// anti-advice in 2.0: classList was removed in favor of class objects/arrays
|
|
67
|
+
"solid/prefer-classlist": 0
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
module.exports = v2;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
export {
|
|
75
|
+
require_v2
|
|
76
|
+
};
|
|
77
|
+
//# sourceMappingURL=chunk-EBU4C5NV.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/configs/v2.ts"],"sourcesContent":["import type { TSESLint } from \"@typescript-eslint/utils\";\n\nimport { plugin } from \"../plugin\";\nimport recommended from \"./recommended\";\n\n// The Solid 2.0 config. Sets `settings.solid.version: 2`, which switches\n// version-aware rules (reactivity, imports, no-unknown-namespaces,\n// event-handlers, jsx-no-undef) into strict 2.0 semantics, and enables the\n// 2.0-specific rules. Errors are reserved for near-certain bugs; heuristics\n// stay warnings. This is the config the official templates ship.\nconst v2 = {\n plugins: {\n solid: plugin,\n },\n languageOptions: {\n sourceType: \"module\",\n parserOptions: {\n ecmaFeatures: {\n jsx: true,\n },\n },\n },\n settings: {\n solid: { version: 2 },\n },\n rules: {\n ...recommended.rules,\n // 1.x APIs that no longer exist; prescriptive migration guidance\n \"solid/removed-api\": 2,\n // 2.0 requires the split createEffect(compute, effect) form\n \"solid/no-single-arg-create-effect\": 2,\n // the store read proxy is read-only; mutations go through the setter's draft\n \"solid/no-store-mutation-outside-setter\": 2,\n // writes inside memos/compute halves create cycles and throw in 2.0 dev\n \"solid/no-write-in-pure-computation\": 2,\n // the apply half receives a value outside tracking; reads must happen in compute\n \"solid/no-reactive-read-in-effect-callback\": 2,\n // signals that are never written (or never read) aren't being used as signals\n \"solid/no-unused-signal\": 1,\n // uncalled accessors as DOM attributes render stringified functions\n \"solid/no-accessor-as-prop\": 2,\n // enumerated attributes (draggable, tristate aria-*) want string tokens;\n // boolean false removes the attribute, a different state than \"false\"\n \"solid/no-boolean-enumerated-attribute\": 2,\n // manual class-string building works but defeats granular class toggling\n \"solid/prefer-structured-class\": 1,\n // graduated from style to correctness in 2.0: only camelCase `onClick` is\n // an event handler; lowercase forms are literal attributes\n \"solid/event-handlers\": 2,\n // className/htmlFor pass through as literal attributes the DOM ignores\n \"solid/no-react-specific-props\": 2,\n // server functions are core in 2.0; misplaced/ignored \"use server\"\n // directives and broken module-level directive files are silent failures\n \"solid/valid-use-server\": 2,\n // a sync server function returns T during SSR but Promise<T> on the client\n \"solid/require-async-server-function\": 2,\n // editor-time mirror of the compiler's closure-capture validation\n \"solid/no-invalid-server-capture\": 2,\n // server functions never run where browser globals exist\n \"solid/no-browser-globals-in-server-function\": 2,\n // premise no longer exists in 2.0 (rule also self-gates on version)\n \"solid/no-react-deps\": 0,\n // anti-advice in 2.0: classList was removed in favor of class objects/arrays\n \"solid/prefer-classlist\": 0,\n },\n} satisfies TSESLint.FlatConfig.Config;\n\nexport = v2;\n"],"mappings":";;;;;;;;;AAAA;AAAA;AAEA;AACA,6BAAwB;AAOxB,QAAM,KAAK;AAAA,MACT,SAAS;AAAA,QACP,OAAO;AAAA,MACT;AAAA,MACA,iBAAiB;AAAA,QACf,YAAY;AAAA,QACZ,eAAe;AAAA,UACb,cAAc;AAAA,YACZ,KAAK;AAAA,UACP;AAAA,QACF;AAAA,MACF;AAAA,MACA,UAAU;AAAA,QACR,OAAO,EAAE,SAAS,EAAE;AAAA,MACtB;AAAA,MACA,OAAO;AAAA,QACL,GAAG,mBAAAA,QAAY;AAAA;AAAA,QAEf,qBAAqB;AAAA;AAAA,QAErB,qCAAqC;AAAA;AAAA,QAErC,0CAA0C;AAAA;AAAA,QAE1C,sCAAsC;AAAA;AAAA,QAEtC,6CAA6C;AAAA;AAAA,QAE7C,0BAA0B;AAAA;AAAA,QAE1B,6BAA6B;AAAA;AAAA;AAAA,QAG7B,yCAAyC;AAAA;AAAA,QAEzC,iCAAiC;AAAA;AAAA;AAAA,QAGjC,wBAAwB;AAAA;AAAA,QAExB,iCAAiC;AAAA;AAAA;AAAA,QAGjC,0BAA0B;AAAA;AAAA,QAE1B,uCAAuC;AAAA;AAAA,QAEvC,mCAAmC;AAAA;AAAA,QAEnC,+CAA+C;AAAA;AAAA,QAE/C,uBAAuB;AAAA;AAAA,QAEvB,0BAA0B;AAAA,MAC5B;AAAA,IACF;AAEA,qBAAS;AAAA;AAAA;","names":["recommended"]}
|