mirror of
https://github.com/stablyai/orca.git
synced 2026-11-13 17:37:40 +00:00
* chore(lint): bump oxlint to 1.91, add perf lint rules and perf audits * fix(lint): await promises returned inside try/catch/finally for return-await Prepare typescript/return-await with error-handling-correctness-only: await returns whose catch or finally was meant to cover them, and suppress the eight sites where the catch must not re-handle the returned promise. * chore(lint): enable return-await (error-handling-correctness-only); exempt secondary-scan directives in the changed gate * refactor(mobile): move file preview discard modal into its own module Keeps MobileFilePreviewScreen under the 400-line limit after merging main. --------- Co-authored-by: m4air <m4air@m4airs-MacBook-Air.local>
32 lines
1.5 KiB
JavaScript
32 lines
1.5 KiB
JavaScript
import { readFileSync } from 'node:fs'
|
|
|
|
export const JS_PLUGINS_CONFIG = 'config/oxlint-js-plugins.json'
|
|
// The root scan no longer loads these plugins, so their suppressions belong to the JS plugins scan.
|
|
const JS_PLUGIN_NAMES = JSON.parse(
|
|
readFileSync(new URL(`../../../../${JS_PLUGINS_CONFIG}`, import.meta.url), 'utf8')
|
|
).jsPlugins.map((plugin) => plugin.name)
|
|
export const JS_PLUGIN_DISABLE_PATTERN = new RegExp(
|
|
String.raw`\/[/*]\s*(?:oxlint|eslint)-disable(?:-next-line|-line)?\s[^\n]*\b(?:${JS_PLUGIN_NAMES.join('|')})\/`
|
|
)
|
|
|
|
function readConfigRules(configPath) {
|
|
const url = new URL(`../../../../${configPath}`, import.meta.url)
|
|
const config = JSON.parse(readFileSync(url, 'utf8'))
|
|
return [config.rules, ...(config.overrides ?? []).map((override) => override.rules)].flatMap(
|
|
(rules) => Object.keys(rules ?? {})
|
|
)
|
|
}
|
|
|
|
// The root scan loads neither tsgolint nor the import plugin, so these rules' suppressions belong to their own scans.
|
|
const rootRuleNames = new Set(readConfigRules('.oxlintrc.json'))
|
|
const secondaryOnlyRuleNames = [
|
|
...new Set([
|
|
...readConfigRules('config/oxlint-code-quality-type-aware.json'),
|
|
...readConfigRules('config/oxlint-code-quality-native-plugins.json')
|
|
])
|
|
].filter((rule) => !rootRuleNames.has(rule))
|
|
|
|
export const SECONDARY_SCAN_DISABLE_PATTERN = new RegExp(
|
|
String.raw`\/[/*]\s*(?:oxlint|eslint)-disable(?:-next-line|-line)?\s[^\n]*(?:${secondaryOnlyRuleNames.map((rule) => rule.replaceAll('/', '\\/')).join('|')})(?![\w-])`
|
|
)
|