Skip to content

Commit

Permalink
build: add oxlint config (#210)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sysix authored Nov 2, 2024
1 parent 4ea3b31 commit 141fe73
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- uses: ./.github/actions/pnpm

- name: Run oxlint
run: npx oxlint
run: npx oxlint --config=oxlint.json --tsconfig=tsconfig.json

- name: Run eslint
run: npx eslint --flag unstable_ts_config
7 changes: 7 additions & 0 deletions oxlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"plugins": ["unicorn", "typescript", "oxc"],
"categories": {
"correctness": "error",
"suspicious": "warn"
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"generate": "node --import @oxc-node/core/register ./scripts/generate.ts",
"clone": "node --import @oxc-node/core/register ./scripts/sparse-clone.ts",
"build": "vite build",
"lint": "npx oxlint && npx eslint --flag unstable_ts_config",
"lint": "npx oxlint --config=oxlint.json --tsconfig=tsconfig.json && npx eslint --flag unstable_ts_config",
"format": "npx prettier --write .",
"test": "vitest --reporter=verbose"
},
Expand Down
14 changes: 7 additions & 7 deletions src/build-from-oxlint-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,23 +121,23 @@ const handleRulesScope = (
}
};

const isOffValue = (value: unknown) => value === 'off' || value === 0;

/**
* check if the value is "off", 0, ["off", ...], or [0, ...]
*/
const isDeactivateValue = (value: unknown): boolean => {
const isOff = (value: unknown) => value === 'off' || value === 0;

return isOff(value) || (Array.isArray(value) && isOff(value[0]));
return isOffValue(value) || (Array.isArray(value) && isOffValue(value[0]));
};

const isOnValue = (value: unknown) =>
value === 'error' || value === 'warn' || value === 1 || value === 2;

/**
* check if the value is "error", "warn", 1, 2, ["error", ...], ["warn", ...], [1, ...], or [2, ...]
*/
const isActiveValue = (value: unknown): boolean => {
const isOn = (value: unknown) =>
value === 'error' || value === 'warn' || value === 1 || value === 2;

return isOn(value) || (Array.isArray(value) && isOn(value[0]));
return isOnValue(value) || (Array.isArray(value) && isOnValue(value[0]));
};

/**
Expand Down

0 comments on commit 141fe73

Please sign in to comment.