-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patheslint.config.js
More file actions
62 lines (61 loc) · 3.05 KB
/
Copy patheslint.config.js
File metadata and controls
62 lines (61 loc) · 3.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import eslint from "@eslint/js";
import tseslint from "@typescript-eslint/eslint-plugin";
import tsparser from "@typescript-eslint/parser";
export default [
eslint.configs.recommended,
{
files: ["**/*.ts"],
languageOptions: {
parser: tsparser,
},
plugins: {
"@typescript-eslint": tseslint,
},
rules: {
"func-style": ["error", "expression"],
"prefer-const": "error",
"no-var": "error",
eqeqeq: ["error", "always", { null: "ignore" }],
curly: ["error", "all"],
"no-undef": "off", // tsgo handles this
"no-redeclare": "off", // tsgo handles this; flags valid TS overload signatures
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": ["error", {
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
}],
"@typescript-eslint/consistent-type-imports": "error",
"no-restricted-syntax": ["error", {
selector: "ImportExpression",
message: "Use top-level imports. Dynamic import() is not allowed unless there is a real performance or correctness reason.",
}, {
selector: "CallExpression[callee.name='require']",
message: "Use top-level imports. require() is not allowed.",
}, {
// Block computed-key mutation where the key is dynamic (a variable,
// identifier, or symbol). `obj["foo"] = x` (literal key) is fine,
// `obj[key] = x` (variable) is the proto-pollution risk.
selector: "AssignmentExpression[left.type='MemberExpression'][left.computed=true][left.property.type!='Literal']",
message: "Don't mutate via dynamic computed keys (proto-pollution risk). Use Object.fromEntries, a Map, or Object.defineProperty when you really mean it.",
}, {
// The literal case still needs guarding for __proto__ specifically —
// both `obj.__proto__ = x` and `obj["__proto__"] = x` invoke the setter.
selector: "AssignmentExpression[left.type='MemberExpression'][left.computed=false][left.property.name='__proto__']",
message: "Don't assign to __proto__ — use Object.setPrototypeOf if you really mean it.",
}, {
selector: "AssignmentExpression[left.type='MemberExpression'][left.computed=true][left.property.value='__proto__']",
message: "Don't assign to __proto__ — use Object.setPrototypeOf if you really mean it.",
}, {
// `@expose.unchecked` skips the zod schema typegres uses to validate
// RPC arguments. Legitimate only for internal methods with generics
// that can't be expressed in zod, or test fixtures. Every use must
// be acknowledged with a disable comment + reason.
selector: "MemberExpression[object.name='expose'][property.name='unchecked']",
message: "Don't use @expose.unchecked — it skips RPC arg validation. Use @expose(zSchema) instead. If the method's signature is genuinely inexpressible in zod (or this is a test fixture), add `// eslint-disable-next-line no-restricted-syntax -- <reason>`.",
}],
},
},
{
ignores: ["dist/", "src/types/*/generated/"],
},
];