2023-06-27 22:15:36 -04:00
|
|
|
// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
|
|
|
|
|
// ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃
|
|
|
|
|
// ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃
|
|
|
|
|
// ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄▄ ┃
|
|
|
|
|
// ┃ █ ██████ █ ▀█▄ █ ██████ █ ███▌▐███ ███████▄ █ ┃
|
|
|
|
|
// ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
|
|
|
|
|
// ┃ Copyright (c) 2017, the Perspective Authors. ┃
|
|
|
|
|
// ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃
|
|
|
|
|
// ┃ This file is part of the Perspective library, distributed under the terms ┃
|
|
|
|
|
// ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
|
|
|
|
|
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
|
2023-06-25 14:58:11 -04:00
|
|
|
|
2025-09-27 22:13:38 -04:00
|
|
|
import { get_scope } from "./sh_perspective.mjs";
|
2023-06-25 14:58:11 -04:00
|
|
|
import * as url from "url";
|
2024-02-08 17:43:49 -06:00
|
|
|
import * as dotenv from "dotenv";
|
2023-06-25 14:58:11 -04:00
|
|
|
|
2025-09-27 22:13:38 -04:00
|
|
|
import "zx/globals";
|
|
|
|
|
|
|
|
|
|
export async function lint_js(is_fix = false) {
|
2024-02-15 00:27:09 -05:00
|
|
|
const prettier_flags = is_fix ? "--write" : "--check";
|
2025-10-25 19:51:40 -04:00
|
|
|
await $`prettier ${prettier_flags} "examples/**/*.js" "examples/**/*.tsx" "tools/scripts/*.mjs" "rust/**/*.ts" "rust/**/*.js" "packages/**/*.js" "packages/**/*.ts"`.verbose();
|
2025-09-27 22:13:38 -04:00
|
|
|
await $`prettier --prose-wrap=always ${prettier_flags} "rust/*/docs/**/*.md"`.verbose();
|
2024-10-16 21:59:31 -04:00
|
|
|
// cmd.sh`prettier ${prettier_flags} "**/*.yaml"`;
|
2025-09-27 22:13:38 -04:00
|
|
|
await $`prettier ${prettier_flags} "**/less/*.less"`.verbose();
|
|
|
|
|
await $`prettier ${prettier_flags} "**/html/*.html"`.verbose();
|
|
|
|
|
await $`prettier ${prettier_flags} "packages/**/package.json" "rust/**/package.json" "examples/**/package.json" "docs/package.json"`.verbose();
|
2023-06-25 14:58:11 -04:00
|
|
|
|
2025-09-27 22:13:38 -04:00
|
|
|
const check = is_fix ? [] : ["--check"];
|
|
|
|
|
const dirty = is_fix ? ["--allow-dirty"] : [];
|
|
|
|
|
const staged = is_fix ? ["--allow-staged"] : [];
|
|
|
|
|
const fix = is_fix ? ["--fix"] : [];
|
2026-02-02 13:29:42 -05:00
|
|
|
await $`cargo build -p perspective-lint --features=yew-fmt`.verbose();
|
2025-09-27 22:13:38 -04:00
|
|
|
await $`cargo clippy ${fix} ${dirty} ${staged} -p perspective-viewer -- -Dwarnings`.verbose();
|
|
|
|
|
await $`RUSTFMT="rust/target/debug/lint" cargo fmt ${check}`.verbose();
|
2023-06-25 14:58:11 -04:00
|
|
|
}
|
|
|
|
|
|
2024-07-28 21:12:49 -04:00
|
|
|
export function lint_python(is_fix = false) {
|
|
|
|
|
if (get_scope().indexOf("perspective-python") > -1) {
|
|
|
|
|
if (is_fix) {
|
2025-09-27 22:13:38 -04:00
|
|
|
$.sync`ruff check --fix`;
|
2024-07-28 21:12:49 -04:00
|
|
|
} else {
|
2025-09-27 22:13:38 -04:00
|
|
|
$.sync`ruff check`;
|
2024-07-28 21:12:49 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-25 14:58:11 -04:00
|
|
|
if (import.meta.url.startsWith("file:")) {
|
|
|
|
|
if (process.argv[1] === url.fileURLToPath(import.meta.url)) {
|
2025-09-27 22:13:38 -04:00
|
|
|
dotenv.config({ path: "./.perspectiverc", quiet: true });
|
2023-06-25 14:58:11 -04:00
|
|
|
const { default: run } = await import("./lint_headers.mjs");
|
|
|
|
|
const exit_code = await run(false);
|
2024-05-27 18:12:36 -04:00
|
|
|
// if (process.env.PSP_PROJECT === "python") {
|
|
|
|
|
// await import("./lint_python.mjs");
|
|
|
|
|
// } else {
|
2025-12-04 14:59:43 -08:00
|
|
|
|
2025-09-27 22:13:38 -04:00
|
|
|
await lint_js();
|
2024-07-28 21:12:49 -04:00
|
|
|
lint_python();
|
2024-05-27 18:12:36 -04:00
|
|
|
// }
|
2024-02-23 21:36:13 -05:00
|
|
|
|
2023-06-25 14:58:11 -04:00
|
|
|
process.exit(exit_code);
|
|
|
|
|
}
|
|
|
|
|
}
|