@konvert7/klint 1.3.0 → 1.4.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/README.md +58 -39
- package/klint.schema.json +1434 -607
- package/klint.schema.yaml +1100 -505
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -53,11 +53,12 @@ Then create `klint.yaml` in your project root.
|
|
|
53
53
|
include: ["src", "!**/node_modules/**"]
|
|
54
54
|
|
|
55
55
|
rules:
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
core:
|
|
57
|
+
no-async-predicate: error
|
|
58
|
+
no-unguarded-json-parse: error
|
|
59
|
+
no-sync-in-async:
|
|
60
|
+
severity: error
|
|
61
|
+
include: ["src/hooks/**"]
|
|
61
62
|
|
|
62
63
|
arch:
|
|
63
64
|
layers:
|
|
@@ -121,6 +122,7 @@ Rules give agents room to move quickly because the unsafe moves are blocked stru
|
|
|
121
122
|
```sh
|
|
122
123
|
klint [--config <dir>] [--fix] [--json] [--hook]
|
|
123
124
|
klint stats [--config <dir>]
|
|
125
|
+
klint migrate [--config <dir>] [--check]
|
|
124
126
|
klint install-skill [--agents <list>] [--symlink | --copy] [--force]
|
|
125
127
|
```
|
|
126
128
|
|
|
@@ -130,6 +132,8 @@ klint install-skill [--agents <list>] [--symlink | --copy] [--force]
|
|
|
130
132
|
| `--fix` | Apply auto-fixes for fixable violations in-place |
|
|
131
133
|
| `--json` | Emit structured JSON to stdout for agents and CI |
|
|
132
134
|
| `--hook` | Count this run as an agent hook run in `klint stats` |
|
|
135
|
+
| `migrate` | Rewrite a v1 config to the v2 rule groups in place, keeping comments and blank lines |
|
|
136
|
+
| `migrate --check` | Exit 1 when the config is v1 and 0 when it is v2; never writes |
|
|
133
137
|
|
|
134
138
|
`klint install-skill` installs the bundled rule-authoring skill for agent environments:
|
|
135
139
|
|
|
@@ -224,15 +228,17 @@ The npm package needs Node.js 18+ and no longer installs `typescript`, `zod`, `y
|
|
|
224
228
|
# yaml-language-server: $schema=./klint.schema.yaml
|
|
225
229
|
|
|
226
230
|
include: ["src", "!**/node_modules/**"]
|
|
227
|
-
plugins: [sonar]
|
|
228
231
|
|
|
229
232
|
rules:
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
233
|
+
recommended: true
|
|
234
|
+
core:
|
|
235
|
+
no-unguarded-json-parse: error
|
|
236
|
+
no-async-predicate: error
|
|
237
|
+
no-sync-in-async:
|
|
238
|
+
severity: error
|
|
239
|
+
include: ["src/server/**"]
|
|
240
|
+
sonar:
|
|
241
|
+
prefer-string-replaceall: warn
|
|
236
242
|
|
|
237
243
|
arch:
|
|
238
244
|
layers:
|
|
@@ -247,9 +253,15 @@ arch:
|
|
|
247
253
|
|
|
248
254
|
`include` selects source files to lint. Patterns support `**` globs and `!` negation.
|
|
249
255
|
|
|
250
|
-
`
|
|
256
|
+
`rules` has three parts. Each rule is `"error"`, `"warn"`, `"off"`, or an options object with `severity` and/or `include`.
|
|
257
|
+
|
|
258
|
+
- `recommended: true` enables the six sonar rules at `error`.
|
|
259
|
+
- `core` holds the built-in rules, by name.
|
|
260
|
+
- `sonar` holds the sonar rules, by name without the `sonar/` prefix. An entry here overrides `recommended`.
|
|
251
261
|
|
|
252
|
-
|
|
262
|
+
The rule ids in the output stay `sonar/…`, for example `sonar/prefer-at`.
|
|
263
|
+
|
|
264
|
+
**v1 still works.** The flat map under `rules` (with `sonar/` prefixes) and `plugins: [sonar]` are still read. A v1 config gets one `klint/config` warning. `klint migrate` or `klint --fix` upgrades it in place and keeps comments, blank lines and key order. It refuses, naming the line, when it cannot do that safely: YAML anchors, aliases, tags, a flow-map `rules`, duplicate keys, or a config that mixes v1 and v2 keys. A mixed config is read as v2 and the v1 entries are ignored, with one warning.
|
|
253
265
|
|
|
254
266
|
`arch` declares architecture constraints without writing a custom rule.
|
|
255
267
|
|
|
@@ -508,7 +520,7 @@ An ignored line still counts in the density denominator — it is a physical lin
|
|
|
508
520
|
|
|
509
521
|
### Language Support
|
|
510
522
|
|
|
511
|
-
klint scans TypeScript/JavaScript, Python, Swift, Rust, and C#. Every architecture rule is enforced from the same `klint.yaml`, but what a rule can *see* depends on what the language actually has.
|
|
523
|
+
klint scans TypeScript/JavaScript (`.ts`, `.tsx`, `.mts`, `.cts`, `.js`, `.jsx`, `.mjs`, `.cjs`), Python, Swift, Rust, and C#. Every architecture rule is enforced from the same `klint.yaml`, but what a rule can *see* depends on what the language actually has.
|
|
512
524
|
|
|
513
525
|
| | TypeScript / JavaScript | Python | Swift | Rust | C# |
|
|
514
526
|
|---|---|---|---|---|---|
|
|
@@ -744,21 +756,23 @@ Rules that needed TypeScript's type checker were removed in 1.0; see [Upgrading
|
|
|
744
756
|
|
|
745
757
|
```yaml
|
|
746
758
|
rules:
|
|
747
|
-
|
|
748
|
-
|
|
759
|
+
core:
|
|
760
|
+
blank-line-before-control-flow: error
|
|
761
|
+
blank-line-after-block: warn
|
|
749
762
|
```
|
|
750
763
|
|
|
751
764
|
```yaml
|
|
752
765
|
rules:
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
766
|
+
core:
|
|
767
|
+
blank-line-before-control-flow:
|
|
768
|
+
severity: error
|
|
769
|
+
include: ["src/**", "!src/generated/**"]
|
|
770
|
+
statements: [if, for, while, switch, try, return, guard, loop, with]
|
|
771
|
+
allowSetup: true
|
|
772
|
+
blank-line-after-block:
|
|
773
|
+
severity: warn
|
|
774
|
+
include: ["src/**"]
|
|
775
|
+
statements: [if, for, while, switch, try, guard, loop, with]
|
|
762
776
|
```
|
|
763
777
|
|
|
764
778
|
- `statements` lists the statement kinds a rule targets. The default is every kind the rule supports. `statements: []` turns the rule off. `match` is an alias of `switch`. `return` is valid only for `blank-line-before-control-flow`. An unknown keyword, or `return` on the after rule, produces one `klint/config` warning, and the remaining keywords still apply.
|
|
@@ -790,15 +804,17 @@ rules:
|
|
|
790
804
|
|
|
791
805
|
```yaml
|
|
792
806
|
rules:
|
|
793
|
-
|
|
807
|
+
core:
|
|
808
|
+
cognitive-complexity: error
|
|
794
809
|
```
|
|
795
810
|
|
|
796
811
|
```yaml
|
|
797
812
|
rules:
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
813
|
+
core:
|
|
814
|
+
cognitive-complexity:
|
|
815
|
+
severity: warn
|
|
816
|
+
include: ["src/**", "!src/generated/**"]
|
|
817
|
+
max: 14
|
|
802
818
|
```
|
|
803
819
|
|
|
804
820
|
- `max` is an integer of at least 1, default 15. A function is reported when its score is **greater than** `max`. Any other value (0, a negative number, a fraction, a string) gives one `klint/config` warning naming the rule and the value, and the rule uses 15.
|
|
@@ -834,6 +850,7 @@ It adds nothing for `try` itself, `return`, `throw`, recursion, Rust `?`, Python
|
|
|
834
850
|
- `??` counts as a boolean operator.
|
|
835
851
|
- A logical operator is scored unless its direct parent is the same operator, so `a && (b && c)` is 2, not 1.
|
|
836
852
|
- Recursion adds nothing.
|
|
853
|
+
- Biome 2.6.5 lowers the nesting level of the code after a plain `else` (an unbalanced decrement), so it can score such functions lower; klint keeps the nesting.
|
|
837
854
|
- A nested function (closure, lambda, arrow, local function) is scored and reported on its own. It starts at its enclosing nesting level plus one and does not add to the outer function.
|
|
838
855
|
|
|
839
856
|
**What counts as a function.** TypeScript/JavaScript: `function` declarations and expressions, arrow functions, methods (including getters and setters), generator functions. Python: `def` and `lambda`. Swift: `func`, `init`, `deinit`, closures, computed getters and setters. Rust: `fn` items and closures. C#: methods, constructors, destructors, local functions, lambdas, anonymous methods, property and indexer accessors, operators and conversion operators.
|
|
@@ -846,16 +863,18 @@ It adds nothing for `try` itself, `return`, `throw`, recursion, Rust `?`, Python
|
|
|
846
863
|
|
|
847
864
|
```yaml
|
|
848
865
|
rules:
|
|
849
|
-
|
|
866
|
+
core:
|
|
867
|
+
function-length: error
|
|
850
868
|
```
|
|
851
869
|
|
|
852
870
|
```yaml
|
|
853
871
|
rules:
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
872
|
+
core:
|
|
873
|
+
function-length:
|
|
874
|
+
severity: warn
|
|
875
|
+
include: ["src/**", "!src/generated/**"]
|
|
876
|
+
max: 40
|
|
877
|
+
skipBlankLines: true
|
|
859
878
|
```
|
|
860
879
|
|
|
861
880
|
- `max` is an integer of at least 1, default 50. A function is reported when its count is **greater than** `max`. Any other value (0, a negative number, a fraction, a string) gives one `klint/config` warning naming the rule and the value, and the rule uses 50.
|
|
@@ -868,9 +887,9 @@ rules:
|
|
|
868
887
|
|
|
869
888
|
**Not checked.** Bodyless declarations, and files with a syntax error.
|
|
870
889
|
|
|
871
|
-
##
|
|
890
|
+
## Sonar rules (`rules.sonar`)
|
|
872
891
|
|
|
873
|
-
|
|
892
|
+
`recommended: true` enables these rules. Override each one under `rules.sonar` by its name without the prefix.
|
|
874
893
|
|
|
875
894
|
| Rule | Description |
|
|
876
895
|
|------|-------------|
|