@vvedantb/config 0.16.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +5 -1
  3. package/dist/android-release-cli.js +0 -40
  4. package/dist/android-release-version.d.ts +0 -20
  5. package/dist/android-release-version.js +0 -15
  6. package/dist/android-release.d.ts +0 -54
  7. package/dist/android-release.js +0 -20
  8. package/dist/check-asar-cli.js +0 -1
  9. package/dist/check-asar.d.ts +0 -2
  10. package/dist/check-asar.js +0 -7
  11. package/dist/check-no-comments.js +2 -3
  12. package/dist/check-no-source-text.js +0 -1
  13. package/dist/check-shared-ui.d.ts +0 -12
  14. package/dist/check-shared-ui.js +0 -1
  15. package/dist/clerk-allow.js +0 -6
  16. package/dist/doctor.d.ts +0 -7
  17. package/dist/doctor.js +0 -14
  18. package/dist/expo.d.ts +0 -14
  19. package/dist/expo.js +0 -5
  20. package/dist/extension.d.ts +0 -18
  21. package/dist/extension.js +0 -2
  22. package/dist/oxlint-anti-slop/define.js +0 -2
  23. package/dist/oxlint-anti-slop/index.d.ts +0 -1
  24. package/dist/oxlint-anti-slop/index.js +0 -1
  25. package/dist/release-signing.d.ts +0 -36
  26. package/dist/release-signing.js +0 -7
  27. package/dist/sync.d.ts +0 -3
  28. package/dist/versions.d.ts +0 -2
  29. package/dist/versions.js +0 -2
  30. package/dist/vite.d.ts +0 -16
  31. package/dist/vitest-shared-setup.js +0 -8
  32. package/dist/vitest-shared.d.ts +0 -9
  33. package/dist/vitest-shared.js +0 -15
  34. package/oxlint/base.json +28 -0
  35. package/oxlint/plugin.mjs +8 -20
  36. package/oxlint/rules/convex-no-collect-in-query.mjs +26 -0
  37. package/oxlint/rules/convex-no-filter-in-query.mjs +38 -0
  38. package/oxlint/rules/convex-no-time-or-random-in-queries.mjs +81 -0
  39. package/oxlint/rules/no-comments.mjs +9 -2
  40. package/oxlint/rules/no-conditional-tests.mjs +0 -2
  41. package/oxlint/rules/no-double-cast.mjs +0 -1
  42. package/oxlint/rules/no-inline-zod-schema.mjs +0 -3
  43. package/oxlint/rules/no-is-record.mjs +0 -5
  44. package/oxlint/rules/no-json-parse.mjs +0 -6
  45. package/oxlint/rules/no-settings-description.mjs +0 -5
  46. package/oxlint/rules/no-source-text-in-tests.mjs +0 -7
  47. package/oxlint/rules/no-tab-search-param.mjs +63 -0
  48. package/oxlint/rules/no-unknown-shape-probing.mjs +0 -6
  49. package/oxlint/rules/no-value-block-in-try.mjs +0 -23
  50. package/oxlint/rules/prefer-schema-inferred-types.mjs +0 -5
  51. package/oxlint/utils.mjs +46 -2
  52. package/package.json +1 -1
@@ -0,0 +1,81 @@
1
+ import { isIdentifier, toPosix, unwrapExpression } from "../utils.mjs";
2
+
3
+ const timeMessage =
4
+ "A Convex query reads the clock here. Query results are cached, so the value goes stale, and reading the clock invalidates the cache more often than needed. " +
5
+ "Pass the time in as an argument, or move this to a mutation or action.";
6
+ const randomMessage =
7
+ "A Convex query generates a random value here. Query results are cached, so every caller gets the same value until the cache invalidates. Use a mutation instead.";
8
+
9
+ const QUERY_NAME = /query$/i;
10
+ const RANDOM_SOURCES = new Set(["Math.random", "crypto.randomUUID", "crypto.getRandomValues"]);
11
+ const TIME_SOURCES = new Set(["Date", "Date.now", "performance.now"]);
12
+
13
+ function staticPath(node) {
14
+ const expression = unwrapExpression(node);
15
+ if (isIdentifier(expression)) return [expression.name];
16
+ if (
17
+ expression?.type === "MemberExpression" &&
18
+ !expression.computed &&
19
+ isIdentifier(expression.property)
20
+ ) {
21
+ const base = staticPath(expression.object);
22
+ return base ? [...base, expression.property.name] : null;
23
+ }
24
+ return null;
25
+ }
26
+
27
+ function classify(node) {
28
+ const path = staticPath(node.callee);
29
+ if (!path) return null;
30
+ const joined = (path[0] === "globalThis" ? path.slice(1) : path).join(".");
31
+ if (node.type === "NewExpression") {
32
+ return joined === "Date" && node.arguments.length === 0 ? timeMessage : null;
33
+ }
34
+ if (TIME_SOURCES.has(joined)) return timeMessage;
35
+ return RANDOM_SOURCES.has(joined) ? randomMessage : null;
36
+ }
37
+
38
+ /** Flags clock and random reads inside Convex query handlers. Syntactic port of `@convex-dev/eslint-plugin` `no-time-or-random-in-queries`; it checks the handler body, not the helpers it calls. */
39
+ export default {
40
+ meta: { type: "problem", docs: { description: timeMessage } },
41
+ create(context) {
42
+ if (toPosix(context.filename).includes("/_generated/")) return {};
43
+ const handlers = new Set();
44
+ let depth = 0;
45
+ const enterFunction = (node) => {
46
+ if (handlers.has(node)) depth += 1;
47
+ };
48
+ const exitFunction = (node) => {
49
+ if (handlers.has(node)) depth -= 1;
50
+ };
51
+ const report = (node) => {
52
+ if (depth === 0) return;
53
+ const message = classify(node);
54
+ if (message) context.report({ node, message });
55
+ };
56
+ return {
57
+ CallExpression(node) {
58
+ const callee = unwrapExpression(node.callee);
59
+ if (isIdentifier(callee) && QUERY_NAME.test(callee.name)) {
60
+ const config = unwrapExpression(node.arguments[0]);
61
+ if (config?.type === "ObjectExpression") {
62
+ for (const property of config.properties) {
63
+ if (property.type === "Property" && isIdentifier(property.key, "handler")) {
64
+ const handler = unwrapExpression(property.value);
65
+ if (handler) handlers.add(handler);
66
+ }
67
+ }
68
+ } else if (config) {
69
+ handlers.add(config);
70
+ }
71
+ }
72
+ report(node);
73
+ },
74
+ NewExpression: report,
75
+ FunctionExpression: enterFunction,
76
+ "FunctionExpression:exit": exitFunction,
77
+ ArrowFunctionExpression: enterFunction,
78
+ "ArrowFunctionExpression:exit": exitFunction,
79
+ };
80
+ },
81
+ };
@@ -3,13 +3,16 @@ const message =
3
3
  "Kept: lint and tool directives, license headers, doc comments on exports, and comments with an issue or RFC link.";
4
4
 
5
5
  const directive =
6
- /^\s*(?:[*/]\s*)?(?:eslint-(?:disable|enable)|oxlint-(?:disable|enable)|@ts-(?:expect-error|ignore|nocheck|check)|[a-z]+(?:-[a-z]+)*-ignore\b|@vite-ignore|@vitest-environment|webpack[A-Z]|[#@]__(?:PURE|NO_SIDE_EFFECTS)__|@refresh\b|@jsx|<reference\b|(?:istanbul|c8|v8) ignore)/;
6
+ /^\s*(?:[*/]\s*)?(?:eslint-(?:disable|enable)|oxlint-(?:disable|enable)|@ts-(?:expect-error|ignore|nocheck|check)|[a-z]+(?:-[a-z]+)*-ignore\b|@vite-ignore|@vitest-environment|check-[a-z]+-allow:|allow-source-read:|webpack[A-Z]|[#@]__(?:PURE|NO_SIDE_EFFECTS)__|@refresh\b|@jsx|<reference\b|(?:istanbul|c8|v8) ignore)/;
7
7
  const license = /\b(?:license|copyright|SPDX-License-Identifier)\b/i;
8
8
  const link = /https?:\/\//;
9
9
  const typeAnnotation = /^\*\s*@(?:type|satisfies)\s*\{/;
10
10
 
11
11
  function isKept(comment, text) {
12
12
  const value = comment.value;
13
+ if (comment.type === "Shebang" || text.startsWith("#!", comment.range[0])) {
14
+ return true;
15
+ }
13
16
  if (directive.test(value) || license.test(value) || link.test(value) || typeAnnotation.test(value)) {
14
17
  return true;
15
18
  }
@@ -92,7 +95,11 @@ export default {
92
95
  },
93
96
  create(context) {
94
97
  const filename = (context.filename ?? context.getFilename?.() ?? "").replaceAll("\\", "/");
95
- if (/\.d\.ts$/.test(filename) || /\/\.(?:claude|agents)\//.test(filename)) {
98
+ if (
99
+ /\.d\.ts$/.test(filename) ||
100
+ /\/oxlint\/no-effect\.mjs$/.test(filename) ||
101
+ /\/\.(?:claude|agents)\//.test(filename)
102
+ ) {
96
103
  return {};
97
104
  }
98
105
  const sourceCode = context.sourceCode;
@@ -20,7 +20,6 @@ function getCallName(callee) {
20
20
  callee.type === "MemberExpression" &&
21
21
  callee.property?.type === "Identifier"
22
22
  ) {
23
- // expect(...).toBe — still report on expect itself via CallExpression on expect
24
23
  return callee.property.name;
25
24
  }
26
25
  return undefined;
@@ -46,7 +45,6 @@ export default {
46
45
  return {
47
46
  CallExpression(node) {
48
47
  if (conditionalDepth === 0) return;
49
- // Only the bare `expect(...)` call — not `.toBe` member calls.
50
48
  if (node.callee?.type !== "Identifier") return;
51
49
  if (getCallName(node.callee) !== "expect") return;
52
50
  context.report({ node, message });
@@ -10,7 +10,6 @@ export default {
10
10
  },
11
11
  create(context) {
12
12
  return {
13
- // `x as A as B` nests one TSAsExpression inside another.
14
13
  TSAsExpression(node) {
15
14
  if (node.expression?.type === "TSAsExpression") {
16
15
  context.report({ node, message });
@@ -44,7 +44,6 @@ const isBlockInsideFunction = (block) => {
44
44
  );
45
45
  };
46
46
 
47
- /** Module scope = not inside functions/methods/control-flow blocks. */
48
47
  const isAtModuleScope = (node) => {
49
48
  let current = node.parent;
50
49
  while (current && current.type !== "Program") {
@@ -52,7 +51,6 @@ const isAtModuleScope = (node) => {
52
51
  if (current.type === "BlockStatement" && isBlockInsideFunction(current)) {
53
52
  return false;
54
53
  }
55
- // Chained schema methods: z.string().optional().catch(null)
56
54
  if (
57
55
  current.type === "MemberExpression" &&
58
56
  current.parent?.type === "CallExpression"
@@ -65,7 +63,6 @@ const isAtModuleScope = (node) => {
65
63
  return current?.type === "Program";
66
64
  };
67
65
 
68
- /** True if expression is `z.<method>(...)` or chained `z.object(...).strict()`. */
69
66
  const isZodSchemaExpression = (node) => {
70
67
  if (node?.type !== "CallExpression") return false;
71
68
  const callee = node.callee;
@@ -1,8 +1,3 @@
1
- /**
2
- * Message shown when the banned `isRecord` identifier is found anywhere. It is
3
- * deliberately written as an instruction to whoever (human or agent) is editing
4
- * the code: the generic `unknown`-narrowing guard is a symptom, not the fix.
5
- */
6
1
  const message =
7
2
  "BANNED: `isRecord`. If you are writing or using `isRecord`, an `unknown` has " +
8
3
  "leaked somewhere it should never reach — that `unknown` is the actual bug. " +
@@ -41,9 +41,6 @@ export default {
41
41
  create(context) {
42
42
  const allowUnknown = context.options?.[0]?.allowUnknownEscapeHatch === true;
43
43
  const message = allowUnknown ? lenientMessage : strictMessage;
44
- // JSON.parse nodes that sit in a disciplined position. Enclosing nodes are
45
- // visited before the inner JSON.parse (top-down), so this is populated in
46
- // time for the check below.
47
44
  const allowed = new Set();
48
45
  const allow = (node) => {
49
46
  if (isJsonParse(node)) allowed.add(node);
@@ -52,7 +49,6 @@ export default {
52
49
  const visitors = {
53
50
  CallExpression(node) {
54
51
  const callee = node.callee;
55
- // `schema.safeParse(JSON.parse(...))` / `schema.parse(JSON.parse(...))`
56
52
  if (
57
53
  callee?.type === "MemberExpression" &&
58
54
  !isIdentifier(callee.object, "JSON") &&
@@ -69,13 +65,11 @@ export default {
69
65
  };
70
66
 
71
67
  if (allowUnknown) {
72
- // `const x: unknown = JSON.parse(...)`
73
68
  visitors.VariableDeclarator = (node) => {
74
69
  if (isUnknownKeyword(node.id?.typeAnnotation?.typeAnnotation)) {
75
70
  allow(node.init);
76
71
  }
77
72
  };
78
- // `JSON.parse(...) as unknown`
79
73
  visitors.TSAsExpression = (node) => {
80
74
  if (isUnknownKeyword(node.typeAnnotation)) allow(node.expression);
81
75
  };
@@ -1,8 +1,3 @@
1
- // Flags a `description` prop on the settings layout components. A section or
2
- // row shows a title only; helper text under it is extra reading for the user.
3
- // Options: `{ "components": ["ProfileCard"] }` adds component names to the
4
- // built-in list.
5
-
6
1
  const DEFAULT_COMPONENTS = ["SettingsSection", "SettingsToggleRow", "LabeledSwitchRow"];
7
2
 
8
3
  function elementName(name) {
@@ -1,7 +1,3 @@
1
- /**
2
- * Message shown when a test reads a repo source file. Written as an
3
- * instruction to whoever (human or agent) is editing the test.
4
- */
5
1
  const message =
6
2
  "BANNED: tests that read source files as text. A regex over source breaks " +
7
3
  "on every refactor and passes on real logic bugs. Import the code and assert " +
@@ -10,9 +6,7 @@ const message =
10
6
 
11
7
  const TEST_FILE =
12
8
  /(\.(test|spec)\.[cm]?[jt]sx?$)|(\/__tests__\/)|(\/tests\/[^/]+\.[cm]?[jt]sx?$)/;
13
- /** A path or file name ending in a source extension, not a bare extension. */
14
9
  const SOURCE_PATH = /[^/.][^/]*\.(ts|tsx|mts|css|html)$/;
15
- /** File reads, plus helpers that wrap them (`read`, `readSource`, `sourceOf`). */
16
10
  const READ_CALL = /^(read|source)|Source$/;
17
11
 
18
12
  function calleeName(call) {
@@ -24,7 +18,6 @@ function calleeName(call) {
24
18
  return "";
25
19
  }
26
20
 
27
- /** True when the string is (part of) an argument to a file-read call. */
28
21
  function isReadArgument(node) {
29
22
  let child = node;
30
23
  for (let parent = node.parent; parent; parent = parent.parent) {
@@ -0,0 +1,63 @@
1
+ import { isIdentifier } from "../utils.mjs";
2
+
3
+ const message =
4
+ "Do not put the tab in the query string (`?tab=x`). Give each tab a nested route, for example `/edit-details/specialisms`, so the tab has its own URL, back button and deep link.";
5
+
6
+ const PARAM_METHODS = new Set(["get", "getAll", "has", "set", "delete", "append"]);
7
+ const PARAM_OBJECT = /search|params|query/i;
8
+ const TAB_IN_URL = /[?&]tab=/;
9
+
10
+ function receiverName(node) {
11
+ if (isIdentifier(node)) return node.name;
12
+ if (node?.type === "MemberExpression" && !node.computed && isIdentifier(node.property)) {
13
+ return node.property.name;
14
+ }
15
+ return null;
16
+ }
17
+
18
+ function isTabLiteral(node) {
19
+ return node?.type === "Literal" && node.value === "tab";
20
+ }
21
+
22
+ /** Flags `?tab=` URLs: `searchParams.get("tab")`, `useQueryState("tab")`, `"...?tab=x"` strings. */
23
+ export default {
24
+ meta: { type: "suggestion", docs: { description: message } },
25
+ create(context) {
26
+ return {
27
+ CallExpression(node) {
28
+ const callee = node.callee;
29
+ if (callee.type === "MemberExpression" && !callee.computed) {
30
+ const name = receiverName(callee.object);
31
+ if (
32
+ name &&
33
+ PARAM_OBJECT.test(name) &&
34
+ isIdentifier(callee.property) &&
35
+ PARAM_METHODS.has(callee.property.name) &&
36
+ isTabLiteral(node.arguments[0])
37
+ ) {
38
+ context.report({ node, message });
39
+ }
40
+ return;
41
+ }
42
+ if (isIdentifier(callee, "useQueryState") && isTabLiteral(node.arguments[0])) {
43
+ context.report({ node, message });
44
+ }
45
+ },
46
+ MemberExpression(node) {
47
+ if (node.computed || !isIdentifier(node.property, "tab")) return;
48
+ const name = receiverName(node.object);
49
+ if (name && /^(?:searchParams|search)$/.test(name)) {
50
+ context.report({ node, message });
51
+ }
52
+ },
53
+ Literal(node) {
54
+ if (typeof node.value === "string" && TAB_IN_URL.test(node.value)) {
55
+ context.report({ node, message });
56
+ }
57
+ },
58
+ TemplateElement(node) {
59
+ if (TAB_IN_URL.test(node.value.raw)) context.report({ node, message });
60
+ },
61
+ };
62
+ },
63
+ };
@@ -1,11 +1,5 @@
1
1
  import { isIdentifier } from "../utils.mjs";
2
2
 
3
- // NOTE: intentionally does NOT flag `"key" in x`. In this codebase `in` is the
4
- // idiomatic, sanctioned way to narrow discriminated unions (`"error" in auth`),
5
- // walk Errors (`"code" in err`), and refine typed SDK unions (Notion, TipTap) —
6
- // the eslint `isRecord` ban explicitly prefers that over `Reflect.get` ceremony.
7
- // Only `Reflect.get` (dynamic property access that defeats the type system in
8
- // domain code) is flagged here.
9
3
  const message =
10
4
  "Do not use `Reflect.get` to read properties in domain code. Narrow a typed " +
11
5
  "value directly, or parse external input at its boundary with a zod schema " +
@@ -27,14 +27,12 @@ const noCatchMessage =
27
27
  "It cannot compile a `try` without a `catch`. Add a `catch` clause — use " +
28
28
  "`catch { }` if there is genuinely nothing to handle.";
29
29
 
30
- /** Value blocks: expression-level control flow the compiler cannot lower here. */
31
30
  const VALUE_BLOCKS = new Set([
32
31
  "ConditionalExpression",
33
32
  "LogicalExpression",
34
33
  "ChainExpression",
35
34
  ]);
36
35
 
37
- /** Loops bail too — their test expression is itself lowered as a value block. */
38
36
  const LOOPS = new Set([
39
37
  "ForStatement",
40
38
  "ForInStatement",
@@ -43,7 +41,6 @@ const LOOPS = new Set([
43
41
  "DoWhileStatement",
44
42
  ]);
45
43
 
46
- /** `&&=` / `||=` / `??=` desugar to a value block just like their operators. */
47
44
  const LOGICAL_ASSIGN = new Set(["&&=", "||=", "??="]);
48
45
 
49
46
  const FUNCTIONS = new Set([
@@ -52,10 +49,8 @@ const FUNCTIONS = new Set([
52
49
  "ArrowFunctionExpression",
53
50
  ]);
54
51
 
55
- /** Wrappers that keep the component name on the outer binding. */
56
52
  const NAME_PRESERVING_CALLS = new Set(["memo", "forwardRef", "observer"]);
57
53
 
58
- /** React Compiler only lowers components (`Foo`) and hooks (`useFoo`). */
59
54
  const isCompiledName = (name) =>
60
55
  typeof name === "string" && /^(use[A-Z]|[A-Z])/.test(name);
61
56
 
@@ -63,13 +58,11 @@ function isOffending(node) {
63
58
  if (VALUE_BLOCKS.has(node.type)) return true;
64
59
  if (LOOPS.has(node.type)) return true;
65
60
  if (node.type === "AssignmentExpression") return LOGICAL_ASSIGN.has(node.operator);
66
- // Optional chaining, when the parser emits no wrapping ChainExpression.
67
61
  if (node.type === "MemberExpression" || node.type === "CallExpression")
68
62
  return node.optional === true;
69
63
  return false;
70
64
  }
71
65
 
72
- /** Generic child iteration, so no per-node-type traversal table is needed. */
73
66
  function* children(node) {
74
67
  for (const key of Object.keys(node)) {
75
68
  if (key === "parent") continue;
@@ -82,10 +75,6 @@ function* children(node) {
82
75
  }
83
76
  }
84
77
 
85
- /**
86
- * Report every value block or loop directly in a bailing block, stopping at
87
- * nested function boundaries — those get their own lowering and do not bail.
88
- */
89
78
  function scanTryBlock(node, report) {
90
79
  if (!node || FUNCTIONS.has(node.type)) return;
91
80
  if (node.type === "ThrowStatement") report(node, throwMessage);
@@ -93,11 +82,6 @@ function scanTryBlock(node, report) {
93
82
  for (const child of children(node)) scanTryBlock(child, report);
94
83
  }
95
84
 
96
- /**
97
- * Walk looking for `try` statements, tracking whether we are inside a function
98
- * React Compiler actually compiles. `compiled` latches on: everything lexically
99
- * within a component or hook is lowered as part of it.
100
- */
101
85
  function walk(node, report, compiled, nameHint) {
102
86
  if (FUNCTIONS.has(node.type)) {
103
87
  const name = node.id?.name ?? nameHint;
@@ -107,17 +91,11 @@ function walk(node, report, compiled, nameHint) {
107
91
  }
108
92
 
109
93
  if (node.type === "TryStatement" && compiled) {
110
- // A finalizer or a missing catch bails on its own, whatever the contents,
111
- // so those are reported against the clause rather than scanned.
112
94
  if (node.finalizer) report(node.finalizer, finallyMessage);
113
95
  if (!node.handler) report(node, noCatchMessage);
114
96
  scanTryBlock(node.block, report);
115
- // Still descend: the catch body, and nested functions anywhere in the
116
- // statement, can hold their own `try` blocks.
117
97
  }
118
98
 
119
- // Carry the binding name onto the function it names, so `const Foo = () => {}`
120
- // and `const Foo = memo(() => {})` are both recognised as components.
121
99
  let hint = null;
122
100
  if (node.type === "VariableDeclarator") hint = node.id?.name;
123
101
  else if (node.type === "PropertyDefinition" || node.type === "Property")
@@ -150,7 +128,6 @@ export default {
150
128
 
151
129
  return {
152
130
  Program(program) {
153
- // Whole-file opt-out; nothing in the file is compiled.
154
131
  const optedOut = (program.body ?? []).some(
155
132
  (statement) =>
156
133
  statement.type === "ExpressionStatement" &&
@@ -12,14 +12,11 @@ const schemaBaseName = (name) => {
12
12
  return base.length > 0 && base !== name ? base : undefined;
13
13
  };
14
14
 
15
- /** True if expression is `z.<method>(...)` or nested `z.object(...).…`. */
16
15
  const isZodSchemaExpression = (node) => {
17
16
  if (node?.type !== "CallExpression") return false;
18
17
  const callee = node.callee;
19
18
  if (callee?.type === "MemberExpression") {
20
- // z.object / z.array / z.string / …
21
19
  if (isIdentifier(callee.object, "z")) return true;
22
- // chained: z.object(...).strict() etc — walk left
23
20
  return isZodSchemaExpression(callee.object);
24
21
  }
25
22
  return false;
@@ -29,7 +26,6 @@ const isObjectTypeAlias = (node) =>
29
26
  node.typeAnnotation?.type === "TSTypeLiteral";
30
27
 
31
28
  const isZodInferredType = (node) => {
32
- // type X = z.infer<typeof schema>
33
29
  const ann = node.typeAnnotation;
34
30
  if (ann?.type !== "TSTypeReference") return false;
35
31
  const nameNode = ann.typeName;
@@ -55,7 +51,6 @@ export default {
55
51
  if (!isIdentifier(node.id) || !isZodSchemaExpression(node.init)) return;
56
52
  const base = schemaBaseName(node.id.name);
57
53
  if (base) schemaBases.add(base);
58
- // Also accept camelCase: fooSchema → Foo (case-insensitive match later)
59
54
  schemaBases.add(node.id.name.replace(schemaSuffixPattern, ""));
60
55
  },
61
56
  TSInterfaceDeclaration(node) {
package/oxlint/utils.mjs CHANGED
@@ -1,5 +1,3 @@
1
- // Shared AST helpers for the @vvedantb/config oxlint rules.
2
-
3
1
  /** True if `node` is an Identifier (optionally with a specific `name`). */
4
2
  export function isIdentifier(node, name) {
5
3
  return node?.type === "Identifier" && (name === undefined || node.name === name);
@@ -9,3 +7,49 @@ export function isIdentifier(node, name) {
9
7
  export function toPosix(filename) {
10
8
  return (filename ?? "").replace(/\\/g, "/");
11
9
  }
10
+
11
+ const TERMINAL_QUERY_METHODS = new Set(["collect", "take", "first", "unique", "paginate"]);
12
+
13
+ const WRAPPER_TYPES = new Set([
14
+ "ChainExpression",
15
+ "AwaitExpression",
16
+ "TSNonNullExpression",
17
+ "TSAsExpression",
18
+ "TSSatisfiesExpression",
19
+ "TSTypeAssertion",
20
+ "TSInstantiationExpression",
21
+ "ParenthesizedExpression",
22
+ ]);
23
+
24
+ /** Strips `?.`, `await`, `!`, `as`, `satisfies`, `<T>` and parentheses around an expression. */
25
+ export function unwrapExpression(node) {
26
+ let current = node;
27
+ while (current && WRAPPER_TYPES.has(current.type)) {
28
+ current = current.type === "AwaitExpression" ? current.argument : current.expression;
29
+ }
30
+ return current;
31
+ }
32
+
33
+ function isDbObject(node) {
34
+ const object = unwrapExpression(node);
35
+ if (isIdentifier(object, "db")) return true;
36
+ return (
37
+ object?.type === "MemberExpression" && !object.computed && isIdentifier(object.property, "db")
38
+ );
39
+ }
40
+
41
+ /** True for `db.query(...)` or `ctx.db.query(...)` plus chained builder calls such as `.withIndex()` and `.order()`. */
42
+ export function isDbQueryChain(node) {
43
+ const call = unwrapExpression(node);
44
+ if (call?.type !== "CallExpression" || call.callee.type !== "MemberExpression") return false;
45
+ const { object, property } = call.callee;
46
+ if (!isIdentifier(property) || TERMINAL_QUERY_METHODS.has(property.name)) return false;
47
+ if (property.name !== "query") return isDbQueryChain(object);
48
+ const base = unwrapExpression(object);
49
+ if (isDbObject(base)) return true;
50
+ return (
51
+ base?.type === "MemberExpression" &&
52
+ isIdentifier(base.property, "privateSystem") &&
53
+ isDbObject(base.object)
54
+ );
55
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vvedantb/config",
3
- "version": "0.16.0",
3
+ "version": "0.17.0",
4
4
  "license": "MIT",
5
5
  "description": "Shared tsconfig bases, oxlint base, Vite, Vitest, Babel and Metro presets, a WXT preset and host-permission helper for Chrome extensions, pinned tool versions, a sync CLI for Claude commands, CLAUDE.md, Cursor environment and Convex tsconfig, a packaged Electron app.asar module check, a shared header and footer check, a no-source-text-in-tests check, a no-comments check with a ratchet baseline, shared oxlint JS plugins and a CLI that adds an extension to Clerk's allowed origins.",
6
6
  "type": "module",