Skip to content

Commit 50e29d6

Browse files
NicolappsConvex, Inc.
authored andcommitted
eslint: merge no-missing-args-validator + no-args-without-validator into one rule (#42036)
This pull request merges rules `@convex-dev/no-missing-args-validator` and `@convex-dev/no-args-without-validator` into one new rule: `@convex-dev/require-argument-validators`. The rule is customizable with an option named `ignoreUnusedArguments`, that allows the user to select whether they want to tolerate functions that don’t define argument validators but don’t use arguments. This option is _disabled_ by default, i.e. we force every function to have a return validator. I also changed the rule so that it behaves correctly with the old syntax. GitOrigin-RevId: 23aaa9835fc9d0682bc680518f6263c723bb8e84
1 parent 92e767f commit 50e29d6

File tree

13 files changed

+611
-716
lines changed

13 files changed

+611
-716
lines changed

npm-packages/@convex-dev/eslint-plugin/src/index.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import { noImportUseNode } from "./lib/noImportUseNode.js";
22
import noOldRegisteredFunctionSyntax from "./lib/noOldRegisteredFunctionSyntax.js";
3-
import { noMissingArgs, noArgsWithoutValidator } from "./lib/noMissingArgs.js";
3+
import { requireArgsValidator } from "./lib/requireArgsValidator.js";
44
import { RuleModule } from "@typescript-eslint/utils/ts-eslint";
55
import { version } from "./version.js";
66

77
const rules = {
88
"no-old-registered-function-syntax": noOldRegisteredFunctionSyntax,
9-
"no-args-without-validator": noArgsWithoutValidator,
10-
"no-missing-args-validator": noMissingArgs,
9+
"require-args-validator": requireArgsValidator,
1110
"import-wrong-runtime": noImportUseNode,
1211
} satisfies Record<string, RuleModule<string, unknown[]>>;
1312

@@ -17,12 +16,7 @@ const recommendedRules = {
1716
// file if all Node.js-specific imports are side-effect free.
1817
"@convex-dev/import-wrong-runtime": "off",
1918
"@convex-dev/no-old-registered-function-syntax": "error",
20-
// This is a reasonable idea in large projects: throw at runtime
21-
// when API endpoints that don't expect arguments receive them.
22-
// But it lacks the typical benefit of a validator providing
23-
// types so it feels more pedantic.
24-
"@convex-dev/no-missing-args-validator": "off",
25-
"@convex-dev/no-args-without-validator": "error",
19+
"@convex-dev/require-args-validator": "error",
2620
} satisfies {
2721
[key: `@convex-dev/${string}`]: "error" | "warn" | "off";
2822
};

npm-packages/@convex-dev/eslint-plugin/src/lib/noMissingArgs.ts

Lines changed: 0 additions & 198 deletions
This file was deleted.

0 commit comments

Comments
 (0)