@utoo/lint 0.0.2

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/lib/binary.cjs ADDED
@@ -0,0 +1,64 @@
1
+ const { existsSync } = require("node:fs");
2
+ const { join } = require("node:path");
3
+
4
+ const here = __dirname;
5
+
6
+ const packages = {
7
+ "darwin-arm64": "@utoo/lint-darwin-arm64",
8
+ "darwin-x64": "@utoo/lint-darwin-x64",
9
+ "linux-arm64": "@utoo/lint-linux-arm64",
10
+ "linux-x64": "@utoo/lint-linux-x64",
11
+ "win32-x64": "@utoo/lint-win32-x64"
12
+ };
13
+
14
+ function platformPackageName(platform = process.platform, arch = process.arch) {
15
+ return packages[`${platform}-${arch}`] ?? null;
16
+ }
17
+
18
+ function binaryName(platform) {
19
+ return platform === "win32" ? "utoo-lint.exe" : "utoo-lint";
20
+ }
21
+
22
+ function resolveBinary(options = {}) {
23
+ const env = options.env ?? process.env;
24
+ const platform = options.platform ?? process.platform;
25
+ const arch = options.arch ?? process.arch;
26
+
27
+ if (env.UTOO_LINT_BIN) {
28
+ if (existsSync(env.UTOO_LINT_BIN)) {
29
+ return env.UTOO_LINT_BIN;
30
+ }
31
+ throw new Error(`utoo-lint: UTOO_LINT_BIN does not exist: ${env.UTOO_LINT_BIN}`);
32
+ }
33
+
34
+ const packageName = platformPackageName(platform, arch);
35
+ if (!packageName) {
36
+ throw new Error(`utoo-lint: unsupported platform ${platform}-${arch}`);
37
+ }
38
+ const executable = binaryName(platform);
39
+
40
+ const candidates = [
41
+ () => require.resolve(`${packageName}/bin/${executable}`),
42
+ () => join(here, "..", "..", packageName, "bin", executable),
43
+ () => join(here, "..", "..", "..", "zig-out", "bin", executable)
44
+ ];
45
+
46
+ for (const candidate of candidates) {
47
+ try {
48
+ const resolved = candidate();
49
+ if (existsSync(resolved)) {
50
+ return resolved;
51
+ }
52
+ } catch {}
53
+ }
54
+
55
+ throw new Error(
56
+ `utoo-lint: missing native package ${packageName}. ` +
57
+ "Run `./scripts/package-npm.sh` from the repository root, or install the matching optional dependency."
58
+ );
59
+ }
60
+
61
+ module.exports = {
62
+ platformPackageName,
63
+ resolveBinary
64
+ };
@@ -0,0 +1,2 @@
1
+ export function platformPackageName(platform?: string, arch?: string): string | undefined;
2
+ export function resolveBinary(options?: { env?: Record<string, string | undefined>; platform?: string; arch?: string }): string;
package/lib/binary.js ADDED
@@ -0,0 +1,62 @@
1
+ import { existsSync } from "node:fs";
2
+ import { dirname, join } from "node:path";
3
+ import { createRequire } from "node:module";
4
+ import { fileURLToPath } from "node:url";
5
+
6
+ const require = createRequire(import.meta.url);
7
+ const here = dirname(fileURLToPath(import.meta.url));
8
+
9
+ const packages = {
10
+ "darwin-arm64": "@utoo/lint-darwin-arm64",
11
+ "darwin-x64": "@utoo/lint-darwin-x64",
12
+ "linux-arm64": "@utoo/lint-linux-arm64",
13
+ "linux-x64": "@utoo/lint-linux-x64",
14
+ "win32-x64": "@utoo/lint-win32-x64"
15
+ };
16
+
17
+ export function platformPackageName(platform = process.platform, arch = process.arch) {
18
+ return packages[`${platform}-${arch}`] ?? null;
19
+ }
20
+
21
+ function binaryName(platform) {
22
+ return platform === "win32" ? "utoo-lint.exe" : "utoo-lint";
23
+ }
24
+
25
+ export function resolveBinary(options = {}) {
26
+ const env = options.env ?? process.env;
27
+ const platform = options.platform ?? process.platform;
28
+ const arch = options.arch ?? process.arch;
29
+
30
+ if (env.UTOO_LINT_BIN) {
31
+ if (existsSync(env.UTOO_LINT_BIN)) {
32
+ return env.UTOO_LINT_BIN;
33
+ }
34
+ throw new Error(`utoo-lint: UTOO_LINT_BIN does not exist: ${env.UTOO_LINT_BIN}`);
35
+ }
36
+
37
+ const packageName = platformPackageName(platform, arch);
38
+ if (!packageName) {
39
+ throw new Error(`utoo-lint: unsupported platform ${platform}-${arch}`);
40
+ }
41
+ const executable = binaryName(platform);
42
+
43
+ const candidates = [
44
+ () => require.resolve(`${packageName}/bin/${executable}`),
45
+ () => join(here, "..", "..", packageName, "bin", executable),
46
+ () => join(here, "..", "..", "..", "zig-out", "bin", executable)
47
+ ];
48
+
49
+ for (const candidate of candidates) {
50
+ try {
51
+ const resolved = candidate();
52
+ if (existsSync(resolved)) {
53
+ return resolved;
54
+ }
55
+ } catch {}
56
+ }
57
+
58
+ throw new Error(
59
+ `utoo-lint: missing native package ${packageName}. ` +
60
+ "Run `./scripts/package-npm.sh` from the repository root, or install the matching optional dependency."
61
+ );
62
+ }
package/package.json ADDED
@@ -0,0 +1,81 @@
1
+ {
2
+ "name": "@utoo/lint",
3
+ "version": "0.0.2",
4
+ "description": "Experimental JavaScript and TypeScript linter powered by Yuku",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/fireairforce/utoo-lint.git"
9
+ },
10
+ "bugs": {
11
+ "url": "https://github.com/fireairforce/utoo-lint/issues"
12
+ },
13
+ "homepage": "https://github.com/fireairforce/utoo-lint#readme",
14
+ "type": "module",
15
+ "types": "./index.d.ts",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./index.d.ts",
19
+ "import": "./index.js",
20
+ "require": "./index.cjs"
21
+ },
22
+ "./binary": {
23
+ "types": "./lib/binary.d.ts",
24
+ "import": "./lib/binary.js",
25
+ "require": "./lib/binary.cjs"
26
+ },
27
+ "./config": {
28
+ "types": "./config.d.ts",
29
+ "import": "./config.js",
30
+ "require": "./config.cjs"
31
+ },
32
+ "./use-at-your-own-risk": {
33
+ "types": "./use-at-your-own-risk.d.ts",
34
+ "import": "./use-at-your-own-risk.js",
35
+ "require": "./use-at-your-own-risk.cjs"
36
+ },
37
+ "./universal": {
38
+ "types": "./universal.d.ts",
39
+ "import": "./universal.js",
40
+ "require": "./universal.cjs"
41
+ },
42
+ "./configs/frontend": "./configs/frontend.json",
43
+ "./schema": "./schema.json",
44
+ "./package.json": "./package.json"
45
+ },
46
+ "bin": {
47
+ "eslint": "./bin/eslint.js",
48
+ "fishlint": "./bin/fishlint.js",
49
+ "fishlint-lint-staged": "./bin/fishlint-lint-staged.js",
50
+ "utoo-lint": "./bin/utoo-lint.js"
51
+ },
52
+ "files": [
53
+ "bin",
54
+ "config.cjs",
55
+ "config.d.ts",
56
+ "config.js",
57
+ "configs",
58
+ "index.cjs",
59
+ "index.d.ts",
60
+ "index.js",
61
+ "lib",
62
+ "schema.json",
63
+ "universal.cjs",
64
+ "universal.d.ts",
65
+ "universal.js",
66
+ "use-at-your-own-risk.cjs",
67
+ "use-at-your-own-risk.d.ts",
68
+ "use-at-your-own-risk.js"
69
+ ],
70
+ "optionalDependencies": {
71
+ "@utoo/lint-darwin-arm64": "0.0.2",
72
+ "@utoo/lint-darwin-x64": "0.0.2",
73
+ "@utoo/lint-linux-arm64": "0.0.2",
74
+ "@utoo/lint-linux-x64": "0.0.2",
75
+ "@utoo/lint-win32-x64": "0.0.2"
76
+ },
77
+ "publishConfig": {
78
+ "access": "public",
79
+ "registry": "https://registry.npmjs.org/"
80
+ }
81
+ }
package/schema.json ADDED
@@ -0,0 +1,74 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft-07/schema",
3
+ "$id": "https://raw.githubusercontent.com/fireairforce/utoo-lint/main/npm/utoo-lint/schema.json",
4
+ "title": "utoo-lint configuration",
5
+ "type": "object",
6
+ "additionalProperties": true,
7
+ "properties": {
8
+ "$schema": {
9
+ "type": "string"
10
+ },
11
+ "rules": {
12
+ "description": "ESLint-compatible rule severity map. Unknown rule names are rejected by utoo-lint.",
13
+ "type": "object",
14
+ "additionalProperties": {
15
+ "$ref": "#/definitions/ruleSeverity"
16
+ }
17
+ },
18
+ "files": {
19
+ "description": "File globs this config entry applies to.",
20
+ "oneOf": [
21
+ {
22
+ "type": "string"
23
+ },
24
+ {
25
+ "type": "array",
26
+ "items": {
27
+ "type": "string"
28
+ }
29
+ }
30
+ ]
31
+ },
32
+ "ignores": {
33
+ "description": "File globs ignored by this config entry.",
34
+ "oneOf": [
35
+ {
36
+ "type": "string"
37
+ },
38
+ {
39
+ "type": "array",
40
+ "items": {
41
+ "type": "string"
42
+ }
43
+ }
44
+ ]
45
+ }
46
+ },
47
+ "definitions": {
48
+ "ruleSeverity": {
49
+ "oneOf": [
50
+ {
51
+ "type": "string",
52
+ "enum": ["off", "warn", "error", "on", "0", "1", "2"]
53
+ },
54
+ {
55
+ "type": "integer",
56
+ "enum": [0, 1, 2]
57
+ },
58
+ {
59
+ "type": "boolean"
60
+ },
61
+ {
62
+ "type": "array",
63
+ "minItems": 1,
64
+ "items": [
65
+ {
66
+ "$ref": "#/definitions/ruleSeverity"
67
+ }
68
+ ],
69
+ "additionalItems": true
70
+ }
71
+ ]
72
+ }
73
+ }
74
+ }
package/universal.cjs ADDED
@@ -0,0 +1,3 @@
1
+ const { Linter } = require("./index.cjs");
2
+
3
+ module.exports = { Linter };
package/universal.d.ts ADDED
@@ -0,0 +1 @@
1
+ export { Linter } from "./index.js";
package/universal.js ADDED
@@ -0,0 +1 @@
1
+ export { Linter } from "./index.js";
@@ -0,0 +1,28 @@
1
+ const { CLIEngine, Linter, UtooLint } = require("./index.cjs");
2
+
3
+ const builtinRules = new Linter().getRules();
4
+ const FlatESLint = UtooLint;
5
+ const LegacyESLint = UtooLint;
6
+
7
+ async function shouldUseFlatConfig() {
8
+ return true;
9
+ }
10
+
11
+ class FileEnumerator {
12
+ constructor(options = {}) {
13
+ this.options = { ...options };
14
+ }
15
+
16
+ iterateFiles(patterns = []) {
17
+ const cli = new CLIEngine(this.options);
18
+ return cli.resolveFileGlobPatterns(patterns).map((filePath) => ({ filePath }));
19
+ }
20
+ }
21
+
22
+ module.exports = {
23
+ builtinRules,
24
+ FileEnumerator,
25
+ FlatESLint,
26
+ LegacyESLint,
27
+ shouldUseFlatConfig
28
+ };
@@ -0,0 +1,12 @@
1
+ import { CLIEngine, Linter, UtooLint } from "./index.js";
2
+
3
+ export const builtinRules: Map<string, unknown>;
4
+ export const FlatESLint: typeof UtooLint;
5
+ export const LegacyESLint: typeof UtooLint;
6
+
7
+ export function shouldUseFlatConfig(): Promise<boolean>;
8
+
9
+ export class FileEnumerator {
10
+ constructor(options?: ConstructorParameters<typeof CLIEngine>[0]);
11
+ iterateFiles(patterns?: string | string[]): Array<{ filePath: string }>;
12
+ }
@@ -0,0 +1,20 @@
1
+ import { CLIEngine, Linter, UtooLint } from "./index.js";
2
+
3
+ export const builtinRules = new Linter().getRules();
4
+ export const FlatESLint = UtooLint;
5
+ export const LegacyESLint = UtooLint;
6
+
7
+ export async function shouldUseFlatConfig() {
8
+ return true;
9
+ }
10
+
11
+ export class FileEnumerator {
12
+ constructor(options = {}) {
13
+ this.options = { ...options };
14
+ }
15
+
16
+ iterateFiles(patterns = []) {
17
+ const cli = new CLIEngine(this.options);
18
+ return cli.resolveFileGlobPatterns(patterns).map((filePath) => ({ filePath }));
19
+ }
20
+ }