@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 CHANGED
@@ -39,8 +39,8 @@ Oxlint-Konfiguration als JS-Plugin geladen:
39
39
  "jsPlugins": ["@murky-web/oxlint-plugin-solid"],
40
40
  "rules": {
41
41
  "solid/reactivity": "error",
42
- "solid/prefer-arrow-components": "error",
43
- },
42
+ "solid/prefer-arrow-components": "error"
43
+ }
44
44
  }
45
45
  ```
46
46
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@murky-web/oxlint-plugin-solid",
3
- "version": "1.4.1",
3
+ "version": "1.5.1",
4
4
  "private": false,
5
5
  "description": "Local Oxlint JS plugin port for Solid rules plus Murky-specific Solid conventions.",
6
6
  "homepage": "https://github.com/MurkyTheMurloc/web_dev_tools/tree/main/packages/oxlint-plugin-solid",
package/src/index.mjs CHANGED
@@ -30,7 +30,7 @@ import validateJsxNestingRule from "./rules/validate_jsx_nesting.mjs";
30
30
  const extendedPlugin = {
31
31
  meta: {
32
32
  name: "solid",
33
- version: "0.14.5",
33
+ version: "0.14.5"
34
34
  },
35
35
  rules: {
36
36
  "components-return-once": componentsReturnOnceRule,
@@ -60,8 +60,8 @@ const extendedPlugin = {
60
60
  "self-closing-comp": selfClosingCompRule,
61
61
  "strict-void-return": strictVoidReturnRule,
62
62
  "style-prop": stylePropRule,
63
- "validate-jsx-nesting": validateJsxNestingRule,
64
- },
63
+ "validate-jsx-nesting": validateJsxNestingRule
64
+ }
65
65
  };
66
66
 
67
67
  // oxlint-disable-next-line import/no-default-export -- Oxlint JS plugins require a default export surface.
@@ -20,7 +20,7 @@ export default {
20
20
  docs: {
21
21
  description:
22
22
  "Disallow early returns in components. Solid components only run once, and so conditionals should be inside JSX.",
23
- url: "https://github.com/solidjs-community/eslint-plugin-solid/blob/main/packages/eslint-plugin-solid/docs/components-return-once.md",
23
+ url: "https://github.com/solidjs-community/eslint-plugin-solid/blob/main/packages/eslint-plugin-solid/docs/components-return-once.md"
24
24
  },
25
25
  fixable: "code",
26
26
  schema: [],
@@ -28,8 +28,8 @@ export default {
28
28
  noEarlyReturn:
29
29
  "Solid components run once, so an early return breaks reactivity. Move the condition inside a JSX element, such as a fragment or <Show />.",
30
30
  noConditionalReturn:
31
- "Solid components run once, so a conditional return breaks reactivity. Move the condition inside a JSX element, such as a fragment or <Show />.",
32
- },
31
+ "Solid components run once, so a conditional return breaks reactivity. Move the condition inside a JSX element, such as a fragment or <Show />."
32
+ }
33
33
  },
34
34
  defaultOptions: [],
35
35
  create(context) {
@@ -46,7 +46,7 @@ export default {
46
46
  if (node.body.type === "BlockStatement") {
47
47
  // find last statement, ignoring function/class/variable declarations (hoisting)
48
48
  const last = node.body.body.findLast(
49
- (node) => !node.type.endsWith("Declaration"),
49
+ (node) => !node.type.endsWith("Declaration")
50
50
  );
51
51
  // if it's a return, store it
52
52
  if (last && last.type === "ReturnStatement") {
@@ -56,7 +56,7 @@ export default {
56
56
  functionStack.push({
57
57
  isComponent: false,
58
58
  lastReturn,
59
- earlyReturns: [],
59
+ earlyReturns: []
60
60
  });
61
61
  };
62
62
  const onFunctionExit = (node) => {
@@ -76,7 +76,7 @@ export default {
76
76
  currentFunction().earlyReturns.forEach((earlyReturn) => {
77
77
  context.report({
78
78
  node: earlyReturn,
79
- messageId: "noEarlyReturn",
79
+ messageId: "noEarlyReturn"
80
80
  });
81
81
  });
82
82
  const argument = currentFunction().lastReturn?.argument;
@@ -92,7 +92,7 @@ export default {
92
92
  while (fallback.type === "ConditionalExpression") {
93
93
  conditions.push({
94
94
  test: fallback.test,
95
- consequent: fallback.consequent,
95
+ consequent: fallback.consequent
96
96
  });
97
97
  fallback = fallback.alternate;
98
98
  }
@@ -106,16 +106,16 @@ export default {
106
106
  `<Switch${fallbackStr}>\n${conditions
107
107
  .map(
108
108
  ({ test, consequent }) =>
109
- `<Match when={${sourceCode.getText(test)}}>${putIntoJSX(consequent)}</Match>`,
109
+ `<Match when={${sourceCode.getText(test)}}>${putIntoJSX(consequent)}</Match>`
110
110
  )
111
- .join("\n")}\n</Switch>`,
111
+ .join("\n")}\n</Switch>`
112
112
  );
113
113
  }
114
114
  if (isNothing(consequent)) {
115
115
  // we have a single ternary and the consequent is nothing. Negate the condition and use a <Show>.
116
116
  return fixer.replaceText(
117
117
  argument,
118
- `<Show when={!(${sourceCode.getText(test)})}>${putIntoJSX(alternate)}</Show>`,
118
+ `<Show when={!(${sourceCode.getText(test)})}>${putIntoJSX(alternate)}</Show>`
119
119
  );
120
120
  }
121
121
  if (
@@ -130,16 +130,16 @@ export default {
130
130
  : "";
131
131
  return fixer.replaceText(
132
132
  argument,
133
- `<Show when={${sourceCode.getText(test)}}${fallbackStr}>${putIntoJSX(consequent)}</Show>`,
133
+ `<Show when={${sourceCode.getText(test)}}${fallbackStr}>${putIntoJSX(consequent)}</Show>`
134
134
  );
135
135
  }
136
136
  // we have a standard ternary, but no signal from the user as to which branch is the "fallback" and
137
137
  // which is the children. Move the whole conditional inside a JSX fragment.
138
138
  return fixer.replaceText(
139
139
  argument,
140
- `<>${putIntoJSX(argument)}</>`,
140
+ `<>${putIntoJSX(argument)}</>`
141
141
  );
142
- },
142
+ }
143
143
  });
144
144
  } else if (argument?.type === "LogicalExpression") {
145
145
  if (argument.operator === "&&") {
@@ -153,15 +153,15 @@ export default {
153
153
  argument;
154
154
  return fixer.replaceText(
155
155
  argument,
156
- `<Show when={${sourceCode.getText(test)}}>${putIntoJSX(consequent)}</Show>`,
156
+ `<Show when={${sourceCode.getText(test)}}>${putIntoJSX(consequent)}</Show>`
157
157
  );
158
- },
158
+ }
159
159
  });
160
160
  } else {
161
161
  // we have some other kind of conditional, warn
162
162
  context.report({
163
163
  node: argument,
164
- messageId: "noConditionalReturn",
164
+ messageId: "noConditionalReturn"
165
165
  });
166
166
  }
167
167
  }
@@ -193,7 +193,7 @@ export default {
193
193
  ) {
194
194
  currentFunction().earlyReturns.push(node);
195
195
  }
196
- },
196
+ }
197
197
  };
198
- },
198
+ }
199
199
  };
@@ -60,17 +60,17 @@ const COMMON_EVENTS = [
60
60
  "onTouchMove",
61
61
  "onTouchStart",
62
62
  "onTransitionEnd",
63
- "onWheel",
63
+ "onWheel"
64
64
  ];
65
65
  const COMMON_EVENTS_MAP = new Map(
66
66
  (function* () {
67
67
  for (const event of COMMON_EVENTS) {
68
68
  yield [event.toLowerCase(), event];
69
69
  }
70
- })(),
70
+ })()
71
71
  );
72
72
  const NONSTANDARD_EVENTS_MAP = {
73
- ondoubleclick: "onDblClick",
73
+ ondoubleclick: "onDblClick"
74
74
  };
75
75
  const isCommonHandlerName = (lowercaseHandlerName) =>
76
76
  COMMON_EVENTS_MAP.has(lowercaseHandlerName);
@@ -86,7 +86,7 @@ export default {
86
86
  docs: {
87
87
  description:
88
88
  "Enforce naming DOM element event handlers consistently and prevent Solid's analysis from misunderstanding whether a prop should be an event handler.",
89
- url: "https://github.com/solidjs-community/eslint-plugin-solid/blob/main/packages/eslint-plugin-solid/docs/event-handlers.md",
89
+ url: "https://github.com/solidjs-community/eslint-plugin-solid/blob/main/packages/eslint-plugin-solid/docs/event-handlers.md"
90
90
  },
91
91
  fixable: "code",
92
92
  hasSuggestions: true,
@@ -98,17 +98,17 @@ export default {
98
98
  type: "boolean",
99
99
  description:
100
100
  "if true, don't warn on ambiguously named event handlers like `onclick` or `onchange`",
101
- default: false,
101
+ default: false
102
102
  },
103
103
  warnOnSpread: {
104
104
  type: "boolean",
105
105
  description:
106
106
  "if true, warn when spreading event handlers onto JSX. Enable for Solid < v1.6.",
107
- default: false,
108
- },
107
+ default: false
108
+ }
109
109
  },
110
- additionalProperties: false,
111
- },
110
+ additionalProperties: false
111
+ }
112
112
  ],
113
113
  messages: {
114
114
  "detected-attr":
@@ -120,8 +120,8 @@ export default {
120
120
  "The {{name}} prop should be renamed to {{fixedName}}, because it's not a standard event handler.",
121
121
  "make-handler": "Change the {{name}} prop to {{handlerName}}.",
122
122
  "spread-handler":
123
- "The {{name}} prop should be added as a JSX attribute, not spread in. Solid doesn't add listeners when spreading into JSX.",
124
- },
123
+ "The {{name}} prop should be added as a JSX attribute, not spread in. Solid doesn't add listeners when spreading into JSX."
124
+ }
125
125
  },
126
126
  defaultOptions: [],
127
127
  create(context) {
@@ -150,7 +150,7 @@ export default {
150
150
  node.value.expression.type !== "ArrayExpression" && // array syntax prevents inlining
151
151
  (staticValue = getStaticValue(
152
152
  node.value.expression,
153
- getScope(context, node),
153
+ getScope(context, node)
154
154
  )) !== null &&
155
155
  (typeof staticValue.value === "string" ||
156
156
  typeof staticValue.value === "number")
@@ -170,8 +170,8 @@ export default {
170
170
  messageId: "detected-attr",
171
171
  data: {
172
172
  name,
173
- staticValue: staticValue.value,
174
- },
173
+ staticValue: staticValue.value
174
+ }
175
175
  });
176
176
  } else if (
177
177
  node.value === null ||
@@ -184,8 +184,8 @@ export default {
184
184
  data: {
185
185
  name,
186
186
  staticValue:
187
- node.value !== null ? node.value.value : true,
188
- },
187
+ node.value !== null ? node.value.value : true
188
+ }
189
189
  });
190
190
  } else if (!context.options[0]?.ignoreCase) {
191
191
  const lowercaseHandlerName = name.toLowerCase();
@@ -197,7 +197,7 @@ export default {
197
197
  messageId: "nonstandard",
198
198
  data: { name, fixedName },
199
199
  fix: (fixer) =>
200
- fixer.replaceText(node.name, fixedName),
200
+ fixer.replaceText(node.name, fixedName)
201
201
  });
202
202
  } else if (isCommonHandlerName(lowercaseHandlerName)) {
203
203
  const fixedName =
@@ -210,7 +210,7 @@ export default {
210
210
  messageId: "capitalization",
211
211
  data: { name, fixedName },
212
212
  fix: (fixer) =>
213
- fixer.replaceText(node.name, fixedName),
213
+ fixer.replaceText(node.name, fixedName)
214
214
  });
215
215
  }
216
216
  } else if (name[2] === name[2].toLowerCase()) {
@@ -231,10 +231,10 @@ export default {
231
231
  fix: (fixer) =>
232
232
  fixer.replaceText(
233
233
  node.name,
234
- handlerName,
235
- ),
236
- },
237
- ],
234
+ handlerName
235
+ )
236
+ }
237
+ ]
238
238
  });
239
239
  }
240
240
  }
@@ -262,7 +262,7 @@ export default {
262
262
  node,
263
263
  messageId: "spread-handler",
264
264
  data: {
265
- name: node.key.name,
265
+ name: node.key.name
266
266
  },
267
267
  *fix(fixer) {
268
268
  const commaAfter =
@@ -270,21 +270,21 @@ export default {
270
270
  yield fixer.remove(
271
271
  node.parent.properties.length === 1
272
272
  ? node.parent.parent
273
- : node,
273
+ : node
274
274
  );
275
275
  if (commaAfter?.value === ",") {
276
276
  yield fixer.remove(commaAfter);
277
277
  }
278
278
  yield fixer.insertTextAfter(
279
279
  node.parent.parent,
280
- ` ${handlerName}={${sourceCode.getText(node.value)}}`,
280
+ ` ${handlerName}={${sourceCode.getText(node.value)}}`
281
281
  );
282
- },
282
+ }
283
283
  });
284
284
  }
285
285
  }
286
286
  }
287
- },
287
+ }
288
288
  };
289
- },
289
+ }
290
290
  };
@@ -3,7 +3,7 @@ import {
3
3
  appendImports,
4
4
  canTakeSpecifier,
5
5
  insertImports,
6
- removeSpecifier,
6
+ removeSpecifier
7
7
  } from "../utils.mjs";
8
8
  // Solid 2.0 moved the renderers into `@solidjs/*` packages and pulled the store
9
9
  // APIs into the core. Symbols that are legitimately exported from more than one
@@ -53,7 +53,7 @@ for (const primitive of [
53
53
  "snapshot",
54
54
  "untrack",
55
55
  "until",
56
- "useContext",
56
+ "useContext"
57
57
  ]) {
58
58
  primitiveMap.set(primitive, "solid-js");
59
59
  }
@@ -74,7 +74,7 @@ for (const primitive of [
74
74
  "reload",
75
75
  "render",
76
76
  "renderToStream",
77
- "renderToString",
77
+ "renderToString"
78
78
  ]) {
79
79
  primitiveMap.set(primitive, "@solidjs/web");
80
80
  }
@@ -95,7 +95,7 @@ for (const type of [
95
95
  "ResolvedChildren",
96
96
  "Signal",
97
97
  "VoidComponent",
98
- "VoidProps",
98
+ "VoidProps"
99
99
  ]) {
100
100
  typeMap.set(type, "solid-js");
101
101
  }
@@ -123,7 +123,7 @@ const findTarget = (program, source, isType) => {
123
123
  (node) =>
124
124
  node.type === "ImportDeclaration" &&
125
125
  node.source.value === source &&
126
- canTakeSpecifier(node, isType),
126
+ canTakeSpecifier(node, isType)
127
127
  );
128
128
  return (
129
129
  (isType ? candidates.find(isTypeDeclaration) : undefined) ??
@@ -136,13 +136,13 @@ export default {
136
136
  docs: {
137
137
  description:
138
138
  'Enforce consistent imports from "solid-js" and the `@solidjs/*` renderer packages.',
139
- url: "https://github.com/solidjs-community/eslint-plugin-solid/blob/main/packages/eslint-plugin-solid/docs/imports.md",
139
+ url: "https://github.com/solidjs-community/eslint-plugin-solid/blob/main/packages/eslint-plugin-solid/docs/imports.md"
140
140
  },
141
141
  fixable: "code",
142
142
  schema: [],
143
143
  messages: {
144
- "prefer-source": 'Prefer importing {{name}} from "{{source}}".',
145
- },
144
+ "prefer-source": 'Prefer importing {{name}} from "{{source}}".'
145
+ }
146
146
  },
147
147
  defaultOptions: [],
148
148
  create(context) {
@@ -163,7 +163,7 @@ export default {
163
163
  messageId: "prefer-source",
164
164
  data: {
165
165
  name: specifier.imported.name,
166
- source: correctSource,
166
+ source: correctSource
167
167
  },
168
168
  fix(fixer) {
169
169
  const sourceCode = getSourceCode(context);
@@ -176,14 +176,14 @@ export default {
176
176
  const correctDeclaration = findTarget(
177
177
  program,
178
178
  correctSource,
179
- isType,
179
+ isType
180
180
  );
181
181
  if (correctDeclaration) {
182
182
  return [
183
183
  removeSpecifier(
184
184
  fixer,
185
185
  sourceCode,
186
- specifier,
186
+ specifier
187
187
  ),
188
188
  appendImports(
189
189
  fixer,
@@ -194,10 +194,10 @@ export default {
194
194
  specifier,
195
195
  isType &&
196
196
  correctDeclaration.importKind !==
197
- "type",
198
- ),
199
- ],
200
- ),
197
+ "type"
198
+ )
199
+ ]
200
+ )
201
201
  ].filter(Boolean);
202
202
  }
203
203
  const firstSolidDeclaration =
@@ -205,13 +205,13 @@ export default {
205
205
  (node) =>
206
206
  node.type ===
207
207
  "ImportDeclaration" &&
208
- isSource(node.source.value),
208
+ isSource(node.source.value)
209
209
  );
210
210
  return [
211
211
  removeSpecifier(
212
212
  fixer,
213
213
  sourceCode,
214
- specifier,
214
+ specifier
215
215
  ),
216
216
  insertImports(
217
217
  fixer,
@@ -219,15 +219,15 @@ export default {
219
219
  correctSource,
220
220
  [specifierText(specifier, false)],
221
221
  firstSolidDeclaration,
222
- isType,
223
- ),
222
+ isType
223
+ )
224
224
  ];
225
- },
225
+ }
226
226
  });
227
227
  }
228
228
  }
229
229
  }
230
- },
230
+ }
231
231
  };
232
- },
232
+ }
233
233
  };
@@ -4,7 +4,7 @@ export default {
4
4
  type: "problem",
5
5
  docs: {
6
6
  description: "Disallow passing the same prop twice in JSX.",
7
- url: "https://github.com/solidjs-community/eslint-plugin-solid/blob/main/packages/eslint-plugin-solid/docs/jsx-no-duplicate-props.md",
7
+ url: "https://github.com/solidjs-community/eslint-plugin-solid/blob/main/packages/eslint-plugin-solid/docs/jsx-no-duplicate-props.md"
8
8
  },
9
9
  schema: [
10
10
  {
@@ -14,19 +14,19 @@ export default {
14
14
  type: "boolean",
15
15
  description:
16
16
  "Consider two prop names differing only by case to be the same.",
17
- default: false,
18
- },
17
+ default: false
18
+ }
19
19
  },
20
- additionalProperties: false,
21
- },
20
+ additionalProperties: false
21
+ }
22
22
  ],
23
23
  messages: {
24
24
  noDuplicateProps: "Duplicate props are not allowed.",
25
25
  noDuplicateClass:
26
26
  "Duplicate `class` props are not allowed; while it might seem to work, it can break unexpectedly. Pass one `class` with the object or array form instead.",
27
27
  noDuplicateChildren:
28
- "Using {{used}} at the same time is not allowed.",
29
- },
28
+ "Using {{used}} at the same time is not allowed."
29
+ }
30
30
  },
31
31
  defaultOptions: [],
32
32
  create(context) {
@@ -47,13 +47,13 @@ export default {
47
47
  messageId:
48
48
  name === "class"
49
49
  ? "noDuplicateClass"
50
- : "noDuplicateProps",
50
+ : "noDuplicateProps"
51
51
  });
52
52
  }
53
53
  props.add(name);
54
54
  };
55
55
  for (const [name, propNode] of jsxGetAllProps(
56
- node.attributes,
56
+ node.attributes
57
57
  )) {
58
58
  checkPropName(name, propNode);
59
59
  }
@@ -67,18 +67,18 @@ export default {
67
67
  hasChildrenProp && "`props.children`",
68
68
  hasChildren && "JSX children",
69
69
  hasInnerHTML && "`props.innerHTML`",
70
- hasTextContent && "`props.textContent`",
70
+ hasTextContent && "`props.textContent`"
71
71
  ].filter(Boolean);
72
72
  if (used.length > 1) {
73
73
  context.report({
74
74
  node,
75
75
  messageId: "noDuplicateChildren",
76
76
  data: {
77
- used: used.join(", "),
78
- },
77
+ used: used.join(", ")
78
+ }
79
79
  });
80
80
  }
81
- },
81
+ }
82
82
  };
83
- },
83
+ }
84
84
  };
@@ -14,14 +14,14 @@ export const jsxNoScriptUrlRule = {
14
14
  meta: {
15
15
  docs: {
16
16
  description: "Disallow javascript: URLs.",
17
- url: "https://github.com/solidjs-community/eslint-plugin-solid/blob/main/packages/eslint-plugin-solid/docs/jsx-no-script-url.md",
17
+ url: "https://github.com/solidjs-community/eslint-plugin-solid/blob/main/packages/eslint-plugin-solid/docs/jsx-no-script-url.md"
18
18
  },
19
19
  messages: {
20
20
  noJSURL:
21
- "For security, don't use javascript: URLs. Use event handlers instead if you can.",
21
+ "For security, don't use javascript: URLs. Use event handlers instead if you can."
22
22
  },
23
23
  schema: [],
24
- type: "problem",
24
+ type: "problem"
25
25
  },
26
26
  defaultOptions: [],
27
27
  create(context) {
@@ -37,7 +37,7 @@ export const jsxNoScriptUrlRule = {
37
37
  : node.value;
38
38
  const staticValue = getStaticValue(
39
39
  expression,
40
- getScope(context, node),
40
+ getScope(context, node)
41
41
  );
42
42
 
43
43
  if (
@@ -47,10 +47,10 @@ export const jsxNoScriptUrlRule = {
47
47
  ) {
48
48
  context.report({
49
49
  messageId: "noJSURL",
50
- node: node.value,
50
+ node: node.value
51
51
  });
52
52
  }
53
- },
53
+ }
54
54
  };
55
- },
55
+ }
56
56
  };