@webpieces/code-rules 0.3.361 → 0.3.362

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 (45) hide show
  1. package/package.json +2 -4
  2. package/src/code-rules-app.js +4 -4
  3. package/src/code-rules-app.js.map +1 -1
  4. package/src/code-rules-engine.js +2 -2
  5. package/src/code-rules-engine.js.map +1 -1
  6. package/src/rule-reporter.js +2 -2
  7. package/src/rule-reporter.js.map +1 -1
  8. package/src/validate-catch-error-pattern.js +2 -2
  9. package/src/validate-catch-error-pattern.js.map +1 -1
  10. package/src/validate-dtos.js +2 -2
  11. package/src/validate-dtos.js.map +1 -1
  12. package/src/validate-framework-tag.js +2 -2
  13. package/src/validate-framework-tag.js.map +1 -1
  14. package/src/validate-inject-annotation-not-needed-for-concrete-class.js +2 -2
  15. package/src/validate-inject-annotation-not-needed-for-concrete-class.js.map +1 -1
  16. package/src/validate-match-rules.js +2 -2
  17. package/src/validate-match-rules.js.map +1 -1
  18. package/src/validate-modified-files.js +2 -2
  19. package/src/validate-modified-files.js.map +1 -1
  20. package/src/validate-modified-methods.js +2 -2
  21. package/src/validate-modified-methods.js.map +1 -1
  22. package/src/validate-no-any-unknown.js +2 -2
  23. package/src/validate-no-any-unknown.js.map +1 -1
  24. package/src/validate-no-destructure.js +2 -2
  25. package/src/validate-no-destructure.js.map +1 -1
  26. package/src/validate-no-direct-api-resolver.js +2 -2
  27. package/src/validate-no-direct-api-resolver.js.map +1 -1
  28. package/src/validate-no-function-outside-class.js +2 -2
  29. package/src/validate-no-function-outside-class.js.map +1 -1
  30. package/src/validate-no-implicit-any.js +2 -2
  31. package/src/validate-no-implicit-any.js.map +1 -1
  32. package/src/validate-no-inline-types.js +2 -2
  33. package/src/validate-no-inline-types.js.map +1 -1
  34. package/src/validate-no-process-exit-outside-main.js +2 -2
  35. package/src/validate-no-process-exit-outside-main.js.map +1 -1
  36. package/src/validate-no-symbol-di-tokens.js +2 -2
  37. package/src/validate-no-symbol-di-tokens.js.map +1 -1
  38. package/src/validate-no-unmanaged-exceptions.js +2 -2
  39. package/src/validate-no-unmanaged-exceptions.js.map +1 -1
  40. package/src/validate-prisma-converters.js +2 -2
  41. package/src/validate-prisma-converters.js.map +1 -1
  42. package/src/validate-return-types.js +2 -2
  43. package/src/validate-return-types.js.map +1 -1
  44. package/src/validate-role-tag.js +2 -2
  45. package/src/validate-role-tag.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"validate-no-function-outside-class.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/validate-no-function-outside-class.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;;;AA4HH,8EAuBC;AAGD,0EAOC;;AA3JD,+CAAyB;AACzB,mDAA6B;AAC7B,uDAAiC;AACjC,0DAAkM;AAClM,qDAAiE;AACjE,0DAA2D;AAC3D,yCAAuC;AACvC,iDAAgD;AAEhD,MAAM,cAAc,GAAG;;;;;;;;;0EASmD,CAAC;AAgB3E,SAAS,UAAU,CAAC,QAAgB;IAChC,OAAO,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;AAC7G,CAAC;AAED,SAAS,iBAAiB,CAAC,QAAgB;IACvC,OAAO,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AACtC,CAAC;AAED,6FAA6F;AAC7F,SAAS,kBAAkB,CAAC,IAAa;IACrC,IAAI,CAAC,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC;IAC7C,MAAM,IAAI,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IACnC,OAAO,IAAI,EAAE,IAAI,CAAC,CAAC,CAAc,EAAW,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,EAAE,CAAC,U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AAE,aAAa,CAAC,CAAC;IACxD,CAAC;CACJ,CAAA;AARY,0EAA+B;0CAA/B,+BAA+B;IAF3C,IAAA,+BAAgB,GAAE;IAClB,IAAA,sBAAU,GAAE;6CAEW,2CAA4B;GADvC,+BAA+B,CAQ3C","sourcesContent":["/**\n * Validate No Function Outside Class\n *\n * Flags a function CREATED OUTSIDE A CLASS at module scope, or a STATIC class member:\n * - a top-level `function foo()` / `export function foo()` declaration,\n * - a top-level `const foo = () => {}` / `const foo = function(){}`, and\n * - a `static foo() {}` method or `static foo = () => {}` field-function (a static member\n * belongs to the class object, not an instance, so it can't be injected either).\n *\n * WHY: webpieces DI + @DocumentDesign only work when behavior lives in injectable classes that can be\n * wired into each other. A module-scope function is a dead-end the DI graph can't reach — move the\n * logic onto a `@provideSingleton()` class and inject it instead.\n *\n * Uses the TypeScript AST so class-membership is checked precisely (not a regex heuristic): a node is a\n * violation only when its parent is the SourceFile (module scope). That automatically EXEMPTS inline\n * callbacks (`arr.map(x => x)`), promise handlers, nested functions inside methods, and functions\n * nested in other functions — their parent is a Block/CallExpression, never the SourceFile.\n *\n * ALLOWED (skip — NOT violations)\n * - Any function/arrow nested inside a class method, another function, or a callback.\n * - Non-function top-level consts: `const SCHEMA = z.object({})`, `const MAX = 5`, object/array literals.\n * - Ambient declarations (`declare function ...`) and whole `*.d.ts` files.\n * - Test files (*.test.ts, *.spec.ts, __tests__/**).\n * - Files under a configured `allowedPaths` glob (e.g. React component/hook trees that legitimately use\n * module-scope functions). Matched with the shared `isPathExcluded` glob/prefix/segment semantics.\n * - Lines with `// webpieces-disable no-function-outside-class -- <reason>` (when disableAllowed).\n *\n * MODES (AST + LINE-SCOPED)\n * - OFF: Skip.\n * - NEW_AND_MODIFIED_CODE: Flag only on changed lines (diff hunks).\n * - NEW_AND_MODIFIED_FILES: Flag every occurrence in any modified file.\n */\n\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as ts from 'typescript';\nimport { hasDisable, RULE_NAMES, NoFunctionOutsideClassConfig, ModifiedCodeMode, detectBase, getChangedFiles, getFileDiff, getChangedLineNumbers, isPathExcluded } from '@webpieces/rules-config';\nimport { CodeValidator, ExecutorResult } from './code-validator';\nimport { provideSingleton } from '@webpieces/core-context';\nimport { injectable } from 'inversify';\nimport { shouldSkipRule } from './resolve-mode';\n\nconst SHARED_MESSAGE = `Functions must live inside a class as INSTANCE methods — a function created at module scope, OR a\nstatic method, can't be injected, so webpieces DI + @DocumentDesign can't wire it into anything. A\nstatic method is just a module-scope function wearing a class as a namespace.\n BAD: export function computeTotal(cart: Cart): number { ... }\n BAD: export class CartMath { static computeTotal(cart: Cart): number { ... } } // static = not injectable\n GOOD: @provideSingleton()\n export class CartService { computeTotal(cart: Cart): number { ... } }\nThen inject CartService where you need it. Inline callbacks (arr.map(x => x)), promise handlers, and\nfunctions nested inside a method are fine — only MODULE-SCOPE function declarations, top-level\nconst-assigned functions, and STATIC methods/field-functions are flagged.`;\n\ninterface FnViolation {\n file: string;\n line: number;\n column: number;\n context: string;\n}\n\ninterface FnViolationInfo {\n line: number;\n column: number;\n context: string;\n hasDisableComment: boolean;\n}\n\nfunction isTestFile(filePath: string): boolean {\n return filePath.includes('.spec.ts') || filePath.includes('.test.ts') || filePath.includes('__tests__/');\n}\n\nfunction isDeclarationFile(filePath: string): boolean {\n return filePath.endsWith('.d.ts');\n}\n\n// True for a node carrying a `declare` modifier (ambient signature — not a real definition).\nfunction hasDeclareModifier(node: ts.Node): boolean {\n if (!ts.canHaveModifiers(node)) return false;\n const mods = ts.getModifiers(node);\n return mods?.some((m: ts.Modifier): boolean => m.kind === ts.SyntaxKind.DeclareKeyword) ?? false;\n}\n\n// True for a class member carrying the `static` modifier. A static method/field-function belongs\n// to the class object, not an instance, so it can't be injected — it is procedural code wearing a\n// class as a namespace, and is flagged the same as a module-scope function.\n// webpieces-disable no-function-outside-class -- the rule engine is inherently functional; validators can't be class members\nfunction hasStaticModifier(node: ts.Node): boolean {\n if (!ts.canHaveModifiers(node)) return false;\n const mods = ts.getModifiers(node);\n return mods?.some((m: ts.Modifier): boolean => m.kind === ts.SyntaxKind.StaticKeyword) ?? false;\n}\n\n// A `static` method, or a `static` field initialized to an arrow/function-expression, on a class.\n// webpieces-disable no-function-outside-class -- the rule engine is inherently functional; validators can't be class members\nfunction isStaticFunctionMember(node: ts.Node): boolean {\n if (ts.isMethodDeclaration(node)) return hasStaticModifier(node);\n if (ts.isPropertyDeclaration(node) && hasStaticModifier(node)) {\n const init = node.initializer;\n return init !== undefined && (ts.isArrowFunction(init) || ts.isFunctionExpression(init));\n }\n return false;\n}\n\n// Display name of a static member for the violation message.\n// webpieces-disable no-function-outside-class -- the rule engine is inherently functional; validators can't be class members\nfunction staticMemberName(node: ts.MethodDeclaration | ts.PropertyDeclaration): string {\n return ts.isIdentifier(node.name) ? node.name.text : '<static>';\n}\n\n// The violation line (or the line just above it) carries the disable comment.\nfunction hasDisableOnLine(fileLines: string[], lineNumber: number): boolean {\n const current = fileLines[lineNumber - 1] ?? '';\n const previous = lineNumber >= 2 ? (fileLines[lineNumber - 2] ?? '') : '';\n return hasDisable(current, RULE_NAMES.NO_FUNCTION_OUTSIDE_CLASS)\n || hasDisable(previous, RULE_NAMES.NO_FUNCTION_OUTSIDE_CLASS);\n}\n\nfunction recordViolation(\n node: ts.Node,\n context: string,\n fileLines: string[],\n sourceFile: ts.SourceFile,\n violations: FnViolationInfo[],\n disableAllowed: boolean,\n): void {\n const startPos = node.getStart(sourceFile);\n if (startPos < 0) return;\n const pos = sourceFile.getLineAndCharacterOfPosition(startPos);\n const line = pos.line + 1;\n const column = pos.character + 1;\n const disabled = hasDisableOnLine(fileLines, line);\n // When disableAllowed is false, a disable comment does NOT clear the violation.\n const effectiveDisabled = disableAllowed ? disabled : false;\n violations.push({ line, column, context, hasDisableComment: effectiveDisabled });\n}\n\n// Report a module-scope const whose initializer is an arrow / function-expression (a function\n// assigned to a top-level const). Non-function consts are left alone.\nfunction checkTopLevelConst(\n node: ts.VariableStatement,\n fileLines: string[],\n sourceFile: ts.SourceFile,\n violations: FnViolationInfo[],\n disableAllowed: boolean,\n): void {\n for (const decl of node.declarationList.declarations) {\n const init = decl.initializer;\n if (!init) continue;\n if (!ts.isArrowFunction(init) && !ts.isFunctionExpression(init)) continue;\n const name = ts.isIdentifier(decl.name) ? decl.name.text : '<fn>';\n recordViolation(decl, `const ${name} = <function> at module scope (outside any class)`, fileLines, sourceFile, violations, disableAllowed);\n }\n}\n\n// AST scan: a node is a violation only when its parent is the SourceFile (module scope).\nexport function findFunctionsOutsideClassInSource(content: string, filePath: string, disableAllowed: boolean): FnViolationInfo[] {\n if (isDeclarationFile(filePath)) return [];\n const fileLines = content.split('\\n');\n const sourceFile = ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true);\n const violations: FnViolationInfo[] = [];\n\n function visit(node: ts.Node): void {\n if (ts.isFunctionDeclaration(node) && ts.isSourceFile(node.parent) && !hasDeclareModifier(node)) {\n const name = node.name?.text ?? '<anonymous>';\n recordViolation(node, `function ${name}() declared at module scope (outside any class)`, fileLines, sourceFile, violations, disableAllowed);\n }\n if (ts.isVariableStatement(node) && ts.isSourceFile(node.parent) && !hasDeclareModifier(node)) {\n checkTopLevelConst(node, fileLines, sourceFile, violations, disableAllowed);\n }\n if (isStaticFunctionMember(node) && !hasDeclareModifier(node)) {\n const name = staticMemberName(node as ts.MethodDeclaration | ts.PropertyDeclaration);\n recordViolation(node, `static ${name}() — a static method can't be injected; make it an instance method and inject the class`, fileLines, sourceFile, violations, disableAllowed);\n }\n ts.forEachChild(node, visit);\n }\n\n visit(sourceFile);\n return violations;\n}\n\n// webpieces-disable no-function-outside-class -- the rule engine is inherently functional; validators can't be class members\nexport function findFunctionsOutsideClassInFile(filePath: string, workspaceRoot: string, disableAllowed: boolean, allowedPaths: string[]): FnViolationInfo[] {\n if (isTestFile(filePath)) return [];\n if (isPathExcluded(filePath, allowedPaths)) return [];\n const fullPath = path.join(workspaceRoot, filePath);\n if (!fs.existsSync(fullPath)) return [];\n const content = fs.readFileSync(fullPath, 'utf-8');\n return findFunctionsOutsideClassInSource(content, filePath, disableAllowed);\n}\n\n// webpieces-disable no-function-outside-class -- the rule engine is inherently functional; validators can't be class members\nfunction findViolationsForModifiedCode(workspaceRoot: string, changedFiles: string[], base: string, head: string | undefined, disableAllowed: boolean, allowedPaths: string[]): FnViolation[] {\n const violations: FnViolation[] = [];\n for (const file of changedFiles) {\n const changedLines = getChangedLineNumbers(getFileDiff(workspaceRoot, file, base, head));\n if (changedLines.size === 0) continue;\n for (const v of findFunctionsOutsideClassInFile(file, workspaceRoot, disableAllowed, allowedPaths)) {\n if (disableAllowed && v.hasDisableComment) continue;\n if (!changedLines.has(v.line)) continue;\n violations.push({ file, line: v.line, column: v.column, context: v.context });\n }\n }\n return violations;\n}\n\n// webpieces-disable no-function-outside-class -- the rule engine is inherently functional; validators can't be class members\nfunction findViolationsForModifiedFiles(workspaceRoot: string, changedFiles: string[], disableAllowed: boolean, allowedPaths: string[]): FnViolation[] {\n const violations: FnViolation[] = [];\n for (const file of changedFiles) {\n for (const v of findFunctionsOutsideClassInFile(file, workspaceRoot, disableAllowed, allowedPaths)) {\n if (disableAllowed && v.hasDisableComment) continue;\n violations.push({ file, line: v.line, column: v.column, context: v.context });\n }\n }\n return violations;\n}\n\nfunction reportViolations(violations: FnViolation[], mode: ModifiedCodeMode, disableAllowed: boolean): void {\n console.error('');\n console.error('❌ Function(s) created outside a class!');\n console.error('');\n console.error(SHARED_MESSAGE);\n console.error('');\n for (const v of violations) {\n console.error(` ❌ ${v.file}:${v.line}:${v.column}`);\n console.error(` ${v.context}`);\n }\n console.error('');\n console.error(disableAllowed\n ? ' Escape hatch (use sparingly): // webpieces-disable no-function-outside-class -- <reason>'\n : ' Escape hatch: DISABLED (disableAllowed: false)');\n console.error(' Whole-tree exemption (e.g. React): add a glob to no-function-outside-class.allowedPaths in webpieces.config.json');\n console.error(`\\n Current mode: ${mode}\\n`);\n}\n\nfunction resolveMode(normalMode: ModifiedCodeMode, epoch: number | undefined, branchPattern: string | undefined): ModifiedCodeMode {\n if (normalMode === 'OFF') return normalMode;\n const skip = shouldSkipRule(epoch, branchPattern);\n if (skip.skip) {\n console.log(`\\n⏭️ Skipping no-function-outside-class validation (${skip.reason})\\n`);\n return 'OFF';\n }\n return normalMode;\n}\n\nasync function runValidatorImpl(options: NoFunctionOutsideClassConfig, workspaceRoot: string): Promise<ExecutorResult> {\n const mode: ModifiedCodeMode = resolveMode(options.mode ?? 'OFF', options.ignoreModifiedUntilEpoch, options.ignoreRuleWhileOnBranch);\n const disableAllowed = options.disableAllowed ?? true;\n const allowedPaths = options.allowedPaths ?? [];\n\n if (mode === 'OFF') {\n console.log('\\n⏭️ Skipping no-function-outside-class validation (mode: OFF)\\n');\n return { success: true };\n }\n\n console.log('\\n📏 Validating No Function Outside Class\\n');\n console.log(` Mode: ${mode}`);\n\n let base = process.env['NX_BASE'];\n const head = process.env['NX_HEAD'];\n if (!base) {\n base = detectBase(workspaceRoot) ?? undefined;\n if (!base) {\n console.log('\\n⏭️ Skipping no-function-outside-class validation (could not detect base branch)\\n');\n return { success: true };\n }\n }\n\n console.log(` Base: ${base}`);\n console.log(` Head: ${head ?? 'working tree (includes uncommitted changes)'}\\n`);\n\n const changedFiles = getChangedFiles(workspaceRoot, base, head);\n if (changedFiles.length === 0) {\n console.log('✅ No TypeScript files changed');\n return { success: true };\n }\n\n console.log(`📂 Checking ${changedFiles.length} changed file(s)...`);\n\n let violations: FnViolation[] = [];\n if (mode === 'NEW_AND_MODIFIED_CODE') {\n violations = findViolationsForModifiedCode(workspaceRoot, changedFiles, base, head, disableAllowed, allowedPaths);\n } else if (mode === 'NEW_AND_MODIFIED_FILES') {\n violations = findViolationsForModifiedFiles(workspaceRoot, changedFiles, disableAllowed, allowedPaths);\n }\n\n if (violations.length === 0) {\n console.log('✅ No function-outside-class violations found');\n return { success: true };\n }\n\n reportViolations(violations, mode, disableAllowed);\n return { success: false };\n}\n\n@provideSingleton()\n@injectable()\nexport class NoFunctionOutsideClassValidator extends CodeValidator<NoFunctionOutsideClassConfig> {\n constructor(config: NoFunctionOutsideClassConfig) {\n super(config, 'no-function-outside-class');\n }\n\n async run(workspaceRoot: string): Promise<ExecutorResult> {\n return runValidatorImpl(this.config, workspaceRoot);\n }\n}\n"]}
1
+ {"version":3,"file":"validate-no-function-outside-class.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/validate-no-function-outside-class.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;;;AA4HH,8EAuBC;AAGD,0EAOC;;AA3JD,+CAAyB;AACzB,mDAA6B;AAC7B,uDAAiC;AACjC,0DAAkM;AAClM,qDAAiE;AACjE,0DAA2D;AAC3D,yCAAuC;AACvC,iDAAgD;AAEhD,MAAM,cAAc,GAAG;;;;;;;;;0EASmD,CAAC;AAgB3E,SAAS,UAAU,CAAC,QAAgB;IAChC,OAAO,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;AAC7G,CAAC;AAED,SAAS,iBAAiB,CAAC,QAAgB;IACvC,OAAO,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AACtC,CAAC;AAED,6FAA6F;AAC7F,SAAS,kBAAkB,CAAC,IAAa;IACrC,IAAI,CAAC,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC;IAC7C,MAAM,IAAI,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IACnC,OAAO,IAAI,EAAE,IAAI,CAAC,CAAC,CAAc,EAAW,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,EAAE,CAAC,UAAU,CAAC,cAAc,CAAC,IAAI,KAAK,CAAC;AACrG,CAAC;AAED,iGAAiG;AACjG,kGAAkG;AAClG,4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A,+BAAgB,GAAE;IAClB,IAAA,sBAAU,GAAE;6CAEW,2CAA4B;GADvC,+BAA+B,CAQ3C","sourcesContent":["/**\n * Validate No Function Outside Class\n *\n * Flags a function CREATED OUTSIDE A CLASS at module scope, or a STATIC class member:\n * - a top-level `function foo()` / `export function foo()` declaration,\n * - a top-level `const foo = () => {}` / `const foo = function(){}`, and\n * - a `static foo() {}` method or `static foo = () => {}` field-function (a static member\n * belongs to the class object, not an instance, so it can't be injected either).\n *\n * WHY: webpieces DI + @DocumentDesign only work when behavior lives in injectable classes that can be\n * wired into each other. A module-scope function is a dead-end the DI graph can't reach — move the\n * logic onto a `@provideSingleton()` class and inject it instead.\n *\n * Uses the TypeScript AST so class-membership is checked precisely (not a regex heuristic): a node is a\n * violation only when its parent is the SourceFile (module scope). That automatically EXEMPTS inline\n * callbacks (`arr.map(x => x)`), promise handlers, nested functions inside methods, and functions\n * nested in other functions — their parent is a Block/CallExpression, never the SourceFile.\n *\n * ALLOWED (skip — NOT violations)\n * - Any function/arrow nested inside a class method, another function, or a callback.\n * - Non-function top-level consts: `const SCHEMA = z.object({})`, `const MAX = 5`, object/array literals.\n * - Ambient declarations (`declare function ...`) and whole `*.d.ts` files.\n * - Test files (*.test.ts, *.spec.ts, __tests__/**).\n * - Files under a configured `allowedPaths` glob (e.g. React component/hook trees that legitimately use\n * module-scope functions). Matched with the shared `isPathExcluded` glob/prefix/segment semantics.\n * - Lines with `// webpieces-disable no-function-outside-class -- <reason>` (when disableAllowed).\n *\n * MODES (AST + LINE-SCOPED)\n * - OFF: Skip.\n * - NEW_AND_MODIFIED_CODE: Flag only on changed lines (diff hunks).\n * - NEW_AND_MODIFIED_FILES: Flag every occurrence in any modified file.\n */\n\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as ts from 'typescript';\nimport { hasDisable, RULE_NAMES, NoFunctionOutsideClassConfig, ModifiedCodeMode, detectBase, getChangedFiles, getFileDiff, getChangedLineNumbers, isPathExcluded } from '@webpieces/rules-config';\nimport { CodeValidator, ExecutorResult } from './code-validator';\nimport { provideSingleton } from '@webpieces/rules-config';\nimport { injectable } from 'inversify';\nimport { shouldSkipRule } from './resolve-mode';\n\nconst SHARED_MESSAGE = `Functions must live inside a class as INSTANCE methods — a function created at module scope, OR a\nstatic method, can't be injected, so webpieces DI + @DocumentDesign can't wire it into anything. A\nstatic method is just a module-scope function wearing a class as a namespace.\n BAD: export function computeTotal(cart: Cart): number { ... }\n BAD: export class CartMath { static computeTotal(cart: Cart): number { ... } } // static = not injectable\n GOOD: @provideSingleton()\n export class CartService { computeTotal(cart: Cart): number { ... } }\nThen inject CartService where you need it. Inline callbacks (arr.map(x => x)), promise handlers, and\nfunctions nested inside a method are fine — only MODULE-SCOPE function declarations, top-level\nconst-assigned functions, and STATIC methods/field-functions are flagged.`;\n\ninterface FnViolation {\n file: string;\n line: number;\n column: number;\n context: string;\n}\n\ninterface FnViolationInfo {\n line: number;\n column: number;\n context: string;\n hasDisableComment: boolean;\n}\n\nfunction isTestFile(filePath: string): boolean {\n return filePath.includes('.spec.ts') || filePath.includes('.test.ts') || filePath.includes('__tests__/');\n}\n\nfunction isDeclarationFile(filePath: string): boolean {\n return filePath.endsWith('.d.ts');\n}\n\n// True for a node carrying a `declare` modifier (ambient signature — not a real definition).\nfunction hasDeclareModifier(node: ts.Node): boolean {\n if (!ts.canHaveModifiers(node)) return false;\n const mods = ts.getModifiers(node);\n return mods?.some((m: ts.Modifier): boolean => m.kind === ts.SyntaxKind.DeclareKeyword) ?? false;\n}\n\n// True for a class member carrying the `static` modifier. A static method/field-function belongs\n// to the class object, not an instance, so it can't be injected — it is procedural code wearing a\n// class as a namespace, and is flagged the same as a module-scope function.\n// webpieces-disable no-function-outside-class -- the rule engine is inherently functional; validators can't be class members\nfunction hasStaticModifier(node: ts.Node): boolean {\n if (!ts.canHaveModifiers(node)) return false;\n const mods = ts.getModifiers(node);\n return mods?.some((m: ts.Modifier): boolean => m.kind === ts.SyntaxKind.StaticKeyword) ?? false;\n}\n\n// A `static` method, or a `static` field initialized to an arrow/function-expression, on a class.\n// webpieces-disable no-function-outside-class -- the rule engine is inherently functional; validators can't be class members\nfunction isStaticFunctionMember(node: ts.Node): boolean {\n if (ts.isMethodDeclaration(node)) return hasStaticModifier(node);\n if (ts.isPropertyDeclaration(node) && hasStaticModifier(node)) {\n const init = node.initializer;\n return init !== undefined && (ts.isArrowFunction(init) || ts.isFunctionExpression(init));\n }\n return false;\n}\n\n// Display name of a static member for the violation message.\n// webpieces-disable no-function-outside-class -- the rule engine is inherently functional; validators can't be class members\nfunction staticMemberName(node: ts.MethodDeclaration | ts.PropertyDeclaration): string {\n return ts.isIdentifier(node.name) ? node.name.text : '<static>';\n}\n\n// The violation line (or the line just above it) carries the disable comment.\nfunction hasDisableOnLine(fileLines: string[], lineNumber: number): boolean {\n const current = fileLines[lineNumber - 1] ?? '';\n const previous = lineNumber >= 2 ? (fileLines[lineNumber - 2] ?? '') : '';\n return hasDisable(current, RULE_NAMES.NO_FUNCTION_OUTSIDE_CLASS)\n || hasDisable(previous, RULE_NAMES.NO_FUNCTION_OUTSIDE_CLASS);\n}\n\nfunction recordViolation(\n node: ts.Node,\n context: string,\n fileLines: string[],\n sourceFile: ts.SourceFile,\n violations: FnViolationInfo[],\n disableAllowed: boolean,\n): void {\n const startPos = node.getStart(sourceFile);\n if (startPos < 0) return;\n const pos = sourceFile.getLineAndCharacterOfPosition(startPos);\n const line = pos.line + 1;\n const column = pos.character + 1;\n const disabled = hasDisableOnLine(fileLines, line);\n // When disableAllowed is false, a disable comment does NOT clear the violation.\n const effectiveDisabled = disableAllowed ? disabled : false;\n violations.push({ line, column, context, hasDisableComment: effectiveDisabled });\n}\n\n// Report a module-scope const whose initializer is an arrow / function-expression (a function\n// assigned to a top-level const). Non-function consts are left alone.\nfunction checkTopLevelConst(\n node: ts.VariableStatement,\n fileLines: string[],\n sourceFile: ts.SourceFile,\n violations: FnViolationInfo[],\n disableAllowed: boolean,\n): void {\n for (const decl of node.declarationList.declarations) {\n const init = decl.initializer;\n if (!init) continue;\n if (!ts.isArrowFunction(init) && !ts.isFunctionExpression(init)) continue;\n const name = ts.isIdentifier(decl.name) ? decl.name.text : '<fn>';\n recordViolation(decl, `const ${name} = <function> at module scope (outside any class)`, fileLines, sourceFile, violations, disableAllowed);\n }\n}\n\n// AST scan: a node is a violation only when its parent is the SourceFile (module scope).\nexport function findFunctionsOutsideClassInSource(content: string, filePath: string, disableAllowed: boolean): FnViolationInfo[] {\n if (isDeclarationFile(filePath)) return [];\n const fileLines = content.split('\\n');\n const sourceFile = ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true);\n const violations: FnViolationInfo[] = [];\n\n function visit(node: ts.Node): void {\n if (ts.isFunctionDeclaration(node) && ts.isSourceFile(node.parent) && !hasDeclareModifier(node)) {\n const name = node.name?.text ?? '<anonymous>';\n recordViolation(node, `function ${name}() declared at module scope (outside any class)`, fileLines, sourceFile, violations, disableAllowed);\n }\n if (ts.isVariableStatement(node) && ts.isSourceFile(node.parent) && !hasDeclareModifier(node)) {\n checkTopLevelConst(node, fileLines, sourceFile, violations, disableAllowed);\n }\n if (isStaticFunctionMember(node) && !hasDeclareModifier(node)) {\n const name = staticMemberName(node as ts.MethodDeclaration | ts.PropertyDeclaration);\n recordViolation(node, `static ${name}() — a static method can't be injected; make it an instance method and inject the class`, fileLines, sourceFile, violations, disableAllowed);\n }\n ts.forEachChild(node, visit);\n }\n\n visit(sourceFile);\n return violations;\n}\n\n// webpieces-disable no-function-outside-class -- the rule engine is inherently functional; validators can't be class members\nexport function findFunctionsOutsideClassInFile(filePath: string, workspaceRoot: string, disableAllowed: boolean, allowedPaths: string[]): FnViolationInfo[] {\n if (isTestFile(filePath)) return [];\n if (isPathExcluded(filePath, allowedPaths)) return [];\n const fullPath = path.join(workspaceRoot, filePath);\n if (!fs.existsSync(fullPath)) return [];\n const content = fs.readFileSync(fullPath, 'utf-8');\n return findFunctionsOutsideClassInSource(content, filePath, disableAllowed);\n}\n\n// webpieces-disable no-function-outside-class -- the rule engine is inherently functional; validators can't be class members\nfunction findViolationsForModifiedCode(workspaceRoot: string, changedFiles: string[], base: string, head: string | undefined, disableAllowed: boolean, allowedPaths: string[]): FnViolation[] {\n const violations: FnViolation[] = [];\n for (const file of changedFiles) {\n const changedLines = getChangedLineNumbers(getFileDiff(workspaceRoot, file, base, head));\n if (changedLines.size === 0) continue;\n for (const v of findFunctionsOutsideClassInFile(file, workspaceRoot, disableAllowed, allowedPaths)) {\n if (disableAllowed && v.hasDisableComment) continue;\n if (!changedLines.has(v.line)) continue;\n violations.push({ file, line: v.line, column: v.column, context: v.context });\n }\n }\n return violations;\n}\n\n// webpieces-disable no-function-outside-class -- the rule engine is inherently functional; validators can't be class members\nfunction findViolationsForModifiedFiles(workspaceRoot: string, changedFiles: string[], disableAllowed: boolean, allowedPaths: string[]): FnViolation[] {\n const violations: FnViolation[] = [];\n for (const file of changedFiles) {\n for (const v of findFunctionsOutsideClassInFile(file, workspaceRoot, disableAllowed, allowedPaths)) {\n if (disableAllowed && v.hasDisableComment) continue;\n violations.push({ file, line: v.line, column: v.column, context: v.context });\n }\n }\n return violations;\n}\n\nfunction reportViolations(violations: FnViolation[], mode: ModifiedCodeMode, disableAllowed: boolean): void {\n console.error('');\n console.error('❌ Function(s) created outside a class!');\n console.error('');\n console.error(SHARED_MESSAGE);\n console.error('');\n for (const v of violations) {\n console.error(` ❌ ${v.file}:${v.line}:${v.column}`);\n console.error(` ${v.context}`);\n }\n console.error('');\n console.error(disableAllowed\n ? ' Escape hatch (use sparingly): // webpieces-disable no-function-outside-class -- <reason>'\n : ' Escape hatch: DISABLED (disableAllowed: false)');\n console.error(' Whole-tree exemption (e.g. React): add a glob to no-function-outside-class.allowedPaths in webpieces.config.json');\n console.error(`\\n Current mode: ${mode}\\n`);\n}\n\nfunction resolveMode(normalMode: ModifiedCodeMode, epoch: number | undefined, branchPattern: string | undefined): ModifiedCodeMode {\n if (normalMode === 'OFF') return normalMode;\n const skip = shouldSkipRule(epoch, branchPattern);\n if (skip.skip) {\n console.log(`\\n⏭️ Skipping no-function-outside-class validation (${skip.reason})\\n`);\n return 'OFF';\n }\n return normalMode;\n}\n\nasync function runValidatorImpl(options: NoFunctionOutsideClassConfig, workspaceRoot: string): Promise<ExecutorResult> {\n const mode: ModifiedCodeMode = resolveMode(options.mode ?? 'OFF', options.ignoreModifiedUntilEpoch, options.ignoreRuleWhileOnBranch);\n const disableAllowed = options.disableAllowed ?? true;\n const allowedPaths = options.allowedPaths ?? [];\n\n if (mode === 'OFF') {\n console.log('\\n⏭️ Skipping no-function-outside-class validation (mode: OFF)\\n');\n return { success: true };\n }\n\n console.log('\\n📏 Validating No Function Outside Class\\n');\n console.log(` Mode: ${mode}`);\n\n let base = process.env['NX_BASE'];\n const head = process.env['NX_HEAD'];\n if (!base) {\n base = detectBase(workspaceRoot) ?? undefined;\n if (!base) {\n console.log('\\n⏭️ Skipping no-function-outside-class validation (could not detect base branch)\\n');\n return { success: true };\n }\n }\n\n console.log(` Base: ${base}`);\n console.log(` Head: ${head ?? 'working tree (includes uncommitted changes)'}\\n`);\n\n const changedFiles = getChangedFiles(workspaceRoot, base, head);\n if (changedFiles.length === 0) {\n console.log('✅ No TypeScript files changed');\n return { success: true };\n }\n\n console.log(`📂 Checking ${changedFiles.length} changed file(s)...`);\n\n let violations: FnViolation[] = [];\n if (mode === 'NEW_AND_MODIFIED_CODE') {\n violations = findViolationsForModifiedCode(workspaceRoot, changedFiles, base, head, disableAllowed, allowedPaths);\n } else if (mode === 'NEW_AND_MODIFIED_FILES') {\n violations = findViolationsForModifiedFiles(workspaceRoot, changedFiles, disableAllowed, allowedPaths);\n }\n\n if (violations.length === 0) {\n console.log('✅ No function-outside-class violations found');\n return { success: true };\n }\n\n reportViolations(violations, mode, disableAllowed);\n return { success: false };\n}\n\n@provideSingleton()\n@injectable()\nexport class NoFunctionOutsideClassValidator extends CodeValidator<NoFunctionOutsideClassConfig> {\n constructor(config: NoFunctionOutsideClassConfig) {\n super(config, 'no-function-outside-class');\n }\n\n async run(workspaceRoot: string): Promise<ExecutorResult> {\n return runValidatorImpl(this.config, workspaceRoot);\n }\n}\n"]}
@@ -33,7 +33,7 @@ const path = tslib_1.__importStar(require("path"));
33
33
  const ts = tslib_1.__importStar(require("typescript"));
34
34
  const rules_config_1 = require("@webpieces/rules-config");
35
35
  const code_validator_1 = require("./code-validator");
36
- const core_context_1 = require("@webpieces/core-context");
36
+ const rules_config_2 = require("@webpieces/rules-config");
37
37
  const inversify_1 = require("inversify");
38
38
  const resolve_mode_1 = require("./resolve-mode");
39
39
  // TS diagnostic codes that describe an implicit-any inference. TS7010 (missing
@@ -254,7 +254,7 @@ let NoImplicitAnyValidator = class NoImplicitAnyValidator extends code_validator
254
254
  };
255
255
  exports.NoImplicitAnyValidator = NoImplicitAnyValidator;
256
256
  exports.NoImplicitAnyValidator = NoImplicitAnyValidator = tslib_1.__decorate([
257
- (0, core_context_1.provideSingleton)(),
257
+ (0, rules_config_2.provideSingleton)(),
258
258
  (0, inversify_1.injectable)(),
259
259
  tslib_1.__metadata("design:paramtypes", [rules_config_1.NoImplicitAnyConfig])
260
260
  ], NoImplicitAnyValidator);
@@ -1 +1 @@
1
- {"version":3,"file":"validate-no-implicit-any.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/validate-no-implicit-any.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;;;;AAEH,+CAAyB;AACzB,mDAA6B;AAC7B,uDAAiC;AACjC,0DAAyK;AACzK,qDAAiE;AACjE,0DAA2D;AAC3D,yCAAuC;AACvC,iDAAgD;AAWhD,+EAA+E;AAC/E,yEAAyE;AACzE,0DAA0D;AAC1D,MAAM,kBAAkB,GAAwB,IAAI,GAAG,CAAS;IAC5D,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;CACvD,CAAC,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AAG,CAAC,yCAAyC,CAAC,CAAC;QACvD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC7B,CAAC;IAED,gBAAgB,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IACnC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AAC9B,CAAC;AAED,KAAK,UAAU,gBAAgB,CAC3B,OAA4B,EAC5B,aAAqB;IAErB,8DAA8D;IAC9D,IAAI,CAAC;QACD,OAAO,MAAM,WAAW,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;IACrD,CAAC;IAAC,OAAO,GAAY,EAAE,CAAC;QACpB,6BAA6B;QAC7B,OAAO,CAAC,IAAI,CAAC,+EAA+E,CAAC,CAAC;QAC9F,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC7B,CAAC;AACL,CAAC;AAIM,IAAM,sBAAsB,GAA5B,MAAM,sBAAuB,SAAQ,8BAAkC;IAC1E,YAAY,MAA2B;QACnC,KAAK,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IACrC,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,aAAqB;QAC3B,OAAO,gBAAgB,CAAC,IAAI,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACxD,CAAC;CACJ,CAAA;AARY,wDAAsB;iCAAtB,sBAAsB;IAFlC,IAAA,+BAAgB,GAAE;IAClB,IAAA,sBAAU,GAAE;6CAEW,kCAAmB;GAD9B,sBAAsB,CAQlC","sourcesContent":["/**\n * Validate No Implicit Any Executor\n *\n * Flags function parameters, variables, and object-literal properties whose\n * types collapse to the implicit `any` produced by TypeScript inference when\n * an annotation is missing. Pairs with validate-no-any-unknown (which bans\n * the literal keyword) so together they force developers to write real types.\n *\n * Detection leverages the TypeScript compiler directly: we build a ts.Program\n * from the project's tsconfig.json with `noImplicitAny: true` overridden, then\n * filter pre-emit diagnostics to the set of codes that describe implicit-any\n * inferences (TS7006, TS7005, TS7018, etc.) and map them back to changed lines.\n *\n * ============================================================================\n * MODES (LINE-BASED)\n * ============================================================================\n * - OFF: Skip validation entirely.\n * - NEW_AND_MODIFIED_CODE: Flag implicit-any on changed lines (lines in diff hunks).\n * - NEW_AND_MODIFIED_FILES: Flag ALL implicit-any in files that were modified.\n *\n * ============================================================================\n * ESCAPE HATCH\n * ============================================================================\n * // webpieces-disable no-implicit-any -- [your justification]\n * function handler(x) { ... }\n */\n\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as ts from 'typescript';\nimport { hasDisable, RULE_NAMES, NoImplicitAnyConfig, ModifiedCodeMode, detectBase, getChangedFiles, getFileDiff, getChangedLineNumbers } from '@webpieces/rules-config';\nimport { CodeValidator, ExecutorResult } from './code-validator';\nimport { provideSingleton } from '@webpieces/core-context';\nimport { injectable } from 'inversify';\nimport { shouldSkipRule } from './resolve-mode';\n\ninterface ImplicitAnyViolation {\n file: string;\n line: number;\n column: number;\n code: number;\n message: string;\n hasDisableComment: boolean;\n}\n\n// TS diagnostic codes that describe an implicit-any inference. TS7010 (missing\n// return-type annotation) is intentionally omitted because it is already\n// covered by the sibling `require-return-type` validator.\nconst IMPLICIT_ANY_CODES: ReadonlySet<number> = new Set<number>([\n 7005, 7006, 7008, 7015, 7018, 7019, 7031, 7034, 7053,\n]);\n\nfunction hasDisableComment(lines: string[], lineNumber: number): boolean {\n const startCheck = Math.max(0, lineNumber - 5);\n for (let i = lineNumber - 2; i >= startCheck; i--) {\n const line = lines[i]?.trim() ?? '';\n if (line.startsWith('function ') || line.startsWith('class ') || line.endsWith('}')) {\n break;\n }\n if (hasDisable(line, RULE_NAMES.NO_IMPLICIT_ANY)) {\n return true;\n }\n }\n return false;\n}\n\n// Cache one ts.Program per tsconfig.json so multiple changed files in the\n// same project share parse/binding cost.\nconst programCache = new Map<string, ts.Program | null>();\n\nfunction findTsConfigForFile(absoluteFilePath: string, workspaceRoot: string): string | null {\n const root = path.resolve(workspaceRoot);\n let dir = path.dirname(absoluteFilePath);\n while (dir.startsWith(root)) {\n const candidate = path.join(dir, 'tsconfig.json');\n if (fs.existsSync(candidate)) return candidate;\n const parent = path.dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n return null;\n}\n\nfunction buildProgram(tsconfigPath: string): ts.Program | null {\n const configFile = ts.readConfigFile(tsconfigPath, (p: string) => ts.sys.readFile(p));\n if (configFile.error) return null;\n const parsed = ts.parseJsonConfigFileContent(configFile.config, ts.sys, path.dirname(tsconfigPath));\n if (parsed.errors.length > 0 || parsed.fileNames.length === 0) return null;\n const options: ts.CompilerOptions = { ...parsed.options, noImplicitAny: true, noEmit: true, skipLibCheck: true };\n return ts.createProgram({ rootNames: parsed.fileNames, options });\n}\n\nfunction getProgramForFile(absoluteFilePath: string, workspaceRoot: string): ts.Program | null {\n const tsconfigPath = findTsConfigForFile(absoluteFilePath, workspaceRoot);\n if (!tsconfigPath) return null;\n if (programCache.has(tsconfigPath)) {\n return programCache.get(tsconfigPath) ?? null;\n }\n const program = buildProgram(tsconfigPath);\n programCache.set(tsconfigPath, program);\n return program;\n}\n\nfunction flattenMessage(message: string | ts.DiagnosticMessageChain): string {\n return ts.flattenDiagnosticMessageText(message, ' ');\n}\n\nfunction findImplicitAnyInFile(filePath: string, workspaceRoot: string): ImplicitAnyViolation[] {\n const absolute = path.resolve(workspaceRoot, filePath);\n if (!fs.existsSync(absolute)) return [];\n\n const program = getProgramForFile(absolute, workspaceRoot);\n if (!program) return [];\n\n const sourceFile = program.getSourceFile(absolute);\n if (!sourceFile) return [];\n\n const fileLines = fs.readFileSync(absolute, 'utf-8').split('\\n');\n const diagnostics = ts.getPreEmitDiagnostics(program, sourceFile);\n const violations: ImplicitAnyViolation[] = [];\n\n for (const diag of diagnostics) {\n if (!IMPLICIT_ANY_CODES.has(diag.code)) continue;\n if (!diag.file || diag.start === undefined) continue;\n const pos = diag.file.getLineAndCharacterOfPosition(diag.start);\n const line = pos.line + 1;\n const column = pos.character + 1;\n violations.push({\n file: filePath,\n line,\n column,\n code: diag.code,\n message: flattenMessage(diag.messageText),\n hasDisableComment: hasDisableComment(fileLines, line),\n });\n }\n\n return violations;\n}\n\nfunction findViolationsForModifiedCode(\n workspaceRoot: string,\n changedFiles: string[],\n base: string,\n head: string | undefined,\n disableAllowed: boolean,\n): ImplicitAnyViolation[] {\n const results: ImplicitAnyViolation[] = [];\n for (const file of changedFiles) {\n const diff = getFileDiff(workspaceRoot, file, base, head);\n const changedLines = getChangedLineNumbers(diff);\n if (changedLines.size === 0) continue;\n\n const all = findImplicitAnyInFile(file, workspaceRoot);\n for (const v of all) {\n if (disableAllowed && v.hasDisableComment) continue;\n if (!changedLines.has(v.line)) continue;\n results.push(v);\n }\n }\n return results;\n}\n\nfunction findViolationsForModifiedFiles(\n workspaceRoot: string,\n changedFiles: string[],\n disableAllowed: boolean,\n): ImplicitAnyViolation[] {\n const results: ImplicitAnyViolation[] = [];\n for (const file of changedFiles) {\n const all = findImplicitAnyInFile(file, workspaceRoot);\n for (const v of all) {\n if (disableAllowed && v.hasDisableComment) continue;\n results.push(v);\n }\n }\n return results;\n}\n\nfunction reportViolations(violations: ImplicitAnyViolation[], mode: ModifiedCodeMode): void {\n console.error('');\n console.error('\\u274c Implicit-any inferences found! Add explicit type annotations.');\n console.error('');\n console.error('\\ud83d\\udcda Why: an untyped parameter or variable erases type safety silently.');\n console.error('');\n console.error(' BAD: function process(input) { return input.length; }');\n console.error(' GOOD: function process(input: string): number { return input.length; }');\n console.error('');\n\n for (const v of violations) {\n console.error(` \\u274c ${v.file}:${v.line}:${v.column}`);\n console.error(` TS${v.code}: ${v.message}`);\n }\n console.error('');\n console.error(' Escape hatch (use sparingly):');\n console.error(' // webpieces-disable no-implicit-any -- [your reason]');\n console.error('');\n console.error(` Current mode: ${mode}`);\n console.error('');\n}\n\nfunction resolveMode(normalMode: ModifiedCodeMode, epoch: number | undefined, branchPattern: string | undefined): ModifiedCodeMode {\n if (normalMode === 'OFF') {\n return normalMode;\n }\n const skip = shouldSkipRule(epoch, branchPattern);\n if (skip.skip) {\n console.log(`\\n\\u23ed\\ufe0f Skipping no-implicit-any validation (${skip.reason})`);\n console.log('');\n return 'OFF';\n }\n return normalMode;\n}\n\nasync function runInternal(\n options: NoImplicitAnyConfig,\n workspaceRoot: string,\n): Promise<ExecutorResult> {\n const mode: ModifiedCodeMode = resolveMode(options.mode ?? 'OFF', options.ignoreModifiedUntilEpoch, options.ignoreRuleWhileOnBranch);\n const disableAllowed = options.disableAllowed ?? true;\n\n if (mode === 'OFF') {\n console.log('\\n\\u23ed\\ufe0f Skipping no-implicit-any validation (mode: OFF)');\n console.log('');\n return { success: true };\n }\n\n console.log('\\n\\ud83d\\udccf Validating No Implicit Any\\n');\n console.log(` Mode: ${mode}`);\n\n let base = process.env['NX_BASE'];\n const head = process.env['NX_HEAD'];\n\n if (!base) {\n base = detectBase(workspaceRoot) ?? undefined;\n if (!base) {\n console.log('\\n\\u23ed\\ufe0f Skipping no-implicit-any validation (could not detect base branch)');\n console.log('');\n return { success: true };\n }\n }\n\n console.log(` Base: ${base}`);\n console.log(` Head: ${head ?? 'working tree (includes uncommitted changes)'}`);\n console.log('');\n\n const changedFiles = getChangedFiles(workspaceRoot, base, head);\n if (changedFiles.length === 0) {\n console.log('\\u2705 No TypeScript files changed');\n return { success: true };\n }\n\n console.log(`\\ud83d\\udcc2 Checking ${changedFiles.length} changed file(s)...`);\n\n let violations: ImplicitAnyViolation[] = [];\n if (mode === 'NEW_AND_MODIFIED_CODE') {\n violations = findViolationsForModifiedCode(workspaceRoot, changedFiles, base, head, disableAllowed);\n } else if (mode === 'NEW_AND_MODIFIED_FILES') {\n violations = findViolationsForModifiedFiles(workspaceRoot, changedFiles, disableAllowed);\n }\n\n if (violations.length === 0) {\n console.log('\\u2705 No implicit-any inferences found');\n return { success: true };\n }\n\n reportViolations(violations, mode);\n return { success: false };\n}\n\nasync function runValidatorImpl(\n options: NoImplicitAnyConfig,\n workspaceRoot: string\n): Promise<ExecutorResult> {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n return await runInternal(options, workspaceRoot);\n } catch (err: unknown) {\n //const error = toError(err);\n console.warn('\\n\\u23ed\\ufe0f Skipping no-implicit-any validation due to unexpected error\\n');\n return { success: true };\n }\n}\n\n@provideSingleton()\n@injectable()\nexport class NoImplicitAnyValidator extends CodeValidator<NoImplicitAnyConfig> {\n constructor(config: NoImplicitAnyConfig) {\n super(config, 'no-implicit-any');\n }\n\n async run(workspaceRoot: string): Promise<ExecutorResult> {\n return runValidatorImpl(this.config, workspaceRoot);\n }\n}\n"]}
1
+ {"version":3,"file":"validate-no-implicit-any.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/validate-no-implicit-any.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;;;;AAEH,+CAAyB;AACzB,mDAA6B;AAC7B,uDAAiC;AACjC,0DAAyK;AACzK,qDAAiE;AACjE,0DAA2D;AAC3D,yCAAuC;AACvC,iDAAgD;AAWhD,+EAA+E;AAC/E,yEAAyE;AACzE,0DAA0D;AAC1D,MAAM,kBAAkB,GAAwB,IAAI,GAAG,CAAS;IAC5D,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;CACvD,CAAC,CAAC;AAEH,SAAS,iBAAiB,CAAC,KAAe,EAAE,UAAkB;IAC1D,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,UAAU,GAAG,CAAC,CAAC,CAAC;IAC/C,KAAK,IAAI,CAAC,GAAG,UAAU,GAAG,CAAC,EAAE,CAAC,IAAI,UAAU,EAAE,CAAC,EAAE,EAAE,CAAC;QAChD,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;QACpC,IAAI,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,Q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7B,OAAO,CAAC,IAAI,CAAC,+EAA+E,CAAC,CAAC;QAC9F,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC7B,CAAC;AACL,CAAC;AAIM,IAAM,sBAAsB,GAA5B,MAAM,sBAAuB,SAAQ,8BAAkC;IAC1E,YAAY,MAA2B;QACnC,KAAK,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IACrC,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,aAAqB;QAC3B,OAAO,gBAAgB,CAAC,IAAI,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACxD,CAAC;CACJ,CAAA;AARY,wDAAsB;iCAAtB,sBAAsB;IAFlC,IAAA,+BAAgB,GAAE;IAClB,IAAA,sBAAU,GAAE;6CAEW,kCAAmB;GAD9B,sBAAsB,CAQlC","sourcesContent":["/**\n * Validate No Implicit Any Executor\n *\n * Flags function parameters, variables, and object-literal properties whose\n * types collapse to the implicit `any` produced by TypeScript inference when\n * an annotation is missing. Pairs with validate-no-any-unknown (which bans\n * the literal keyword) so together they force developers to write real types.\n *\n * Detection leverages the TypeScript compiler directly: we build a ts.Program\n * from the project's tsconfig.json with `noImplicitAny: true` overridden, then\n * filter pre-emit diagnostics to the set of codes that describe implicit-any\n * inferences (TS7006, TS7005, TS7018, etc.) and map them back to changed lines.\n *\n * ============================================================================\n * MODES (LINE-BASED)\n * ============================================================================\n * - OFF: Skip validation entirely.\n * - NEW_AND_MODIFIED_CODE: Flag implicit-any on changed lines (lines in diff hunks).\n * - NEW_AND_MODIFIED_FILES: Flag ALL implicit-any in files that were modified.\n *\n * ============================================================================\n * ESCAPE HATCH\n * ============================================================================\n * // webpieces-disable no-implicit-any -- [your justification]\n * function handler(x) { ... }\n */\n\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as ts from 'typescript';\nimport { hasDisable, RULE_NAMES, NoImplicitAnyConfig, ModifiedCodeMode, detectBase, getChangedFiles, getFileDiff, getChangedLineNumbers } from '@webpieces/rules-config';\nimport { CodeValidator, ExecutorResult } from './code-validator';\nimport { provideSingleton } from '@webpieces/rules-config';\nimport { injectable } from 'inversify';\nimport { shouldSkipRule } from './resolve-mode';\n\ninterface ImplicitAnyViolation {\n file: string;\n line: number;\n column: number;\n code: number;\n message: string;\n hasDisableComment: boolean;\n}\n\n// TS diagnostic codes that describe an implicit-any inference. TS7010 (missing\n// return-type annotation) is intentionally omitted because it is already\n// covered by the sibling `require-return-type` validator.\nconst IMPLICIT_ANY_CODES: ReadonlySet<number> = new Set<number>([\n 7005, 7006, 7008, 7015, 7018, 7019, 7031, 7034, 7053,\n]);\n\nfunction hasDisableComment(lines: string[], lineNumber: number): boolean {\n const startCheck = Math.max(0, lineNumber - 5);\n for (let i = lineNumber - 2; i >= startCheck; i--) {\n const line = lines[i]?.trim() ?? '';\n if (line.startsWith('function ') || line.startsWith('class ') || line.endsWith('}')) {\n break;\n }\n if (hasDisable(line, RULE_NAMES.NO_IMPLICIT_ANY)) {\n return true;\n }\n }\n return false;\n}\n\n// Cache one ts.Program per tsconfig.json so multiple changed files in the\n// same project share parse/binding cost.\nconst programCache = new Map<string, ts.Program | null>();\n\nfunction findTsConfigForFile(absoluteFilePath: string, workspaceRoot: string): string | null {\n const root = path.resolve(workspaceRoot);\n let dir = path.dirname(absoluteFilePath);\n while (dir.startsWith(root)) {\n const candidate = path.join(dir, 'tsconfig.json');\n if (fs.existsSync(candidate)) return candidate;\n const parent = path.dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n return null;\n}\n\nfunction buildProgram(tsconfigPath: string): ts.Program | null {\n const configFile = ts.readConfigFile(tsconfigPath, (p: string) => ts.sys.readFile(p));\n if (configFile.error) return null;\n const parsed = ts.parseJsonConfigFileContent(configFile.config, ts.sys, path.dirname(tsconfigPath));\n if (parsed.errors.length > 0 || parsed.fileNames.length === 0) return null;\n const options: ts.CompilerOptions = { ...parsed.options, noImplicitAny: true, noEmit: true, skipLibCheck: true };\n return ts.createProgram({ rootNames: parsed.fileNames, options });\n}\n\nfunction getProgramForFile(absoluteFilePath: string, workspaceRoot: string): ts.Program | null {\n const tsconfigPath = findTsConfigForFile(absoluteFilePath, workspaceRoot);\n if (!tsconfigPath) return null;\n if (programCache.has(tsconfigPath)) {\n return programCache.get(tsconfigPath) ?? null;\n }\n const program = buildProgram(tsconfigPath);\n programCache.set(tsconfigPath, program);\n return program;\n}\n\nfunction flattenMessage(message: string | ts.DiagnosticMessageChain): string {\n return ts.flattenDiagnosticMessageText(message, ' ');\n}\n\nfunction findImplicitAnyInFile(filePath: string, workspaceRoot: string): ImplicitAnyViolation[] {\n const absolute = path.resolve(workspaceRoot, filePath);\n if (!fs.existsSync(absolute)) return [];\n\n const program = getProgramForFile(absolute, workspaceRoot);\n if (!program) return [];\n\n const sourceFile = program.getSourceFile(absolute);\n if (!sourceFile) return [];\n\n const fileLines = fs.readFileSync(absolute, 'utf-8').split('\\n');\n const diagnostics = ts.getPreEmitDiagnostics(program, sourceFile);\n const violations: ImplicitAnyViolation[] = [];\n\n for (const diag of diagnostics) {\n if (!IMPLICIT_ANY_CODES.has(diag.code)) continue;\n if (!diag.file || diag.start === undefined) continue;\n const pos = diag.file.getLineAndCharacterOfPosition(diag.start);\n const line = pos.line + 1;\n const column = pos.character + 1;\n violations.push({\n file: filePath,\n line,\n column,\n code: diag.code,\n message: flattenMessage(diag.messageText),\n hasDisableComment: hasDisableComment(fileLines, line),\n });\n }\n\n return violations;\n}\n\nfunction findViolationsForModifiedCode(\n workspaceRoot: string,\n changedFiles: string[],\n base: string,\n head: string | undefined,\n disableAllowed: boolean,\n): ImplicitAnyViolation[] {\n const results: ImplicitAnyViolation[] = [];\n for (const file of changedFiles) {\n const diff = getFileDiff(workspaceRoot, file, base, head);\n const changedLines = getChangedLineNumbers(diff);\n if (changedLines.size === 0) continue;\n\n const all = findImplicitAnyInFile(file, workspaceRoot);\n for (const v of all) {\n if (disableAllowed && v.hasDisableComment) continue;\n if (!changedLines.has(v.line)) continue;\n results.push(v);\n }\n }\n return results;\n}\n\nfunction findViolationsForModifiedFiles(\n workspaceRoot: string,\n changedFiles: string[],\n disableAllowed: boolean,\n): ImplicitAnyViolation[] {\n const results: ImplicitAnyViolation[] = [];\n for (const file of changedFiles) {\n const all = findImplicitAnyInFile(file, workspaceRoot);\n for (const v of all) {\n if (disableAllowed && v.hasDisableComment) continue;\n results.push(v);\n }\n }\n return results;\n}\n\nfunction reportViolations(violations: ImplicitAnyViolation[], mode: ModifiedCodeMode): void {\n console.error('');\n console.error('\\u274c Implicit-any inferences found! Add explicit type annotations.');\n console.error('');\n console.error('\\ud83d\\udcda Why: an untyped parameter or variable erases type safety silently.');\n console.error('');\n console.error(' BAD: function process(input) { return input.length; }');\n console.error(' GOOD: function process(input: string): number { return input.length; }');\n console.error('');\n\n for (const v of violations) {\n console.error(` \\u274c ${v.file}:${v.line}:${v.column}`);\n console.error(` TS${v.code}: ${v.message}`);\n }\n console.error('');\n console.error(' Escape hatch (use sparingly):');\n console.error(' // webpieces-disable no-implicit-any -- [your reason]');\n console.error('');\n console.error(` Current mode: ${mode}`);\n console.error('');\n}\n\nfunction resolveMode(normalMode: ModifiedCodeMode, epoch: number | undefined, branchPattern: string | undefined): ModifiedCodeMode {\n if (normalMode === 'OFF') {\n return normalMode;\n }\n const skip = shouldSkipRule(epoch, branchPattern);\n if (skip.skip) {\n console.log(`\\n\\u23ed\\ufe0f Skipping no-implicit-any validation (${skip.reason})`);\n console.log('');\n return 'OFF';\n }\n return normalMode;\n}\n\nasync function runInternal(\n options: NoImplicitAnyConfig,\n workspaceRoot: string,\n): Promise<ExecutorResult> {\n const mode: ModifiedCodeMode = resolveMode(options.mode ?? 'OFF', options.ignoreModifiedUntilEpoch, options.ignoreRuleWhileOnBranch);\n const disableAllowed = options.disableAllowed ?? true;\n\n if (mode === 'OFF') {\n console.log('\\n\\u23ed\\ufe0f Skipping no-implicit-any validation (mode: OFF)');\n console.log('');\n return { success: true };\n }\n\n console.log('\\n\\ud83d\\udccf Validating No Implicit Any\\n');\n console.log(` Mode: ${mode}`);\n\n let base = process.env['NX_BASE'];\n const head = process.env['NX_HEAD'];\n\n if (!base) {\n base = detectBase(workspaceRoot) ?? undefined;\n if (!base) {\n console.log('\\n\\u23ed\\ufe0f Skipping no-implicit-any validation (could not detect base branch)');\n console.log('');\n return { success: true };\n }\n }\n\n console.log(` Base: ${base}`);\n console.log(` Head: ${head ?? 'working tree (includes uncommitted changes)'}`);\n console.log('');\n\n const changedFiles = getChangedFiles(workspaceRoot, base, head);\n if (changedFiles.length === 0) {\n console.log('\\u2705 No TypeScript files changed');\n return { success: true };\n }\n\n console.log(`\\ud83d\\udcc2 Checking ${changedFiles.length} changed file(s)...`);\n\n let violations: ImplicitAnyViolation[] = [];\n if (mode === 'NEW_AND_MODIFIED_CODE') {\n violations = findViolationsForModifiedCode(workspaceRoot, changedFiles, base, head, disableAllowed);\n } else if (mode === 'NEW_AND_MODIFIED_FILES') {\n violations = findViolationsForModifiedFiles(workspaceRoot, changedFiles, disableAllowed);\n }\n\n if (violations.length === 0) {\n console.log('\\u2705 No implicit-any inferences found');\n return { success: true };\n }\n\n reportViolations(violations, mode);\n return { success: false };\n}\n\nasync function runValidatorImpl(\n options: NoImplicitAnyConfig,\n workspaceRoot: string\n): Promise<ExecutorResult> {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n return await runInternal(options, workspaceRoot);\n } catch (err: unknown) {\n //const error = toError(err);\n console.warn('\\n\\u23ed\\ufe0f Skipping no-implicit-any validation due to unexpected error\\n');\n return { success: true };\n }\n}\n\n@provideSingleton()\n@injectable()\nexport class NoImplicitAnyValidator extends CodeValidator<NoImplicitAnyConfig> {\n constructor(config: NoImplicitAnyConfig) {\n super(config, 'no-implicit-any');\n }\n\n async run(workspaceRoot: string): Promise<ExecutorResult> {\n return runValidatorImpl(this.config, workspaceRoot);\n }\n}\n"]}
@@ -87,7 +87,7 @@ const path = tslib_1.__importStar(require("path"));
87
87
  const ts = tslib_1.__importStar(require("typescript"));
88
88
  const rules_config_1 = require("@webpieces/rules-config");
89
89
  const code_validator_1 = require("./code-validator");
90
- const core_context_1 = require("@webpieces/core-context");
90
+ const rules_config_2 = require("@webpieces/rules-config");
91
91
  const inversify_1 = require("inversify");
92
92
  const resolve_mode_1 = require("./resolve-mode");
93
93
  /**
@@ -529,7 +529,7 @@ let NoInlineTypeLiteralsValidator = class NoInlineTypeLiteralsValidator extends
529
529
  };
530
530
  exports.NoInlineTypeLiteralsValidator = NoInlineTypeLiteralsValidator;
531
531
  exports.NoInlineTypeLiteralsValidator = NoInlineTypeLiteralsValidator = tslib_1.__decorate([
532
- (0, core_context_1.provideSingleton)(),
532
+ (0, rules_config_2.provideSingleton)(),
533
533
  (0, inversify_1.injectable)(),
534
534
  tslib_1.__metadata("design:paramtypes", [rules_config_1.NoInlineTypeLiteralsConfig])
535
535
  ], NoInlineTypeLiteralsValidator);
@@ -1 +1 @@
1
- {"version":3,"file":"validate-no-inline-types.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/validate-no-inline-types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+EG;;;;AAEH,+CAAyB;AACzB,mDAA6B;AAC7B,uDAAiC;AACjC,0DAUiC;AACjC,qDAAiE;AACjE,0DAA2D;AAC3D,yCAAuC;AACvC,iDAAgD;AAShD;;GAEG;AACH,SAAS,iBAAiB,CAAC,KAAe,EAAE,UAAkB;IAC1D,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,UAAU,GAAG,CAAC,CAAC,CAAC;IAC/C,KAAK,IAAI,CAAC,GAAG,UAAU,GAAG,CAAC,EAAE,CAAC,IAAI,UAAU,EAAE,CAAC,EAAE,EAAE,CAAC;QAChD,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,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cesContent":["/**\n * Validate No Inline Types Executor\n *\n * Validates that inline type literals AND tuple types are not used in type positions.\n * Prefer named types/interfaces/classes for clarity and reusability.\n *\n * ============================================================================\n * VIOLATIONS (BAD) - These patterns are flagged:\n * ============================================================================\n *\n * 1. INLINE TYPE LITERALS { }\n * -------------------------\n * - Inline parameter type: function foo(arg: { x: number }) { }\n * - Inline return type: function foo(): { x: number } { }\n * - Inline variable type: const config: { timeout: number } = { timeout: 5 };\n * - Inline property type: class C { data: { id: number }; }\n * - Inline in union: type T = { x: number } | null;\n * - Inline in intersection: type T = { x: number } & { y: number };\n * - Inline in generic: Promise<{ data: string }>\n * - Inline in array: function foo(): { id: string }[] { }\n * - Nested inline in alias: type T = { data: { nested: number } }; // inner { } flagged\n * - Inline in tuple: type T = [{ x: number }, string];\n *\n * 2. TUPLE TYPES [ ]\n * ----------------\n * - Tuple return type: function foo(): [Items[], number] { }\n * - Tuple parameter type: function foo(arg: [string, number]) { }\n * - Tuple variable type: const result: [Data[], number] = getData();\n * - Tuple in generic: Promise<[Items[], number]>\n * - Tuple in union: type T = [A, B] | null;\n * - Nested tuple: type T = { data: [A, B] };\n *\n * ============================================================================\n * ALLOWED (GOOD) - These patterns pass validation:\n * ============================================================================\n *\n * 1. TYPE ALIAS DEFINITIONS (direct body only)\n * -----------------------------------------\n * - Type alias with literal: type MyConfig = { timeout: number };\n * - Type alias with tuple: type MyResult = [Items[], number];\n * - Interface definition: interface MyData { id: number }\n * - Class definition: class UserData { id: number; name: string; }\n *\n * 2. USING NAMED TYPES\n * ------------------\n * - Named param type: function foo(arg: MyConfig) { }\n * - Named return type: function foo(): MyConfig { }\n * - Named with null: function foo(): MyConfig | null { }\n * - Named with undefined: function foo(): MyConfig | undefined { }\n * - Union of named types: type Either = TypeA | TypeB;\n * - Named in generic: Promise<MyResult>\n * - Named tuple alias: function foo(): MyTupleResult { }\n *\n * 3. PRIMITIVES AND BUILT-INS\n * -------------------------\n * - Primitive types: function foo(): string { }\n * - Primitive arrays: function foo(): string[] { }\n * - Built-in generics: function foo(): Promise<string> { }\n * - Void return: function foo(): void { }\n *\n * ============================================================================\n * MODES\n * ============================================================================\n * - OFF: Skip validation entirely\n * - NEW_METHODS: Only validate in new methods (detected via git diff)\n * - NEW_AND_MODIFIED_METHODS: Validate in new methods + methods with changes\n * - NEW_AND_MODIFIED_FILES: Validate all violations in modified files\n *\n * ============================================================================\n * ESCAPE HATCH\n * ============================================================================\n * Add comment above the violation:\n * // webpieces-disable no-inline-types -- [your justification]\n * function foo(arg: { x: number }) { }\n *\n * Use sparingly! Common valid reasons:\n * - Prisma payload types that require inline generics\n * - Third-party library APIs that expect inline types\n * - Legacy code being incrementally migrated\n */\n\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as ts from 'typescript';\nimport {\n hasDisable,\n RULE_NAMES,\n NoInlineTypeLiteralsConfig,\n InlineTypeMode,\n detectBase,\n getChangedFiles,\n getFileDiff,\n getChangedLineNumbers,\n findNewMethodSignaturesInDiff,\n} from '@webpieces/rules-config';\nimport { CodeValidator, ExecutorResult } from './code-validator';\nimport { provideSingleton } from '@webpieces/core-context';\nimport { injectable } from 'inversify';\nimport { shouldSkipRule } from './resolve-mode';\n\ninterface InlineTypeViolation {\n file: string;\n line: number;\n column: number;\n context: string;\n}\n\n/**\n * Check if a line contains a webpieces-disable comment for no-inline-types.\n */\nfunction hasDisableComment(lines: string[], lineNumber: number): boolean {\n const startCheck = Math.max(0, lineNumber - 5);\n for (let i = lineNumber - 2; i >= startCheck; i--) {\n const line = lines[i]?.trim() ?? '';\n if (line.startsWith('function ') || line.startsWith('class ') || line.endsWith('}')) {\n break;\n }\n if (hasDisable(line, RULE_NAMES.NO_INLINE_TYPES)) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Check if a TypeLiteral or TupleType node is in an allowed context.\n * Only allowed if the DIRECT parent is a TypeAliasDeclaration.\n *\n * ALLOWED:\n * type MyConfig = { x: number }; // TypeLiteral direct child of TypeAliasDeclaration\n * type MyTuple = [A, B]; // TupleType direct child of TypeAliasDeclaration\n *\n * NOT ALLOWED (flagged):\n * type T = { x: number } | null; // Parent is UnionType, not TypeAliasDeclaration\n * type T = { data: { nested: number } }; // Inner TypeLiteral's parent is PropertySignature\n * function foo(): [A, B] { } // TupleType's parent is FunctionDeclaration\n * type T = Prisma.GetPayload<{ include: {...} }>; // TypeLiteral in generic argument\n *\n * NOTE: Prisma types require inline type literals in generic arguments. Use the escape hatch:\n * // webpieces-disable no-inline-types -- Prisma API requires inline type argument\n * type T = Prisma.GetPayload<{ include: {...} }>;\n */\nfunction isInAllowedContext(node: ts.TypeLiteralNode | ts.TupleTypeNode): boolean {\n const parent = node.parent;\n if (!parent) return false;\n\n // Only allowed if it's the DIRECT body of a type alias\n if (ts.isTypeAliasDeclaration(parent)) {\n return true;\n }\n return false;\n}\n\n/**\n * Get a description of the context where the inline type or tuple appears.\n *\n * Returns human-readable context like:\n * - \"inline parameter type\"\n * - \"tuple return type\"\n * - \"inline type in generic argument\"\n */\n// webpieces-disable max-lines-new-methods -- Context detection requires checking many AST node types\nfunction getViolationContext(node: ts.TypeLiteralNode | ts.TupleTypeNode, sourceFile: ts.SourceFile): string {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const isTuple = ts.isTupleTypeNode(node);\n const prefix = isTuple ? 'tuple' : 'inline';\n\n let current: ts.Node = node;\n while (current.parent) {\n const parent = current.parent;\n if (ts.isParameter(parent)) {\n return `${prefix} parameter type`;\n }\n if (ts.isFunctionDeclaration(parent) || ts.isMethodDeclaration(parent) || ts.isArrowFunction(parent)) {\n if (parent.type === current) {\n return `${prefix} return type`;\n }\n }\n if (ts.isVariableDeclaration(parent)) {\n return `${prefix} variable type`;\n }\n if (ts.isPropertyDeclaration(parent) || ts.isPropertySignature(parent)) {\n if (parent.type === current) {\n return `${prefix} property type`;\n }\n // Check if it's nested inside another type literal\n let ancestor: ts.Node | undefined = parent.parent;\n while (ancestor) {\n if (ts.isTypeLiteralNode(ancestor)) {\n return `nested ${prefix} type`;\n }\n if (ts.isTypeAliasDeclaration(ancestor)) {\n return `nested ${prefix} type in type alias`;\n }\n ancestor = ancestor.parent;\n }\n }\n if (ts.isUnionTypeNode(parent) || ts.isIntersectionTypeNode(parent)) {\n return `${prefix} type in union/intersection`;\n }\n // Safely check parent.parent before accessing it\n if (parent.parent && ts.isTypeReferenceNode(parent.parent) && ts.isTypeNode(parent)) {\n return `${prefix} type in generic argument`;\n }\n // Direct parent is TypeReferenceNode (e.g., Prisma.GetPayload<{...}>)\n if (ts.isTypeReferenceNode(parent)) {\n return `${prefix} type in generic argument`;\n }\n if (ts.isArrayTypeNode(parent)) {\n return `${prefix} type in array`;\n }\n if (ts.isTupleTypeNode(parent) && !isTuple) {\n return `inline type in tuple`;\n }\n current = parent;\n }\n return isTuple ? 'tuple type' : 'inline type literal';\n } catch (err: unknown) {\n //const error = toError(err);\n // Defensive: return generic context if AST traversal fails\n return ts.isTupleTypeNode(node) ? 'tuple type' : 'inline type literal';\n }\n}\n\ninterface MethodInfo {\n name: string;\n startLine: number;\n endLine: number;\n}\n\n/**\n * Find all methods/functions in a file with their line ranges.\n */\n// webpieces-disable max-lines-new-methods -- AST traversal requires inline visitor function\nfunction findMethodsInFile(filePath: string, workspaceRoot: string): MethodInfo[] {\n const fullPath = path.join(workspaceRoot, filePath);\n if (!fs.existsSync(fullPath)) return [];\n\n const content = fs.readFileSync(fullPath, 'utf-8');\n const sourceFile = ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true);\n\n const methods: MethodInfo[] = [];\n\n // webpieces-disable max-lines-new-methods -- AST visitor pattern requires handling multiple node types\n function visit(node: ts.Node): void {\n let methodName: string | undefined;\n let startLine: number | undefined;\n let endLine: number | undefined;\n\n if (ts.isMethodDeclaration(node) && node.name) {\n methodName = node.name.getText(sourceFile);\n const start = sourceFile.getLineAndCharacterOfPosition(node.getStart());\n const end = sourceFile.getLineAndCharacterOfPosition(node.getEnd());\n startLine = start.line + 1;\n endLine = end.line + 1;\n } else if (ts.isFunctionDeclaration(node) && node.name) {\n methodName = node.name.getText(sourceFile);\n const start = sourceFile.getLineAndCharacterOfPosition(node.getStart());\n const end = sourceFile.getLineAndCharacterOfPosition(node.getEnd());\n startLine = start.line + 1;\n endLine = end.line + 1;\n } else if (ts.isArrowFunction(node)) {\n if (ts.isVariableDeclaration(node.parent) && ts.isIdentifier(node.parent.name)) {\n methodName = node.parent.name.getText(sourceFile);\n const start = sourceFile.getLineAndCharacterOfPosition(node.getStart());\n const end = sourceFile.getLineAndCharacterOfPosition(node.getEnd());\n startLine = start.line + 1;\n endLine = end.line + 1;\n }\n }\n\n if (methodName && startLine !== undefined && endLine !== undefined) {\n methods.push({ name: methodName, startLine, endLine });\n }\n\n ts.forEachChild(node, visit);\n }\n\n visit(sourceFile);\n return methods;\n}\n\n/**\n * Check if a line is within any method's range and if that method has changes.\n */\nfunction isLineInChangedMethod(\n line: number,\n methods: MethodInfo[],\n changedLines: Set<number>,\n newMethodNames: Set<string>\n): boolean {\n for (const method of methods) {\n if (line >= method.startLine && line <= method.endLine) {\n // Check if this method is new or has changes\n if (newMethodNames.has(method.name)) {\n return true;\n }\n // Check if any line in the method range has changes\n for (let l = method.startLine; l <= method.endLine; l++) {\n if (changedLines.has(l)) {\n return true;\n }\n }\n }\n }\n return false;\n}\n\n/**\n * Check if a line is within a new method.\n */\nfunction isLineInNewMethod(line: number, methods: MethodInfo[], newMethodNames: Set<string>): boolean {\n for (const method of methods) {\n if (line >= method.startLine && line <= method.endLine && newMethodNames.has(method.name)) {\n return true;\n }\n }\n return false;\n}\n\ninterface InlineTypeInfo {\n line: number;\n column: number;\n context: string;\n hasDisableComment: boolean;\n}\n\n/**\n * Find all inline type literals AND tuple types in a file.\n *\n * Detects:\n * - TypeLiteral nodes: { x: number }\n * - TupleType nodes: [A, B]\n *\n * Both are flagged unless they are the DIRECT body of a type alias.\n */\n// webpieces-disable max-lines-new-methods -- AST traversal with visitor pattern\nfunction findInlineTypesInFile(filePath: string, workspaceRoot: string): InlineTypeInfo[] {\n const fullPath = path.join(workspaceRoot, filePath);\n if (!fs.existsSync(fullPath)) return [];\n\n const content = fs.readFileSync(fullPath, 'utf-8');\n const fileLines = content.split('\\n');\n const sourceFile = ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true);\n\n const inlineTypes: InlineTypeInfo[] = [];\n\n function visit(node: ts.Node): void {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n // Check for inline type literals: { x: number }\n if (ts.isTypeLiteralNode(node)) {\n if (!isInAllowedContext(node)) {\n const startPos = node.getStart(sourceFile);\n if (startPos >= 0) {\n const pos = sourceFile.getLineAndCharacterOfPosition(startPos);\n const line = pos.line + 1;\n const column = pos.character + 1;\n const context = getViolationContext(node, sourceFile);\n const disabled = hasDisableComment(fileLines, line);\n\n inlineTypes.push({\n line,\n column,\n context,\n hasDisableComment: disabled,\n });\n }\n }\n }\n\n // Check for tuple types: [A, B]\n if (ts.isTupleTypeNode(node)) {\n if (!isInAllowedContext(node)) {\n const startPos = node.getStart(sourceFile);\n if (startPos >= 0) {\n const pos = sourceFile.getLineAndCharacterOfPosition(startPos);\n const line = pos.line + 1;\n const column = pos.character + 1;\n const context = getViolationContext(node, sourceFile);\n const disabled = hasDisableComment(fileLines, line);\n\n inlineTypes.push({\n line,\n column,\n context,\n hasDisableComment: disabled,\n });\n }\n }\n }\n } catch (err: unknown) {\n //const error = toError(err);\n // Skip nodes that cause errors during analysis\n }\n\n ts.forEachChild(node, visit);\n }\n\n visit(sourceFile);\n return inlineTypes;\n}\n\n/**\n * Find violations in new methods only (NEW_METHODS mode).\n */\n// webpieces-disable max-lines-new-methods -- File iteration with diff parsing and method matching\nfunction findViolationsForNewMethods(\n workspaceRoot: string,\n changedFiles: string[],\n base: string,\n head: string | undefined,\n disableAllowed: boolean\n): InlineTypeViolation[] {\n const violations: InlineTypeViolation[] = [];\n\n for (const file of changedFiles) {\n const diff = getFileDiff(workspaceRoot, file, base, head);\n const newMethodNames = findNewMethodSignaturesInDiff(diff);\n\n if (newMethodNames.size === 0) continue;\n\n const methods = findMethodsInFile(file, workspaceRoot);\n const inlineTypes = findInlineTypesInFile(file, workspaceRoot);\n\n for (const inlineType of inlineTypes) {\n if (disableAllowed && inlineType.hasDisableComment) continue;\n if (!isLineInNewMethod(inlineType.line, methods, newMethodNames)) continue;\n\n violations.push({\n file,\n line: inlineType.line,\n column: inlineType.column,\n context: inlineType.context,\n });\n }\n }\n\n return violations;\n}\n\n/**\n * Find violations in new and modified methods (NEW_AND_MODIFIED_METHODS mode).\n */\n// webpieces-disable max-lines-new-methods -- Combines new method detection with change detection\nfunction findViolationsForModifiedAndNewMethods(\n workspaceRoot: string,\n changedFiles: string[],\n base: string,\n head: string | undefined,\n disableAllowed: boolean\n): InlineTypeViolation[] {\n const violations: InlineTypeViolation[] = [];\n\n for (const file of changedFiles) {\n const diff = getFileDiff(workspaceRoot, file, base, head);\n const newMethodNames = findNewMethodSignaturesInDiff(diff);\n const changedLines = getChangedLineNumbers(diff);\n\n const methods = findMethodsInFile(file, workspaceRoot);\n const inlineTypes = findInlineTypesInFile(file, workspaceRoot);\n\n for (const inlineType of inlineTypes) {\n if (disableAllowed && inlineType.hasDisableComment) continue;\n if (!isLineInChangedMethod(inlineType.line, methods, changedLines, newMethodNames)) continue;\n\n violations.push({\n file,\n line: inlineType.line,\n column: inlineType.column,\n context: inlineType.context,\n });\n }\n }\n\n return violations;\n}\n\n/**\n * Find all violations in modified files (NEW_AND_MODIFIED_FILES mode).\n */\nfunction findViolationsForModifiedFiles(workspaceRoot: string, changedFiles: string[], disableAllowed: boolean): InlineTypeViolation[] {\n const violations: InlineTypeViolation[] = [];\n\n for (const file of changedFiles) {\n const inlineTypes = findInlineTypesInFile(file, workspaceRoot);\n\n for (const inlineType of inlineTypes) {\n if (disableAllowed && inlineType.hasDisableComment) continue;\n\n violations.push({\n file,\n line: inlineType.line,\n column: inlineType.column,\n context: inlineType.context,\n });\n }\n }\n\n return violations;\n}\n\n/**\n * Report violations to console.\n */\nfunction reportViolations(violations: InlineTypeViolation[], mode: InlineTypeMode): void {\n console.error('');\n console.error('❌ Inline type literals found! Use named types instead.');\n console.error('');\n console.error('📚 Named types improve code clarity and reusability:');\n console.error('');\n console.error(' BAD: function foo(arg: { x: number }) { }');\n console.error(' GOOD: type MyConfig = { x: number };');\n console.error(' function foo(arg: MyConfig) { }');\n console.error('');\n console.error(' BAD: type Nullable = { x: number } | null;');\n console.error(' GOOD: type MyData = { x: number };');\n console.error(' type Nullable = MyData | null;');\n console.error('');\n\n for (const v of violations) {\n console.error(` ❌ ${v.file}:${v.line}:${v.column}`);\n console.error(` ${v.context}`);\n }\n console.error('');\n\n console.error(' To fix: Extract inline types to named type aliases or interfaces');\n console.error('');\n console.error(' Escape hatch (use sparingly):');\n console.error(' // webpieces-disable no-inline-types -- [your reason]');\n console.error('');\n console.error(` Current mode: ${mode}`);\n console.error('');\n}\n\n/**\n * Resolve mode considering ignoreModifiedUntilEpoch override.\n * When active, downgrades to OFF. When expired, logs a warning.\n */\nfunction resolveMode(normalMode: InlineTypeMode, epoch: number | undefined, branchPattern: string | undefined): InlineTypeMode {\n if (normalMode === 'OFF') {\n return normalMode;\n }\n const skip = shouldSkipRule(epoch, branchPattern);\n if (skip.skip) {\n console.log(`\\n⏭️ Skipping no-inline-types validation (${skip.reason})`);\n console.log('');\n return 'OFF';\n }\n return normalMode;\n}\n\nasync function runValidatorImpl(\n options: NoInlineTypeLiteralsConfig,\n workspaceRoot: string\n): Promise<ExecutorResult> {\n const mode: InlineTypeMode = resolveMode(options.mode ?? 'OFF', options.ignoreModifiedUntilEpoch, options.ignoreRuleWhileOnBranch);\n const disableAllowed = options.disableAllowed ?? true;\n\n if (mode === 'OFF') {\n console.log('\\n⏭️ Skipping no-inline-types validation (mode: OFF)');\n console.log('');\n return { success: true };\n }\n\n console.log('\\n📏 Validating No Inline Types\\n');\n console.log(` Mode: ${mode}`);\n\n let base = process.env['NX_BASE'];\n const head = process.env['NX_HEAD'];\n\n if (!base) {\n base = detectBase(workspaceRoot) ?? undefined;\n\n if (!base) {\n console.log('\\n⏭️ Skipping no-inline-types validation (could not detect base branch)');\n console.log('');\n return { success: true };\n }\n }\n\n console.log(` Base: ${base}`);\n console.log(` Head: ${head ?? 'working tree (includes uncommitted changes)'}`);\n console.log('');\n\n const changedFiles = getChangedFiles(workspaceRoot, base, head);\n\n if (changedFiles.length === 0) {\n console.log('✅ No TypeScript files changed');\n return { success: true };\n }\n\n console.log(`📂 Checking ${changedFiles.length} changed file(s)...`);\n\n let violations: InlineTypeViolation[] = [];\n\n if (mode === 'NEW_METHODS') {\n violations = findViolationsForNewMethods(workspaceRoot, changedFiles, base, head, disableAllowed);\n } else if (mode === 'NEW_AND_MODIFIED_METHODS') {\n violations = findViolationsForModifiedAndNewMethods(workspaceRoot, changedFiles, base, head, disableAllowed);\n } else if (mode === 'NEW_AND_MODIFIED_FILES') {\n violations = findViolationsForModifiedFiles(workspaceRoot, changedFiles, disableAllowed);\n }\n\n if (violations.length === 0) {\n console.log('✅ No inline type literals found');\n return { success: true };\n }\n\n reportViolations(violations, mode);\n\n return { success: false };\n}\n\n@provideSingleton()\n@injectable()\nexport class NoInlineTypeLiteralsValidator extends CodeValidator<NoInlineTypeLiteralsConfig> {\n constructor(config: NoInlineTypeLiteralsConfig) {\n super(config, 'no-inline-type-literals');\n }\n\n async run(workspaceRoot: string): Promise<ExecutorResult> {\n return runValidatorImpl(this.config, workspaceRoot);\n }\n}\n"]}
1
+ {"version":3,"file":"validate-no-inline-types.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/validate-no-inline-types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+EG;;;;AAEH,+CAAyB;AACzB,mDAA6B;AAC7B,uDAAiC;AACjC,0DAUiC;AACjC,qDAAiE;AACjE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nC,MAAM,6BAA8B,SAAQ,8BAAyC;IACxF,YAAY,MAAkC;QAC1C,KAAK,CAAC,MAAM,EAAE,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,aAAqB;QAC3B,OAAO,gBAAgB,CAAC,IAAI,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACxD,CAAC;CACJ,CAAA;AARY,sEAA6B;wCAA7B,6BAA6B;IAFzC,IAAA,+BAAgB,GAAE;IAClB,IAAA,sBAAU,GAAE;6CAEW,yCAA0B;GADrC,6BAA6B,CAQzC","sourcesContent":["/**\n * Validate No Inline Types Executor\n *\n * Validates that inline type literals AND tuple types are not used in type positions.\n * Prefer named types/interfaces/classes for clarity and reusability.\n *\n * ============================================================================\n * VIOLATIONS (BAD) - These patterns are flagged:\n * ============================================================================\n *\n * 1. INLINE TYPE LITERALS { }\n * -------------------------\n * - Inline parameter type: function foo(arg: { x: number }) { }\n * - Inline return type: function foo(): { x: number } { }\n * - Inline variable type: const config: { timeout: number } = { timeout: 5 };\n * - Inline property type: class C { data: { id: number }; }\n * - Inline in union: type T = { x: number } | null;\n * - Inline in intersection: type T = { x: number } & { y: number };\n * - Inline in generic: Promise<{ data: string }>\n * - Inline in array: function foo(): { id: string }[] { }\n * - Nested inline in alias: type T = { data: { nested: number } }; // inner { } flagged\n * - Inline in tuple: type T = [{ x: number }, string];\n *\n * 2. TUPLE TYPES [ ]\n * ----------------\n * - Tuple return type: function foo(): [Items[], number] { }\n * - Tuple parameter type: function foo(arg: [string, number]) { }\n * - Tuple variable type: const result: [Data[], number] = getData();\n * - Tuple in generic: Promise<[Items[], number]>\n * - Tuple in union: type T = [A, B] | null;\n * - Nested tuple: type T = { data: [A, B] };\n *\n * ============================================================================\n * ALLOWED (GOOD) - These patterns pass validation:\n * ============================================================================\n *\n * 1. TYPE ALIAS DEFINITIONS (direct body only)\n * -----------------------------------------\n * - Type alias with literal: type MyConfig = { timeout: number };\n * - Type alias with tuple: type MyResult = [Items[], number];\n * - Interface definition: interface MyData { id: number }\n * - Class definition: class UserData { id: number; name: string; }\n *\n * 2. USING NAMED TYPES\n * ------------------\n * - Named param type: function foo(arg: MyConfig) { }\n * - Named return type: function foo(): MyConfig { }\n * - Named with null: function foo(): MyConfig | null { }\n * - Named with undefined: function foo(): MyConfig | undefined { }\n * - Union of named types: type Either = TypeA | TypeB;\n * - Named in generic: Promise<MyResult>\n * - Named tuple alias: function foo(): MyTupleResult { }\n *\n * 3. PRIMITIVES AND BUILT-INS\n * -------------------------\n * - Primitive types: function foo(): string { }\n * - Primitive arrays: function foo(): string[] { }\n * - Built-in generics: function foo(): Promise<string> { }\n * - Void return: function foo(): void { }\n *\n * ============================================================================\n * MODES\n * ============================================================================\n * - OFF: Skip validation entirely\n * - NEW_METHODS: Only validate in new methods (detected via git diff)\n * - NEW_AND_MODIFIED_METHODS: Validate in new methods + methods with changes\n * - NEW_AND_MODIFIED_FILES: Validate all violations in modified files\n *\n * ============================================================================\n * ESCAPE HATCH\n * ============================================================================\n * Add comment above the violation:\n * // webpieces-disable no-inline-types -- [your justification]\n * function foo(arg: { x: number }) { }\n *\n * Use sparingly! Common valid reasons:\n * - Prisma payload types that require inline generics\n * - Third-party library APIs that expect inline types\n * - Legacy code being incrementally migrated\n */\n\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as ts from 'typescript';\nimport {\n hasDisable,\n RULE_NAMES,\n NoInlineTypeLiteralsConfig,\n InlineTypeMode,\n detectBase,\n getChangedFiles,\n getFileDiff,\n getChangedLineNumbers,\n findNewMethodSignaturesInDiff,\n} from '@webpieces/rules-config';\nimport { CodeValidator, ExecutorResult } from './code-validator';\nimport { provideSingleton } from '@webpieces/rules-config';\nimport { injectable } from 'inversify';\nimport { shouldSkipRule } from './resolve-mode';\n\ninterface InlineTypeViolation {\n file: string;\n line: number;\n column: number;\n context: string;\n}\n\n/**\n * Check if a line contains a webpieces-disable comment for no-inline-types.\n */\nfunction hasDisableComment(lines: string[], lineNumber: number): boolean {\n const startCheck = Math.max(0, lineNumber - 5);\n for (let i = lineNumber - 2; i >= startCheck; i--) {\n const line = lines[i]?.trim() ?? '';\n if (line.startsWith('function ') || line.startsWith('class ') || line.endsWith('}')) {\n break;\n }\n if (hasDisable(line, RULE_NAMES.NO_INLINE_TYPES)) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Check if a TypeLiteral or TupleType node is in an allowed context.\n * Only allowed if the DIRECT parent is a TypeAliasDeclaration.\n *\n * ALLOWED:\n * type MyConfig = { x: number }; // TypeLiteral direct child of TypeAliasDeclaration\n * type MyTuple = [A, B]; // TupleType direct child of TypeAliasDeclaration\n *\n * NOT ALLOWED (flagged):\n * type T = { x: number } | null; // Parent is UnionType, not TypeAliasDeclaration\n * type T = { data: { nested: number } }; // Inner TypeLiteral's parent is PropertySignature\n * function foo(): [A, B] { } // TupleType's parent is FunctionDeclaration\n * type T = Prisma.GetPayload<{ include: {...} }>; // TypeLiteral in generic argument\n *\n * NOTE: Prisma types require inline type literals in generic arguments. Use the escape hatch:\n * // webpieces-disable no-inline-types -- Prisma API requires inline type argument\n * type T = Prisma.GetPayload<{ include: {...} }>;\n */\nfunction isInAllowedContext(node: ts.TypeLiteralNode | ts.TupleTypeNode): boolean {\n const parent = node.parent;\n if (!parent) return false;\n\n // Only allowed if it's the DIRECT body of a type alias\n if (ts.isTypeAliasDeclaration(parent)) {\n return true;\n }\n return false;\n}\n\n/**\n * Get a description of the context where the inline type or tuple appears.\n *\n * Returns human-readable context like:\n * - \"inline parameter type\"\n * - \"tuple return type\"\n * - \"inline type in generic argument\"\n */\n// webpieces-disable max-lines-new-methods -- Context detection requires checking many AST node types\nfunction getViolationContext(node: ts.TypeLiteralNode | ts.TupleTypeNode, sourceFile: ts.SourceFile): string {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const isTuple = ts.isTupleTypeNode(node);\n const prefix = isTuple ? 'tuple' : 'inline';\n\n let current: ts.Node = node;\n while (current.parent) {\n const parent = current.parent;\n if (ts.isParameter(parent)) {\n return `${prefix} parameter type`;\n }\n if (ts.isFunctionDeclaration(parent) || ts.isMethodDeclaration(parent) || ts.isArrowFunction(parent)) {\n if (parent.type === current) {\n return `${prefix} return type`;\n }\n }\n if (ts.isVariableDeclaration(parent)) {\n return `${prefix} variable type`;\n }\n if (ts.isPropertyDeclaration(parent) || ts.isPropertySignature(parent)) {\n if (parent.type === current) {\n return `${prefix} property type`;\n }\n // Check if it's nested inside another type literal\n let ancestor: ts.Node | undefined = parent.parent;\n while (ancestor) {\n if (ts.isTypeLiteralNode(ancestor)) {\n return `nested ${prefix} type`;\n }\n if (ts.isTypeAliasDeclaration(ancestor)) {\n return `nested ${prefix} type in type alias`;\n }\n ancestor = ancestor.parent;\n }\n }\n if (ts.isUnionTypeNode(parent) || ts.isIntersectionTypeNode(parent)) {\n return `${prefix} type in union/intersection`;\n }\n // Safely check parent.parent before accessing it\n if (parent.parent && ts.isTypeReferenceNode(parent.parent) && ts.isTypeNode(parent)) {\n return `${prefix} type in generic argument`;\n }\n // Direct parent is TypeReferenceNode (e.g., Prisma.GetPayload<{...}>)\n if (ts.isTypeReferenceNode(parent)) {\n return `${prefix} type in generic argument`;\n }\n if (ts.isArrayTypeNode(parent)) {\n return `${prefix} type in array`;\n }\n if (ts.isTupleTypeNode(parent) && !isTuple) {\n return `inline type in tuple`;\n }\n current = parent;\n }\n return isTuple ? 'tuple type' : 'inline type literal';\n } catch (err: unknown) {\n //const error = toError(err);\n // Defensive: return generic context if AST traversal fails\n return ts.isTupleTypeNode(node) ? 'tuple type' : 'inline type literal';\n }\n}\n\ninterface MethodInfo {\n name: string;\n startLine: number;\n endLine: number;\n}\n\n/**\n * Find all methods/functions in a file with their line ranges.\n */\n// webpieces-disable max-lines-new-methods -- AST traversal requires inline visitor function\nfunction findMethodsInFile(filePath: string, workspaceRoot: string): MethodInfo[] {\n const fullPath = path.join(workspaceRoot, filePath);\n if (!fs.existsSync(fullPath)) return [];\n\n const content = fs.readFileSync(fullPath, 'utf-8');\n const sourceFile = ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true);\n\n const methods: MethodInfo[] = [];\n\n // webpieces-disable max-lines-new-methods -- AST visitor pattern requires handling multiple node types\n function visit(node: ts.Node): void {\n let methodName: string | undefined;\n let startLine: number | undefined;\n let endLine: number | undefined;\n\n if (ts.isMethodDeclaration(node) && node.name) {\n methodName = node.name.getText(sourceFile);\n const start = sourceFile.getLineAndCharacterOfPosition(node.getStart());\n const end = sourceFile.getLineAndCharacterOfPosition(node.getEnd());\n startLine = start.line + 1;\n endLine = end.line + 1;\n } else if (ts.isFunctionDeclaration(node) && node.name) {\n methodName = node.name.getText(sourceFile);\n const start = sourceFile.getLineAndCharacterOfPosition(node.getStart());\n const end = sourceFile.getLineAndCharacterOfPosition(node.getEnd());\n startLine = start.line + 1;\n endLine = end.line + 1;\n } else if (ts.isArrowFunction(node)) {\n if (ts.isVariableDeclaration(node.parent) && ts.isIdentifier(node.parent.name)) {\n methodName = node.parent.name.getText(sourceFile);\n const start = sourceFile.getLineAndCharacterOfPosition(node.getStart());\n const end = sourceFile.getLineAndCharacterOfPosition(node.getEnd());\n startLine = start.line + 1;\n endLine = end.line + 1;\n }\n }\n\n if (methodName && startLine !== undefined && endLine !== undefined) {\n methods.push({ name: methodName, startLine, endLine });\n }\n\n ts.forEachChild(node, visit);\n }\n\n visit(sourceFile);\n return methods;\n}\n\n/**\n * Check if a line is within any method's range and if that method has changes.\n */\nfunction isLineInChangedMethod(\n line: number,\n methods: MethodInfo[],\n changedLines: Set<number>,\n newMethodNames: Set<string>\n): boolean {\n for (const method of methods) {\n if (line >= method.startLine && line <= method.endLine) {\n // Check if this method is new or has changes\n if (newMethodNames.has(method.name)) {\n return true;\n }\n // Check if any line in the method range has changes\n for (let l = method.startLine; l <= method.endLine; l++) {\n if (changedLines.has(l)) {\n return true;\n }\n }\n }\n }\n return false;\n}\n\n/**\n * Check if a line is within a new method.\n */\nfunction isLineInNewMethod(line: number, methods: MethodInfo[], newMethodNames: Set<string>): boolean {\n for (const method of methods) {\n if (line >= method.startLine && line <= method.endLine && newMethodNames.has(method.name)) {\n return true;\n }\n }\n return false;\n}\n\ninterface InlineTypeInfo {\n line: number;\n column: number;\n context: string;\n hasDisableComment: boolean;\n}\n\n/**\n * Find all inline type literals AND tuple types in a file.\n *\n * Detects:\n * - TypeLiteral nodes: { x: number }\n * - TupleType nodes: [A, B]\n *\n * Both are flagged unless they are the DIRECT body of a type alias.\n */\n// webpieces-disable max-lines-new-methods -- AST traversal with visitor pattern\nfunction findInlineTypesInFile(filePath: string, workspaceRoot: string): InlineTypeInfo[] {\n const fullPath = path.join(workspaceRoot, filePath);\n if (!fs.existsSync(fullPath)) return [];\n\n const content = fs.readFileSync(fullPath, 'utf-8');\n const fileLines = content.split('\\n');\n const sourceFile = ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true);\n\n const inlineTypes: InlineTypeInfo[] = [];\n\n function visit(node: ts.Node): void {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n // Check for inline type literals: { x: number }\n if (ts.isTypeLiteralNode(node)) {\n if (!isInAllowedContext(node)) {\n const startPos = node.getStart(sourceFile);\n if (startPos >= 0) {\n const pos = sourceFile.getLineAndCharacterOfPosition(startPos);\n const line = pos.line + 1;\n const column = pos.character + 1;\n const context = getViolationContext(node, sourceFile);\n const disabled = hasDisableComment(fileLines, line);\n\n inlineTypes.push({\n line,\n column,\n context,\n hasDisableComment: disabled,\n });\n }\n }\n }\n\n // Check for tuple types: [A, B]\n if (ts.isTupleTypeNode(node)) {\n if (!isInAllowedContext(node)) {\n const startPos = node.getStart(sourceFile);\n if (startPos >= 0) {\n const pos = sourceFile.getLineAndCharacterOfPosition(startPos);\n const line = pos.line + 1;\n const column = pos.character + 1;\n const context = getViolationContext(node, sourceFile);\n const disabled = hasDisableComment(fileLines, line);\n\n inlineTypes.push({\n line,\n column,\n context,\n hasDisableComment: disabled,\n });\n }\n }\n }\n } catch (err: unknown) {\n //const error = toError(err);\n // Skip nodes that cause errors during analysis\n }\n\n ts.forEachChild(node, visit);\n }\n\n visit(sourceFile);\n return inlineTypes;\n}\n\n/**\n * Find violations in new methods only (NEW_METHODS mode).\n */\n// webpieces-disable max-lines-new-methods -- File iteration with diff parsing and method matching\nfunction findViolationsForNewMethods(\n workspaceRoot: string,\n changedFiles: string[],\n base: string,\n head: string | undefined,\n disableAllowed: boolean\n): InlineTypeViolation[] {\n const violations: InlineTypeViolation[] = [];\n\n for (const file of changedFiles) {\n const diff = getFileDiff(workspaceRoot, file, base, head);\n const newMethodNames = findNewMethodSignaturesInDiff(diff);\n\n if (newMethodNames.size === 0) continue;\n\n const methods = findMethodsInFile(file, workspaceRoot);\n const inlineTypes = findInlineTypesInFile(file, workspaceRoot);\n\n for (const inlineType of inlineTypes) {\n if (disableAllowed && inlineType.hasDisableComment) continue;\n if (!isLineInNewMethod(inlineType.line, methods, newMethodNames)) continue;\n\n violations.push({\n file,\n line: inlineType.line,\n column: inlineType.column,\n context: inlineType.context,\n });\n }\n }\n\n return violations;\n}\n\n/**\n * Find violations in new and modified methods (NEW_AND_MODIFIED_METHODS mode).\n */\n// webpieces-disable max-lines-new-methods -- Combines new method detection with change detection\nfunction findViolationsForModifiedAndNewMethods(\n workspaceRoot: string,\n changedFiles: string[],\n base: string,\n head: string | undefined,\n disableAllowed: boolean\n): InlineTypeViolation[] {\n const violations: InlineTypeViolation[] = [];\n\n for (const file of changedFiles) {\n const diff = getFileDiff(workspaceRoot, file, base, head);\n const newMethodNames = findNewMethodSignaturesInDiff(diff);\n const changedLines = getChangedLineNumbers(diff);\n\n const methods = findMethodsInFile(file, workspaceRoot);\n const inlineTypes = findInlineTypesInFile(file, workspaceRoot);\n\n for (const inlineType of inlineTypes) {\n if (disableAllowed && inlineType.hasDisableComment) continue;\n if (!isLineInChangedMethod(inlineType.line, methods, changedLines, newMethodNames)) continue;\n\n violations.push({\n file,\n line: inlineType.line,\n column: inlineType.column,\n context: inlineType.context,\n });\n }\n }\n\n return violations;\n}\n\n/**\n * Find all violations in modified files (NEW_AND_MODIFIED_FILES mode).\n */\nfunction findViolationsForModifiedFiles(workspaceRoot: string, changedFiles: string[], disableAllowed: boolean): InlineTypeViolation[] {\n const violations: InlineTypeViolation[] = [];\n\n for (const file of changedFiles) {\n const inlineTypes = findInlineTypesInFile(file, workspaceRoot);\n\n for (const inlineType of inlineTypes) {\n if (disableAllowed && inlineType.hasDisableComment) continue;\n\n violations.push({\n file,\n line: inlineType.line,\n column: inlineType.column,\n context: inlineType.context,\n });\n }\n }\n\n return violations;\n}\n\n/**\n * Report violations to console.\n */\nfunction reportViolations(violations: InlineTypeViolation[], mode: InlineTypeMode): void {\n console.error('');\n console.error('❌ Inline type literals found! Use named types instead.');\n console.error('');\n console.error('📚 Named types improve code clarity and reusability:');\n console.error('');\n console.error(' BAD: function foo(arg: { x: number }) { }');\n console.error(' GOOD: type MyConfig = { x: number };');\n console.error(' function foo(arg: MyConfig) { }');\n console.error('');\n console.error(' BAD: type Nullable = { x: number } | null;');\n console.error(' GOOD: type MyData = { x: number };');\n console.error(' type Nullable = MyData | null;');\n console.error('');\n\n for (const v of violations) {\n console.error(` ❌ ${v.file}:${v.line}:${v.column}`);\n console.error(` ${v.context}`);\n }\n console.error('');\n\n console.error(' To fix: Extract inline types to named type aliases or interfaces');\n console.error('');\n console.error(' Escape hatch (use sparingly):');\n console.error(' // webpieces-disable no-inline-types -- [your reason]');\n console.error('');\n console.error(` Current mode: ${mode}`);\n console.error('');\n}\n\n/**\n * Resolve mode considering ignoreModifiedUntilEpoch override.\n * When active, downgrades to OFF. When expired, logs a warning.\n */\nfunction resolveMode(normalMode: InlineTypeMode, epoch: number | undefined, branchPattern: string | undefined): InlineTypeMode {\n if (normalMode === 'OFF') {\n return normalMode;\n }\n const skip = shouldSkipRule(epoch, branchPattern);\n if (skip.skip) {\n console.log(`\\n⏭️ Skipping no-inline-types validation (${skip.reason})`);\n console.log('');\n return 'OFF';\n }\n return normalMode;\n}\n\nasync function runValidatorImpl(\n options: NoInlineTypeLiteralsConfig,\n workspaceRoot: string\n): Promise<ExecutorResult> {\n const mode: InlineTypeMode = resolveMode(options.mode ?? 'OFF', options.ignoreModifiedUntilEpoch, options.ignoreRuleWhileOnBranch);\n const disableAllowed = options.disableAllowed ?? true;\n\n if (mode === 'OFF') {\n console.log('\\n⏭️ Skipping no-inline-types validation (mode: OFF)');\n console.log('');\n return { success: true };\n }\n\n console.log('\\n📏 Validating No Inline Types\\n');\n console.log(` Mode: ${mode}`);\n\n let base = process.env['NX_BASE'];\n const head = process.env['NX_HEAD'];\n\n if (!base) {\n base = detectBase(workspaceRoot) ?? undefined;\n\n if (!base) {\n console.log('\\n⏭️ Skipping no-inline-types validation (could not detect base branch)');\n console.log('');\n return { success: true };\n }\n }\n\n console.log(` Base: ${base}`);\n console.log(` Head: ${head ?? 'working tree (includes uncommitted changes)'}`);\n console.log('');\n\n const changedFiles = getChangedFiles(workspaceRoot, base, head);\n\n if (changedFiles.length === 0) {\n console.log('✅ No TypeScript files changed');\n return { success: true };\n }\n\n console.log(`📂 Checking ${changedFiles.length} changed file(s)...`);\n\n let violations: InlineTypeViolation[] = [];\n\n if (mode === 'NEW_METHODS') {\n violations = findViolationsForNewMethods(workspaceRoot, changedFiles, base, head, disableAllowed);\n } else if (mode === 'NEW_AND_MODIFIED_METHODS') {\n violations = findViolationsForModifiedAndNewMethods(workspaceRoot, changedFiles, base, head, disableAllowed);\n } else if (mode === 'NEW_AND_MODIFIED_FILES') {\n violations = findViolationsForModifiedFiles(workspaceRoot, changedFiles, disableAllowed);\n }\n\n if (violations.length === 0) {\n console.log('✅ No inline type literals found');\n return { success: true };\n }\n\n reportViolations(violations, mode);\n\n return { success: false };\n}\n\n@provideSingleton()\n@injectable()\nexport class NoInlineTypeLiteralsValidator extends CodeValidator<NoInlineTypeLiteralsConfig> {\n constructor(config: NoInlineTypeLiteralsConfig) {\n super(config, 'no-inline-type-literals');\n }\n\n async run(workspaceRoot: string): Promise<ExecutorResult> {\n return runValidatorImpl(this.config, workspaceRoot);\n }\n}\n"]}
@@ -27,7 +27,7 @@ const fs = tslib_1.__importStar(require("fs"));
27
27
  const path = tslib_1.__importStar(require("path"));
28
28
  const rules_config_1 = require("@webpieces/rules-config");
29
29
  const code_validator_1 = require("./code-validator");
30
- const core_context_1 = require("@webpieces/core-context");
30
+ const rules_config_2 = require("@webpieces/rules-config");
31
31
  const inversify_1 = require("inversify");
32
32
  const resolve_mode_1 = require("./resolve-mode");
33
33
  const INSTRUCT_FILE = 'webpieces.noexitinmain.md';
@@ -199,7 +199,7 @@ let NoProcessExitOutsideMainValidator = class NoProcessExitOutsideMainValidator
199
199
  };
200
200
  exports.NoProcessExitOutsideMainValidator = NoProcessExitOutsideMainValidator;
201
201
  exports.NoProcessExitOutsideMainValidator = NoProcessExitOutsideMainValidator = tslib_1.__decorate([
202
- (0, core_context_1.provideSingleton)(),
202
+ (0, rules_config_2.provideSingleton)(),
203
203
  (0, inversify_1.injectable)(),
204
204
  tslib_1.__metadata("design:paramtypes", [rules_config_1.NoProcessExitOutsideMainConfig])
205
205
  ], NoProcessExitOutsideMainValidator);
@@ -1 +1 @@
1
- {"version":3,"file":"validate-no-process-exit-outside-main.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/validate-no-process-exit-outside-main.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AAiEH,4DAuBC;;AAtFD,+CAAyB;AACzB,mDAA6B;AAC7B,0DAA4N;AAC5N,qDAAiE;AACjE,0DAA2D;AAC3D,yCAAuC;AACvC,iDAAgD;AAEhD,MAAM,aAAa,GAAG,2BAA2B,CAAC;AAClD,MAAM,UAAU,GAAG,sBAAsB,CAAC;AAC1C,MAAM,iBAAiB,GAAG,sDAAsD,CAAC;AACjF,iGAAiG;AACjG,iDAAiD;AACjD,MAAM,cAAc,GAAG,2HAA2H,CAAC;AACnJ,MAAM,UAAU,G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iC,GAAvC,MAAM,iCAAkC,SAAQ,8BAA6C;IAChG,YAAY,MAAsC;QAC9C,KAAK,CAAC,MAAM,EAAE,8BAA8B,CAAC,CAAC;IAClD,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,aAAqB;QAC3B,OAAO,gBAAgB,CAAC,IAAI,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACxD,CAAC;CACJ,CAAA;AARY,8EAAiC;4CAAjC,iCAAiC;IAF7C,IAAA,+BAAgB,GAAE;IAClB,IAAA,sBAAU,GAAE;6CAEW,6CAA8B;GADzC,iCAAiC,CAQ7C","sourcesContent":["/**\n * Validate No Process Exit Outside Main\n *\n * Flags `process.exit(...)` outside a `main()`/`runMain` wrapper, and `import { main }` from another\n * module. A `process.exit` deep in a reused call stack crashes a server or command far too early and\n * unexpectedly — and with exit 0 it masquerades as success. Throw a semantic error instead and let\n * the ONE top-level `main()`/`runMain` try-catch pick the exit code.\n *\n * See .webpieces/instruct-ai/webpieces.noexitinmain.md (generated on violation) for the full pattern.\n *\n * ALLOWED\n * - A `process.exit` whose nearest enclosing function is named `main` or `runMain`.\n * - Test files (*.test.ts, *.spec.ts, __tests__/**).\n * - Lines with `// webpieces-disable no-process-exit-outside-main -- <reason>` (when disableAllowed).\n *\n * MODES (LINE-BASED)\n * - OFF: Skip.\n * - NEW_AND_MODIFIED_CODE: Flag only on changed lines (diff hunks).\n * - NEW_AND_MODIFIED_FILES: Flag every occurrence in any modified file.\n */\n\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { hasDisable, RULE_NAMES, NoProcessExitOutsideMainConfig, ModifiedCodeMode, detectBase, getChangedFiles, getFileDiff, getChangedLineNumbers, writeTemplateIfMissing, RepoRootFinder } from '@webpieces/rules-config';\nimport { CodeValidator, ExecutorResult } from './code-validator';\nimport { provideSingleton } from '@webpieces/core-context';\nimport { injectable } from 'inversify';\nimport { shouldSkipRule } from './resolve-mode';\n\nconst INSTRUCT_FILE = 'webpieces.noexitinmain.md';\nconst EXIT_REGEX = /\\bprocess\\.exit\\s*\\(/;\nconst IMPORT_MAIN_REGEX = /^\\s*import\\b[^;]*\\{[^}]*\\bmain\\b[^}]*\\}[^;]*\\bfrom\\b/;\n// Named function / arrow-const DEFINITION openers (never a call like `main()`), used to find the\n// enclosing function's name via a backward scan.\nconst FUNC_DEF_REGEX = /(?:export\\s+)?(?:async\\s+)?function\\s+(\\w+)\\s*\\(|(?:export\\s+)?(?:const|let)\\s+(\\w+)\\s*=\\s*(?:async\\s*)?(?:\\(|function\\b)/;\nconst ALLOWED_FN = new Set(['main', 'runMain']);\n\nconst SHARED_MESSAGE = `Do not call process.exit() deep in the stack — any code may be reused, and a deep exit crashes a\nserver or command far too early (exit 0 even masquerades as success). Throw a semantic error instead:\n - Expected/normal failure → your domain's failure error (in the rules engine: RuleFailError).\n - A bug / broken precondition (should-never-happen, missing required var) → an ordinary Error.\nLet the ONE top-level main()/runMain try-catch pick the exit code (non-zero on failure, 0 on success):\n if (require.main === module) runMain(main)\nNeed a specific exit code deep down? throw new CliExitError(code, message) — runMain maps it.\nAlso: do NOT import another module's main — call a named function; only a thin wrapper calls main.\nLast resort: append // webpieces-disable no-process-exit-outside-main -- <reason> at a genuine terminal boundary.`;\n\ninterface ExitViolation {\n file: string;\n line: number;\n context: string;\n}\n\ninterface ExitViolationInfo {\n line: number;\n context: string;\n hasDisableComment: boolean;\n}\n\nfunction isTestFile(filePath: string): boolean {\n return filePath.includes('.spec.ts') || filePath.includes('.test.ts') || filePath.includes('__tests__/');\n}\n\nfunction stripLineComments(line: string): string {\n const idx = line.indexOf('//');\n if (idx === -1) return line;\n return line.substring(0, idx);\n}\n\n// Walk backward from `idx` for the nearest NAMED function/arrow definition and return its name.\n// Line-based heuristic (no AST): recognises a `main`/`runMain` wrapper enclosing the exit.\nfunction enclosingFunctionName(strippedLines: string[], idx: number): string | null {\n for (let j = idx; j >= 0; j -= 1) {\n const m = FUNC_DEF_REGEX.exec(strippedLines[j] ?? '');\n if (m) return m[1] ?? m[2] ?? null;\n }\n return null;\n}\n\nfunction resolveDisable(disabled: boolean, disableAllowed: boolean): boolean {\n if (!disableAllowed && disabled) return false;\n return disabled;\n}\n\nexport function findExitViolationsInFile(filePath: string, workspaceRoot: string, disableAllowed: boolean): ExitViolationInfo[] {\n if (isTestFile(filePath)) return [];\n const fullPath = path.join(workspaceRoot, filePath);\n if (!fs.existsSync(fullPath)) return [];\n\n const content = fs.readFileSync(fullPath, 'utf-8');\n const lines = content.split('\\n');\n const stripped = lines.map((l: string): string => stripLineComments(l));\n const violations: ExitViolationInfo[] = [];\n\n for (let i = 0; i < lines.length; i += 1) {\n const line = lines[i] ?? '';\n const strippedLine = stripped[i] ?? '';\n const isExit = EXIT_REGEX.test(strippedLine) && !ALLOWED_FN.has(enclosingFunctionName(stripped, i) ?? '');\n const isImportMain = IMPORT_MAIN_REGEX.test(strippedLine);\n if (!isExit && !isImportMain) continue;\n\n const lineNum = i + 1;\n const prevLine = i > 0 ? (lines[i - 1] ?? '') : '';\n const disabled = hasDisable(line, RULE_NAMES.NO_PROCESS_EXIT_OUTSIDE_MAIN) || hasDisable(prevLine, RULE_NAMES.NO_PROCESS_EXIT_OUTSIDE_MAIN);\n violations.push({ line: lineNum, context: line.trim(), hasDisableComment: resolveDisable(disabled, disableAllowed) });\n }\n return violations;\n}\n\nfunction findViolationsForModifiedCode(workspaceRoot: string, changedFiles: string[], base: string, head: string | undefined, disableAllowed: boolean): ExitViolation[] {\n const violations: ExitViolation[] = [];\n for (const file of changedFiles) {\n const changedLines = getChangedLineNumbers(getFileDiff(workspaceRoot, file, base, head));\n if (changedLines.size === 0) continue;\n for (const v of findExitViolationsInFile(file, workspaceRoot, disableAllowed)) {\n if (disableAllowed && v.hasDisableComment) continue;\n if (!changedLines.has(v.line)) continue;\n violations.push({ file, line: v.line, context: v.context });\n }\n }\n return violations;\n}\n\nfunction findViolationsForModifiedFiles(workspaceRoot: string, changedFiles: string[], disableAllowed: boolean): ExitViolation[] {\n const violations: ExitViolation[] = [];\n for (const file of changedFiles) {\n for (const v of findExitViolationsInFile(file, workspaceRoot, disableAllowed)) {\n if (disableAllowed && v.hasDisableComment) continue;\n violations.push({ file, line: v.line, context: v.context });\n }\n }\n return violations;\n}\n\nfunction reportViolations(workspaceRoot: string, violations: ExitViolation[], mode: ModifiedCodeMode, disableAllowed: boolean): void {\n writeTemplateIfMissing(workspaceRoot, INSTRUCT_FILE);\n console.error('');\n console.error('❌ process.exit() outside main()/runMain (or an import of another module\\'s main)!');\n console.error('');\n console.error(SHARED_MESSAGE);\n console.error(`READ ${new RepoRootFinder().instructAiDocPath(workspaceRoot, INSTRUCT_FILE)} for the full pattern.`);\n console.error('');\n for (const v of violations) {\n console.error(` ❌ ${v.file}:${v.line}`);\n console.error(` ${v.context}`);\n }\n console.error('');\n console.error(disableAllowed\n ? ' Escape hatch (genuine terminal boundary only): // webpieces-disable no-process-exit-outside-main -- <reason>'\n : ' Escape hatch: DISABLED (disableAllowed: false)');\n console.error(`\\n Current mode: ${mode}\\n`);\n}\n\nfunction resolveMode(normalMode: ModifiedCodeMode, epoch: number | undefined, branchPattern: string | undefined): ModifiedCodeMode {\n if (normalMode === 'OFF') return normalMode;\n const skip = shouldSkipRule(epoch, branchPattern);\n if (skip.skip) {\n console.log(`\\n⏭️ Skipping no-process-exit-outside-main validation (${skip.reason})\\n`);\n return 'OFF';\n }\n return normalMode;\n}\n\nasync function runValidatorImpl(options: NoProcessExitOutsideMainConfig, workspaceRoot: string): Promise<ExecutorResult> {\n const mode: ModifiedCodeMode = resolveMode(options.mode ?? 'OFF', options.ignoreModifiedUntilEpoch, options.ignoreRuleWhileOnBranch);\n const disableAllowed = options.disableAllowed ?? true;\n\n if (mode === 'OFF') {\n console.log('\\n⏭️ Skipping no-process-exit-outside-main validation (mode: OFF)\\n');\n return { success: true };\n }\n\n console.log('\\n📏 Validating No Process Exit Outside Main\\n');\n console.log(` Mode: ${mode}`);\n\n let base = process.env['NX_BASE'];\n const head = process.env['NX_HEAD'];\n if (!base) {\n base = detectBase(workspaceRoot) ?? undefined;\n if (!base) {\n console.log('\\n⏭️ Skipping no-process-exit-outside-main validation (could not detect base branch)\\n');\n return { success: true };\n }\n }\n\n console.log(` Base: ${base}`);\n console.log(` Head: ${head ?? 'working tree (includes uncommitted changes)'}\\n`);\n\n const changedFiles = getChangedFiles(workspaceRoot, base, head);\n if (changedFiles.length === 0) {\n console.log('✅ No TypeScript files changed');\n return { success: true };\n }\n\n console.log(`📂 Checking ${changedFiles.length} changed file(s)...`);\n\n let violations: ExitViolation[] = [];\n if (mode === 'NEW_AND_MODIFIED_CODE') {\n violations = findViolationsForModifiedCode(workspaceRoot, changedFiles, base, head, disableAllowed);\n } else if (mode === 'NEW_AND_MODIFIED_FILES') {\n violations = findViolationsForModifiedFiles(workspaceRoot, changedFiles, disableAllowed);\n }\n\n if (violations.length === 0) {\n console.log('✅ No process.exit-outside-main violations found');\n return { success: true };\n }\n\n reportViolations(workspaceRoot, violations, mode, disableAllowed);\n return { success: false };\n}\n\n@provideSingleton()\n@injectable()\nexport class NoProcessExitOutsideMainValidator extends CodeValidator<NoProcessExitOutsideMainConfig> {\n constructor(config: NoProcessExitOutsideMainConfig) {\n super(config, 'no-process-exit-outside-main');\n }\n\n async run(workspaceRoot: string): Promise<ExecutorResult> {\n return runValidatorImpl(this.config, workspaceRoot);\n }\n}\n"]}
1
+ {"version":3,"file":"validate-no-process-exit-outside-main.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/validate-no-process-exit-outside-main.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AAiEH,4DAuBC;;AAtFD,+CAAyB;AACzB,mDAA6B;AAC7B,0DAA4N;AAC5N,qDAAiE;AACjE,0DAA2D;AAC3D,yCAAuC;AACvC,iDAAgD;AAEhD,MAAM,aAAa,GAAG,2BAA2B,CAAC;AAClD,MAAM,UAAU,GAAG,sBAAsB,CAAC;AAC1C,MAAM,iBAAiB,GAAG,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EAAE,cAAc,CAAC,CAAC;IAClE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AAC9B,CAAC;AAIM,IAAM,iCAAiC,GAAvC,MAAM,iCAAkC,SAAQ,8BAA6C;IAChG,YAAY,MAAsC;QAC9C,KAAK,CAAC,MAAM,EAAE,8BAA8B,CAAC,CAAC;IAClD,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,aAAqB;QAC3B,OAAO,gBAAgB,CAAC,IAAI,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACxD,CAAC;CACJ,CAAA;AARY,8EAAiC;4CAAjC,iCAAiC;IAF7C,IAAA,+BAAgB,GAAE;IAClB,IAAA,sBAAU,GAAE;6CAEW,6CAA8B;GADzC,iCAAiC,CAQ7C","sourcesContent":["/**\n * Validate No Process Exit Outside Main\n *\n * Flags `process.exit(...)` outside a `main()`/`runMain` wrapper, and `import { main }` from another\n * module. A `process.exit` deep in a reused call stack crashes a server or command far too early and\n * unexpectedly — and with exit 0 it masquerades as success. Throw a semantic error instead and let\n * the ONE top-level `main()`/`runMain` try-catch pick the exit code.\n *\n * See .webpieces/instruct-ai/webpieces.noexitinmain.md (generated on violation) for the full pattern.\n *\n * ALLOWED\n * - A `process.exit` whose nearest enclosing function is named `main` or `runMain`.\n * - Test files (*.test.ts, *.spec.ts, __tests__/**).\n * - Lines with `// webpieces-disable no-process-exit-outside-main -- <reason>` (when disableAllowed).\n *\n * MODES (LINE-BASED)\n * - OFF: Skip.\n * - NEW_AND_MODIFIED_CODE: Flag only on changed lines (diff hunks).\n * - NEW_AND_MODIFIED_FILES: Flag every occurrence in any modified file.\n */\n\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { hasDisable, RULE_NAMES, NoProcessExitOutsideMainConfig, ModifiedCodeMode, detectBase, getChangedFiles, getFileDiff, getChangedLineNumbers, writeTemplateIfMissing, RepoRootFinder } from '@webpieces/rules-config';\nimport { CodeValidator, ExecutorResult } from './code-validator';\nimport { provideSingleton } from '@webpieces/rules-config';\nimport { injectable } from 'inversify';\nimport { shouldSkipRule } from './resolve-mode';\n\nconst INSTRUCT_FILE = 'webpieces.noexitinmain.md';\nconst EXIT_REGEX = /\\bprocess\\.exit\\s*\\(/;\nconst IMPORT_MAIN_REGEX = /^\\s*import\\b[^;]*\\{[^}]*\\bmain\\b[^}]*\\}[^;]*\\bfrom\\b/;\n// Named function / arrow-const DEFINITION openers (never a call like `main()`), used to find the\n// enclosing function's name via a backward scan.\nconst FUNC_DEF_REGEX = /(?:export\\s+)?(?:async\\s+)?function\\s+(\\w+)\\s*\\(|(?:export\\s+)?(?:const|let)\\s+(\\w+)\\s*=\\s*(?:async\\s*)?(?:\\(|function\\b)/;\nconst ALLOWED_FN = new Set(['main', 'runMain']);\n\nconst SHARED_MESSAGE = `Do not call process.exit() deep in the stack — any code may be reused, and a deep exit crashes a\nserver or command far too early (exit 0 even masquerades as success). Throw a semantic error instead:\n - Expected/normal failure → your domain's failure error (in the rules engine: RuleFailError).\n - A bug / broken precondition (should-never-happen, missing required var) → an ordinary Error.\nLet the ONE top-level main()/runMain try-catch pick the exit code (non-zero on failure, 0 on success):\n if (require.main === module) runMain(main)\nNeed a specific exit code deep down? throw new CliExitError(code, message) — runMain maps it.\nAlso: do NOT import another module's main — call a named function; only a thin wrapper calls main.\nLast resort: append // webpieces-disable no-process-exit-outside-main -- <reason> at a genuine terminal boundary.`;\n\ninterface ExitViolation {\n file: string;\n line: number;\n context: string;\n}\n\ninterface ExitViolationInfo {\n line: number;\n context: string;\n hasDisableComment: boolean;\n}\n\nfunction isTestFile(filePath: string): boolean {\n return filePath.includes('.spec.ts') || filePath.includes('.test.ts') || filePath.includes('__tests__/');\n}\n\nfunction stripLineComments(line: string): string {\n const idx = line.indexOf('//');\n if (idx === -1) return line;\n return line.substring(0, idx);\n}\n\n// Walk backward from `idx` for the nearest NAMED function/arrow definition and return its name.\n// Line-based heuristic (no AST): recognises a `main`/`runMain` wrapper enclosing the exit.\nfunction enclosingFunctionName(strippedLines: string[], idx: number): string | null {\n for (let j = idx; j >= 0; j -= 1) {\n const m = FUNC_DEF_REGEX.exec(strippedLines[j] ?? '');\n if (m) return m[1] ?? m[2] ?? null;\n }\n return null;\n}\n\nfunction resolveDisable(disabled: boolean, disableAllowed: boolean): boolean {\n if (!disableAllowed && disabled) return false;\n return disabled;\n}\n\nexport function findExitViolationsInFile(filePath: string, workspaceRoot: string, disableAllowed: boolean): ExitViolationInfo[] {\n if (isTestFile(filePath)) return [];\n const fullPath = path.join(workspaceRoot, filePath);\n if (!fs.existsSync(fullPath)) return [];\n\n const content = fs.readFileSync(fullPath, 'utf-8');\n const lines = content.split('\\n');\n const stripped = lines.map((l: string): string => stripLineComments(l));\n const violations: ExitViolationInfo[] = [];\n\n for (let i = 0; i < lines.length; i += 1) {\n const line = lines[i] ?? '';\n const strippedLine = stripped[i] ?? '';\n const isExit = EXIT_REGEX.test(strippedLine) && !ALLOWED_FN.has(enclosingFunctionName(stripped, i) ?? '');\n const isImportMain = IMPORT_MAIN_REGEX.test(strippedLine);\n if (!isExit && !isImportMain) continue;\n\n const lineNum = i + 1;\n const prevLine = i > 0 ? (lines[i - 1] ?? '') : '';\n const disabled = hasDisable(line, RULE_NAMES.NO_PROCESS_EXIT_OUTSIDE_MAIN) || hasDisable(prevLine, RULE_NAMES.NO_PROCESS_EXIT_OUTSIDE_MAIN);\n violations.push({ line: lineNum, context: line.trim(), hasDisableComment: resolveDisable(disabled, disableAllowed) });\n }\n return violations;\n}\n\nfunction findViolationsForModifiedCode(workspaceRoot: string, changedFiles: string[], base: string, head: string | undefined, disableAllowed: boolean): ExitViolation[] {\n const violations: ExitViolation[] = [];\n for (const file of changedFiles) {\n const changedLines = getChangedLineNumbers(getFileDiff(workspaceRoot, file, base, head));\n if (changedLines.size === 0) continue;\n for (const v of findExitViolationsInFile(file, workspaceRoot, disableAllowed)) {\n if (disableAllowed && v.hasDisableComment) continue;\n if (!changedLines.has(v.line)) continue;\n violations.push({ file, line: v.line, context: v.context });\n }\n }\n return violations;\n}\n\nfunction findViolationsForModifiedFiles(workspaceRoot: string, changedFiles: string[], disableAllowed: boolean): ExitViolation[] {\n const violations: ExitViolation[] = [];\n for (const file of changedFiles) {\n for (const v of findExitViolationsInFile(file, workspaceRoot, disableAllowed)) {\n if (disableAllowed && v.hasDisableComment) continue;\n violations.push({ file, line: v.line, context: v.context });\n }\n }\n return violations;\n}\n\nfunction reportViolations(workspaceRoot: string, violations: ExitViolation[], mode: ModifiedCodeMode, disableAllowed: boolean): void {\n writeTemplateIfMissing(workspaceRoot, INSTRUCT_FILE);\n console.error('');\n console.error('❌ process.exit() outside main()/runMain (or an import of another module\\'s main)!');\n console.error('');\n console.error(SHARED_MESSAGE);\n console.error(`READ ${new RepoRootFinder().instructAiDocPath(workspaceRoot, INSTRUCT_FILE)} for the full pattern.`);\n console.error('');\n for (const v of violations) {\n console.error(` ❌ ${v.file}:${v.line}`);\n console.error(` ${v.context}`);\n }\n console.error('');\n console.error(disableAllowed\n ? ' Escape hatch (genuine terminal boundary only): // webpieces-disable no-process-exit-outside-main -- <reason>'\n : ' Escape hatch: DISABLED (disableAllowed: false)');\n console.error(`\\n Current mode: ${mode}\\n`);\n}\n\nfunction resolveMode(normalMode: ModifiedCodeMode, epoch: number | undefined, branchPattern: string | undefined): ModifiedCodeMode {\n if (normalMode === 'OFF') return normalMode;\n const skip = shouldSkipRule(epoch, branchPattern);\n if (skip.skip) {\n console.log(`\\n⏭️ Skipping no-process-exit-outside-main validation (${skip.reason})\\n`);\n return 'OFF';\n }\n return normalMode;\n}\n\nasync function runValidatorImpl(options: NoProcessExitOutsideMainConfig, workspaceRoot: string): Promise<ExecutorResult> {\n const mode: ModifiedCodeMode = resolveMode(options.mode ?? 'OFF', options.ignoreModifiedUntilEpoch, options.ignoreRuleWhileOnBranch);\n const disableAllowed = options.disableAllowed ?? true;\n\n if (mode === 'OFF') {\n console.log('\\n⏭️ Skipping no-process-exit-outside-main validation (mode: OFF)\\n');\n return { success: true };\n }\n\n console.log('\\n📏 Validating No Process Exit Outside Main\\n');\n console.log(` Mode: ${mode}`);\n\n let base = process.env['NX_BASE'];\n const head = process.env['NX_HEAD'];\n if (!base) {\n base = detectBase(workspaceRoot) ?? undefined;\n if (!base) {\n console.log('\\n⏭️ Skipping no-process-exit-outside-main validation (could not detect base branch)\\n');\n return { success: true };\n }\n }\n\n console.log(` Base: ${base}`);\n console.log(` Head: ${head ?? 'working tree (includes uncommitted changes)'}\\n`);\n\n const changedFiles = getChangedFiles(workspaceRoot, base, head);\n if (changedFiles.length === 0) {\n console.log('✅ No TypeScript files changed');\n return { success: true };\n }\n\n console.log(`📂 Checking ${changedFiles.length} changed file(s)...`);\n\n let violations: ExitViolation[] = [];\n if (mode === 'NEW_AND_MODIFIED_CODE') {\n violations = findViolationsForModifiedCode(workspaceRoot, changedFiles, base, head, disableAllowed);\n } else if (mode === 'NEW_AND_MODIFIED_FILES') {\n violations = findViolationsForModifiedFiles(workspaceRoot, changedFiles, disableAllowed);\n }\n\n if (violations.length === 0) {\n console.log('✅ No process.exit-outside-main violations found');\n return { success: true };\n }\n\n reportViolations(workspaceRoot, violations, mode, disableAllowed);\n return { success: false };\n}\n\n@provideSingleton()\n@injectable()\nexport class NoProcessExitOutsideMainValidator extends CodeValidator<NoProcessExitOutsideMainConfig> {\n constructor(config: NoProcessExitOutsideMainConfig) {\n super(config, 'no-process-exit-outside-main');\n }\n\n async run(workspaceRoot: string): Promise<ExecutorResult> {\n return runValidatorImpl(this.config, workspaceRoot);\n }\n}\n"]}
@@ -43,7 +43,7 @@ const fs = tslib_1.__importStar(require("fs"));
43
43
  const path = tslib_1.__importStar(require("path"));
44
44
  const rules_config_1 = require("@webpieces/rules-config");
45
45
  const code_validator_1 = require("./code-validator");
46
- const core_context_1 = require("@webpieces/core-context");
46
+ const rules_config_2 = require("@webpieces/rules-config");
47
47
  const inversify_1 = require("inversify");
48
48
  const resolve_mode_1 = require("./resolve-mode");
49
49
  const SYMBOL_DI_REGEX = /=\s*Symbol(?:\.for)?\(/;
@@ -264,7 +264,7 @@ let NoSymbolDiTokensValidator = class NoSymbolDiTokensValidator extends code_val
264
264
  };
265
265
  exports.NoSymbolDiTokensValidator = NoSymbolDiTokensValidator;
266
266
  exports.NoSymbolDiTokensValidator = NoSymbolDiTokensValidator = tslib_1.__decorate([
267
- (0, core_context_1.provideSingleton)(),
267
+ (0, rules_config_2.provideSingleton)(),
268
268
  (0, inversify_1.injectable)(),
269
269
  tslib_1.__metadata("design:paramtypes", [rules_config_1.NoSymbolDiTokensConfig])
270
270
  ], NoSymbolDiTokensValidator);