Skip to content

Commit 669704a

Browse files
committed
add jsPlugins for rules that need ESLint plugin runtime
recover rules that have no native oxlint equivalent by running the original ESLint plugins via oxlint's jsPlugins (alpha) feature: - oxlint-plugin-eslint: no-restricted-properties, no-restricted-syntax, prefer-arrow-callback, object-shorthand, logical-assignment-operators, one-var, operator-assignment, spaced-comment, quotes, etc. - eslint-plugin-react-hooks: React Compiler rules (refs, purity, set-state-in-effect, immutability, etc.) — set to warn for now since react-hooks v6 is stricter than the old monolithic react-compiler rule sonarjs and @Shopify require eslint as a peer dep at runtime, so they can't be used as jsPlugins without pulling eslint back in. dropped.
1 parent a14ae7d commit 669704a

4 files changed

Lines changed: 268 additions & 1 deletion

File tree

.oxlintrc.json

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
},
3030
// TODO: enable after TS 5.8 upgrade lands (trevor/ts-native-and-5.8)
3131
// "options": { "typeAware": true },
32+
"jsPlugins": [
33+
{ "name": "eslint-js", "specifier": "oxlint-plugin-eslint" },
34+
{ "name": "react-hooks-js", "specifier": "eslint-plugin-react-hooks" }
35+
],
3236
"rules": {
3337
// --- Core ESLint rules ---
3438
"no-console": "error",
@@ -160,6 +164,65 @@
160164
// --- Promise rules ---
161165
"promise/no-multiple-resolved": "error",
162166

167+
// --- JS plugin: core ESLint rules (via oxlint-plugin-eslint) ---
168+
"eslint-js/no-restricted-properties": [
169+
"error",
170+
{
171+
"object": "window",
172+
"property": "localStorage",
173+
"message": "Use `localStorage` instead"
174+
},
175+
{
176+
"object": "window",
177+
"property": "location",
178+
"message": "Use `location` instead"
179+
},
180+
{
181+
"object": "window",
182+
"property": "navigator",
183+
"message": "Use `navigator` instead"
184+
},
185+
{
186+
"object": "window",
187+
"property": "getComputedStyle",
188+
"message": "Use `getComputedStyle` instead"
189+
},
190+
{
191+
"object": "self",
192+
"message": "Use `globalThis` instead"
193+
}
194+
],
195+
"eslint-js/no-restricted-syntax": [
196+
"error",
197+
{
198+
"selector": "CallExpression[callee.name=useMemo][arguments.1.type=ArrayExpression][arguments.1.elements.length=0]",
199+
"message": "`useMemo` with an empty dependency array can't provide a stable reference, use `useRef` instead."
200+
},
201+
{
202+
"selector": "MemberExpression > .property[type=Identifier][name=keyCode]",
203+
"message": "Use `.key` instead of `.keyCode`"
204+
}
205+
],
206+
"eslint-js/prefer-arrow-callback": ["error", { "allowNamedFunctions": true }],
207+
"eslint-js/object-shorthand": ["error", "always", { "avoidExplicitReturnArrows": true }],
208+
"eslint-js/one-var": ["error", "never"],
209+
"eslint-js/operator-assignment": "error",
210+
"eslint-js/logical-assignment-operators": ["error", "always", { "enforceForIfStatements": true }],
211+
"eslint-js/no-octal-escape": "error",
212+
"eslint-js/no-return-await": "error",
213+
"eslint-js/spaced-comment": ["error", "always", { "markers": ["/"] }],
214+
"eslint-js/quotes": ["error", "single", { "avoidEscape": true }],
215+
216+
// sonarjs and @shopify require eslint as a peer dep, can't use as jsPlugins
217+
// without pulling eslint back in. Drop for now — low-value rules.
218+
// If sonarjs ships a standalone version, re-add these:
219+
// "sonarjs/no-inverted-boolean-check", "sonarjs/no-identical-functions",
220+
// "sonarjs/no-unused-collection", "sonarjs/no-extra-arguments",
221+
// "sonarjs/no-ignored-return", "sonarjs/no-redundant-jump",
222+
// "sonarjs/no-small-switch", "sonarjs/no-duplicated-branches",
223+
// "sonarjs/prefer-promise-shorthand", "sonarjs/no-dead-store", "sonarjs/void-use"
224+
// "@shopify/prefer-early-return"
225+
163226
// Disable plugin defaults not in original config
164227
"jest/no-standalone-expect": "off",
165228
"jest/valid-expect": "off",
@@ -255,6 +318,20 @@
255318
}
256319
],
257320
// "typescript/no-deprecated": "error" // TODO: re-enable with typeAware
321+
// React Compiler rules (react-hooks v6 split react-compiler into granular rules)
322+
"react-hooks-js/static-components": "error",
323+
"react-hooks-js/use-memo": "error",
324+
"react-hooks-js/component-hook-factories": "error",
325+
"react-hooks-js/preserve-manual-memoization": "error",
326+
"react-hooks-js/immutability": "error",
327+
"react-hooks-js/globals": "error",
328+
"react-hooks-js/refs": "warn",
329+
"react-hooks-js/set-state-in-effect": "warn",
330+
"react-hooks-js/error-boundaries": "error",
331+
"react-hooks-js/purity": "error",
332+
"react-hooks-js/set-state-in-render": "error",
333+
"react-hooks-js/config": "error",
334+
"react-hooks-js/gating": "error"
258335
}
259336
},
260337
{

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,14 @@
9494
"concurrently": "^7.0.0",
9595
"copy": "^0.3.2",
9696
"cspell": "^5.15.2",
97+
"eslint-plugin-react-hooks": "^6.0.0-rc.1",
9798
"execa": "^7.1.1",
9899
"fetch-mock": "6.5.2",
99100
"jest": "^27.5.1",
100101
"js-green-licenses": "4.0.0",
101102
"mkdirp": "^1.0.4",
102103
"oxlint": "^1",
104+
"oxlint-plugin-eslint": "^1",
103105
"oxlint-tsgolint": "latest",
104106
"patch-package": "^7.0.2",
105107
"postinstall-postinstall": "^2.1.0",

packages/graphql-language-service/src/interface/getAutocompleteSuggestions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ function getSuggestionsForFieldNames(
542542

543543
suggestion.insertText = getFieldInsertText(field);
544544

545-
// eslint-disable-next-line logical-assignment-operators
545+
// oxlint-disable-next-line eslint-js/logical-assignment-operators
546546
if (!suggestion.insertText) {
547547
suggestion.insertText = getInsertText(
548548
field.name,

0 commit comments

Comments
 (0)