Skip to content

Commit 234a4de

Browse files
committed
style(oxlint): order rule constants by cohort frequency; null over undefined sentinel
- prefer-exists-sync, prefer-safe-delete, sort-set-args, no-promise-race-in-loop: reorder method/type sets so the most-common variant comes first and related variants cluster (e.g. `stat`, `statSync`, `lstat`, `lstatSync` rather than alphabetical `lstat, lstatSync, stat, statSync`). Behavior is unchanged — these are Sets used for membership lookup — but scanning the rule code stays readable. - sort-source-methods: switch the `lastNameInGroup` / `currentVisibility` sentinels from `undefined` to `null`. The state machine is "nothing seen yet" not "value missing".
1 parent 06973be commit 234a4de

5 files changed

Lines changed: 20 additions & 7 deletions

File tree

.config/oxlint-plugin/rules/no-promise-race-in-loop.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,15 @@
2020
* Reporting only.
2121
*/
2222

23-
const RACE_METHODS = new Set(['any', 'race'])
23+
const RACE_METHODS = new Set(['race', 'any'])
2424

25-
const LOOP_TYPES = new Set(['DoWhileStatement', 'ForInStatement', 'ForOfStatement', 'ForStatement', 'WhileStatement'])
25+
const LOOP_TYPES = new Set([
26+
'ForStatement',
27+
'ForOfStatement',
28+
'ForInStatement',
29+
'WhileStatement',
30+
'DoWhileStatement',
31+
])
2632

2733
function isInsideLoop(node) {
2834
let current = node.parent

.config/oxlint-plugin/rules/prefer-exists-sync.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*/
2020

2121
const ACCESS_METHODS = new Set(['access', 'accessSync'])
22-
const STAT_METHODS = new Set(['lstat', 'lstatSync', 'stat', 'statSync'])
22+
const STAT_METHODS = new Set(['stat', 'statSync', 'lstat', 'lstatSync'])
2323

2424
/** @type {import('eslint').Rule.RuleModule} */
2525
const rule = {

.config/oxlint-plugin/rules/prefer-safe-delete.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,14 @@
1717
* (`.claude/hooks/path-guard/`) — this rule covers the JavaScript side.
1818
*/
1919

20-
const DELETE_METHODS = new Set(['rm', 'rmSync', 'rmdir', 'rmdirSync', 'unlink', 'unlinkSync'])
20+
const DELETE_METHODS = new Set([
21+
'rm',
22+
'rmSync',
23+
'unlink',
24+
'unlinkSync',
25+
'rmdir',
26+
'rmdirSync',
27+
])
2128

2229
/** @type {import('eslint').Rule.RuleModule} */
2330
const rule = {

.config/oxlint-plugin/rules/sort-set-args.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* but not auto-fixed (sorting computed values would change behavior).
1111
*/
1212

13-
const SET_NAMES = new Set(['SafeSet', 'Set'])
13+
const SET_NAMES = new Set(['Set', 'SafeSet'])
1414

1515
function isSortableElement(node) {
1616
return (

.config/oxlint-plugin/rules/sort-source-methods.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ const rule = {
6767
return {
6868
Program(programNode) {
6969
let lastVisibilityRank = -1
70-
let lastNameInGroup = undefined
71-
let currentVisibility = undefined
70+
let lastNameInGroup = null
71+
let currentVisibility = null
7272

7373
for (const node of programNode.body) {
7474
const info = declVisibility(node)

0 commit comments

Comments
 (0)