@pragmatiks/lint 0.9.0 → 0.10.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## js-v0.10.0 (2026-11-08)
4
+
5
+ ### Features
6
+
7
+ - **rules**: add Python shape rules from the PRA-703 reviews (PRA-733)
8
+
3
9
  ## js-v0.9.0 (2026-11-08)
4
10
 
5
11
  ### Features
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pragmatiks/lint",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "Pragmatiks engineering principles eslint config and bundled semgrep rules.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -0,0 +1,14 @@
1
+ rules:
2
+ - id: pra-exists-gated-read
3
+ patterns:
4
+ - pattern: $READ if $PATH.exists() else None
5
+ - metavariable-pattern:
6
+ metavariable: $READ
7
+ pattern-either:
8
+ - pattern: <... $FILE.read_text(...) ...>
9
+ - pattern: <... $FILE.read_bytes(...) ...>
10
+ - pattern: <... $FILE.open(...) ...>
11
+ - pattern: <... open(...) ...>
12
+ message: "principle #9 an existence check folded into a read ternary hides the absent case. Return None in a guard clause first, then read."
13
+ severity: WARNING
14
+ languages: [python]
@@ -0,0 +1,14 @@
1
+ rules:
2
+ - id: pra-if-chain-else-continue
3
+ pattern: |
4
+ if $FIRST:
5
+ $NAME = $FIRST_VALUE
6
+ elif $SECOND:
7
+ $NAME = $SECOND_VALUE
8
+ else:
9
+ continue
10
+ message: "principle #9 an if/elif chain that assigns one name in every branch and ends in else: continue hides a value lookup in the loop body. Move the chain into a helper that returns the value or None, and continue on None."
11
+ severity: WARNING
12
+ languages: [python]
13
+ metadata:
14
+ note: "The pattern matches the last two assigning branches, so a chain of any length is reported once at its final elif."
@@ -0,0 +1,6 @@
1
+ rules:
2
+ - id: pra-multi-underscore-unpack
3
+ pattern: "..., _, ..., _, ... = $VALUE[$KEY]"
4
+ message: "principle #9 unpacking a subscript into two or more _ placeholders hides the shape of the record. Read the parts by name: a named record, a dataclass or attribute access."
5
+ severity: WARNING
6
+ languages: [python]
@@ -0,0 +1,23 @@
1
+ rules:
2
+ - id: pra-optional-tuple-index
3
+ pattern-either:
4
+ - pattern: $FIRST, $SECOND = $CALL(...) or ($FIRST_DEFAULT, $SECOND_DEFAULT)
5
+ - patterns:
6
+ - pattern-either:
7
+ - pattern: $TUPLE is None or <... $TUPLE[$INDEX] ...>
8
+ - pattern: $TUPLE is not None and <... $TUPLE[$INDEX] ...>
9
+ - patterns:
10
+ - pattern-inside: |
11
+ def $FUNCTION(...):
12
+ ...
13
+ <... $TUPLE[$FIRST_INDEX] if $TUPLE else $FIRST_DEFAULT ...>
14
+ ...
15
+ <... $TUPLE[$SECOND_INDEX] if $TUPLE else $SECOND_DEFAULT ...>
16
+ ...
17
+ - pattern: $TUPLE[$INDEX] if $TUPLE else $DEFAULT
18
+ - metavariable-regex:
19
+ metavariable: $INDEX
20
+ regex: '^-?\d+$'
21
+ message: "principle #9 indexing an optional tuple under a None test mixes the absent case with positional access. Return on None in a guard clause, then unpack once into named locals."
22
+ severity: WARNING
23
+ languages: [python]
@@ -0,0 +1,15 @@
1
+ rules:
2
+ - id: pra-parsed-result-index
3
+ patterns:
4
+ - pattern-either:
5
+ - pattern: $FUNCTION(...)[$INDEX]
6
+ - pattern: $OBJECT.$FUNCTION(...)[$INDEX]
7
+ - metavariable-regex:
8
+ metavariable: $FUNCTION
9
+ regex: '^(parse|extract)_\w+$'
10
+ - metavariable-regex:
11
+ metavariable: $INDEX
12
+ regex: '^-?\d+$'
13
+ message: "principle #9 a literal index into a parse or extract result hides which part is meant. Unpack the result into named locals, or return a named record."
14
+ severity: WARNING
15
+ languages: [python]
@@ -0,0 +1,16 @@
1
+ rules:
2
+ - id: pra-pure-call-result-dropped
3
+ patterns:
4
+ - pattern-regex: '(?m)^[ \t]*(?:await[ \t]+)?(?:(?:self|cls)\.)?(?:compute|build|derive|format|parse|extract)_\w+\((?![^\n]*\)[ \t]*[.\[])(?:[^\n]*[(),])?[ \t]*$'
5
+ - pattern-not-inside: $CALL(...)
6
+ - pattern-not-inside: "[...]"
7
+ - pattern-not-inside: "{...}"
8
+ - pattern-not-inside: "(...)"
9
+ - pattern-not-inside: '"..."'
10
+ - pattern-not-inside: $TARGET = $VALUE
11
+ - pattern-not-inside: "$TARGET: $TYPE = $VALUE"
12
+ message: "principle #7 a compute, build, derive, format, parse or extract function is pure, so a call whose result is dropped does nothing. Use the result, or call the function that performs the side effect."
13
+ severity: WARNING
14
+ languages: [python]
15
+ metadata:
16
+ note: "Matches a call statement that opens its own line, so a call used as an argument, element, assignment value or chained receiver is not flagged. Principle #7 makes these prefixes pure; a result consumed only to raise on bad input belongs in a validate function that says so."