@webpieces/code-rules 0.4.456 → 0.4.458

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webpieces/code-rules",
3
- "version": "0.4.456",
3
+ "version": "0.4.458",
4
4
  "description": "Standalone code validation rules extracted from architecture-validators, no Nx dependency required",
5
5
  "type": "commonjs",
6
6
  "main": "./src/index.js",
@@ -20,7 +20,7 @@
20
20
  "directory": "packages/tooling/code-rules"
21
21
  },
22
22
  "dependencies": {
23
- "@webpieces/rules-config": "0.4.456",
23
+ "@webpieces/rules-config": "0.4.458",
24
24
  "@inversifyjs/binding-decorators": "1.1.5",
25
25
  "inversify": "7.10.4",
26
26
  "reflect-metadata": "0.2.2"
@@ -24,6 +24,9 @@
24
24
  * - for (const [key, value] of Object.entries(obj)) — Object.entries in for-of
25
25
  * - const { extracted, ...rest } = obj — rest operator separation
26
26
  * - Lines with // webpieces-disable no-destructure -- [reason] (only when disableAllowed: true)
27
+ * - Files under a configured `allowedPaths` glob (shared isPathExcluded glob/prefix/segment
28
+ * semantics) — e.g. a React/React Native tree, where useState and destructured props are the
29
+ * framework's own idiom. This is the ONLY escape when disableAllowed: false.
27
30
  *
28
31
  * ============================================================================
29
32
  * MODES (LINE-BASED)
@@ -41,6 +44,16 @@
41
44
  */
42
45
  import { NoDestructureConfig } from '@webpieces/rules-config';
43
46
  import { CodeValidator, ExecutorResult } from './code-validator';
47
+ export interface DestructureInfo {
48
+ line: number;
49
+ column: number;
50
+ context: string;
51
+ hasDisableComment: boolean;
52
+ }
53
+ /**
54
+ * Find all destructuring patterns in a file using AST.
55
+ */
56
+ export declare function findDestructuringInFile(filePath: string, workspaceRoot: string, disableAllowed: boolean, allowedPaths: string[]): DestructureInfo[];
44
57
  export declare class NoDestructureValidator extends CodeValidator<NoDestructureConfig> {
45
58
  constructor(config: NoDestructureConfig);
46
59
  run(workspaceRoot: string): Promise<ExecutorResult>;
@@ -25,6 +25,9 @@
25
25
  * - for (const [key, value] of Object.entries(obj)) — Object.entries in for-of
26
26
  * - const { extracted, ...rest } = obj — rest operator separation
27
27
  * - Lines with // webpieces-disable no-destructure -- [reason] (only when disableAllowed: true)
28
+ * - Files under a configured `allowedPaths` glob (shared isPathExcluded glob/prefix/segment
29
+ * semantics) — e.g. a React/React Native tree, where useState and destructured props are the
30
+ * framework's own idiom. This is the ONLY escape when disableAllowed: false.
28
31
  *
29
32
  * ============================================================================
30
33
  * MODES (LINE-BASED)
@@ -42,6 +45,7 @@
42
45
  */
43
46
  Object.defineProperty(exports, "__esModule", { value: true });
44
47
  exports.NoDestructureValidator = void 0;
48
+ exports.findDestructuringInFile = findDestructuringInFile;
45
49
  const tslib_1 = require("tslib");
46
50
  const fs = tslib_1.__importStar(require("fs"));
47
51
  const path = tslib_1.__importStar(require("path"));
@@ -131,7 +135,12 @@ function hasRestElement(node) {
131
135
  * Find all destructuring patterns in a file using AST.
132
136
  */
133
137
  // webpieces-disable max-lines-new-methods -- AST traversal with multiple destructuring pattern checks and exception detection
134
- function findDestructuringInFile(filePath, workspaceRoot, disableAllowed) {
138
+ // webpieces-disable no-function-outside-class -- the rule engine is inherently functional; validators can't be class members
139
+ function findDestructuringInFile(filePath, workspaceRoot, disableAllowed, allowedPaths) {
140
+ // Guard on the REPO-RELATIVE path, before the join below — globs like `mobile/**` never match an
141
+ // absolute path. This is the only escape when disableAllowed is false.
142
+ if ((0, rules_config_1.isPathExcluded)(filePath, allowedPaths))
143
+ return [];
135
144
  const fullPath = path.join(workspaceRoot, filePath);
136
145
  if (!fs.existsSync(fullPath))
137
146
  return [];
@@ -224,14 +233,14 @@ function getDestructureContext(node) {
224
233
  * NEW_AND_MODIFIED_CODE mode: Flag violations on changed lines in diff hunks.
225
234
  */
226
235
  // webpieces-disable max-lines-new-methods -- File iteration with diff parsing and line filtering
227
- function findViolationsForModifiedCode(workspaceRoot, changedFiles, base, head, disableAllowed) {
236
+ function findViolationsForModifiedCode(workspaceRoot, changedFiles, base, head, disableAllowed, allowedPaths) {
228
237
  const violations = [];
229
238
  for (const file of changedFiles) {
230
239
  const diff = (0, rules_config_1.getFileDiff)(workspaceRoot, file, base, head);
231
240
  const changedLines = (0, rules_config_1.getChangedLineNumbers)(diff);
232
241
  if (changedLines.size === 0)
233
242
  continue;
234
- const allViolations = findDestructuringInFile(file, workspaceRoot, disableAllowed);
243
+ const allViolations = findDestructuringInFile(file, workspaceRoot, disableAllowed, allowedPaths);
235
244
  for (const v of allViolations) {
236
245
  if (disableAllowed && v.hasDisableComment)
237
246
  continue;
@@ -251,10 +260,11 @@ function findViolationsForModifiedCode(workspaceRoot, changedFiles, base, head,
251
260
  /**
252
261
  * NEW_AND_MODIFIED_FILES mode: Flag ALL violations in files that were modified.
253
262
  */
254
- function findViolationsForModifiedFiles(workspaceRoot, changedFiles, disableAllowed) {
263
+ // webpieces-disable no-function-outside-class -- the rule engine is inherently functional; validators can't be class members
264
+ function findViolationsForModifiedFiles(workspaceRoot, changedFiles, disableAllowed, allowedPaths) {
255
265
  const violations = [];
256
266
  for (const file of changedFiles) {
257
- const allViolations = findDestructuringInFile(file, workspaceRoot, disableAllowed);
267
+ const allViolations = findDestructuringInFile(file, workspaceRoot, disableAllowed, allowedPaths);
258
268
  for (const v of allViolations) {
259
269
  if (disableAllowed && v.hasDisableComment)
260
270
  continue;
@@ -303,6 +313,7 @@ function reportViolations(violations, mode, disableAllowed) {
303
313
  console.error(' Escape hatch: DISABLED (disableAllowed: false)');
304
314
  console.error(' Disable comments are ignored. Fix the destructuring directly.');
305
315
  }
316
+ console.error(' Whole-tree exemption (e.g. React/React Native): add a glob to no-destructure.allowedPaths in webpieces.config.json');
306
317
  console.error('');
307
318
  console.error(` Current mode: ${mode}`);
308
319
  console.error('');
@@ -326,6 +337,7 @@ function resolveNoDestructureMode(normalMode, epoch, branchPattern) {
326
337
  async function runValidatorImpl(options, workspaceRoot) {
327
338
  const mode = resolveNoDestructureMode(options.mode ?? 'OFF', options.ignoreModifiedUntilEpoch, options.ignoreRuleWhileOnBranch);
328
339
  const disableAllowed = options.disableAllowed ?? true;
340
+ const allowedPaths = options.allowedPaths ?? [];
329
341
  if (mode === 'OFF') {
330
342
  console.log('\n\u23ed\ufe0f Skipping no-destructure validation (mode: OFF)');
331
343
  console.log('');
@@ -354,10 +366,10 @@ async function runValidatorImpl(options, workspaceRoot) {
354
366
  console.log(`\ud83d\udcc2 Checking ${changedFiles.length} changed file(s)...`);
355
367
  let violations = [];
356
368
  if (mode === 'NEW_AND_MODIFIED_CODE') {
357
- violations = findViolationsForModifiedCode(workspaceRoot, changedFiles, base, head, disableAllowed);
369
+ violations = findViolationsForModifiedCode(workspaceRoot, changedFiles, base, head, disableAllowed, allowedPaths);
358
370
  }
359
371
  else if (mode === 'NEW_AND_MODIFIED_FILES') {
360
- violations = findViolationsForModifiedFiles(workspaceRoot, changedFiles, disableAllowed);
372
+ violations = findViolationsForModifiedFiles(workspaceRoot, changedFiles, disableAllowed, allowedPaths);
361
373
  }
362
374
  if (violations.length === 0) {
363
375
  console.log('\u2705 No destructuring patterns found');
@@ -1 +1 @@
1
- {"version":3,"file":"validate-no-destructure.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/validate-no-destructure.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;;;;AAEH,+CAAyB;AACzB,mDAA6B;AAC7B,uDAAiC;AACjC,0DAAyK;AACzK,qDAAiE;AACjE,yCAA2D;AAC3D,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,E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IAE5C,IAAI,IAAI,KAAK,uBAAuB,EAAE,CAAC;QACnC,UAAU,GAAG,6BAA6B,CAAC,aAAa,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;IACxG,CAAC;SAAM,IAAI,IAAI,KAAK,wBAAwB,EAAE,CAAC;QAC3C,UAAU,GAAG,8BAA8B,CAAC,aAAa,EAAE,YAAY,EAAE,cAAc,CAAC,CAAC;IAC7F,CAAC;IAED,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,CAAC,GAAG,CAAC,wCAAwC,CAAC,CAAC;QACtD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC7B,CAAC;IAED,gBAAgB,CAAC,UAAU,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;IAEnD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AAC9B,CAAC;AAGM,IAAM,sBAAsB,GAA5B,MAAM,sBAAuB,SAAQ,8BAAkC;IAC1E,YAAY,MAA2B;QACnC,KAAK,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IACpC,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;IADlC,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEjB,kCAAmB;GAD9B,sBAAsB,CAQlC","sourcesContent":["/**\n * Validate No Destructure Executor\n *\n * Validates that destructuring patterns are not used in TypeScript code.\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, y } = obj — object destructuring in variable declarations\n * - const [a, b] = fn() — array destructuring (except Promise.all)\n * - for (const { email } of items) — object destructuring in for-of loops\n * - for (const [a, b] of items) — array destructuring in for-of (except Object.entries)\n * - const { page = 0 } = opts — destructuring with defaults\n * - const { done: streamDone } = obj — destructuring with renaming\n * - function foo({ x, y }: Type) — function parameter destructuring\n *\n * ============================================================================\n * ALLOWED (skip — NOT violations)\n * ============================================================================\n *\n * - const [a, b] = await Promise.all([...]) — Promise.all array destructuring\n * - for (const [key, value] of Object.entries(obj)) — Object.entries in for-of\n * - const { extracted, ...rest } = obj — rest operator separation\n * - Lines with // webpieces-disable no-destructure -- [reason] (only when disableAllowed: true)\n *\n * ============================================================================\n * MODES (LINE-BASED)\n * ============================================================================\n * - OFF: Skip validation entirely\n * - NEW_AND_MODIFIED_CODE: Flag destructuring on changed lines (lines in diff hunks)\n * - NEW_AND_MODIFIED_FILES: Flag ALL destructuring in files that were modified\n *\n * ============================================================================\n * ESCAPE HATCH\n * ============================================================================\n * Add comment above the violation:\n * // webpieces-disable no-destructure -- [your justification]\n * const { x, y } = obj;\n */\n\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as ts from 'typescript';\nimport { hasDisable, RULE_NAMES, NoDestructureConfig, ModifiedCodeMode, detectBase, getChangedFiles, getFileDiff, getChangedLineNumbers } from '@webpieces/rules-config';\nimport { CodeValidator, ExecutorResult } from './code-validator';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { shouldSkipRule } from './resolve-mode';\n\ninterface DestructureViolation {\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-destructure.\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_DESTRUCTURE)) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Check if an ArrayBindingPattern's initializer is `await Promise.all(...)`.\n */\nfunction isPromiseAllDestructure(node: ts.ArrayBindingPattern): boolean {\n const parent = node.parent;\n if (!ts.isVariableDeclaration(parent)) return false;\n const initializer = parent.initializer;\n if (!initializer) return false;\n\n // Handle: const [a, b] = await Promise.all([...])\n if (ts.isAwaitExpression(initializer)) {\n const awaitedExpr = initializer.expression;\n if (ts.isCallExpression(awaitedExpr)) {\n const callExpr = awaitedExpr.expression;\n // Promise.all(...)\n if (ts.isPropertyAccessExpression(callExpr) && callExpr.name.text === 'all') {\n const obj = callExpr.expression;\n if (ts.isIdentifier(obj) && obj.text === 'Promise') {\n return true;\n }\n }\n }\n }\n\n return false;\n}\n\n/**\n * Check if an ArrayBindingPattern in a for-of loop iterates over Object.entries(...).\n */\nfunction isObjectEntriesForOf(node: ts.ArrayBindingPattern): boolean {\n // Walk up: ArrayBindingPattern -> VariableDeclaration -> VariableDeclarationList -> ForOfStatement\n const varDecl = node.parent;\n if (!ts.isVariableDeclaration(varDecl)) return false;\n\n const varDeclList = varDecl.parent;\n if (!ts.isVariableDeclarationList(varDeclList)) return false;\n\n const forOfStmt = varDeclList.parent;\n if (!ts.isForOfStatement(forOfStmt)) return false;\n\n // Check iterable expression ends with .entries()\n const iterable = forOfStmt.expression;\n if (ts.isCallExpression(iterable)) {\n const callExpr = iterable.expression;\n if (ts.isPropertyAccessExpression(callExpr) && callExpr.name.text === 'entries') {\n return true;\n }\n }\n\n return false;\n}\n\n/**\n * Check if an ObjectBindingPattern contains a rest element (...rest).\n */\nfunction hasRestElement(node: ts.ObjectBindingPattern): boolean {\n for (const element of node.elements) {\n if (element.dotDotDotToken) {\n return true;\n }\n }\n return false;\n}\n\ninterface DestructureInfo {\n line: number;\n column: number;\n context: string;\n hasDisableComment: boolean;\n}\n\n/**\n * Find all destructuring patterns in a file using AST.\n */\n// webpieces-disable max-lines-new-methods -- AST traversal with multiple destructuring pattern checks and exception detection\nfunction findDestructuringInFile(filePath: string, workspaceRoot: string, disableAllowed: boolean): DestructureInfo[] {\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: DestructureInfo[] = [];\n\n // webpieces-disable max-lines-new-methods -- AST visitor needs to handle object/array binding patterns in declarations, for-of, and parameters\n function visit(node: ts.Node): void {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n // Check ObjectBindingPattern\n if (ts.isObjectBindingPattern(node)) {\n // Exception: rest operator separation\n if (hasRestElement(node)) {\n ts.forEachChild(node, visit);\n return;\n }\n\n const context = getDestructureContext(node);\n recordViolation(node, context, fileLines, sourceFile, violations, disableAllowed);\n }\n\n // Check ArrayBindingPattern\n if (ts.isArrayBindingPattern(node)) {\n // Exception: Promise.all destructure\n if (isPromiseAllDestructure(node)) {\n ts.forEachChild(node, visit);\n return;\n }\n\n // Exception: Object.entries in for-of\n if (isObjectEntriesForOf(node)) {\n ts.forEachChild(node, visit);\n return;\n }\n\n const context = getDestructureContext(node);\n recordViolation(node, context, fileLines, sourceFile, violations, disableAllowed);\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 violations;\n}\n\nfunction recordViolation(\n node: ts.Node,\n context: string,\n fileLines: string[],\n sourceFile: ts.SourceFile,\n violations: DestructureInfo[],\n disableAllowed: boolean,\n): void {\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 disabled = hasDisableComment(fileLines, line);\n\n if (!disableAllowed && disabled) {\n // When disableAllowed is false, ignore disable comments — still a violation\n violations.push({ line, column, context, hasDisableComment: false });\n } else {\n violations.push({ line, column, context, hasDisableComment: disabled });\n }\n }\n}\n\n/**\n * Get a description of where the destructuring pattern appears.\n */\nfunction getDestructureContext(node: ts.Node): string {\n const parent = node.parent;\n if (ts.isParameter(parent)) {\n return 'function parameter destructuring';\n }\n if (ts.isVariableDeclaration(parent)) {\n const grandparent = parent.parent;\n if (grandparent && ts.isVariableDeclarationList(grandparent)) {\n const forOfParent = grandparent.parent;\n if (forOfParent && ts.isForOfStatement(forOfParent)) {\n return ts.isObjectBindingPattern(node)\n ? 'object destructuring in for-of loop'\n : 'array destructuring in for-of loop';\n }\n }\n return ts.isObjectBindingPattern(node)\n ? 'object destructuring in variable declaration'\n : 'array destructuring in variable declaration';\n }\n return ts.isObjectBindingPattern(node)\n ? 'object destructuring'\n : 'array destructuring';\n}\n\n/**\n * NEW_AND_MODIFIED_CODE mode: Flag violations on changed lines in diff hunks.\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 | undefined,\n disableAllowed: boolean\n): DestructureViolation[] {\n const violations: DestructureViolation[] = [];\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 = findDestructuringInFile(file, workspaceRoot, disableAllowed);\n\n for (const v of allViolations) {\n if (disableAllowed && 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 context: v.context,\n });\n }\n }\n\n return violations;\n}\n\n/**\n * NEW_AND_MODIFIED_FILES mode: Flag ALL violations in files that were modified.\n */\nfunction findViolationsForModifiedFiles(workspaceRoot: string, changedFiles: string[], disableAllowed: boolean): DestructureViolation[] {\n const violations: DestructureViolation[] = [];\n\n for (const file of changedFiles) {\n const allViolations = findDestructuringInFile(file, workspaceRoot, disableAllowed);\n\n for (const v of allViolations) {\n if (disableAllowed && v.hasDisableComment) continue;\n\n violations.push({\n file,\n line: v.line,\n column: v.column,\n context: v.context,\n });\n }\n }\n\n return violations;\n}\n\n/**\n * Report violations to console.\n */\n// webpieces-disable max-lines-new-methods -- Console output with examples and escape hatch information\nfunction reportViolations(violations: DestructureViolation[], mode: ModifiedCodeMode, disableAllowed: boolean): void {\n console.error('');\n console.error('\\u274c Destructuring patterns found! Use explicit property access instead.');\n console.error('');\n console.error('\\ud83d\\udcda Avoiding destructuring improves code traceability:');\n console.error('');\n console.error(' BAD: const { name, age } = user;');\n console.error(' GOOD: const name = user.name;');\n console.error(' const age = user.age;');\n console.error('');\n console.error(' BAD: function process({ x, y }: Point) { }');\n console.error(' GOOD: function process(point: Point) { point.x; point.y; }');\n console.error('');\n\n for (const v of violations) {\n console.error(` \\u274c ${v.file}:${v.line}:${v.column}`);\n console.error(` ${v.context}`);\n }\n console.error('');\n\n console.error(' Allowed exceptions:');\n console.error(' - const [a, b] = await Promise.all([...])');\n console.error(' - for (const [key, value] of Object.entries(obj))');\n console.error(' - const { extracted, ...rest } = obj (rest operator separation)');\n console.error('');\n\n if (disableAllowed) {\n console.error(' Escape hatch (use sparingly):');\n console.error(' // webpieces-disable no-destructure -- [your reason]');\n } else {\n console.error(' Escape hatch: DISABLED (disableAllowed: false)');\n console.error(' Disable comments are ignored. Fix the destructuring directly.');\n }\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 resolveNoDestructureMode(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-destructure validation (${skip.reason})`);\n console.log('');\n return 'OFF';\n }\n return normalMode;\n}\n\nasync function runValidatorImpl(\n options: NoDestructureConfig,\n workspaceRoot: string\n): Promise<ExecutorResult> {\n const mode: ModifiedCodeMode = resolveNoDestructureMode(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-destructure validation (mode: OFF)');\n console.log('');\n return { success: true };\n }\n\n console.log('\\n\\ud83d\\udccf Validating No Destructuring\\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\\u23ed\\ufe0f Skipping no-destructure 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('\\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: DestructureViolation[] = [];\n\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 destructuring patterns found');\n return { success: true };\n }\n\n reportViolations(violations, mode, disableAllowed);\n\n return { success: false };\n}\n\n@injectable(bindingScopeValues.Singleton)\nexport class NoDestructureValidator extends CodeValidator<NoDestructureConfig> {\n constructor(config: NoDestructureConfig) {\n super(config, 'no-destructure');\n }\n\n async run(workspaceRoot: string): Promise<ExecutorResult> {\n return runValidatorImpl(this.config, workspaceRoot);\n }\n}\n"]}
1
+ {"version":3,"file":"validate-no-destructure.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/validate-no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C;IAC7B,CAAC;IAED,gBAAgB,CAAC,UAAU,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;IAEnD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AAC9B,CAAC;AAGM,IAAM,sBAAsB,GAA5B,MAAM,sBAAuB,SAAQ,8BAAkC;IAC1E,YAAY,MAA2B;QACnC,KAAK,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IACpC,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;IADlC,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEjB,kCAAmB;GAD9B,sBAAsB,CAQlC","sourcesContent":["/**\n * Validate No Destructure Executor\n *\n * Validates that destructuring patterns are not used in TypeScript code.\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, y } = obj — object destructuring in variable declarations\n * - const [a, b] = fn() — array destructuring (except Promise.all)\n * - for (const { email } of items) — object destructuring in for-of loops\n * - for (const [a, b] of items) — array destructuring in for-of (except Object.entries)\n * - const { page = 0 } = opts — destructuring with defaults\n * - const { done: streamDone } = obj — destructuring with renaming\n * - function foo({ x, y }: Type) — function parameter destructuring\n *\n * ============================================================================\n * ALLOWED (skip — NOT violations)\n * ============================================================================\n *\n * - const [a, b] = await Promise.all([...]) — Promise.all array destructuring\n * - for (const [key, value] of Object.entries(obj)) — Object.entries in for-of\n * - const { extracted, ...rest } = obj — rest operator separation\n * - Lines with // webpieces-disable no-destructure -- [reason] (only when disableAllowed: true)\n * - Files under a configured `allowedPaths` glob (shared isPathExcluded glob/prefix/segment\n * semantics) — e.g. a React/React Native tree, where useState and destructured props are the\n * framework's own idiom. This is the ONLY escape when disableAllowed: false.\n *\n * ============================================================================\n * MODES (LINE-BASED)\n * ============================================================================\n * - OFF: Skip validation entirely\n * - NEW_AND_MODIFIED_CODE: Flag destructuring on changed lines (lines in diff hunks)\n * - NEW_AND_MODIFIED_FILES: Flag ALL destructuring in files that were modified\n *\n * ============================================================================\n * ESCAPE HATCH\n * ============================================================================\n * Add comment above the violation:\n * // webpieces-disable no-destructure -- [your justification]\n * const { x, y } = obj;\n */\n\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as ts from 'typescript';\nimport { hasDisable, RULE_NAMES, NoDestructureConfig, ModifiedCodeMode, detectBase, getChangedFiles, getFileDiff, getChangedLineNumbers, isPathExcluded } from '@webpieces/rules-config';\nimport { CodeValidator, ExecutorResult } from './code-validator';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { shouldSkipRule } from './resolve-mode';\n\ninterface DestructureViolation {\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-destructure.\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_DESTRUCTURE)) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Check if an ArrayBindingPattern's initializer is `await Promise.all(...)`.\n */\nfunction isPromiseAllDestructure(node: ts.ArrayBindingPattern): boolean {\n const parent = node.parent;\n if (!ts.isVariableDeclaration(parent)) return false;\n const initializer = parent.initializer;\n if (!initializer) return false;\n\n // Handle: const [a, b] = await Promise.all([...])\n if (ts.isAwaitExpression(initializer)) {\n const awaitedExpr = initializer.expression;\n if (ts.isCallExpression(awaitedExpr)) {\n const callExpr = awaitedExpr.expression;\n // Promise.all(...)\n if (ts.isPropertyAccessExpression(callExpr) && callExpr.name.text === 'all') {\n const obj = callExpr.expression;\n if (ts.isIdentifier(obj) && obj.text === 'Promise') {\n return true;\n }\n }\n }\n }\n\n return false;\n}\n\n/**\n * Check if an ArrayBindingPattern in a for-of loop iterates over Object.entries(...).\n */\nfunction isObjectEntriesForOf(node: ts.ArrayBindingPattern): boolean {\n // Walk up: ArrayBindingPattern -> VariableDeclaration -> VariableDeclarationList -> ForOfStatement\n const varDecl = node.parent;\n if (!ts.isVariableDeclaration(varDecl)) return false;\n\n const varDeclList = varDecl.parent;\n if (!ts.isVariableDeclarationList(varDeclList)) return false;\n\n const forOfStmt = varDeclList.parent;\n if (!ts.isForOfStatement(forOfStmt)) return false;\n\n // Check iterable expression ends with .entries()\n const iterable = forOfStmt.expression;\n if (ts.isCallExpression(iterable)) {\n const callExpr = iterable.expression;\n if (ts.isPropertyAccessExpression(callExpr) && callExpr.name.text === 'entries') {\n return true;\n }\n }\n\n return false;\n}\n\n/**\n * Check if an ObjectBindingPattern contains a rest element (...rest).\n */\nfunction hasRestElement(node: ts.ObjectBindingPattern): boolean {\n for (const element of node.elements) {\n if (element.dotDotDotToken) {\n return true;\n }\n }\n return false;\n}\n\nexport interface DestructureInfo {\n line: number;\n column: number;\n context: string;\n hasDisableComment: boolean;\n}\n\n/**\n * Find all destructuring patterns in a file using AST.\n */\n// webpieces-disable max-lines-new-methods -- AST traversal with multiple destructuring pattern checks and exception detection\n// webpieces-disable no-function-outside-class -- the rule engine is inherently functional; validators can't be class members\nexport function findDestructuringInFile(filePath: string, workspaceRoot: string, disableAllowed: boolean, allowedPaths: string[]): DestructureInfo[] {\n // Guard on the REPO-RELATIVE path, before the join below — globs like `mobile/**` never match an\n // absolute path. This is the only escape when disableAllowed is false.\n if (isPathExcluded(filePath, allowedPaths)) 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 fileLines = content.split('\\n');\n const sourceFile = ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true);\n\n const violations: DestructureInfo[] = [];\n\n // webpieces-disable max-lines-new-methods -- AST visitor needs to handle object/array binding patterns in declarations, for-of, and parameters\n function visit(node: ts.Node): void {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n // Check ObjectBindingPattern\n if (ts.isObjectBindingPattern(node)) {\n // Exception: rest operator separation\n if (hasRestElement(node)) {\n ts.forEachChild(node, visit);\n return;\n }\n\n const context = getDestructureContext(node);\n recordViolation(node, context, fileLines, sourceFile, violations, disableAllowed);\n }\n\n // Check ArrayBindingPattern\n if (ts.isArrayBindingPattern(node)) {\n // Exception: Promise.all destructure\n if (isPromiseAllDestructure(node)) {\n ts.forEachChild(node, visit);\n return;\n }\n\n // Exception: Object.entries in for-of\n if (isObjectEntriesForOf(node)) {\n ts.forEachChild(node, visit);\n return;\n }\n\n const context = getDestructureContext(node);\n recordViolation(node, context, fileLines, sourceFile, violations, disableAllowed);\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 violations;\n}\n\nfunction recordViolation(\n node: ts.Node,\n context: string,\n fileLines: string[],\n sourceFile: ts.SourceFile,\n violations: DestructureInfo[],\n disableAllowed: boolean,\n): void {\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 disabled = hasDisableComment(fileLines, line);\n\n if (!disableAllowed && disabled) {\n // When disableAllowed is false, ignore disable comments — still a violation\n violations.push({ line, column, context, hasDisableComment: false });\n } else {\n violations.push({ line, column, context, hasDisableComment: disabled });\n }\n }\n}\n\n/**\n * Get a description of where the destructuring pattern appears.\n */\nfunction getDestructureContext(node: ts.Node): string {\n const parent = node.parent;\n if (ts.isParameter(parent)) {\n return 'function parameter destructuring';\n }\n if (ts.isVariableDeclaration(parent)) {\n const grandparent = parent.parent;\n if (grandparent && ts.isVariableDeclarationList(grandparent)) {\n const forOfParent = grandparent.parent;\n if (forOfParent && ts.isForOfStatement(forOfParent)) {\n return ts.isObjectBindingPattern(node)\n ? 'object destructuring in for-of loop'\n : 'array destructuring in for-of loop';\n }\n }\n return ts.isObjectBindingPattern(node)\n ? 'object destructuring in variable declaration'\n : 'array destructuring in variable declaration';\n }\n return ts.isObjectBindingPattern(node)\n ? 'object destructuring'\n : 'array destructuring';\n}\n\n/**\n * NEW_AND_MODIFIED_CODE mode: Flag violations on changed lines in diff hunks.\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 | undefined,\n disableAllowed: boolean,\n allowedPaths: string[]\n): DestructureViolation[] {\n const violations: DestructureViolation[] = [];\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 = findDestructuringInFile(file, workspaceRoot, disableAllowed, allowedPaths);\n\n for (const v of allViolations) {\n if (disableAllowed && 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 context: v.context,\n });\n }\n }\n\n return violations;\n}\n\n/**\n * NEW_AND_MODIFIED_FILES mode: Flag ALL violations in files that were modified.\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[]): DestructureViolation[] {\n const violations: DestructureViolation[] = [];\n\n for (const file of changedFiles) {\n const allViolations = findDestructuringInFile(file, workspaceRoot, disableAllowed, allowedPaths);\n\n for (const v of allViolations) {\n if (disableAllowed && v.hasDisableComment) continue;\n\n violations.push({\n file,\n line: v.line,\n column: v.column,\n context: v.context,\n });\n }\n }\n\n return violations;\n}\n\n/**\n * Report violations to console.\n */\n// webpieces-disable max-lines-new-methods -- Console output with examples and escape hatch information\nfunction reportViolations(violations: DestructureViolation[], mode: ModifiedCodeMode, disableAllowed: boolean): void {\n console.error('');\n console.error('\\u274c Destructuring patterns found! Use explicit property access instead.');\n console.error('');\n console.error('\\ud83d\\udcda Avoiding destructuring improves code traceability:');\n console.error('');\n console.error(' BAD: const { name, age } = user;');\n console.error(' GOOD: const name = user.name;');\n console.error(' const age = user.age;');\n console.error('');\n console.error(' BAD: function process({ x, y }: Point) { }');\n console.error(' GOOD: function process(point: Point) { point.x; point.y; }');\n console.error('');\n\n for (const v of violations) {\n console.error(` \\u274c ${v.file}:${v.line}:${v.column}`);\n console.error(` ${v.context}`);\n }\n console.error('');\n\n console.error(' Allowed exceptions:');\n console.error(' - const [a, b] = await Promise.all([...])');\n console.error(' - for (const [key, value] of Object.entries(obj))');\n console.error(' - const { extracted, ...rest } = obj (rest operator separation)');\n console.error('');\n\n if (disableAllowed) {\n console.error(' Escape hatch (use sparingly):');\n console.error(' // webpieces-disable no-destructure -- [your reason]');\n } else {\n console.error(' Escape hatch: DISABLED (disableAllowed: false)');\n console.error(' Disable comments are ignored. Fix the destructuring directly.');\n }\n console.error(' Whole-tree exemption (e.g. React/React Native): add a glob to no-destructure.allowedPaths in webpieces.config.json');\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 resolveNoDestructureMode(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-destructure validation (${skip.reason})`);\n console.log('');\n return 'OFF';\n }\n return normalMode;\n}\n\nasync function runValidatorImpl(\n options: NoDestructureConfig,\n workspaceRoot: string\n): Promise<ExecutorResult> {\n const mode: ModifiedCodeMode = resolveNoDestructureMode(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\\u23ed\\ufe0f Skipping no-destructure validation (mode: OFF)');\n console.log('');\n return { success: true };\n }\n\n console.log('\\n\\ud83d\\udccf Validating No Destructuring\\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\\u23ed\\ufe0f Skipping no-destructure 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('\\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: DestructureViolation[] = [];\n\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('\\u2705 No destructuring patterns found');\n return { success: true };\n }\n\n reportViolations(violations, mode, disableAllowed);\n\n return { success: false };\n}\n\n@injectable(bindingScopeValues.Singleton)\nexport class NoDestructureValidator extends CodeValidator<NoDestructureConfig> {\n constructor(config: NoDestructureConfig) {\n super(config, 'no-destructure');\n }\n\n async run(workspaceRoot: string): Promise<ExecutorResult> {\n return runValidatorImpl(this.config, workspaceRoot);\n }\n}\n"]}