Skip to content

Commit 4dfed72

Browse files
NicolappsConvex, Inc.
authored andcommitted
Set up ESLint in @convex-dev/eslint-plugin (#41767)
GitOrigin-RevId: 99824490b61f24e8243fe661bcbd86ad7cb268fe
1 parent bb67159 commit 4dfed72

File tree

9 files changed

+311
-41
lines changed

9 files changed

+311
-41
lines changed

npm-packages/@convex-dev/eslint-plugin/.eslintrc

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// @ts-check
2+
3+
import eslint from "@eslint/js";
4+
import { defineConfig, globalIgnores } from "eslint/config";
5+
import tseslint from "typescript-eslint";
6+
import eslintPlugin from "eslint-plugin-eslint-plugin";
7+
8+
export default defineConfig(
9+
eslint.configs.recommended,
10+
tseslint.configs.recommended,
11+
eslintPlugin.configs.recommended,
12+
globalIgnores(["dist/**", "node_modules/**"]),
13+
);

npm-packages/@convex-dev/eslint-plugin/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,28 @@
44
"license": "Apache-2.0",
55
"type": "module",
66
"scripts": {
7-
"dev": "npm-run-all --parallel dev:db dev:frontend",
8-
"dev:db": "convex dev",
9-
"dev:frontend": "vite --open --clearScreen false",
107
"build": "tshy",
11-
"preview": "vite preview",
128
"test": "vitest run",
139
"test:types": "tsc --noEmit",
1410
"test:watch": "vitest",
15-
"prepare": "tshy"
11+
"prepare": "tshy",
12+
"lint": "eslint ."
1613
},
1714
"dependencies": {
1815
"@typescript-eslint/utils": "~8.38.0"
1916
},
2017
"devDependencies": {
18+
"@eslint/js": "~9.34.0",
2119
"@types/eslint": "~9.6.1",
2220
"@types/node": "^18.17.0",
2321
"@typescript-eslint/rule-tester": "~8.38.0",
2422
"@typescript-eslint/types": "~8.38.0",
2523
"eslint": "^9.37.0",
2624
"eslint-doc-generator": "^1.7.1",
25+
"eslint-plugin-eslint-plugin": "~7.0.0",
2726
"tshy": "^3.0.0",
2827
"typescript": "^5.9.2",
28+
"typescript-eslint": "^8.45.0",
2929
"vitest": "^3.2.4"
3030
},
3131
"tshy": {

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const rules = {
88
"no-args-without-validator": noArgsWithoutValidator,
99
"no-missing-args-validator": noMissingArgs,
1010
"import-wrong-runtime": noImportUseNode,
11-
} satisfies Record<string, RuleModule<any>>;
11+
} satisfies Record<string, RuleModule<string, unknown[]>>;
1212

1313
const recommendedRules = {
1414
// This rule is a good idea but bothersome to convert projects to later:
@@ -32,8 +32,10 @@ const isESM = typeof require === "undefined";
3232
const plugin = {
3333
// loose types so this can work with ESlint 8 and 9
3434
configs: {} as {
35+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
3536
recommended: any;
3637
/** Only available in ESlint 8 */
38+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
3739
recommendedRulesCustomConvexDirectoryLocation: any;
3840
},
3941
meta: {

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import path from "path";
22
import fs from "fs";
3-
import { AST_NODE_TYPES, TSESTree } from "@typescript-eslint/utils";
43
import { createRule, isEntryPoint } from "../util.js";
54

65
export const noImportUseNode = createRule({

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import type { TSESTree } from "@typescript-eslint/utils";
22
import { CONVEX_REGISTRARS, createRule } from "../util.js";
3+
import {
4+
ReportFixFunction,
5+
RuleContext,
6+
} from "@typescript-eslint/utils/ts-eslint";
37

48
/**
59
* Helper function to check if an object expression has an args property
@@ -44,9 +48,9 @@ function getHandlerProperty(
4448
* Helper function to create a fix for missing args property
4549
*/
4650
function createArgsFix(
47-
context: any,
51+
context: RuleContext<string, unknown[]>,
4852
objectArg: TSESTree.ObjectExpression,
49-
): ((fixer: any) => any) | undefined {
53+
): ReportFixFunction {
5054
return (fixer) => {
5155
const sourceCode = context.getSourceCode();
5256
const objectText = sourceCode.getText(objectArg);

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,6 @@ export const noOldRegisteredFunctionSyntax = createRule({
7474
node: node.init,
7575
messageId: "use-object-syntax",
7676
fix: (fixer) => {
77-
// Get function parameters and body
78-
const params = functionArg.params;
79-
8077
// Check if the function has a second parameter (args)
8178
const hasArgsParam = hasFunctionArgs(functionArg);
8279

npm-packages/common/config/rush/common-versions.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
"@types/node": ["^20", "^22.5.4"],
109109
"@types/react": ["^18", "^18.3.17", "^18.2.65"],
110110
"@types/react-dom": ["^18", "^18.3.1", "^18.2.21"],
111+
"typescript-eslint": ["^8.45.0"],
111112
"@typescript-eslint/eslint-plugin": ["^8.45.0"],
112113
//"eslint": ["^8"],
113114
"@eslint/eslintrc": ["^3"],

0 commit comments

Comments
 (0)