@murky-web/oxlint-plugin-solid 1.4.1 → 1.5.1
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 +2 -2
- package/package.json +1 -1
- package/src/index.mjs +3 -3
- package/src/rules/components_return_once.mjs +18 -18
- package/src/rules/event_handlers.mjs +28 -28
- package/src/rules/imports.mjs +22 -22
- package/src/rules/jsx_no_duplicate_props.mjs +14 -14
- package/src/rules/jsx_no_script_url.mjs +7 -7
- package/src/rules/jsx_no_undef.mjs +29 -29
- package/src/rules/jsx_uses_vars.mjs +4 -4
- package/src/rules/no_array_handlers.mjs +6 -6
- package/src/rules/no_destructure.mjs +33 -35
- package/src/rules/no_innerhtml.mjs +22 -22
- package/src/rules/no_owned_primitives_in_ref.mjs +9 -9
- package/src/rules/no_proxy_apis.mjs +10 -10
- package/src/rules/no_react_deps.mjs +9 -9
- package/src/rules/no_react_specific_props.mjs +8 -8
- package/src/rules/no_server_import_in_client.mjs +9 -9
- package/src/rules/no_setter_in_effect.mjs +11 -11
- package/src/rules/no_unknown_namespaces.mjs +34 -15
- package/src/rules/no_untracked_effect_read.mjs +9 -9
- package/src/rules/prefer_arrow_components.mjs +17 -17
- package/src/rules/prefer_class_object.mjs +16 -16
- package/src/rules/prefer_for.mjs +11 -11
- package/src/rules/prefer_show.mjs +9 -9
- package/src/rules/reactive_async.mjs +12 -12
- package/src/rules/reactivity.mjs +83 -84
- package/src/rules/self_closing_comp.mjs +17 -17
- package/src/rules/strict_void_return.mjs +12 -12
- package/src/rules/style_prop.mjs +21 -22
- package/src/rules/validate_jsx_nesting.mjs +15 -15
- package/src/utils.mjs +14 -14
|
@@ -6,7 +6,7 @@ export default {
|
|
|
6
6
|
docs: {
|
|
7
7
|
description:
|
|
8
8
|
"Enforce the `class` object/array form over the removed `classList` prop or a classnames helper. Solid 2.0 accepts `{ [class: string]: boolean }` on `class` directly.",
|
|
9
|
-
url: "https://docs.solidjs.com/"
|
|
9
|
+
url: "https://docs.solidjs.com/"
|
|
10
10
|
},
|
|
11
11
|
fixable: "code",
|
|
12
12
|
schema: [
|
|
@@ -19,21 +19,21 @@ export default {
|
|
|
19
19
|
"An array of names to treat as `classnames` functions",
|
|
20
20
|
default: DEFAULT_CLASSNAMES,
|
|
21
21
|
items: {
|
|
22
|
-
type: "string"
|
|
22
|
+
type: "string"
|
|
23
23
|
},
|
|
24
24
|
minItems: 1,
|
|
25
|
-
uniqueItems: true
|
|
26
|
-
}
|
|
25
|
+
uniqueItems: true
|
|
26
|
+
}
|
|
27
27
|
},
|
|
28
|
-
additionalProperties: false
|
|
29
|
-
}
|
|
28
|
+
additionalProperties: false
|
|
29
|
+
}
|
|
30
30
|
],
|
|
31
31
|
messages: {
|
|
32
32
|
classlistRemoved:
|
|
33
33
|
"The `classList` prop was removed in Solid 2.0. Pass the object to `class` instead.",
|
|
34
34
|
preferClassObject:
|
|
35
|
-
"Pass the object to `class` directly instead of through {{ classnames }}."
|
|
36
|
-
}
|
|
35
|
+
"Pass the object to `class` directly instead of through {{ classnames }}."
|
|
36
|
+
}
|
|
37
37
|
},
|
|
38
38
|
defaultOptions: [],
|
|
39
39
|
create(context) {
|
|
@@ -53,14 +53,14 @@ export default {
|
|
|
53
53
|
const hasClassAttribute = node.parent.attributes.some(
|
|
54
54
|
(attribute) =>
|
|
55
55
|
attribute.type === "JSXAttribute" &&
|
|
56
|
-
jsxPropName(attribute) === "class"
|
|
56
|
+
jsxPropName(attribute) === "class"
|
|
57
57
|
);
|
|
58
58
|
context.report({
|
|
59
59
|
node,
|
|
60
60
|
messageId: "classlistRemoved",
|
|
61
61
|
fix: hasClassAttribute
|
|
62
62
|
? null
|
|
63
|
-
: (fixer) => fixer.replaceText(node.name, "class")
|
|
63
|
+
: (fixer) => fixer.replaceText(node.name, "class")
|
|
64
64
|
});
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
@@ -90,17 +90,17 @@ export default {
|
|
|
90
90
|
return [
|
|
91
91
|
fixer.replaceTextRange(
|
|
92
92
|
[node.range[0], objectRange[0]],
|
|
93
|
-
"class={"
|
|
93
|
+
"class={"
|
|
94
94
|
),
|
|
95
95
|
fixer.replaceTextRange(
|
|
96
96
|
[objectRange[1], node.range[1]],
|
|
97
|
-
"}"
|
|
98
|
-
)
|
|
97
|
+
"}"
|
|
98
|
+
)
|
|
99
99
|
];
|
|
100
|
-
}
|
|
100
|
+
}
|
|
101
101
|
});
|
|
102
102
|
}
|
|
103
|
-
}
|
|
103
|
+
}
|
|
104
104
|
};
|
|
105
|
-
}
|
|
105
|
+
}
|
|
106
106
|
};
|
package/src/rules/prefer_for.mjs
CHANGED
|
@@ -7,7 +7,7 @@ export default {
|
|
|
7
7
|
docs: {
|
|
8
8
|
description:
|
|
9
9
|
"Enforce using Solid's `<For />` component for mapping an array to JSX elements.",
|
|
10
|
-
url: "https://github.com/solidjs-community/eslint-plugin-solid/blob/main/packages/eslint-plugin-solid/docs/prefer-for.md"
|
|
10
|
+
url: "https://github.com/solidjs-community/eslint-plugin-solid/blob/main/packages/eslint-plugin-solid/docs/prefer-for.md"
|
|
11
11
|
},
|
|
12
12
|
fixable: "code",
|
|
13
13
|
schema: [],
|
|
@@ -15,8 +15,8 @@ export default {
|
|
|
15
15
|
preferFor:
|
|
16
16
|
"Use Solid's `<For />` component for efficiently rendering lists. Array#map causes DOM elements to be recreated.",
|
|
17
17
|
preferForOrIndex:
|
|
18
|
-
"Use Solid's `<For />` component for rendering lists (`keyed={false}` for the index-based form). Array#map causes DOM elements to be recreated."
|
|
19
|
-
}
|
|
18
|
+
"Use Solid's `<For />` component for rendering lists (`keyed={false}` for the index-based form). Array#map causes DOM elements to be recreated."
|
|
19
|
+
}
|
|
20
20
|
},
|
|
21
21
|
defaultOptions: [],
|
|
22
22
|
create(context) {
|
|
@@ -30,23 +30,23 @@ export default {
|
|
|
30
30
|
fix: (fixer) => {
|
|
31
31
|
const beforeArray = [
|
|
32
32
|
jsxExpressionContainerNode.range[0],
|
|
33
|
-
arrayNode.range[0]
|
|
33
|
+
arrayNode.range[0]
|
|
34
34
|
];
|
|
35
35
|
const betweenArrayAndMapFn = [
|
|
36
36
|
arrayNode.range[1],
|
|
37
|
-
mapFnNode.range[0]
|
|
37
|
+
mapFnNode.range[0]
|
|
38
38
|
];
|
|
39
39
|
const afterMapFn = [
|
|
40
40
|
mapFnNode.range[1],
|
|
41
|
-
jsxExpressionContainerNode.range[1]
|
|
41
|
+
jsxExpressionContainerNode.range[1]
|
|
42
42
|
];
|
|
43
43
|
// We can insert the <For /> component
|
|
44
44
|
return [
|
|
45
45
|
fixer.replaceTextRange(beforeArray, "<For each={"),
|
|
46
46
|
fixer.replaceTextRange(betweenArrayAndMapFn, "}>{"),
|
|
47
|
-
fixer.replaceTextRange(afterMapFn, "}</For>")
|
|
47
|
+
fixer.replaceTextRange(afterMapFn, "}</For>")
|
|
48
48
|
];
|
|
49
|
-
}
|
|
49
|
+
}
|
|
50
50
|
});
|
|
51
51
|
};
|
|
52
52
|
return {
|
|
@@ -79,12 +79,12 @@ export default {
|
|
|
79
79
|
// Too many possible solutions to make a suggestion or fix
|
|
80
80
|
context.report({
|
|
81
81
|
node,
|
|
82
|
-
messageId: "preferForOrIndex"
|
|
82
|
+
messageId: "preferForOrIndex"
|
|
83
83
|
});
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
|
-
}
|
|
87
|
+
}
|
|
88
88
|
};
|
|
89
|
-
}
|
|
89
|
+
}
|
|
90
90
|
};
|
|
@@ -7,7 +7,7 @@ export default {
|
|
|
7
7
|
docs: {
|
|
8
8
|
description:
|
|
9
9
|
"Enforce using Solid's `<Show />` component for conditionally showing content. Solid's compiler covers this case, so it's a stylistic rule only.",
|
|
10
|
-
url: "https://github.com/solidjs-community/eslint-plugin-solid/blob/main/packages/eslint-plugin-solid/docs/prefer-show.md"
|
|
10
|
+
url: "https://github.com/solidjs-community/eslint-plugin-solid/blob/main/packages/eslint-plugin-solid/docs/prefer-show.md"
|
|
11
11
|
},
|
|
12
12
|
fixable: "code",
|
|
13
13
|
schema: [],
|
|
@@ -15,8 +15,8 @@ export default {
|
|
|
15
15
|
preferShowAnd:
|
|
16
16
|
"Use Solid's `<Show />` component for conditionally showing content.",
|
|
17
17
|
preferShowTernary:
|
|
18
|
-
"Use Solid's `<Show />` component for conditionally showing content with a fallback."
|
|
19
|
-
}
|
|
18
|
+
"Use Solid's `<Show />` component for conditionally showing content with a fallback."
|
|
19
|
+
}
|
|
20
20
|
},
|
|
21
21
|
defaultOptions: [],
|
|
22
22
|
create(context) {
|
|
@@ -39,8 +39,8 @@ export default {
|
|
|
39
39
|
isJSXElementOrFragment(node.parent.parent)
|
|
40
40
|
? node.parent
|
|
41
41
|
: node,
|
|
42
|
-
`<Show when={${sourceCode.getText(node.left)}}>${putIntoJSX(node.right)}</Show
|
|
43
|
-
)
|
|
42
|
+
`<Show when={${sourceCode.getText(node.left)}}>${putIntoJSX(node.right)}</Show>`
|
|
43
|
+
)
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
46
|
};
|
|
@@ -58,8 +58,8 @@ export default {
|
|
|
58
58
|
isJSXElementOrFragment(node.parent.parent)
|
|
59
59
|
? node.parent
|
|
60
60
|
: node,
|
|
61
|
-
`<Show when={${sourceCode.getText(node.test)}} fallback={${sourceCode.getText(node.alternate)}}>${putIntoJSX(node.consequent)}</Show
|
|
62
|
-
)
|
|
61
|
+
`<Show when={${sourceCode.getText(node.test)}} fallback={${sourceCode.getText(node.alternate)}}>${putIntoJSX(node.consequent)}</Show>`
|
|
62
|
+
)
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
65
|
};
|
|
@@ -83,7 +83,7 @@ export default {
|
|
|
83
83
|
) {
|
|
84
84
|
conditionalExpressionHandler(node.expression.body);
|
|
85
85
|
}
|
|
86
|
-
}
|
|
86
|
+
}
|
|
87
87
|
};
|
|
88
|
-
}
|
|
88
|
+
}
|
|
89
89
|
};
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
isFunctionNode,
|
|
4
4
|
isPropsByName,
|
|
5
5
|
trackImports,
|
|
6
|
-
walkOwnBody
|
|
6
|
+
walkOwnBody
|
|
7
7
|
} from "../utils.mjs";
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -18,7 +18,7 @@ const COMPUTATION_PRIMITIVES = [
|
|
|
18
18
|
"createOptimisticStore",
|
|
19
19
|
"createProjection",
|
|
20
20
|
"createSignal",
|
|
21
|
-
"createStore"
|
|
21
|
+
"createStore"
|
|
22
22
|
];
|
|
23
23
|
|
|
24
24
|
/** The two-argument effects: the first function is the tracked compute phase. */
|
|
@@ -29,14 +29,14 @@ const ACCESSOR_PRIMITIVES = [
|
|
|
29
29
|
"createDeferred",
|
|
30
30
|
"createMemo",
|
|
31
31
|
"createOptimistic",
|
|
32
|
-
"createSignal"
|
|
32
|
+
"createSignal"
|
|
33
33
|
];
|
|
34
34
|
|
|
35
35
|
/** Primitives whose result is read by property access: `store.items`. */
|
|
36
36
|
const STORE_PRIMITIVES = [
|
|
37
37
|
"createOptimisticStore",
|
|
38
38
|
"createProjection",
|
|
39
|
-
"createStore"
|
|
39
|
+
"createStore"
|
|
40
40
|
];
|
|
41
41
|
|
|
42
42
|
const FIRST_ELEMENT = 0;
|
|
@@ -96,15 +96,15 @@ export const reactiveAsyncRule = {
|
|
|
96
96
|
docs: {
|
|
97
97
|
description:
|
|
98
98
|
"Keep reads before the first await in async reactive computations and return promises without async.",
|
|
99
|
-
url: "https://docs.solidjs.com/"
|
|
99
|
+
url: "https://docs.solidjs.com/"
|
|
100
100
|
},
|
|
101
101
|
schema: [],
|
|
102
102
|
messages: {
|
|
103
103
|
untrackedReadAfterAwait:
|
|
104
104
|
"'{{name}}' is read after an `await` in this `{{primitive}}` callback. Solid reports this as UNTRACKED_READ_AFTER_AWAIT: only reads before the first `await` are dependencies, so the result goes stale when it changes. Read it before the `await` and use the local afterwards: `const current = {{name}}; … await …`.",
|
|
105
105
|
redundantAsync:
|
|
106
|
-
"This `async` `{{primitive}}` callback only does `return await …`. Solid reads a returned promise like a value, so remove `async` and `await` and return the promise: `{{primitive}}(() => load(id()))`."
|
|
107
|
-
}
|
|
106
|
+
"This `async` `{{primitive}}` callback only does `return await …`. Solid reads a returned promise like a value, so remove `async` and `await` and return the promise: `{{primitive}}(() => load(id()))`."
|
|
107
|
+
}
|
|
108
108
|
},
|
|
109
109
|
defaultOptions: [],
|
|
110
110
|
create(context) {
|
|
@@ -178,7 +178,7 @@ export const reactiveAsyncRule = {
|
|
|
178
178
|
context.report({
|
|
179
179
|
node: callback,
|
|
180
180
|
messageId: "redundantAsync",
|
|
181
|
-
data: { primitive }
|
|
181
|
+
data: { primitive }
|
|
182
182
|
});
|
|
183
183
|
}
|
|
184
184
|
|
|
@@ -190,7 +190,7 @@ export const reactiveAsyncRule = {
|
|
|
190
190
|
context.report({
|
|
191
191
|
node: read.node,
|
|
192
192
|
messageId: "untrackedReadAfterAwait",
|
|
193
|
-
data: { name: read.name, primitive }
|
|
193
|
+
data: { name: read.name, primitive }
|
|
194
194
|
});
|
|
195
195
|
}
|
|
196
196
|
}
|
|
@@ -230,7 +230,7 @@ export const reactiveAsyncRule = {
|
|
|
230
230
|
|
|
231
231
|
const computation = matchImport(
|
|
232
232
|
COMPUTATION_PRIMITIVES,
|
|
233
|
-
node.callee.name
|
|
233
|
+
node.callee.name
|
|
234
234
|
);
|
|
235
235
|
if (computation) {
|
|
236
236
|
checkCallback(first, computation);
|
|
@@ -242,7 +242,7 @@ export const reactiveAsyncRule = {
|
|
|
242
242
|
if (effect && isFunctionNode(second)) {
|
|
243
243
|
checkCallback(first, effect);
|
|
244
244
|
}
|
|
245
|
-
}
|
|
245
|
+
}
|
|
246
246
|
};
|
|
247
|
-
}
|
|
247
|
+
}
|
|
248
248
|
};
|