bend-lint 0.1.0 → 0.2.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 +23 -10
- package/package.json +4 -4
- package/src/files/main.bend +2 -2
- package/src/json/main.bend +2 -2
- package/src/linter/cli.bend +386 -118
- package/src/linter/defaults.json +1 -0
- package/src/linter/directives.bend +4 -4
- package/src/linter/fixes.bend +73 -8
- package/src/linter/seam.ts +215 -46
- package/src/shared/utils.ts +2 -0
- package/src/text/main.bend +3 -3
package/README.md
CHANGED
|
@@ -10,8 +10,8 @@ Install bend-lint in each project, never globally:
|
|
|
10
10
|
bun add -D --trust bend-lint
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
The install writes `bend-lint.json`
|
|
14
|
-
|
|
13
|
+
The install writes a `bend-lint.json` that turns on the formatter, downloads Bend, and builds your
|
|
14
|
+
rules. Without `--trust`, Bun skips that: run `bunx bend-lint init`, then `bunx bend-lint prepare`.
|
|
15
15
|
|
|
16
16
|
> **Why per project:** a Bend limitation. Bend imports a file only by a relative path of plain names
|
|
17
17
|
> (or from BendHub), so bend-lint can reach your rules only inside your project. bend-lint refuses
|
|
@@ -29,7 +29,7 @@ and says so on each run.
|
|
|
29
29
|
|
|
30
30
|
```sh
|
|
31
31
|
bunx bend-lint [<file or glob>...] [--fix | --fix-dangerously] [--show-suppressed] [--json]
|
|
32
|
-
[--jobs <number or max>]
|
|
32
|
+
[--jobs <number or max>] [--overlays] [--report <file>]
|
|
33
33
|
```
|
|
34
34
|
|
|
35
35
|
| Flag | Does |
|
|
@@ -39,16 +39,29 @@ bunx bend-lint [<file or glob>...] [--fix | --fix-dangerously] [--show-suppresse
|
|
|
39
39
|
| `--show-suppressed` | also prints the findings that a directive covers |
|
|
40
40
|
| `--json` | prints one JSON object on stdout, with every fix. The summary goes to stderr |
|
|
41
41
|
| `--jobs` | how many files to lint at once: a number, or `max` (default: half the CPU threads) |
|
|
42
|
+
| `--overlays` | reads a JSON object of paths to texts on stdin, which stand for those files |
|
|
43
|
+
| `--report` | writes a JSON report to the file: versions, backend, build, caches and timings |
|
|
42
44
|
|
|
43
45
|
- With no files, it lints the `.bend` files in the folder you run it in: those git lists (so none
|
|
44
46
|
that `.gitignore` lists), and none in `node_modules` or a hidden folder.
|
|
45
47
|
- Quote globs, and use `/` in paths.
|
|
48
|
+
- With `--overlays`, the checker and the rules read each overlay in place of its file, also when a
|
|
49
|
+
file imports it, and the file need not be on disk; name such a file to lint it. An editor gives
|
|
50
|
+
its unsaved buffers so. It does not go with `--fix-dangerously`, which writes files on disk.
|
|
46
51
|
- bend-lint builds your rules on its first run (about 40 s), and keeps the build until a rule or
|
|
47
|
-
Bend changes.
|
|
52
|
+
Bend changes. `bunx bend-lint prepare` builds them, and lints nothing: an editor runs it at start.
|
|
53
|
+
If each rule you turn on is one of bend-lint's own, from `bend-lint-rules`, the build holds all of
|
|
54
|
+
them, so you can turn them on and off without a new build.
|
|
48
55
|
- A fix that touches an earlier fix's edits waits for the next run.
|
|
49
56
|
- bend-lint runs at low priority: a long run slows down, not your computer.
|
|
50
57
|
- bend-lint does not report Bend's own errors: `bend <file> --check-only` does. If Bend's check of a
|
|
51
58
|
file fails, the rules that need its types do not run on it, and bend-lint names them on stderr.
|
|
59
|
+
- With `--json`, a finding of one of bend-lint's own rules has `docs`: the link to its rule's file,
|
|
60
|
+
whose header explains it.
|
|
61
|
+
- With `--json`, `skipped` gives each file that rules did not run on: its `path`, the `reason`
|
|
62
|
+
(`unloaded`, `unchecked` or `unentered`), the `rules`, the `entry` (for `unentered`), and the
|
|
63
|
+
`message` stderr gets. An error that ends the run prints `{"ok": false, "errors": [...]}` instead,
|
|
64
|
+
each error with its `message`, and the `path` of the file it is about, if one.
|
|
52
65
|
- Exit code: 0 no errors (warnings do not count), 1 an error, 2 a usage or config error.
|
|
53
66
|
- The downloaded Bend, builds and cached checks go to `~/.cache/bend-lint/`. You can delete it at
|
|
54
67
|
any time.
|
|
@@ -65,18 +78,18 @@ bend-lint reads the nearest `bend-lint.json` above the folder it runs in.
|
|
|
65
78
|
"packages": { "jane-rules": "1.0.0.0" },
|
|
66
79
|
"rules": {
|
|
67
80
|
"format": { "tabWidth": 4, "severity": "hint" },
|
|
68
|
-
"style/
|
|
69
|
-
"style/
|
|
70
|
-
"jane-rules/
|
|
81
|
+
"style/no_foo": "error",
|
|
82
|
+
"style/no_bar": "off",
|
|
83
|
+
"jane-rules/no_baz": "warning"
|
|
71
84
|
}
|
|
72
85
|
}
|
|
73
86
|
```
|
|
74
87
|
|
|
75
88
|
- `rules`: each rule to run, by its id: its path in `bend-lint-rules/`, without `.bend`
|
|
76
|
-
(`bend-lint-rules/style/
|
|
89
|
+
(`bend-lint-rules/style/no_foo.bend` is `style/no_foo`). Give it `"off"`, a severity (`error`,
|
|
77
90
|
`warning`, `information`, `hint`), or an object of its options and a `"severity"`.
|
|
78
91
|
- `packages`: BendHub packages of rules, names to versions. A rule whose id starts with a package's
|
|
79
|
-
name, then `/`, is that package's file at the rest of the id: `jane-rules/
|
|
92
|
+
name, then `/`, is that package's file at the rest of the id: `jane-rules/no_baz` is `no_baz.bend`
|
|
80
93
|
in `jane-rules@1.0.0.0`.
|
|
81
94
|
- `entries`: your program's entry files, as paths from the folder of `bend-lint.json`. A rule that
|
|
82
95
|
reads the whole program ("this def is never used") then sees it, even when you lint one file.
|
|
@@ -115,7 +128,7 @@ A rule is a file in `bend-lint-rules/`. It imports bend-lint's rule API from Ben
|
|
|
115
128
|
|
|
116
129
|
```
|
|
117
130
|
import Base
|
|
118
|
-
import bend-lint-api@0.
|
|
131
|
+
import bend-lint-api@0.2.0.0/linter/lint.bend as Lint
|
|
119
132
|
|
|
120
133
|
def rule() -> Lint.Rule:
|
|
121
134
|
...
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bend-lint",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Diagnostics for Bend 2 from rules outside the language: source text, and the checker's types",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
},
|
|
9
9
|
"type": "module",
|
|
10
10
|
"engines": {
|
|
11
|
-
"bun": "1.4.
|
|
11
|
+
"bun": "1.4.4"
|
|
12
12
|
},
|
|
13
|
-
"bendRelease": "bendlang/bend/v2.0.
|
|
14
|
-
"bendWindows": "MattCozendey/bend/
|
|
13
|
+
"bendRelease": "bendlang/bend/v2.0.39",
|
|
14
|
+
"bendWindows": "MattCozendey/bend/126afd6cbded7e392302b41d2504083ad26b40c1",
|
|
15
15
|
"scripts": {
|
|
16
16
|
"postinstall": "bun ./src/linter/seam.ts postinstall"
|
|
17
17
|
}
|
package/src/files/main.bend
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Base
|
|
2
|
-
import bend-lint-api@0.
|
|
3
|
-
import bend-lint-api@0.
|
|
2
|
+
import bend-lint-api@0.2.0.0/shared/lists.bend as Lists
|
|
3
|
+
import bend-lint-api@0.2.0.0/shared/strings.bend as Strings
|
|
4
4
|
|
|
5
5
|
# Types
|
|
6
6
|
# =====
|
package/src/json/main.bend
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Base
|
|
2
|
-
import bend-lint-api@0.
|
|
3
|
-
import bend-lint-api@0.
|
|
2
|
+
import bend-lint-api@0.2.0.0/shared/names.bend as Names
|
|
3
|
+
import bend-lint-api@0.2.0.0/shared/strings.bend as Strings
|
|
4
4
|
|
|
5
5
|
# Types
|
|
6
6
|
# =====
|