{"record":{"id":"9677a0a6f57b2725","repo":"mastra-ai/mastra","slug":"missing-tsconfig","errorCode":"MISSING_TSCONFIG","errorMessage":"MISSING_TSCONFIG","messagePattern":"MISSING_TSCONFIG","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/cli/src/commands/lint/rules/tsConfigRule.ts","lineNumber":25,"sourceCode":"  const tsConfigPath = join(dir, 'tsconfig.json');\n  try {\n    const tsConfigContent = readFileSync(tsConfigPath, 'utf-8');\n    const cleanTsConfigContent = stripJsonComments(tsConfigContent);\n    return JSON.parse(cleanTsConfigContent);\n  } catch {\n    return null;\n  }\n}\n\nexport const tsConfigRule: LintRule = {\n  name: 'ts-config',\n  description: 'Checks if TypeScript config is properly configured for Mastra packages',\n  async run(context: LintContext): Promise<LintIssue[]> {\n    const tsConfig = readTsConfig(context.rootDir);\n    if (!tsConfig) {\n      return [\n        {\n          code: 'MISSING_TSCONFIG',\n          severity: 'warning',\n          scope: 'project',\n          message: 'No tsconfig.json found. Mastra projects should include a TypeScript config.',\n          fix: 'Add a tsconfig.json file. See https://mastra.ai/en/docs/getting-started/installation#initialize-typescript',\n        },\n      ];\n    }\n\n    const { module, moduleResolution } = tsConfig.compilerOptions || {};\n\n    const isValidConfig = moduleResolution === 'bundler' || module === 'CommonJS';\n    if (!isValidConfig) {\n      return [\n        {\n          code: 'INVALID_TSCONFIG',\n          severity: 'error',\n          scope: 'project',\n          message:","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/cli/src/commands/lint/rules/tsConfigRule.ts#L7-L43","documentation":"The `mastra lint` tsconfig rule warns when no tsconfig.json can be found or parsed in the project root. Mastra relies on TypeScript configuration to compile scorers, workflows, and tools correctly, so a missing tsconfig is flagged as a project-scope warning. readTsConfig returned falsy, meaning the file is absent or unreadable.","triggerScenarios":"Running `mastra lint` in a directory where context.rootDir contains no tsconfig.json, or where readTsConfig fails to parse/find one.","commonSituations":"Fresh JavaScript-only projects initialized without `mastra init`; running lint from the wrong directory; tsconfig.json named differently (e.g. tsconfig.build.json); repo where tsconfig lives in a subdirectory.","solutions":["Add a tsconfig.json to the project root","Run `mastra init` to scaffold the recommended TypeScript setup","Run lint from the directory that actually contains tsconfig.json"],"exampleFix":"// before\n(no tsconfig.json in project root)\n// after\n// tsconfig.json\n{ \"compilerOptions\": { \"module\": \"CommonJS\", \"target\": \"ES2022\" }, \"include\": [\"src\"] }","handlingStrategy":"validation","validationCode":"import { existsSync } from 'node:fs';\nimport { join } from 'node:path';\nif (!existsSync(join(rootDir, 'tsconfig.json'))) {\n  throw new Error('tsconfig.json missing in project root — run `mastra init` first');\n}","typeGuard":"const hasTsConfig = (rootDir: string): boolean =>\n  existsSync(join(rootDir, 'tsconfig.json'));","tryCatchPattern":"try {\n  await lintProject();\n} catch (e) {\n  if ((e as Error).message.includes('MISSING_TSCONFIG')) {\n    console.warn('No tsconfig.json found; skipping TypeScript lint checks.');\n  } else throw e;\n}","preventionTips":["Always run `mastra init` when scaffolding a project","Run lint from the project root, not a subdirectory","Commit tsconfig.json to the repo","Verify tsconfig presence in CI before running mastra lint"],"tags":["typescript","config","lint","cli"],"backgroundTag":"missing-tsconfig","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}