badness 0.1.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/LICENSE +21 -0
- package/README.md +51 -0
- package/bin/badness.js +82 -0
- package/package.json +40 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Johan Larsson
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# badness
|
|
2
|
+
|
|
3
|
+
[Badness](https://jolars.github.io/badness/) is an LSP, formatter, and linter
|
|
4
|
+
for LaTeX documents.
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
npm install -g badness
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
This installs the `badness` command globally. The package detects your platform
|
|
13
|
+
at install time and pulls in a prebuilt binary via npm's optional dependencies
|
|
14
|
+
--- no Rust toolchain or postinstall download required.
|
|
15
|
+
|
|
16
|
+
You can also use it without a global install:
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
npx badness format document.tex
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
badness format document.tex # format in place
|
|
26
|
+
badness format <document.tex # read stdin, write stdout
|
|
27
|
+
badness lint document.tex # lint
|
|
28
|
+
badness lint --fix document.tex # lint and apply auto-fixes
|
|
29
|
+
badness lsp # start the language server
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
See `badness --help` and the [documentation](https://jolars.github.io/badness/)
|
|
33
|
+
for the full feature list and configuration reference.
|
|
34
|
+
|
|
35
|
+
## Supported platforms
|
|
36
|
+
|
|
37
|
+
Prebuilt binaries are shipped for:
|
|
38
|
+
|
|
39
|
+
- Linux x64 (glibc and musl)
|
|
40
|
+
- Linux arm64 (glibc and musl)
|
|
41
|
+
- macOS x64 (Intel) and arm64 (Apple Silicon)
|
|
42
|
+
- Windows x64 and arm64
|
|
43
|
+
|
|
44
|
+
If your platform isn't covered, install via
|
|
45
|
+
[Cargo](https://crates.io/crates/badness),
|
|
46
|
+
[PyPI](https://pypi.org/project/badness/), or one of the other methods listed at
|
|
47
|
+
<https://jolars.github.io/badness/>.
|
|
48
|
+
|
|
49
|
+
## License
|
|
50
|
+
|
|
51
|
+
MIT --- see [LICENSE](./LICENSE).
|
package/bin/badness.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const { execFileSync } = require("node:child_process");
|
|
5
|
+
|
|
6
|
+
function detectLibc() {
|
|
7
|
+
if (process.platform !== "linux") return null;
|
|
8
|
+
try {
|
|
9
|
+
const report = process.report.getReport();
|
|
10
|
+
return report.header.glibcVersionRuntime ? "gnu" : "musl";
|
|
11
|
+
} catch {
|
|
12
|
+
return "gnu";
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function platformPackage() {
|
|
17
|
+
const { platform, arch } = process;
|
|
18
|
+
const libc = detectLibc();
|
|
19
|
+
|
|
20
|
+
const map = {
|
|
21
|
+
"linux-x64-gnu": "@badness/linux-x64-gnu",
|
|
22
|
+
"linux-arm64-gnu": "@badness/linux-arm64-gnu",
|
|
23
|
+
"linux-x64-musl": "@badness/linux-x64-musl",
|
|
24
|
+
"linux-arm64-musl": "@badness/linux-arm64-musl",
|
|
25
|
+
"darwin-x64": "@badness/darwin-x64",
|
|
26
|
+
"darwin-arm64": "@badness/darwin-arm64",
|
|
27
|
+
"win32-x64": "@badness/win32-x64",
|
|
28
|
+
"win32-arm64": "@badness/win32-arm64",
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const key = libc ? `${platform}-${arch}-${libc}` : `${platform}-${arch}`;
|
|
32
|
+
return { key, name: map[key] };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function resolveBinary() {
|
|
36
|
+
const { key, name } = platformPackage();
|
|
37
|
+
if (!name) {
|
|
38
|
+
throw new Error(
|
|
39
|
+
`badness does not ship a prebuilt binary for ${key}.\n` +
|
|
40
|
+
`Supported platforms: linux (x64/arm64, gnu+musl), darwin (x64/arm64), win32 (x64/arm64).\n` +
|
|
41
|
+
`See https://jolars.github.io/badness/ for alternative install methods.`,
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
const binaryName = process.platform === "win32" ? "badness.exe" : "badness";
|
|
45
|
+
try {
|
|
46
|
+
return require.resolve(`${name}/${binaryName}`);
|
|
47
|
+
} catch (err) {
|
|
48
|
+
throw new Error(
|
|
49
|
+
`badness expected the optional dependency ${name} to be installed, ` +
|
|
50
|
+
`but it could not be resolved.\n` +
|
|
51
|
+
`This usually means npm skipped it (e.g. \`--no-optional\` or a registry/network issue ` +
|
|
52
|
+
`during install). Try reinstalling with optional dependencies enabled.\n` +
|
|
53
|
+
`Original error: ${err.message}`,
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function main() {
|
|
59
|
+
let binary;
|
|
60
|
+
try {
|
|
61
|
+
binary = resolveBinary();
|
|
62
|
+
} catch (err) {
|
|
63
|
+
process.stderr.write(`${err.message}\n`);
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
try {
|
|
68
|
+
execFileSync(binary, process.argv.slice(2), { stdio: "inherit" });
|
|
69
|
+
} catch (err) {
|
|
70
|
+
if (typeof err.status === "number") {
|
|
71
|
+
process.exit(err.status);
|
|
72
|
+
}
|
|
73
|
+
if (err.signal) {
|
|
74
|
+
process.kill(process.pid, err.signal);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
process.stderr.write(`Failed to execute badness: ${err.message}\n`);
|
|
78
|
+
process.exit(1);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
main();
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "badness",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "An LSP, formatter, and linter for LaTeX",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"latex",
|
|
7
|
+
"formatter",
|
|
8
|
+
"linter",
|
|
9
|
+
"language-server"
|
|
10
|
+
],
|
|
11
|
+
"homepage": "https://jolars.github.io/badness/",
|
|
12
|
+
"bugs": "https://github.com/jolars/badness/issues",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/jolars/badness.git"
|
|
16
|
+
},
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"author": "Johan Larsson <johan@jolars.co>",
|
|
19
|
+
"bin": {
|
|
20
|
+
"badness": "bin/badness.js"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"bin/",
|
|
24
|
+
"README.md",
|
|
25
|
+
"LICENSE"
|
|
26
|
+
],
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=20"
|
|
29
|
+
},
|
|
30
|
+
"optionalDependencies": {
|
|
31
|
+
"@badness/linux-x64-gnu": "0.1.0",
|
|
32
|
+
"@badness/linux-arm64-gnu": "0.1.0",
|
|
33
|
+
"@badness/linux-x64-musl": "0.1.0",
|
|
34
|
+
"@badness/linux-arm64-musl": "0.1.0",
|
|
35
|
+
"@badness/darwin-x64": "0.1.0",
|
|
36
|
+
"@badness/darwin-arm64": "0.1.0",
|
|
37
|
+
"@badness/win32-x64": "0.1.0",
|
|
38
|
+
"@badness/win32-arm64": "0.1.0"
|
|
39
|
+
}
|
|
40
|
+
}
|