pi-lens 2.0.25 → 2.0.26

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/index.ts CHANGED
@@ -662,6 +662,26 @@ export default function (pi: ExtensionAPI) {
662
662
  type: "skip",
663
663
  note: "Renaming requires understanding all variable scopes.",
664
664
  },
665
+ "no-process-env": {
666
+ type: "skip",
667
+ note: "Using process.env directly makes code untestable. Use DI or a config module.",
668
+ },
669
+ "no-param-reassign": {
670
+ type: "agent",
671
+ note: "Create a new variable instead of reassigning the parameter.",
672
+ },
673
+ "no-single-char-var": {
674
+ type: "skip",
675
+ note: "Renaming requires understanding the variable's purpose.",
676
+ },
677
+ "switch-without-default": {
678
+ type: "agent",
679
+ note: "Add a default case to handle unexpected values.",
680
+ },
681
+ "no-architecture-violation": {
682
+ type: "skip",
683
+ note: "Layer boundary violations require architectural decisions.",
684
+ },
665
685
  };
666
686
 
667
687
  // Derived from RULE_ACTIONS — used to suppress architectural rules from inline hard stops.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-lens",
3
- "version": "2.0.25",
3
+ "version": "2.0.26",
4
4
  "description": "Real-time code quality feedback for pi — TypeScript LSP, Biome, ast-grep, Ruff, complexity metrics, duplicate detection. Includes automated fix loop (/lens-booboo-fix) and interactive architectural refactoring (/lens-booboo-refactor) with browser-based interviews.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -0,0 +1,15 @@
1
+ id: no-architecture-violation
2
+ language: TypeScript
3
+ message: "Forbidden import — layer boundary violation: importing from database/model layer"
4
+ severity: error
5
+ note: |
6
+ This import crosses an architectural layer boundary.
7
+ Use dependency injection or a shared types/interfaces module instead.
8
+
9
+ BAD: import { User } from '../models/user';
10
+ GOOD: import { User } from '../types/user';
11
+ rule:
12
+ pattern: import { $$$ } from "$PATH"
13
+ constraints:
14
+ PATH:
15
+ regex: ".*models.*|.*database.*|.*prisma.*"
@@ -0,0 +1,16 @@
1
+ id: no-param-reassign
2
+ language: TypeScript
3
+ message: "Do not reassign function parameters — create a new variable instead"
4
+ severity: warning
5
+ note: |
6
+ Reassigning parameters makes code harder to debug and reason about.
7
+ It can cause unexpected side effects when the caller's reference changes.
8
+ Create a new variable with a descriptive name instead.
9
+
10
+ BAD: function update(user) { user = { ...user, active: true }; }
11
+ GOOD: function update(user) { const updated = { ...user, active: true }; }
12
+ rule:
13
+ pattern: |
14
+ function $FUNC($PARAM, $$$) {
15
+ $PARAM = $VALUE
16
+ }
@@ -0,0 +1,18 @@
1
+ id: no-process-env
2
+ language: TypeScript
3
+ message: "Do not access process.env directly — use dependency injection or a config module"
4
+ severity: error
5
+ note: |
6
+ Direct process.env access makes code untestable and tightly coupled to the
7
+ runtime environment. Use a configuration service or DI container instead.
8
+
9
+ BAD: const dbUrl = process.env.DATABASE_URL;
10
+ GOOD: constructor(private config: ConfigService) {}
11
+ const dbUrl = this.config.get('DATABASE_URL');
12
+
13
+ Grade 2.0 — critical architectural violation for testability.
14
+ rule:
15
+ any:
16
+ - pattern: process.env.$KEY
17
+ - pattern: process.env[$KEY]
18
+ - pattern: Deno.env.get($KEY)
@@ -0,0 +1,12 @@
1
+ id: no-single-char-var
2
+ language: TypeScript
3
+ message: "Avoid single-character variable names — use descriptive names"
4
+ severity: info
5
+ note: |
6
+ Single-character variable names reduce readability.
7
+ Exception: loop counters (i, j, k) in short loops are acceptable.
8
+ rule:
9
+ pattern: const $VAR = $VALUE
10
+ constraints:
11
+ VAR:
12
+ regex: "^[a-z]$"
@@ -0,0 +1,12 @@
1
+ id: switch-without-default
2
+ language: TypeScript
3
+ message: "Switch statement is missing a default case"
4
+ severity: warning
5
+ note: |
6
+ Every switch should have a default case. Without it, new enum values won't be caught at runtime.
7
+ rule:
8
+ all:
9
+ - pattern: switch ($EXPR) { $$$CASES }
10
+ - not:
11
+ has:
12
+ pattern: "default: $$$"