bend-lint 0.2.0 → 0.2.1

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 CHANGED
@@ -128,7 +128,7 @@ A rule is a file in `bend-lint-rules/`. It imports bend-lint's rule API from Ben
128
128
 
129
129
  ```
130
130
  import Base
131
- import bend-lint-api@0.2.0.0/linter/lint.bend as Lint
131
+ import bend-lint-api@0.2.1.0/linter/lint.bend as Lint
132
132
 
133
133
  def rule() -> Lint.Rule:
134
134
  ...
package/package.json CHANGED
@@ -1,8 +1,12 @@
1
1
  {
2
2
  "name": "bend-lint",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Diagnostics for Bend 2 from rules outside the language: source text, and the checker's types",
5
5
  "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/MattCozendey/bend-lint.git"
9
+ },
6
10
  "bin": {
7
11
  "bend-lint": "src/linter/seam.ts"
8
12
  },
@@ -11,7 +15,7 @@
11
15
  "bun": "1.4.4"
12
16
  },
13
17
  "bendRelease": "bendlang/bend/v2.0.39",
14
- "bendWindows": "MattCozendey/bend/126afd6cbded7e392302b41d2504083ad26b40c1",
18
+ "bendWindows": "MattCozendey/bend/676492b71a3020e2be5630b6ed3afbe0ccc06da8",
15
19
  "scripts": {
16
20
  "postinstall": "bun ./src/linter/seam.ts postinstall"
17
21
  }
@@ -1,6 +1,6 @@
1
1
  import Base
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
2
+ import bend-lint-api@0.2.1.0/shared/lists.bend as Lists
3
+ import bend-lint-api@0.2.1.0/shared/strings.bend as Strings
4
4
 
5
5
  # Types
6
6
  # =====
@@ -1,6 +1,6 @@
1
1
  import Base
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
2
+ import bend-lint-api@0.2.1.0/shared/names.bend as Names
3
+ import bend-lint-api@0.2.1.0/shared/strings.bend as Strings
4
4
 
5
5
  # Types
6
6
  # =====
@@ -2,13 +2,13 @@
2
2
  import Base
3
3
  import ../files/main.bend as Files
4
4
  import ../json/main.bend as Json
5
- import bend-lint-api@0.2.0.0/shared/lists.bend as Lists
6
- import bend-lint-api@0.2.0.0/shared/names.bend as Names
7
- import bend-lint-api@0.2.0.0/shared/sets.bend as Sets
5
+ import bend-lint-api@0.2.1.0/shared/lists.bend as Lists
6
+ import bend-lint-api@0.2.1.0/shared/names.bend as Names
7
+ import bend-lint-api@0.2.1.0/shared/sets.bend as Sets
8
8
  import ../text/main.bend as Text
9
9
  import ./directives.bend as Directives
10
10
  import ./fixes.bend as Fixes
11
- import bend-lint-api@0.2.0.0/linter/lint.bend as Lint
11
+ import bend-lint-api@0.2.1.0/linter/lint.bend as Lint
12
12
 
13
13
  # Errors
14
14
  # ======
@@ -1,9 +1,9 @@
1
1
  import Base
2
- import bend-lint-api@0.2.0.0/shared/lists.bend as Lists
3
- import bend-lint-api@0.2.0.0/shared/names.bend as Names
4
- import bend-lint-api@0.2.0.0/shared/strings.bend as Strings
2
+ import bend-lint-api@0.2.1.0/shared/lists.bend as Lists
3
+ import bend-lint-api@0.2.1.0/shared/names.bend as Names
4
+ import bend-lint-api@0.2.1.0/shared/strings.bend as Strings
5
5
  import ../text/main.bend as Text
6
- import bend-lint-api@0.2.0.0/linter/lint.bend as Lint
6
+ import bend-lint-api@0.2.1.0/linter/lint.bend as Lint
7
7
 
8
8
  # Scanning
9
9
  # ========
@@ -1,12 +1,12 @@
1
1
  # The fixes a run makes with `--fix-dangerously`: no fix is proven to keep the program until Bend's checker is Bend.
2
2
  import Base
3
3
  import ../files/main.bend as Files
4
- import bend-lint-api@0.2.0.0/shared/lists.bend as Lists
5
- import bend-lint-api@0.2.0.0/shared/names.bend as Names
6
- import bend-lint-api@0.2.0.0/shared/sets.bend as Sets
7
- import bend-lint-api@0.2.0.0/shared/strings.bend as Strings
4
+ import bend-lint-api@0.2.1.0/shared/lists.bend as Lists
5
+ import bend-lint-api@0.2.1.0/shared/names.bend as Names
6
+ import bend-lint-api@0.2.1.0/shared/sets.bend as Sets
7
+ import bend-lint-api@0.2.1.0/shared/strings.bend as Strings
8
8
  import ../text/main.bend as Text
9
- import bend-lint-api@0.2.0.0/linter/lint.bend as Lint
9
+ import bend-lint-api@0.2.1.0/linter/lint.bend as Lint
10
10
 
11
11
  # Types
12
12
  # =====
@@ -18,9 +18,7 @@ import type { Result } from "./result.ts";
18
18
  import {
19
19
  getErrorMessageFromUnknown,
20
20
  tryGet,
21
- tryGetJson,
22
21
  tryGetUrlFromFolderPathOrUrl,
23
- tryWriteJsonAtomically,
24
22
  writeNewFileAtomically,
25
23
  } from "./utils.ts";
26
24
 
@@ -100,33 +98,19 @@ export const getClang = (): string | undefined => {
100
98
  // The line bend-lint prints when the `bend` on PATH is another version than
101
99
  // the Bend in the bend2 folder `dir`, which bend-lint checks and builds with;
102
100
  // undefined if it is the same, or if none is installed or `bend version` names
103
- // no version. `bend version` takes a third of a second, so its answer is kept
104
- // by the path, size and time of the `bend` that gave it. It runs by name:
105
- // Windows runs a bend.cmd only that way.
101
+ // no version. It asks `bend version` on each run, as the `bend` on PATH can be
102
+ // a script that runs a checkout, whose version changes while the script does
103
+ // not. It runs by name: Windows runs a bend.cmd only that way.
106
104
  export const getBendVersionNote = async (dir: URL): Promise<string | undefined> => {
107
- const bend = Bun.which("bend");
108
- const stat = bend === null ? undefined : nodeFs.statSync(bend, { throwIfNoEntry: false });
109
- if (bend === null || stat === undefined) {
110
- return undefined;
111
- }
112
- const key = [bend, stat.size, stat.mtimeMs].join(" ");
113
- const file = url.fileURLToPath(new URL("installed-bend.json", getBendLintCacheDir()));
114
- const kept = tryGetJson(file) as { key?: string; version?: string } | undefined;
115
- const version =
116
- kept?.key === key
117
- ? kept.version
118
- : await new Promise<string | undefined>((resolve) => {
119
- const resolveVersion = (e: Error | null, stdout: string): void =>
120
- resolve(/^bend (\d+\.\d+\.\d+)(?:\r?\n|$)/.exec(e === null ? stdout : "")?.[1]);
121
- try {
122
- execFile("bend", ["version"], { encoding: "utf8", timeout: 10_000 }, resolveVersion);
123
- } catch (e) {
124
- resolveVersion(e as Error, "");
125
- }
126
- });
127
- if (kept?.key !== key) {
128
- tryWriteJsonAtomically(file, { key, version });
129
- }
105
+ const version = await new Promise<string | undefined>((resolve) => {
106
+ const resolveVersion = (e: Error | null, stdout: string): void =>
107
+ resolve(/^bend (\d+\.\d+\.\d+)(?:\r?\n|$)/.exec(e === null ? stdout : "")?.[1]);
108
+ try {
109
+ execFile("bend", ["version"], { encoding: "utf8", timeout: 10_000 }, resolveVersion);
110
+ } catch (e) {
111
+ resolveVersion(e as Error, "");
112
+ }
113
+ });
130
114
  const pinned = /^const VERSION = "([^"]+)";$/m.exec(
131
115
  nodeFs.readFileSync(new URL("main.ts", dir), "utf8"),
132
116
  )?.[1];
@@ -1,9 +1,9 @@
1
1
  # Edits to texts, and places in them: the edits to make, spans that must not touch, and the lines and columns of
2
2
  # offsets.
3
3
  import Base
4
- import bend-lint-api@0.2.0.0/shared/lists.bend as Lists
5
- import bend-lint-api@0.2.0.0/shared/names.bend as Names
6
- import bend-lint-api@0.2.0.0/shared/strings.bend as Strings
4
+ import bend-lint-api@0.2.1.0/shared/lists.bend as Lists
5
+ import bend-lint-api@0.2.1.0/shared/names.bend as Names
6
+ import bend-lint-api@0.2.1.0/shared/strings.bend as Strings
7
7
 
8
8
  # Edits
9
9
  # =====