Open History to see the last commit
1// @ts-check
2
3import { tanstackConfig } from '@tanstack/eslint-config'
4import unusedImports from 'eslint-plugin-unused-imports'
5
6/** @type {import('eslint').Linter.Config[]} */
7const config = [
8 ...tanstackConfig,
9 {
10 name: 'tanstack/temp',
11 plugins: {
12 'unused-imports': unusedImports,
13 },
14 rules: {
15 'unused-imports/no-unused-imports': 'warn',
16 },
17 },
18 {
19 // Typed-linting rules scoped to library source — issue #564.
20 //
21 // Restricted to `packages/typescript/*/src/**` so streaming + agent-loop
22 // bugs that violate `no-floating-promises`, exhaustive-switch checks, or
23 // async-misuse guarantees fail in CI without dragging tests, examples,
24 // or build artefacts under the typed-linting cost.
25 name: 'tanstack/ai/typed',
26 files: ['packages/typescript/*/src/**/*.{ts,tsx}'],
27 rules: {
28 '@typescript-eslint/no-floating-promises': 'error',
29 '@typescript-eslint/no-misused-promises': 'error',
30 '@typescript-eslint/await-thenable': 'error',
31 '@typescript-eslint/switch-exhaustiveness-check': 'error',
32 '@typescript-eslint/consistent-type-exports': 'error',
33 '@typescript-eslint/prefer-readonly': 'error',
34 '@typescript-eslint/no-non-null-assertion': 'error',
35 // `no-explicit-any` stays as a warning — much of the existing `any`
36 // is structurally load-bearing (`Tool<any, any>` / `Adapter<any>`
37 // variance wildcards, `Record<string, any>` provider option
38 // carriers), but new `any` introductions should still get a second
39 // look. Tracked as warnings to surface in editors without blocking CI.
40 '@typescript-eslint/no-explicit-any': 'warn',
41 // Override the base config which currently allows `@ts-ignore` with a
42 // description and forbids `@ts-expect-error`. Invert that: require
43 // descriptions on `@ts-expect-error` (which self-heals when the
44 // underlying error disappears) and disallow `@ts-ignore` outright.
45 '@typescript-eslint/ban-ts-comment': [
46 'error',
47 {
48 'ts-expect-error': 'allow-with-description',
49 'ts-ignore': false,
50 'ts-nocheck': true,
51 'ts-check': false,
52 },
53 ],
54 },
55 },
56 {
57 // `no-restricted-syntax` banning `as unknown as <Type>` double-casts.
58 //
59 // Why separate from the typed-linting block: a few packages still ship a
60 // local `eslint.config.js` that re-exports root. Flat-config evaluates
61 // `files` globs relative to the *config-file's* directory, so the typed
62 // block's `packages/typescript/*/src/**` glob fails to match anything
63 // when re-exported from inside `packages/typescript/<pkg>/`. The dual
64 // glob below works in both contexts.
65 //
66 // Why ban `as unknown as T`: it bypasses TS's structural-overlap check
67 // (the safety net that errors when two types don't sufficiently
68 // overlap), like `@ts-ignore` for type assertions. Plain `as T` keeps
69 // the check. Genuine boundaries (vendor SDK shape drift, DOM lib
70 // limitations, conditional-return narrowing failures) can opt out via
71 // `// eslint-disable-next-line no-restricted-syntax -- <reason>`.
72 name: 'tanstack/ai/no-double-as',
73 files: ['packages/typescript/*/src/**/*.{ts,tsx}', 'src/**/*.{ts,tsx}'],
74 rules: {
75 'no-restricted-syntax': [
76 'error',
77 {
78 selector:
79 "TSAsExpression > TSAsExpression[typeAnnotation.type='TSUnknownKeyword']",
80 message:
81 "Avoid `as unknown as <Type>` — it bypasses TS's structural overlap check. Prefer plain `as <Type>`, fix the root cause, or opt out with `// eslint-disable-next-line no-restricted-syntax -- <reason>`.",
82 },
83 ],
84 },
85 },
86]
87
88export default config