@webpieces/dev-config 0.2.73 ā 0.2.75
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.
- package/architecture/executors/validate-code/executor.d.ts +4 -0
- package/architecture/executors/validate-code/executor.js +11 -1
- package/architecture/executors/validate-code/executor.js.map +1 -1
- package/architecture/executors/validate-code/executor.ts +15 -1
- package/architecture/executors/validate-code/schema.json +12 -0
- package/architecture/executors/validate-no-any-unknown/executor.d.ts +41 -0
- package/architecture/executors/validate-no-any-unknown/executor.js +442 -0
- package/architecture/executors/validate-no-any-unknown/executor.js.map +1 -0
- package/architecture/executors/validate-no-any-unknown/executor.ts +513 -0
- package/architecture/executors/validate-no-any-unknown/schema.json +15 -0
- package/architecture/executors/validate-no-inline-types/executor.d.ts +90 -0
- package/architecture/executors/validate-no-inline-types/executor.js +684 -0
- package/architecture/executors/validate-no-inline-types/executor.js.map +1 -0
- package/architecture/executors/validate-no-inline-types/executor.ts +785 -0
- package/architecture/executors/validate-no-inline-types/schema.json +15 -0
- package/executors.json +10 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/dev-config/architecture/executors/validate-no-any-unknown/executor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;;AAiaH,8BAgEC;;AA9dD,iDAAyC;AACzC,+CAAyB;AACzB,mDAA6B;AAC7B,uDAAiC;AAoBjC;;GAEG;AACH,oHAAoH;AACpH,SAAS,yBAAyB,CAAC,aAAqB,EAAE,IAAY,EAAE,IAAa;IACjF,IAAI,CAAC;QACD,MAAM,UAAU,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;QACnD,MAAM,MAAM,GAAG,IAAA,wBAAQ,EAAC,wBAAwB,UAAU,oBAAoB,EAAE;YA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AK,gBAAgB,EAAE,CAAC;YACnC,UAAU,GAAG,8BAA8B,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;QAC7E,CAAC;IACL,CAAC;IAED,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC;QAC/C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC7B,CAAC;IAED,gBAAgB,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IAEnC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AAC9B,CAAC","sourcesContent":["/**\n * Validate No Any Unknown Executor\n *\n * Validates that `any` and `unknown` TypeScript keywords are not used.\n * Uses LINE-BASED detection (not method-based) for git diff filtering.\n *\n * ============================================================================\n * VIOLATIONS (BAD) - These patterns are flagged:\n * ============================================================================\n *\n * - const x: any = ...\n * - function foo(arg: any): any { }\n * - const data = response as any;\n * - type T = any;\n * - const x: unknown = ...\n * - function foo(arg: unknown): unknown { }\n *\n * ============================================================================\n * MODES (LINE-BASED)\n * ============================================================================\n * - OFF: Skip validation entirely\n * - MODIFIED_CODE: Flag any/unknown on changed lines (lines in diff hunks)\n * - MODIFIED_FILES: Flag ALL any/unknown in files that were modified\n * - ALL: Flag everywhere in all TypeScript files\n *\n * ============================================================================\n * ESCAPE HATCH\n * ============================================================================\n * Add comment above the violation:\n * // webpieces-disable no-any-unknown -- [your justification]\n * const x: any = ...;\n */\n\nimport type { ExecutorContext } from '@nx/devkit';\nimport { execSync } from 'child_process';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as ts from 'typescript';\n\nexport type NoAnyUnknownMode = 'OFF' | 'MODIFIED_CODE' | 'MODIFIED_FILES' | 'ALL';\n\nexport interface ValidateNoAnyUnknownOptions {\n mode?: NoAnyUnknownMode;\n}\n\nexport interface ExecutorResult {\n success: boolean;\n}\n\ninterface AnyUnknownViolation {\n file: string;\n line: number;\n column: number;\n keyword: 'any' | 'unknown';\n context: string;\n}\n\n/**\n * Get changed TypeScript files between base and head (or working tree if head not specified).\n */\n// webpieces-disable max-lines-new-methods -- Git command handling with untracked files requires multiple code paths\nfunction getChangedTypeScriptFiles(workspaceRoot: string, base: string, head?: string): string[] {\n try {\n const diffTarget = head ? `${base} ${head}` : base;\n const output = execSync(`git diff --name-only ${diffTarget} -- '*.ts' '*.tsx'`, {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n });\n const changedFiles = output\n .trim()\n .split('\\n')\n .filter((f) => f && !f.includes('.spec.ts') && !f.includes('.test.ts'));\n\n if (!head) {\n try {\n const untrackedOutput = execSync(`git ls-files --others --exclude-standard '*.ts' '*.tsx'`, {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n });\n const untrackedFiles = untrackedOutput\n .trim()\n .split('\\n')\n .filter((f) => f && !f.includes('.spec.ts') && !f.includes('.test.ts'));\n const allFiles = new Set([...changedFiles, ...untrackedFiles]);\n return Array.from(allFiles);\n } catch {\n return changedFiles;\n }\n }\n\n return changedFiles;\n } catch {\n return [];\n }\n}\n\n/**\n * Get all TypeScript files in the workspace using git ls-files (excluding tests).\n */\nfunction getAllTypeScriptFiles(workspaceRoot: string): string[] {\n try {\n const output = execSync(`git ls-files '*.ts' '*.tsx'`, {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n });\n return output\n .trim()\n .split('\\n')\n .filter((f) => f && !f.includes('.spec.ts') && !f.includes('.test.ts'));\n } catch {\n return [];\n }\n}\n\n/**\n * Get the diff content for a specific file.\n */\nfunction getFileDiff(workspaceRoot: string, file: string, base: string, head?: string): string {\n try {\n const diffTarget = head ? `${base} ${head}` : base;\n const diff = execSync(`git diff ${diffTarget} -- \"${file}\"`, {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n });\n\n if (!diff && !head) {\n const fullPath = path.join(workspaceRoot, file);\n if (fs.existsSync(fullPath)) {\n const isUntracked = execSync(`git ls-files --others --exclude-standard \"${file}\"`, {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n }).trim();\n\n if (isUntracked) {\n const content = fs.readFileSync(fullPath, 'utf-8');\n const lines = content.split('\\n');\n return lines.map((line) => `+${line}`).join('\\n');\n }\n }\n }\n\n return diff;\n } catch {\n return '';\n }\n}\n\n/**\n * Parse diff to extract changed line numbers (additions only - lines starting with +).\n */\nfunction getChangedLineNumbers(diffContent: string): Set<number> {\n const changedLines = new Set<number>();\n const lines = diffContent.split('\\n');\n let currentLine = 0;\n\n for (const line of lines) {\n const hunkMatch = line.match(/^@@ -\\d+(?:,\\d+)? \\+(\\d+)(?:,\\d+)? @@/);\n if (hunkMatch) {\n currentLine = parseInt(hunkMatch[1], 10);\n continue;\n }\n\n if (line.startsWith('+') && !line.startsWith('+++')) {\n changedLines.add(currentLine);\n currentLine++;\n } else if (line.startsWith('-') && !line.startsWith('---')) {\n // Deletions don't increment line number\n } else {\n currentLine++;\n }\n }\n\n return changedLines;\n}\n\n/**\n * Check if a line contains a webpieces-disable comment for no-any-unknown.\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 (line.includes('webpieces-disable') && line.includes('no-any-unknown')) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Get a description of the context where the any/unknown keyword appears.\n */\n// webpieces-disable max-lines-new-methods -- Context detection requires checking many AST node types\nfunction getViolationContext(node: ts.Node, sourceFile: ts.SourceFile): string {\n try {\n let current: ts.Node = node;\n while (current.parent) {\n const parent = current.parent;\n if (ts.isParameter(parent)) {\n return 'parameter type';\n }\n if (ts.isFunctionDeclaration(parent) || ts.isMethodDeclaration(parent) || ts.isArrowFunction(parent)) {\n if (parent.type === current) {\n return 'return type';\n }\n }\n if (ts.isVariableDeclaration(parent)) {\n return 'variable type';\n }\n if (ts.isPropertyDeclaration(parent) || ts.isPropertySignature(parent)) {\n return 'property type';\n }\n if (ts.isAsExpression(parent)) {\n return 'type assertion';\n }\n if (ts.isTypeAliasDeclaration(parent)) {\n return 'type alias';\n }\n if (ts.isTypeReferenceNode(parent)) {\n return 'generic argument';\n }\n if (ts.isArrayTypeNode(parent)) {\n return 'array element type';\n }\n if (ts.isUnionTypeNode(parent) || ts.isIntersectionTypeNode(parent)) {\n return 'union/intersection type';\n }\n current = parent;\n }\n return 'type position';\n } catch {\n return 'type position';\n }\n}\n\ninterface AnyUnknownInfo {\n line: number;\n column: number;\n keyword: 'any' | 'unknown';\n context: string;\n hasDisableComment: boolean;\n}\n\n/**\n * Find all `any` and `unknown` keywords in a file using AST.\n */\n// webpieces-disable max-lines-new-methods -- AST traversal with nested visitor function for keyword detection\nfunction findAnyUnknownInFile(filePath: string, workspaceRoot: string): AnyUnknownInfo[] {\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 violations: AnyUnknownInfo[] = [];\n\n // webpieces-disable max-lines-new-methods -- AST visitor needs to handle both any and unknown keywords with full context detection\n function visit(node: ts.Node): void {\n try {\n // Detect `any` keyword\n if (node.kind === ts.SyntaxKind.AnyKeyword) {\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 violations.push({\n line,\n column,\n keyword: 'any',\n context,\n hasDisableComment: disabled,\n });\n }\n }\n\n // Detect `unknown` keyword\n if (node.kind === ts.SyntaxKind.UnknownKeyword) {\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 violations.push({\n line,\n column,\n keyword: 'unknown',\n context,\n hasDisableComment: disabled,\n });\n }\n }\n } catch {\n // Skip nodes that cause errors during analysis\n }\n\n ts.forEachChild(node, visit);\n }\n\n visit(sourceFile);\n return violations;\n}\n\n/**\n * MODIFIED_CODE mode: Flag violations on changed lines in diff hunks.\n * This is LINE-BASED detection.\n */\n// webpieces-disable max-lines-new-methods -- File iteration with diff parsing and line filtering\nfunction findViolationsForModifiedCode(\n workspaceRoot: string,\n changedFiles: string[],\n base: string,\n head?: string\n): AnyUnknownViolation[] {\n const violations: AnyUnknownViolation[] = [];\n\n for (const file of changedFiles) {\n const diff = getFileDiff(workspaceRoot, file, base, head);\n const changedLines = getChangedLineNumbers(diff);\n\n if (changedLines.size === 0) continue;\n\n const allViolations = findAnyUnknownInFile(file, workspaceRoot);\n\n for (const v of allViolations) {\n if (v.hasDisableComment) continue;\n // LINE-BASED: Only include if the violation is on a changed line\n if (!changedLines.has(v.line)) continue;\n\n violations.push({\n file,\n line: v.line,\n column: v.column,\n keyword: v.keyword,\n context: v.context,\n });\n }\n }\n\n return violations;\n}\n\n/**\n * MODIFIED_FILES mode: Flag ALL violations in files that were modified.\n */\nfunction findViolationsForModifiedFiles(workspaceRoot: string, changedFiles: string[]): AnyUnknownViolation[] {\n const violations: AnyUnknownViolation[] = [];\n\n for (const file of changedFiles) {\n const allViolations = findAnyUnknownInFile(file, workspaceRoot);\n\n for (const v of allViolations) {\n if (v.hasDisableComment) continue;\n\n violations.push({\n file,\n line: v.line,\n column: v.column,\n keyword: v.keyword,\n context: v.context,\n });\n }\n }\n\n return violations;\n}\n\n/**\n * ALL mode: Flag violations in all TypeScript files.\n */\nfunction findViolationsForAll(workspaceRoot: string): AnyUnknownViolation[] {\n const allFiles = getAllTypeScriptFiles(workspaceRoot);\n return findViolationsForModifiedFiles(workspaceRoot, allFiles);\n}\n\n/**\n * Auto-detect the base branch by finding the merge-base with origin/main.\n */\nfunction detectBase(workspaceRoot: string): string | null {\n try {\n const mergeBase = execSync('git merge-base HEAD origin/main', {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n stdio: ['pipe', 'pipe', 'pipe'],\n }).trim();\n\n if (mergeBase) {\n return mergeBase;\n }\n } catch {\n try {\n const mergeBase = execSync('git merge-base HEAD main', {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n stdio: ['pipe', 'pipe', 'pipe'],\n }).trim();\n\n if (mergeBase) {\n return mergeBase;\n }\n } catch {\n // Ignore\n }\n }\n return null;\n}\n\n/**\n * Report violations to console.\n */\nfunction reportViolations(violations: AnyUnknownViolation[], mode: NoAnyUnknownMode): void {\n console.error('');\n console.error('ā `any` and `unknown` keywords found! Use specific types instead.');\n console.error('');\n console.error('š Avoiding any/unknown improves type safety:');\n console.error('');\n console.error(' BAD: const data: any = fetchData();');\n console.error(' GOOD: const data: UserData = fetchData();');\n console.error('');\n console.error(' BAD: function process(input: unknown): unknown { }');\n console.error(' GOOD: function process(input: ValidInput): ValidOutput { }');\n console.error('');\n\n for (const v of violations) {\n console.error(` ā ${v.file}:${v.line}:${v.column}`);\n console.error(` \\`${v.keyword}\\` keyword in ${v.context}`);\n }\n console.error('');\n\n console.error(' To fix: Replace with specific types or interfaces');\n console.error('');\n console.error(' Escape hatch (use sparingly):');\n console.error(' // webpieces-disable no-any-unknown -- [your reason]');\n console.error('');\n console.error(` Current mode: ${mode}`);\n console.error('');\n}\n\nexport default async function runExecutor(\n options: ValidateNoAnyUnknownOptions,\n context: ExecutorContext\n): Promise<ExecutorResult> {\n const workspaceRoot = context.root;\n const mode: NoAnyUnknownMode = options.mode ?? 'OFF';\n\n if (mode === 'OFF') {\n console.log('\\nāļø Skipping no-any-unknown validation (mode: OFF)');\n console.log('');\n return { success: true };\n }\n\n console.log('\\nš Validating No Any/Unknown\\n');\n console.log(` Mode: ${mode}`);\n\n let violations: AnyUnknownViolation[] = [];\n\n if (mode === 'ALL') {\n console.log(' Scope: All tracked TypeScript files');\n console.log('');\n violations = findViolationsForAll(workspaceRoot);\n } else {\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-any-unknown 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 = getChangedTypeScriptFiles(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 if (mode === 'MODIFIED_CODE') {\n violations = findViolationsForModifiedCode(workspaceRoot, changedFiles, base, head);\n } else if (mode === 'MODIFIED_FILES') {\n violations = findViolationsForModifiedFiles(workspaceRoot, changedFiles);\n }\n }\n\n if (violations.length === 0) {\n console.log('ā
No any/unknown keywords found');\n return { success: true };\n }\n\n reportViolations(violations, mode);\n\n return { success: false };\n}\n"]}
|
|
@@ -0,0 +1,513 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validate No Any Unknown Executor
|
|
3
|
+
*
|
|
4
|
+
* Validates that `any` and `unknown` TypeScript keywords are not used.
|
|
5
|
+
* Uses LINE-BASED detection (not method-based) for git diff filtering.
|
|
6
|
+
*
|
|
7
|
+
* ============================================================================
|
|
8
|
+
* VIOLATIONS (BAD) - These patterns are flagged:
|
|
9
|
+
* ============================================================================
|
|
10
|
+
*
|
|
11
|
+
* - const x: any = ...
|
|
12
|
+
* - function foo(arg: any): any { }
|
|
13
|
+
* - const data = response as any;
|
|
14
|
+
* - type T = any;
|
|
15
|
+
* - const x: unknown = ...
|
|
16
|
+
* - function foo(arg: unknown): unknown { }
|
|
17
|
+
*
|
|
18
|
+
* ============================================================================
|
|
19
|
+
* MODES (LINE-BASED)
|
|
20
|
+
* ============================================================================
|
|
21
|
+
* - OFF: Skip validation entirely
|
|
22
|
+
* - MODIFIED_CODE: Flag any/unknown on changed lines (lines in diff hunks)
|
|
23
|
+
* - MODIFIED_FILES: Flag ALL any/unknown in files that were modified
|
|
24
|
+
* - ALL: Flag everywhere in all TypeScript files
|
|
25
|
+
*
|
|
26
|
+
* ============================================================================
|
|
27
|
+
* ESCAPE HATCH
|
|
28
|
+
* ============================================================================
|
|
29
|
+
* Add comment above the violation:
|
|
30
|
+
* // webpieces-disable no-any-unknown -- [your justification]
|
|
31
|
+
* const x: any = ...;
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
import type { ExecutorContext } from '@nx/devkit';
|
|
35
|
+
import { execSync } from 'child_process';
|
|
36
|
+
import * as fs from 'fs';
|
|
37
|
+
import * as path from 'path';
|
|
38
|
+
import * as ts from 'typescript';
|
|
39
|
+
|
|
40
|
+
export type NoAnyUnknownMode = 'OFF' | 'MODIFIED_CODE' | 'MODIFIED_FILES' | 'ALL';
|
|
41
|
+
|
|
42
|
+
export interface ValidateNoAnyUnknownOptions {
|
|
43
|
+
mode?: NoAnyUnknownMode;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface ExecutorResult {
|
|
47
|
+
success: boolean;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
interface AnyUnknownViolation {
|
|
51
|
+
file: string;
|
|
52
|
+
line: number;
|
|
53
|
+
column: number;
|
|
54
|
+
keyword: 'any' | 'unknown';
|
|
55
|
+
context: string;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Get changed TypeScript files between base and head (or working tree if head not specified).
|
|
60
|
+
*/
|
|
61
|
+
// webpieces-disable max-lines-new-methods -- Git command handling with untracked files requires multiple code paths
|
|
62
|
+
function getChangedTypeScriptFiles(workspaceRoot: string, base: string, head?: string): string[] {
|
|
63
|
+
try {
|
|
64
|
+
const diffTarget = head ? `${base} ${head}` : base;
|
|
65
|
+
const output = execSync(`git diff --name-only ${diffTarget} -- '*.ts' '*.tsx'`, {
|
|
66
|
+
cwd: workspaceRoot,
|
|
67
|
+
encoding: 'utf-8',
|
|
68
|
+
});
|
|
69
|
+
const changedFiles = output
|
|
70
|
+
.trim()
|
|
71
|
+
.split('\n')
|
|
72
|
+
.filter((f) => f && !f.includes('.spec.ts') && !f.includes('.test.ts'));
|
|
73
|
+
|
|
74
|
+
if (!head) {
|
|
75
|
+
try {
|
|
76
|
+
const untrackedOutput = execSync(`git ls-files --others --exclude-standard '*.ts' '*.tsx'`, {
|
|
77
|
+
cwd: workspaceRoot,
|
|
78
|
+
encoding: 'utf-8',
|
|
79
|
+
});
|
|
80
|
+
const untrackedFiles = untrackedOutput
|
|
81
|
+
.trim()
|
|
82
|
+
.split('\n')
|
|
83
|
+
.filter((f) => f && !f.includes('.spec.ts') && !f.includes('.test.ts'));
|
|
84
|
+
const allFiles = new Set([...changedFiles, ...untrackedFiles]);
|
|
85
|
+
return Array.from(allFiles);
|
|
86
|
+
} catch {
|
|
87
|
+
return changedFiles;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return changedFiles;
|
|
92
|
+
} catch {
|
|
93
|
+
return [];
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Get all TypeScript files in the workspace using git ls-files (excluding tests).
|
|
99
|
+
*/
|
|
100
|
+
function getAllTypeScriptFiles(workspaceRoot: string): string[] {
|
|
101
|
+
try {
|
|
102
|
+
const output = execSync(`git ls-files '*.ts' '*.tsx'`, {
|
|
103
|
+
cwd: workspaceRoot,
|
|
104
|
+
encoding: 'utf-8',
|
|
105
|
+
});
|
|
106
|
+
return output
|
|
107
|
+
.trim()
|
|
108
|
+
.split('\n')
|
|
109
|
+
.filter((f) => f && !f.includes('.spec.ts') && !f.includes('.test.ts'));
|
|
110
|
+
} catch {
|
|
111
|
+
return [];
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Get the diff content for a specific file.
|
|
117
|
+
*/
|
|
118
|
+
function getFileDiff(workspaceRoot: string, file: string, base: string, head?: string): string {
|
|
119
|
+
try {
|
|
120
|
+
const diffTarget = head ? `${base} ${head}` : base;
|
|
121
|
+
const diff = execSync(`git diff ${diffTarget} -- "${file}"`, {
|
|
122
|
+
cwd: workspaceRoot,
|
|
123
|
+
encoding: 'utf-8',
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
if (!diff && !head) {
|
|
127
|
+
const fullPath = path.join(workspaceRoot, file);
|
|
128
|
+
if (fs.existsSync(fullPath)) {
|
|
129
|
+
const isUntracked = execSync(`git ls-files --others --exclude-standard "${file}"`, {
|
|
130
|
+
cwd: workspaceRoot,
|
|
131
|
+
encoding: 'utf-8',
|
|
132
|
+
}).trim();
|
|
133
|
+
|
|
134
|
+
if (isUntracked) {
|
|
135
|
+
const content = fs.readFileSync(fullPath, 'utf-8');
|
|
136
|
+
const lines = content.split('\n');
|
|
137
|
+
return lines.map((line) => `+${line}`).join('\n');
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return diff;
|
|
143
|
+
} catch {
|
|
144
|
+
return '';
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Parse diff to extract changed line numbers (additions only - lines starting with +).
|
|
150
|
+
*/
|
|
151
|
+
function getChangedLineNumbers(diffContent: string): Set<number> {
|
|
152
|
+
const changedLines = new Set<number>();
|
|
153
|
+
const lines = diffContent.split('\n');
|
|
154
|
+
let currentLine = 0;
|
|
155
|
+
|
|
156
|
+
for (const line of lines) {
|
|
157
|
+
const hunkMatch = line.match(/^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/);
|
|
158
|
+
if (hunkMatch) {
|
|
159
|
+
currentLine = parseInt(hunkMatch[1], 10);
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (line.startsWith('+') && !line.startsWith('+++')) {
|
|
164
|
+
changedLines.add(currentLine);
|
|
165
|
+
currentLine++;
|
|
166
|
+
} else if (line.startsWith('-') && !line.startsWith('---')) {
|
|
167
|
+
// Deletions don't increment line number
|
|
168
|
+
} else {
|
|
169
|
+
currentLine++;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return changedLines;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Check if a line contains a webpieces-disable comment for no-any-unknown.
|
|
178
|
+
*/
|
|
179
|
+
function hasDisableComment(lines: string[], lineNumber: number): boolean {
|
|
180
|
+
const startCheck = Math.max(0, lineNumber - 5);
|
|
181
|
+
for (let i = lineNumber - 2; i >= startCheck; i--) {
|
|
182
|
+
const line = lines[i]?.trim() ?? '';
|
|
183
|
+
if (line.startsWith('function ') || line.startsWith('class ') || line.endsWith('}')) {
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
if (line.includes('webpieces-disable') && line.includes('no-any-unknown')) {
|
|
187
|
+
return true;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Get a description of the context where the any/unknown keyword appears.
|
|
195
|
+
*/
|
|
196
|
+
// webpieces-disable max-lines-new-methods -- Context detection requires checking many AST node types
|
|
197
|
+
function getViolationContext(node: ts.Node, sourceFile: ts.SourceFile): string {
|
|
198
|
+
try {
|
|
199
|
+
let current: ts.Node = node;
|
|
200
|
+
while (current.parent) {
|
|
201
|
+
const parent = current.parent;
|
|
202
|
+
if (ts.isParameter(parent)) {
|
|
203
|
+
return 'parameter type';
|
|
204
|
+
}
|
|
205
|
+
if (ts.isFunctionDeclaration(parent) || ts.isMethodDeclaration(parent) || ts.isArrowFunction(parent)) {
|
|
206
|
+
if (parent.type === current) {
|
|
207
|
+
return 'return type';
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
if (ts.isVariableDeclaration(parent)) {
|
|
211
|
+
return 'variable type';
|
|
212
|
+
}
|
|
213
|
+
if (ts.isPropertyDeclaration(parent) || ts.isPropertySignature(parent)) {
|
|
214
|
+
return 'property type';
|
|
215
|
+
}
|
|
216
|
+
if (ts.isAsExpression(parent)) {
|
|
217
|
+
return 'type assertion';
|
|
218
|
+
}
|
|
219
|
+
if (ts.isTypeAliasDeclaration(parent)) {
|
|
220
|
+
return 'type alias';
|
|
221
|
+
}
|
|
222
|
+
if (ts.isTypeReferenceNode(parent)) {
|
|
223
|
+
return 'generic argument';
|
|
224
|
+
}
|
|
225
|
+
if (ts.isArrayTypeNode(parent)) {
|
|
226
|
+
return 'array element type';
|
|
227
|
+
}
|
|
228
|
+
if (ts.isUnionTypeNode(parent) || ts.isIntersectionTypeNode(parent)) {
|
|
229
|
+
return 'union/intersection type';
|
|
230
|
+
}
|
|
231
|
+
current = parent;
|
|
232
|
+
}
|
|
233
|
+
return 'type position';
|
|
234
|
+
} catch {
|
|
235
|
+
return 'type position';
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
interface AnyUnknownInfo {
|
|
240
|
+
line: number;
|
|
241
|
+
column: number;
|
|
242
|
+
keyword: 'any' | 'unknown';
|
|
243
|
+
context: string;
|
|
244
|
+
hasDisableComment: boolean;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Find all `any` and `unknown` keywords in a file using AST.
|
|
249
|
+
*/
|
|
250
|
+
// webpieces-disable max-lines-new-methods -- AST traversal with nested visitor function for keyword detection
|
|
251
|
+
function findAnyUnknownInFile(filePath: string, workspaceRoot: string): AnyUnknownInfo[] {
|
|
252
|
+
const fullPath = path.join(workspaceRoot, filePath);
|
|
253
|
+
if (!fs.existsSync(fullPath)) return [];
|
|
254
|
+
|
|
255
|
+
const content = fs.readFileSync(fullPath, 'utf-8');
|
|
256
|
+
const fileLines = content.split('\n');
|
|
257
|
+
const sourceFile = ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true);
|
|
258
|
+
|
|
259
|
+
const violations: AnyUnknownInfo[] = [];
|
|
260
|
+
|
|
261
|
+
// webpieces-disable max-lines-new-methods -- AST visitor needs to handle both any and unknown keywords with full context detection
|
|
262
|
+
function visit(node: ts.Node): void {
|
|
263
|
+
try {
|
|
264
|
+
// Detect `any` keyword
|
|
265
|
+
if (node.kind === ts.SyntaxKind.AnyKeyword) {
|
|
266
|
+
const startPos = node.getStart(sourceFile);
|
|
267
|
+
if (startPos >= 0) {
|
|
268
|
+
const pos = sourceFile.getLineAndCharacterOfPosition(startPos);
|
|
269
|
+
const line = pos.line + 1;
|
|
270
|
+
const column = pos.character + 1;
|
|
271
|
+
const context = getViolationContext(node, sourceFile);
|
|
272
|
+
const disabled = hasDisableComment(fileLines, line);
|
|
273
|
+
|
|
274
|
+
violations.push({
|
|
275
|
+
line,
|
|
276
|
+
column,
|
|
277
|
+
keyword: 'any',
|
|
278
|
+
context,
|
|
279
|
+
hasDisableComment: disabled,
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// Detect `unknown` keyword
|
|
285
|
+
if (node.kind === ts.SyntaxKind.UnknownKeyword) {
|
|
286
|
+
const startPos = node.getStart(sourceFile);
|
|
287
|
+
if (startPos >= 0) {
|
|
288
|
+
const pos = sourceFile.getLineAndCharacterOfPosition(startPos);
|
|
289
|
+
const line = pos.line + 1;
|
|
290
|
+
const column = pos.character + 1;
|
|
291
|
+
const context = getViolationContext(node, sourceFile);
|
|
292
|
+
const disabled = hasDisableComment(fileLines, line);
|
|
293
|
+
|
|
294
|
+
violations.push({
|
|
295
|
+
line,
|
|
296
|
+
column,
|
|
297
|
+
keyword: 'unknown',
|
|
298
|
+
context,
|
|
299
|
+
hasDisableComment: disabled,
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
} catch {
|
|
304
|
+
// Skip nodes that cause errors during analysis
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
ts.forEachChild(node, visit);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
visit(sourceFile);
|
|
311
|
+
return violations;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* MODIFIED_CODE mode: Flag violations on changed lines in diff hunks.
|
|
316
|
+
* This is LINE-BASED detection.
|
|
317
|
+
*/
|
|
318
|
+
// webpieces-disable max-lines-new-methods -- File iteration with diff parsing and line filtering
|
|
319
|
+
function findViolationsForModifiedCode(
|
|
320
|
+
workspaceRoot: string,
|
|
321
|
+
changedFiles: string[],
|
|
322
|
+
base: string,
|
|
323
|
+
head?: string
|
|
324
|
+
): AnyUnknownViolation[] {
|
|
325
|
+
const violations: AnyUnknownViolation[] = [];
|
|
326
|
+
|
|
327
|
+
for (const file of changedFiles) {
|
|
328
|
+
const diff = getFileDiff(workspaceRoot, file, base, head);
|
|
329
|
+
const changedLines = getChangedLineNumbers(diff);
|
|
330
|
+
|
|
331
|
+
if (changedLines.size === 0) continue;
|
|
332
|
+
|
|
333
|
+
const allViolations = findAnyUnknownInFile(file, workspaceRoot);
|
|
334
|
+
|
|
335
|
+
for (const v of allViolations) {
|
|
336
|
+
if (v.hasDisableComment) continue;
|
|
337
|
+
// LINE-BASED: Only include if the violation is on a changed line
|
|
338
|
+
if (!changedLines.has(v.line)) continue;
|
|
339
|
+
|
|
340
|
+
violations.push({
|
|
341
|
+
file,
|
|
342
|
+
line: v.line,
|
|
343
|
+
column: v.column,
|
|
344
|
+
keyword: v.keyword,
|
|
345
|
+
context: v.context,
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
return violations;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* MODIFIED_FILES mode: Flag ALL violations in files that were modified.
|
|
355
|
+
*/
|
|
356
|
+
function findViolationsForModifiedFiles(workspaceRoot: string, changedFiles: string[]): AnyUnknownViolation[] {
|
|
357
|
+
const violations: AnyUnknownViolation[] = [];
|
|
358
|
+
|
|
359
|
+
for (const file of changedFiles) {
|
|
360
|
+
const allViolations = findAnyUnknownInFile(file, workspaceRoot);
|
|
361
|
+
|
|
362
|
+
for (const v of allViolations) {
|
|
363
|
+
if (v.hasDisableComment) continue;
|
|
364
|
+
|
|
365
|
+
violations.push({
|
|
366
|
+
file,
|
|
367
|
+
line: v.line,
|
|
368
|
+
column: v.column,
|
|
369
|
+
keyword: v.keyword,
|
|
370
|
+
context: v.context,
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
return violations;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* ALL mode: Flag violations in all TypeScript files.
|
|
380
|
+
*/
|
|
381
|
+
function findViolationsForAll(workspaceRoot: string): AnyUnknownViolation[] {
|
|
382
|
+
const allFiles = getAllTypeScriptFiles(workspaceRoot);
|
|
383
|
+
return findViolationsForModifiedFiles(workspaceRoot, allFiles);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Auto-detect the base branch by finding the merge-base with origin/main.
|
|
388
|
+
*/
|
|
389
|
+
function detectBase(workspaceRoot: string): string | null {
|
|
390
|
+
try {
|
|
391
|
+
const mergeBase = execSync('git merge-base HEAD origin/main', {
|
|
392
|
+
cwd: workspaceRoot,
|
|
393
|
+
encoding: 'utf-8',
|
|
394
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
395
|
+
}).trim();
|
|
396
|
+
|
|
397
|
+
if (mergeBase) {
|
|
398
|
+
return mergeBase;
|
|
399
|
+
}
|
|
400
|
+
} catch {
|
|
401
|
+
try {
|
|
402
|
+
const mergeBase = execSync('git merge-base HEAD main', {
|
|
403
|
+
cwd: workspaceRoot,
|
|
404
|
+
encoding: 'utf-8',
|
|
405
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
406
|
+
}).trim();
|
|
407
|
+
|
|
408
|
+
if (mergeBase) {
|
|
409
|
+
return mergeBase;
|
|
410
|
+
}
|
|
411
|
+
} catch {
|
|
412
|
+
// Ignore
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
return null;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* Report violations to console.
|
|
420
|
+
*/
|
|
421
|
+
function reportViolations(violations: AnyUnknownViolation[], mode: NoAnyUnknownMode): void {
|
|
422
|
+
console.error('');
|
|
423
|
+
console.error('ā `any` and `unknown` keywords found! Use specific types instead.');
|
|
424
|
+
console.error('');
|
|
425
|
+
console.error('š Avoiding any/unknown improves type safety:');
|
|
426
|
+
console.error('');
|
|
427
|
+
console.error(' BAD: const data: any = fetchData();');
|
|
428
|
+
console.error(' GOOD: const data: UserData = fetchData();');
|
|
429
|
+
console.error('');
|
|
430
|
+
console.error(' BAD: function process(input: unknown): unknown { }');
|
|
431
|
+
console.error(' GOOD: function process(input: ValidInput): ValidOutput { }');
|
|
432
|
+
console.error('');
|
|
433
|
+
|
|
434
|
+
for (const v of violations) {
|
|
435
|
+
console.error(` ā ${v.file}:${v.line}:${v.column}`);
|
|
436
|
+
console.error(` \`${v.keyword}\` keyword in ${v.context}`);
|
|
437
|
+
}
|
|
438
|
+
console.error('');
|
|
439
|
+
|
|
440
|
+
console.error(' To fix: Replace with specific types or interfaces');
|
|
441
|
+
console.error('');
|
|
442
|
+
console.error(' Escape hatch (use sparingly):');
|
|
443
|
+
console.error(' // webpieces-disable no-any-unknown -- [your reason]');
|
|
444
|
+
console.error('');
|
|
445
|
+
console.error(` Current mode: ${mode}`);
|
|
446
|
+
console.error('');
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
export default async function runExecutor(
|
|
450
|
+
options: ValidateNoAnyUnknownOptions,
|
|
451
|
+
context: ExecutorContext
|
|
452
|
+
): Promise<ExecutorResult> {
|
|
453
|
+
const workspaceRoot = context.root;
|
|
454
|
+
const mode: NoAnyUnknownMode = options.mode ?? 'OFF';
|
|
455
|
+
|
|
456
|
+
if (mode === 'OFF') {
|
|
457
|
+
console.log('\nāļø Skipping no-any-unknown validation (mode: OFF)');
|
|
458
|
+
console.log('');
|
|
459
|
+
return { success: true };
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
console.log('\nš Validating No Any/Unknown\n');
|
|
463
|
+
console.log(` Mode: ${mode}`);
|
|
464
|
+
|
|
465
|
+
let violations: AnyUnknownViolation[] = [];
|
|
466
|
+
|
|
467
|
+
if (mode === 'ALL') {
|
|
468
|
+
console.log(' Scope: All tracked TypeScript files');
|
|
469
|
+
console.log('');
|
|
470
|
+
violations = findViolationsForAll(workspaceRoot);
|
|
471
|
+
} else {
|
|
472
|
+
let base = process.env['NX_BASE'];
|
|
473
|
+
const head = process.env['NX_HEAD'];
|
|
474
|
+
|
|
475
|
+
if (!base) {
|
|
476
|
+
base = detectBase(workspaceRoot) ?? undefined;
|
|
477
|
+
|
|
478
|
+
if (!base) {
|
|
479
|
+
console.log('\nāļø Skipping no-any-unknown validation (could not detect base branch)');
|
|
480
|
+
console.log('');
|
|
481
|
+
return { success: true };
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
console.log(` Base: ${base}`);
|
|
486
|
+
console.log(` Head: ${head ?? 'working tree (includes uncommitted changes)'}`);
|
|
487
|
+
console.log('');
|
|
488
|
+
|
|
489
|
+
const changedFiles = getChangedTypeScriptFiles(workspaceRoot, base, head);
|
|
490
|
+
|
|
491
|
+
if (changedFiles.length === 0) {
|
|
492
|
+
console.log('ā
No TypeScript files changed');
|
|
493
|
+
return { success: true };
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
console.log(`š Checking ${changedFiles.length} changed file(s)...`);
|
|
497
|
+
|
|
498
|
+
if (mode === 'MODIFIED_CODE') {
|
|
499
|
+
violations = findViolationsForModifiedCode(workspaceRoot, changedFiles, base, head);
|
|
500
|
+
} else if (mode === 'MODIFIED_FILES') {
|
|
501
|
+
violations = findViolationsForModifiedFiles(workspaceRoot, changedFiles);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
if (violations.length === 0) {
|
|
506
|
+
console.log('ā
No any/unknown keywords found');
|
|
507
|
+
return { success: true };
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
reportViolations(violations, mode);
|
|
511
|
+
|
|
512
|
+
return { success: false };
|
|
513
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"title": "Validate No Any Unknown Executor",
|
|
4
|
+
"description": "Validates that `any` and `unknown` TypeScript keywords are not used. Uses LINE-BASED detection for git diff filtering.",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"mode": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"enum": ["OFF", "MODIFIED_CODE", "MODIFIED_FILES", "ALL"],
|
|
10
|
+
"description": "OFF: skip validation. MODIFIED_CODE: only changed lines in diff. MODIFIED_FILES: all in modified files. ALL: everywhere. Disallows `any` and `unknown` TypeScript keywords.",
|
|
11
|
+
"default": "OFF"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"required": []
|
|
15
|
+
}
|