Schema.is, Schema.decode*, Schema.encode*, Schema.validate*, and Schema.parse* each compile a parser/guard from a schema. Calling them inside a function body rebuilds that function on every invocation. Adds executor/no-inline-schema-compile (oxlint plugin rule) that flags these calls when they appear inside a function body, with two severities: HIGH when the schema argument is itself an inline Schema.X(...) literal (both AST and compile rebuilt), MEDIUM when only the compiler is re-called. Fixes the 44 existing violations across 22 files by hoisting the compiled function (and where applicable, its schema literal) to module scope. Notable consolidations: - oauth-service.ts: 8 sites (5 decode + 3 encode of OAuthProviderState) collapse into two hoisted helpers - jwks-cache.ts, mcp-auth.ts: per-call guard compilation removed from JWT verify error path - React Add*Source / EditOpenApiSource components: shared decodeErrorMessage / isOpenApiSourceBindingValue hoisted migrate-connections.ts has one targeted oxlint-disable for a higher-order helper whose schema is a function parameter; the compile is hoisted into the outer closure but the rule (correctly) flags any Schema compiler call inside a function body.
Showing the changes to scripts/oxlint-plugin-executor.js (1 of 25 files). Show all
Unified · Split
| @@ -5,6 +5,7 @@ import noEffectEscapeHatch from "./oxlint-plugin-executor/rules/no-effect-escape · 4 unmodified lines | |||
| 5 | import noEffectInternalTags from "./oxlint-plugin-executor/rules/no-effect-internal-tags.js"; | 5 | import noEffectInternalTags from "./oxlint-plugin-executor/rules/no-effect-internal-tags.js"; |
| 6 | import noErrorConstructor from "./oxlint-plugin-executor/rules/no-error-constructor.js"; | 6 | import noErrorConstructor from "./oxlint-plugin-executor/rules/no-error-constructor.js"; |
| 7 | import noInlineObjectTypeAssertion from "./oxlint-plugin-executor/rules/no-inline-object-type-assertion.js"; | 7 | import noInlineObjectTypeAssertion from "./oxlint-plugin-executor/rules/no-inline-object-type-assertion.js"; |
| 8 | import noInlineSchemaCompile from "./oxlint-plugin-executor/rules/no-inline-schema-compile.js"; | ||
| 8 | import noInstanceofError from "./oxlint-plugin-executor/rules/no-instanceof-error.js"; | 9 | import noInstanceofError from "./oxlint-plugin-executor/rules/no-instanceof-error.js"; |
| 9 | import noInstanceofTaggedError from "./oxlint-plugin-executor/rules/no-instanceof-tagged-error.js"; | 10 | import noInstanceofTaggedError from "./oxlint-plugin-executor/rules/no-instanceof-tagged-error.js"; |
| 10 | import noJsonParse from "./oxlint-plugin-executor/rules/no-json-parse.js"; | 11 | import noJsonParse from "./oxlint-plugin-executor/rules/no-json-parse.js"; |
| @@ -42,6 +43,7 @@ export default { · 31 unmodified lines | |||
| 42 | "no-error-constructor": noErrorConstructor, | 43 | "no-error-constructor": noErrorConstructor, |
| 43 | "no-ts-nocheck": noTsNocheck, | 44 | "no-ts-nocheck": noTsNocheck, |
| 44 | "no-inline-object-type-assertion": noInlineObjectTypeAssertion, | 45 | "no-inline-object-type-assertion": noInlineObjectTypeAssertion, |
| 46 | "no-inline-schema-compile": noInlineSchemaCompile, | ||
| 45 | "no-instanceof-error": noInstanceofError, | 47 | "no-instanceof-error": noInstanceofError, |
| 46 | "no-instanceof-tagged-error": noInstanceofTaggedError, | 48 | "no-instanceof-tagged-error": noInstanceofTaggedError, |
| 47 | "no-json-parse": noJsonParse, | 49 | "no-json-parse": noJsonParse, |