@webpieces/dev-config 0.2.74 → 0.2.76

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.
@@ -1,6 +1,7 @@
1
1
  import { ExecutorContext } from '@nx/devkit';
2
2
  import { ReturnTypeMode } from '../validate-return-types/executor';
3
3
  import { NoInlineTypesMode } from '../validate-no-inline-types/executor';
4
+ import { NoAnyUnknownMode } from '../validate-no-any-unknown/executor';
4
5
  export type ValidationMode = 'STRICT' | 'NORMAL' | 'OFF';
5
6
  export interface ValidateCodeOptions {
6
7
  mode?: ValidationMode;
@@ -10,6 +11,7 @@ export interface ValidateCodeOptions {
10
11
  modifiedFilesMaxLines?: number;
11
12
  requireReturnTypeMode?: ReturnTypeMode;
12
13
  noInlineTypeLiteralsMode?: NoInlineTypesMode;
14
+ noAnyUnknownMode?: NoAnyUnknownMode;
13
15
  }
14
16
  export interface ExecutorResult {
15
17
  success: boolean;
@@ -7,6 +7,7 @@ const executor_2 = tslib_1.__importDefault(require("../validate-modified-methods
7
7
  const executor_3 = tslib_1.__importDefault(require("../validate-modified-files/executor"));
8
8
  const executor_4 = tslib_1.__importDefault(require("../validate-return-types/executor"));
9
9
  const executor_5 = tslib_1.__importDefault(require("../validate-no-inline-types/executor"));
10
+ const executor_6 = tslib_1.__importDefault(require("../validate-no-any-unknown/executor"));
10
11
  async function runExecutor(options, context) {
11
12
  const mode = options.mode ?? 'NORMAL';
12
13
  if (mode === 'OFF') {
@@ -15,6 +16,7 @@ async function runExecutor(options, context) {
15
16
  }
16
17
  const returnTypeMode = options.requireReturnTypeMode ?? 'OFF';
17
18
  const noInlineTypesMode = options.noInlineTypeLiteralsMode ?? 'OFF';
19
+ const noAnyUnknownMode = options.noAnyUnknownMode ?? 'OFF';
18
20
  console.log('\nšŸ“ Running Code Validations\n');
19
21
  console.log(` Validation mode: ${mode}${mode === 'STRICT' ? ' (disable comments ignored for modified code)' : ''}`);
20
22
  console.log(` New methods max: ${options.newMethodsMaxLines ?? 30} lines (soft limit)`);
@@ -25,6 +27,7 @@ async function runExecutor(options, context) {
25
27
  console.log(` Modified files max: ${options.modifiedFilesMaxLines ?? 900} lines`);
26
28
  console.log(` Require return types: ${returnTypeMode}`);
27
29
  console.log(` No inline type literals: ${noInlineTypesMode}`);
30
+ console.log(` No any/unknown: ${noAnyUnknownMode}`);
28
31
  console.log('');
29
32
  // Run all three validators sequentially to avoid interleaved output
30
33
  const newMethodsResult = await (0, executor_1.default)({ max: options.newMethodsMaxLines ?? 30, strictMax: options.strictNewMethodMaxLines, mode }, context);
@@ -32,11 +35,13 @@ async function runExecutor(options, context) {
32
35
  const modifiedFilesResult = await (0, executor_3.default)({ max: options.modifiedFilesMaxLines ?? 900, mode }, context);
33
36
  const returnTypesResult = await (0, executor_4.default)({ mode: returnTypeMode }, context);
34
37
  const noInlineTypesResult = await (0, executor_5.default)({ mode: noInlineTypesMode }, context);
38
+ const noAnyUnknownResult = await (0, executor_6.default)({ mode: noAnyUnknownMode }, context);
35
39
  const allSuccess = newMethodsResult.success &&
36
40
  modifiedMethodsResult.success &&
37
41
  modifiedFilesResult.success &&
38
42
  returnTypesResult.success &&
39
- noInlineTypesResult.success;
43
+ noInlineTypesResult.success &&
44
+ noAnyUnknownResult.success;
40
45
  if (allSuccess) {
41
46
  console.log('\nāœ… All code validations passed\n');
42
47
  }
@@ -1 +1 @@
1
- {"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/dev-config/architecture/executors/validate-code/executor.ts"],"names":[],"mappings":";;AAuBA,8BA4DC;;AAlFD,wFAAqE;AACrE,6FAA+E;AAC/E,2FAA2E;AAC3E,yFAA2F;AAC3F,4FAAmG;AAkBpF,KAAK,UAAU,WAAW,CACrC,OAA4B,EAC5B,OAAwB;IAExB,MAAM,IAAI,GAAmB,OAAO,CAAC,IAAI,IAAI,QAAQ,CAAC;IAEtD,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;QACjB,OAAO,CAAC,GAA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AA,kBAA0B,EAC1D,EAAE,GAAG,EAAE,OAAO,CAAC,uBAAuB,IAAI,EAAE,EAAE,IAAI,EAAE,EACpD,OAAO,CACV,CAAC;IAEF,MAAM,mBAAmB,GAAG,MAAM,IAAA,kBAAwB,EACtD,EAAE,GAAG,EAAE,OAAO,CAAC,qBAAqB,IAAI,GAAG,EAAE,IAAI,EAAE,EACnD,OAAO,CACV,CAAC;IAEF,MAAM,iBAAiB,GAAG,MAAM,IAAA,kBAAsB,EAAC,EAAE,IAAI,EAAE,cAAc,EAAE,EAAE,OAAO,CAAC,CAAC;IAE1F,MAAM,mBAAmB,GAAG,MAAM,IAAA,kBAAwB,EAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,EAAE,OAAO,CAAC,CAAC;IAEjG,MAAM,UAAU,GACZ,gBAAgB,CAAC,OAAO;QACxB,qBAAqB,CAAC,OAAO;QAC7B,mBAAmB,CAAC,OAAO;QAC3B,iBAAiB,CAAC,OAAO;QACzB,mBAAmB,CAAC,OAAO,CAAC;IAEhC,IAAI,UAAU,EAAE,CAAC;QACb,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC;IACrD,CAAC;SAAM,CAAC;QACJ,OAAO,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;IACtD,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;AACnC,CAAC","sourcesContent":["import { ExecutorContext } from '@nx/devkit';\nimport runNewMethodsExecutor from '../validate-new-methods/executor';\nimport runModifiedMethodsExecutor from '../validate-modified-methods/executor';\nimport runModifiedFilesExecutor from '../validate-modified-files/executor';\nimport runReturnTypesExecutor, { ReturnTypeMode } from '../validate-return-types/executor';\nimport runNoInlineTypesExecutor, { NoInlineTypesMode } from '../validate-no-inline-types/executor';\n\nexport type ValidationMode = 'STRICT' | 'NORMAL' | 'OFF';\n\nexport interface ValidateCodeOptions {\n mode?: ValidationMode;\n newMethodsMaxLines?: number;\n strictNewMethodMaxLines?: number;\n modifiedMethodsMaxLines?: number;\n modifiedFilesMaxLines?: number;\n requireReturnTypeMode?: ReturnTypeMode;\n noInlineTypeLiteralsMode?: NoInlineTypesMode;\n}\n\nexport interface ExecutorResult {\n success: boolean;\n}\n\nexport default async function runExecutor(\n options: ValidateCodeOptions,\n context: ExecutorContext\n): Promise<ExecutorResult> {\n const mode: ValidationMode = options.mode ?? 'NORMAL';\n\n if (mode === 'OFF') {\n console.log('\\nā­ļø Skipping all code validations (validationMode: OFF)\\n');\n return { success: true };\n }\n\n const returnTypeMode: ReturnTypeMode = options.requireReturnTypeMode ?? 'OFF';\n const noInlineTypesMode: NoInlineTypesMode = options.noInlineTypeLiteralsMode ?? 'OFF';\n\n console.log('\\nšŸ“ Running Code Validations\\n');\n console.log(` Validation mode: ${mode}${mode === 'STRICT' ? ' (disable comments ignored for modified code)' : ''}`);\n console.log(` New methods max: ${options.newMethodsMaxLines ?? 30} lines (soft limit)`);\n if (options.strictNewMethodMaxLines) {\n console.log(` New methods max: ${options.strictNewMethodMaxLines} lines (hard limit, no escape)`);\n }\n console.log(` Modified methods max: ${options.modifiedMethodsMaxLines ?? 80} lines`);\n console.log(` Modified files max: ${options.modifiedFilesMaxLines ?? 900} lines`);\n console.log(` Require return types: ${returnTypeMode}`);\n console.log(` No inline type literals: ${noInlineTypesMode}`);\n console.log('');\n\n // Run all three validators sequentially to avoid interleaved output\n const newMethodsResult = await runNewMethodsExecutor(\n { max: options.newMethodsMaxLines ?? 30, strictMax: options.strictNewMethodMaxLines, mode },\n context\n );\n\n const modifiedMethodsResult = await runModifiedMethodsExecutor(\n { max: options.modifiedMethodsMaxLines ?? 80, mode },\n context\n );\n\n const modifiedFilesResult = await runModifiedFilesExecutor(\n { max: options.modifiedFilesMaxLines ?? 900, mode },\n context\n );\n\n const returnTypesResult = await runReturnTypesExecutor({ mode: returnTypeMode }, context);\n\n const noInlineTypesResult = await runNoInlineTypesExecutor({ mode: noInlineTypesMode }, context);\n\n const allSuccess =\n newMethodsResult.success &&\n modifiedMethodsResult.success &&\n modifiedFilesResult.success &&\n returnTypesResult.success &&\n noInlineTypesResult.success;\n\n if (allSuccess) {\n console.log('\\nāœ… All code validations passed\\n');\n } else {\n console.log('\\nāŒ Some code validations failed\\n');\n }\n\n return { success: allSuccess };\n}\n"]}
1
+ {"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/dev-config/architecture/executors/validate-code/executor.ts"],"names":[],"mappings":";;AAyBA,8BAiEC;;AAzFD,wFAAqE;AACrE,6FAA+E;AAC/E,2FAA2E;AAC3E,yFAA2F;AAC3F,4FAAmG;AACnG,2FAAgG;AAmBjF,KAAK,UAAU,WAAW,CACrC,OAA4B,EAC5B,OAAwB;IAExB,MAAM,IAAI,GAAmB,OAAO,CAAC,IAAI,IAAI,QAAQ,CAAC;IAEtD,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;QACjB,OAAO,CAAC,GAAG,CAAC,6DAA6D,CAAC,CAAC;QAC3E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC7B,CAAC;IAED,MAAM,cAAc,GAAmB,OAAO,CAAC,qBAAqB,IAAI,KAAK,CAAC;IAC9E,MAAM,iBAAiB,GAAsB,OAAO,CAAC,wBAAwB,IAAI,KAAK,CAAC;IACvF,MAAM,gBAAgB,GAAqB,OAAO,CAAC,gBAAgB,IAAI,KAAK,CAAC;IAE7E,OAAO,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC;IAC/C,OAAO,CAAC,GAAG,CAAC,uBAAuB,IAAI,GAAG,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,+CAA+C,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACtH,OAAO,CAAC,GAAG,CAAC,uBAAuB,OAAO,CAAC,kBAAkB,IAAI,EAAE,qBAAqB,CAAC,CAAC;IAC1F,IAAI,OAAO,CAAC,uBAAuB,EAAE,CAAC;QAClC,OAAO,CAAC,GAAG,CAAC,uBAAuB,OAAO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AAE,IAAI,EAAE,gBAAgB,EAAE,EAAE,OAAO,CAAC,CAAC;IAE9F,MAAM,UAAU,GACZ,gBAAgB,CAAC,OAAO;QACxB,qBAAqB,CAAC,OAAO;QAC7B,mBAAmB,CAAC,OAAO;QAC3B,iBAAiB,CAAC,OAAO;QACzB,mBAAmB,CAAC,OAAO;QAC3B,kBAAkB,CAAC,OAAO,CAAC;IAE/B,IAAI,UAAU,EAAE,CAAC;QACb,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC;IACrD,CAAC;SAAM,CAAC;QACJ,OAAO,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;IACtD,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;AACnC,CAAC","sourcesContent":["import { ExecutorContext } from '@nx/devkit';\nimport runNewMethodsExecutor from '../validate-new-methods/executor';\nimport runModifiedMethodsExecutor from '../validate-modified-methods/executor';\nimport runModifiedFilesExecutor from '../validate-modified-files/executor';\nimport runReturnTypesExecutor, { ReturnTypeMode } from '../validate-return-types/executor';\nimport runNoInlineTypesExecutor, { NoInlineTypesMode } from '../validate-no-inline-types/executor';\nimport runNoAnyUnknownExecutor, { NoAnyUnknownMode } from '../validate-no-any-unknown/executor';\n\nexport type ValidationMode = 'STRICT' | 'NORMAL' | 'OFF';\n\nexport interface ValidateCodeOptions {\n mode?: ValidationMode;\n newMethodsMaxLines?: number;\n strictNewMethodMaxLines?: number;\n modifiedMethodsMaxLines?: number;\n modifiedFilesMaxLines?: number;\n requireReturnTypeMode?: ReturnTypeMode;\n noInlineTypeLiteralsMode?: NoInlineTypesMode;\n noAnyUnknownMode?: NoAnyUnknownMode;\n}\n\nexport interface ExecutorResult {\n success: boolean;\n}\n\nexport default async function runExecutor(\n options: ValidateCodeOptions,\n context: ExecutorContext\n): Promise<ExecutorResult> {\n const mode: ValidationMode = options.mode ?? 'NORMAL';\n\n if (mode === 'OFF') {\n console.log('\\nā­ļø Skipping all code validations (validationMode: OFF)\\n');\n return { success: true };\n }\n\n const returnTypeMode: ReturnTypeMode = options.requireReturnTypeMode ?? 'OFF';\n const noInlineTypesMode: NoInlineTypesMode = options.noInlineTypeLiteralsMode ?? 'OFF';\n const noAnyUnknownMode: NoAnyUnknownMode = options.noAnyUnknownMode ?? 'OFF';\n\n console.log('\\nšŸ“ Running Code Validations\\n');\n console.log(` Validation mode: ${mode}${mode === 'STRICT' ? ' (disable comments ignored for modified code)' : ''}`);\n console.log(` New methods max: ${options.newMethodsMaxLines ?? 30} lines (soft limit)`);\n if (options.strictNewMethodMaxLines) {\n console.log(` New methods max: ${options.strictNewMethodMaxLines} lines (hard limit, no escape)`);\n }\n console.log(` Modified methods max: ${options.modifiedMethodsMaxLines ?? 80} lines`);\n console.log(` Modified files max: ${options.modifiedFilesMaxLines ?? 900} lines`);\n console.log(` Require return types: ${returnTypeMode}`);\n console.log(` No inline type literals: ${noInlineTypesMode}`);\n console.log(` No any/unknown: ${noAnyUnknownMode}`);\n console.log('');\n\n // Run all three validators sequentially to avoid interleaved output\n const newMethodsResult = await runNewMethodsExecutor(\n { max: options.newMethodsMaxLines ?? 30, strictMax: options.strictNewMethodMaxLines, mode },\n context\n );\n\n const modifiedMethodsResult = await runModifiedMethodsExecutor(\n { max: options.modifiedMethodsMaxLines ?? 80, mode },\n context\n );\n\n const modifiedFilesResult = await runModifiedFilesExecutor(\n { max: options.modifiedFilesMaxLines ?? 900, mode },\n context\n );\n\n const returnTypesResult = await runReturnTypesExecutor({ mode: returnTypeMode }, context);\n\n const noInlineTypesResult = await runNoInlineTypesExecutor({ mode: noInlineTypesMode }, context);\n\n const noAnyUnknownResult = await runNoAnyUnknownExecutor({ mode: noAnyUnknownMode }, context);\n\n const allSuccess =\n newMethodsResult.success &&\n modifiedMethodsResult.success &&\n modifiedFilesResult.success &&\n returnTypesResult.success &&\n noInlineTypesResult.success &&\n noAnyUnknownResult.success;\n\n if (allSuccess) {\n console.log('\\nāœ… All code validations passed\\n');\n } else {\n console.log('\\nāŒ Some code validations failed\\n');\n }\n\n return { success: allSuccess };\n}\n"]}
@@ -4,6 +4,7 @@ import runModifiedMethodsExecutor from '../validate-modified-methods/executor';
4
4
  import runModifiedFilesExecutor from '../validate-modified-files/executor';
5
5
  import runReturnTypesExecutor, { ReturnTypeMode } from '../validate-return-types/executor';
6
6
  import runNoInlineTypesExecutor, { NoInlineTypesMode } from '../validate-no-inline-types/executor';
7
+ import runNoAnyUnknownExecutor, { NoAnyUnknownMode } from '../validate-no-any-unknown/executor';
7
8
 
8
9
  export type ValidationMode = 'STRICT' | 'NORMAL' | 'OFF';
9
10
 
@@ -15,6 +16,7 @@ export interface ValidateCodeOptions {
15
16
  modifiedFilesMaxLines?: number;
16
17
  requireReturnTypeMode?: ReturnTypeMode;
17
18
  noInlineTypeLiteralsMode?: NoInlineTypesMode;
19
+ noAnyUnknownMode?: NoAnyUnknownMode;
18
20
  }
19
21
 
20
22
  export interface ExecutorResult {
@@ -34,6 +36,7 @@ export default async function runExecutor(
34
36
 
35
37
  const returnTypeMode: ReturnTypeMode = options.requireReturnTypeMode ?? 'OFF';
36
38
  const noInlineTypesMode: NoInlineTypesMode = options.noInlineTypeLiteralsMode ?? 'OFF';
39
+ const noAnyUnknownMode: NoAnyUnknownMode = options.noAnyUnknownMode ?? 'OFF';
37
40
 
38
41
  console.log('\nšŸ“ Running Code Validations\n');
39
42
  console.log(` Validation mode: ${mode}${mode === 'STRICT' ? ' (disable comments ignored for modified code)' : ''}`);
@@ -45,6 +48,7 @@ export default async function runExecutor(
45
48
  console.log(` Modified files max: ${options.modifiedFilesMaxLines ?? 900} lines`);
46
49
  console.log(` Require return types: ${returnTypeMode}`);
47
50
  console.log(` No inline type literals: ${noInlineTypesMode}`);
51
+ console.log(` No any/unknown: ${noAnyUnknownMode}`);
48
52
  console.log('');
49
53
 
50
54
  // Run all three validators sequentially to avoid interleaved output
@@ -67,12 +71,15 @@ export default async function runExecutor(
67
71
 
68
72
  const noInlineTypesResult = await runNoInlineTypesExecutor({ mode: noInlineTypesMode }, context);
69
73
 
74
+ const noAnyUnknownResult = await runNoAnyUnknownExecutor({ mode: noAnyUnknownMode }, context);
75
+
70
76
  const allSuccess =
71
77
  newMethodsResult.success &&
72
78
  modifiedMethodsResult.success &&
73
79
  modifiedFilesResult.success &&
74
80
  returnTypesResult.success &&
75
- noInlineTypesResult.success;
81
+ noInlineTypesResult.success &&
82
+ noAnyUnknownResult.success;
76
83
 
77
84
  if (allSuccess) {
78
85
  console.log('\nāœ… All code validations passed\n');
@@ -40,6 +40,12 @@
40
40
  "enum": ["OFF", "NEW_METHODS", "MODIFIED_AND_NEW_METHODS", "MODIFIED_FILES", "ALL"],
41
41
  "description": "OFF: skip validation. NEW_METHODS: only new methods. MODIFIED_AND_NEW_METHODS: new + modified methods. MODIFIED_FILES: all in modified files. ALL: everywhere. Disallows inline type literals like { x: number } - use named types instead.",
42
42
  "default": "OFF"
43
+ },
44
+ "noAnyUnknownMode": {
45
+ "type": "string",
46
+ "enum": ["OFF", "MODIFIED_CODE", "MODIFIED_FILES", "ALL"],
47
+ "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.",
48
+ "default": "OFF"
43
49
  }
44
50
  },
45
51
  "required": []
@@ -0,0 +1,41 @@
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
+ import type { ExecutorContext } from '@nx/devkit';
34
+ export type NoAnyUnknownMode = 'OFF' | 'MODIFIED_CODE' | 'MODIFIED_FILES' | 'ALL';
35
+ export interface ValidateNoAnyUnknownOptions {
36
+ mode?: NoAnyUnknownMode;
37
+ }
38
+ export interface ExecutorResult {
39
+ success: boolean;
40
+ }
41
+ export default function runExecutor(options: ValidateNoAnyUnknownOptions, context: ExecutorContext): Promise<ExecutorResult>;
@@ -0,0 +1,442 @@
1
+ "use strict";
2
+ /**
3
+ * Validate No Any Unknown Executor
4
+ *
5
+ * Validates that `any` and `unknown` TypeScript keywords are not used.
6
+ * Uses LINE-BASED detection (not method-based) for git diff filtering.
7
+ *
8
+ * ============================================================================
9
+ * VIOLATIONS (BAD) - These patterns are flagged:
10
+ * ============================================================================
11
+ *
12
+ * - const x: any = ...
13
+ * - function foo(arg: any): any { }
14
+ * - const data = response as any;
15
+ * - type T = any;
16
+ * - const x: unknown = ...
17
+ * - function foo(arg: unknown): unknown { }
18
+ *
19
+ * ============================================================================
20
+ * MODES (LINE-BASED)
21
+ * ============================================================================
22
+ * - OFF: Skip validation entirely
23
+ * - MODIFIED_CODE: Flag any/unknown on changed lines (lines in diff hunks)
24
+ * - MODIFIED_FILES: Flag ALL any/unknown in files that were modified
25
+ * - ALL: Flag everywhere in all TypeScript files
26
+ *
27
+ * ============================================================================
28
+ * ESCAPE HATCH
29
+ * ============================================================================
30
+ * Add comment above the violation:
31
+ * // webpieces-disable no-any-unknown -- [your justification]
32
+ * const x: any = ...;
33
+ */
34
+ Object.defineProperty(exports, "__esModule", { value: true });
35
+ exports.default = runExecutor;
36
+ const tslib_1 = require("tslib");
37
+ const child_process_1 = require("child_process");
38
+ const fs = tslib_1.__importStar(require("fs"));
39
+ const path = tslib_1.__importStar(require("path"));
40
+ const ts = tslib_1.__importStar(require("typescript"));
41
+ /**
42
+ * Get changed TypeScript files between base and head (or working tree if head not specified).
43
+ */
44
+ // webpieces-disable max-lines-new-methods -- Git command handling with untracked files requires multiple code paths
45
+ function getChangedTypeScriptFiles(workspaceRoot, base, head) {
46
+ try {
47
+ const diffTarget = head ? `${base} ${head}` : base;
48
+ const output = (0, child_process_1.execSync)(`git diff --name-only ${diffTarget} -- '*.ts' '*.tsx'`, {
49
+ cwd: workspaceRoot,
50
+ encoding: 'utf-8',
51
+ });
52
+ const changedFiles = output
53
+ .trim()
54
+ .split('\n')
55
+ .filter((f) => f && !f.includes('.spec.ts') && !f.includes('.test.ts'));
56
+ if (!head) {
57
+ try {
58
+ const untrackedOutput = (0, child_process_1.execSync)(`git ls-files --others --exclude-standard '*.ts' '*.tsx'`, {
59
+ cwd: workspaceRoot,
60
+ encoding: 'utf-8',
61
+ });
62
+ const untrackedFiles = untrackedOutput
63
+ .trim()
64
+ .split('\n')
65
+ .filter((f) => f && !f.includes('.spec.ts') && !f.includes('.test.ts'));
66
+ const allFiles = new Set([...changedFiles, ...untrackedFiles]);
67
+ return Array.from(allFiles);
68
+ }
69
+ catch {
70
+ return changedFiles;
71
+ }
72
+ }
73
+ return changedFiles;
74
+ }
75
+ catch {
76
+ return [];
77
+ }
78
+ }
79
+ /**
80
+ * Get all TypeScript files in the workspace using git ls-files (excluding tests).
81
+ */
82
+ function getAllTypeScriptFiles(workspaceRoot) {
83
+ try {
84
+ const output = (0, child_process_1.execSync)(`git ls-files '*.ts' '*.tsx'`, {
85
+ cwd: workspaceRoot,
86
+ encoding: 'utf-8',
87
+ });
88
+ return output
89
+ .trim()
90
+ .split('\n')
91
+ .filter((f) => f && !f.includes('.spec.ts') && !f.includes('.test.ts'));
92
+ }
93
+ catch {
94
+ return [];
95
+ }
96
+ }
97
+ /**
98
+ * Get the diff content for a specific file.
99
+ */
100
+ function getFileDiff(workspaceRoot, file, base, head) {
101
+ try {
102
+ const diffTarget = head ? `${base} ${head}` : base;
103
+ const diff = (0, child_process_1.execSync)(`git diff ${diffTarget} -- "${file}"`, {
104
+ cwd: workspaceRoot,
105
+ encoding: 'utf-8',
106
+ });
107
+ if (!diff && !head) {
108
+ const fullPath = path.join(workspaceRoot, file);
109
+ if (fs.existsSync(fullPath)) {
110
+ const isUntracked = (0, child_process_1.execSync)(`git ls-files --others --exclude-standard "${file}"`, {
111
+ cwd: workspaceRoot,
112
+ encoding: 'utf-8',
113
+ }).trim();
114
+ if (isUntracked) {
115
+ const content = fs.readFileSync(fullPath, 'utf-8');
116
+ const lines = content.split('\n');
117
+ return lines.map((line) => `+${line}`).join('\n');
118
+ }
119
+ }
120
+ }
121
+ return diff;
122
+ }
123
+ catch {
124
+ return '';
125
+ }
126
+ }
127
+ /**
128
+ * Parse diff to extract changed line numbers (additions only - lines starting with +).
129
+ */
130
+ function getChangedLineNumbers(diffContent) {
131
+ const changedLines = new Set();
132
+ const lines = diffContent.split('\n');
133
+ let currentLine = 0;
134
+ for (const line of lines) {
135
+ const hunkMatch = line.match(/^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/);
136
+ if (hunkMatch) {
137
+ currentLine = parseInt(hunkMatch[1], 10);
138
+ continue;
139
+ }
140
+ if (line.startsWith('+') && !line.startsWith('+++')) {
141
+ changedLines.add(currentLine);
142
+ currentLine++;
143
+ }
144
+ else if (line.startsWith('-') && !line.startsWith('---')) {
145
+ // Deletions don't increment line number
146
+ }
147
+ else {
148
+ currentLine++;
149
+ }
150
+ }
151
+ return changedLines;
152
+ }
153
+ /**
154
+ * Check if a line contains a webpieces-disable comment for no-any-unknown.
155
+ */
156
+ function hasDisableComment(lines, lineNumber) {
157
+ const startCheck = Math.max(0, lineNumber - 5);
158
+ for (let i = lineNumber - 2; i >= startCheck; i--) {
159
+ const line = lines[i]?.trim() ?? '';
160
+ if (line.startsWith('function ') || line.startsWith('class ') || line.endsWith('}')) {
161
+ break;
162
+ }
163
+ if (line.includes('webpieces-disable') && line.includes('no-any-unknown')) {
164
+ return true;
165
+ }
166
+ }
167
+ return false;
168
+ }
169
+ /**
170
+ * Get a description of the context where the any/unknown keyword appears.
171
+ */
172
+ // webpieces-disable max-lines-new-methods -- Context detection requires checking many AST node types
173
+ function getViolationContext(node, sourceFile) {
174
+ try {
175
+ let current = node;
176
+ while (current.parent) {
177
+ const parent = current.parent;
178
+ if (ts.isParameter(parent)) {
179
+ return 'parameter type';
180
+ }
181
+ if (ts.isFunctionDeclaration(parent) || ts.isMethodDeclaration(parent) || ts.isArrowFunction(parent)) {
182
+ if (parent.type === current) {
183
+ return 'return type';
184
+ }
185
+ }
186
+ if (ts.isVariableDeclaration(parent)) {
187
+ return 'variable type';
188
+ }
189
+ if (ts.isPropertyDeclaration(parent) || ts.isPropertySignature(parent)) {
190
+ return 'property type';
191
+ }
192
+ if (ts.isAsExpression(parent)) {
193
+ return 'type assertion';
194
+ }
195
+ if (ts.isTypeAliasDeclaration(parent)) {
196
+ return 'type alias';
197
+ }
198
+ if (ts.isTypeReferenceNode(parent)) {
199
+ return 'generic argument';
200
+ }
201
+ if (ts.isArrayTypeNode(parent)) {
202
+ return 'array element type';
203
+ }
204
+ if (ts.isUnionTypeNode(parent) || ts.isIntersectionTypeNode(parent)) {
205
+ return 'union/intersection type';
206
+ }
207
+ current = parent;
208
+ }
209
+ return 'type position';
210
+ }
211
+ catch {
212
+ return 'type position';
213
+ }
214
+ }
215
+ /**
216
+ * Find all `any` and `unknown` keywords in a file using AST.
217
+ */
218
+ // webpieces-disable max-lines-new-methods -- AST traversal with nested visitor function for keyword detection
219
+ function findAnyUnknownInFile(filePath, workspaceRoot) {
220
+ const fullPath = path.join(workspaceRoot, filePath);
221
+ if (!fs.existsSync(fullPath))
222
+ return [];
223
+ const content = fs.readFileSync(fullPath, 'utf-8');
224
+ const fileLines = content.split('\n');
225
+ const sourceFile = ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true);
226
+ const violations = [];
227
+ // webpieces-disable max-lines-new-methods -- AST visitor needs to handle both any and unknown keywords with full context detection
228
+ function visit(node) {
229
+ try {
230
+ // Detect `any` keyword
231
+ if (node.kind === ts.SyntaxKind.AnyKeyword) {
232
+ const startPos = node.getStart(sourceFile);
233
+ if (startPos >= 0) {
234
+ const pos = sourceFile.getLineAndCharacterOfPosition(startPos);
235
+ const line = pos.line + 1;
236
+ const column = pos.character + 1;
237
+ const context = getViolationContext(node, sourceFile);
238
+ const disabled = hasDisableComment(fileLines, line);
239
+ violations.push({
240
+ line,
241
+ column,
242
+ keyword: 'any',
243
+ context,
244
+ hasDisableComment: disabled,
245
+ });
246
+ }
247
+ }
248
+ // Detect `unknown` keyword
249
+ if (node.kind === ts.SyntaxKind.UnknownKeyword) {
250
+ const startPos = node.getStart(sourceFile);
251
+ if (startPos >= 0) {
252
+ const pos = sourceFile.getLineAndCharacterOfPosition(startPos);
253
+ const line = pos.line + 1;
254
+ const column = pos.character + 1;
255
+ const context = getViolationContext(node, sourceFile);
256
+ const disabled = hasDisableComment(fileLines, line);
257
+ violations.push({
258
+ line,
259
+ column,
260
+ keyword: 'unknown',
261
+ context,
262
+ hasDisableComment: disabled,
263
+ });
264
+ }
265
+ }
266
+ }
267
+ catch {
268
+ // Skip nodes that cause errors during analysis
269
+ }
270
+ ts.forEachChild(node, visit);
271
+ }
272
+ visit(sourceFile);
273
+ return violations;
274
+ }
275
+ /**
276
+ * MODIFIED_CODE mode: Flag violations on changed lines in diff hunks.
277
+ * This is LINE-BASED detection.
278
+ */
279
+ // webpieces-disable max-lines-new-methods -- File iteration with diff parsing and line filtering
280
+ function findViolationsForModifiedCode(workspaceRoot, changedFiles, base, head) {
281
+ const violations = [];
282
+ for (const file of changedFiles) {
283
+ const diff = getFileDiff(workspaceRoot, file, base, head);
284
+ const changedLines = getChangedLineNumbers(diff);
285
+ if (changedLines.size === 0)
286
+ continue;
287
+ const allViolations = findAnyUnknownInFile(file, workspaceRoot);
288
+ for (const v of allViolations) {
289
+ if (v.hasDisableComment)
290
+ continue;
291
+ // LINE-BASED: Only include if the violation is on a changed line
292
+ if (!changedLines.has(v.line))
293
+ continue;
294
+ violations.push({
295
+ file,
296
+ line: v.line,
297
+ column: v.column,
298
+ keyword: v.keyword,
299
+ context: v.context,
300
+ });
301
+ }
302
+ }
303
+ return violations;
304
+ }
305
+ /**
306
+ * MODIFIED_FILES mode: Flag ALL violations in files that were modified.
307
+ */
308
+ function findViolationsForModifiedFiles(workspaceRoot, changedFiles) {
309
+ const violations = [];
310
+ for (const file of changedFiles) {
311
+ const allViolations = findAnyUnknownInFile(file, workspaceRoot);
312
+ for (const v of allViolations) {
313
+ if (v.hasDisableComment)
314
+ continue;
315
+ violations.push({
316
+ file,
317
+ line: v.line,
318
+ column: v.column,
319
+ keyword: v.keyword,
320
+ context: v.context,
321
+ });
322
+ }
323
+ }
324
+ return violations;
325
+ }
326
+ /**
327
+ * ALL mode: Flag violations in all TypeScript files.
328
+ */
329
+ function findViolationsForAll(workspaceRoot) {
330
+ const allFiles = getAllTypeScriptFiles(workspaceRoot);
331
+ return findViolationsForModifiedFiles(workspaceRoot, allFiles);
332
+ }
333
+ /**
334
+ * Auto-detect the base branch by finding the merge-base with origin/main.
335
+ */
336
+ function detectBase(workspaceRoot) {
337
+ try {
338
+ const mergeBase = (0, child_process_1.execSync)('git merge-base HEAD origin/main', {
339
+ cwd: workspaceRoot,
340
+ encoding: 'utf-8',
341
+ stdio: ['pipe', 'pipe', 'pipe'],
342
+ }).trim();
343
+ if (mergeBase) {
344
+ return mergeBase;
345
+ }
346
+ }
347
+ catch {
348
+ try {
349
+ const mergeBase = (0, child_process_1.execSync)('git merge-base HEAD main', {
350
+ cwd: workspaceRoot,
351
+ encoding: 'utf-8',
352
+ stdio: ['pipe', 'pipe', 'pipe'],
353
+ }).trim();
354
+ if (mergeBase) {
355
+ return mergeBase;
356
+ }
357
+ }
358
+ catch {
359
+ // Ignore
360
+ }
361
+ }
362
+ return null;
363
+ }
364
+ /**
365
+ * Report violations to console.
366
+ */
367
+ function reportViolations(violations, mode) {
368
+ console.error('');
369
+ console.error('āŒ `any` and `unknown` keywords found! Use specific types instead.');
370
+ console.error('');
371
+ console.error('šŸ“š Avoiding any/unknown improves type safety:');
372
+ console.error('');
373
+ console.error(' BAD: const data: any = fetchData();');
374
+ console.error(' GOOD: const data: UserData = fetchData();');
375
+ console.error('');
376
+ console.error(' BAD: function process(input: unknown): unknown { }');
377
+ console.error(' GOOD: function process(input: ValidInput): ValidOutput { }');
378
+ console.error('');
379
+ for (const v of violations) {
380
+ console.error(` āŒ ${v.file}:${v.line}:${v.column}`);
381
+ console.error(` \`${v.keyword}\` keyword in ${v.context}`);
382
+ }
383
+ console.error('');
384
+ console.error(' To fix: Replace with specific types or interfaces');
385
+ console.error('');
386
+ console.error(' Escape hatch (use sparingly):');
387
+ console.error(' // webpieces-disable no-any-unknown -- [your reason]');
388
+ console.error('');
389
+ console.error(` Current mode: ${mode}`);
390
+ console.error('');
391
+ }
392
+ async function runExecutor(options, context) {
393
+ const workspaceRoot = context.root;
394
+ const mode = options.mode ?? 'OFF';
395
+ if (mode === 'OFF') {
396
+ console.log('\nā­ļø Skipping no-any-unknown validation (mode: OFF)');
397
+ console.log('');
398
+ return { success: true };
399
+ }
400
+ console.log('\nšŸ“ Validating No Any/Unknown\n');
401
+ console.log(` Mode: ${mode}`);
402
+ let violations = [];
403
+ if (mode === 'ALL') {
404
+ console.log(' Scope: All tracked TypeScript files');
405
+ console.log('');
406
+ violations = findViolationsForAll(workspaceRoot);
407
+ }
408
+ else {
409
+ let base = process.env['NX_BASE'];
410
+ const head = process.env['NX_HEAD'];
411
+ if (!base) {
412
+ base = detectBase(workspaceRoot) ?? undefined;
413
+ if (!base) {
414
+ console.log('\nā­ļø Skipping no-any-unknown validation (could not detect base branch)');
415
+ console.log('');
416
+ return { success: true };
417
+ }
418
+ }
419
+ console.log(` Base: ${base}`);
420
+ console.log(` Head: ${head ?? 'working tree (includes uncommitted changes)'}`);
421
+ console.log('');
422
+ const changedFiles = getChangedTypeScriptFiles(workspaceRoot, base, head);
423
+ if (changedFiles.length === 0) {
424
+ console.log('āœ… No TypeScript files changed');
425
+ return { success: true };
426
+ }
427
+ console.log(`šŸ“‚ Checking ${changedFiles.length} changed file(s)...`);
428
+ if (mode === 'MODIFIED_CODE') {
429
+ violations = findViolationsForModifiedCode(workspaceRoot, changedFiles, base, head);
430
+ }
431
+ else if (mode === 'MODIFIED_FILES') {
432
+ violations = findViolationsForModifiedFiles(workspaceRoot, changedFiles);
433
+ }
434
+ }
435
+ if (violations.length === 0) {
436
+ console.log('āœ… No any/unknown keywords found');
437
+ return { success: true };
438
+ }
439
+ reportViolations(violations, mode);
440
+ return { success: false };
441
+ }
442
+ //# sourceMappingURL=executor.js.map