Skip to content

Commit

Permalink
Add yew-fmt and clippy to linter
Browse files Browse the repository at this point in the history
only lint current project

yew-fmt in ci
  • Loading branch information
ada-x64 authored and texodus committed Feb 15, 2024
1 parent aaff331 commit 29fc54c
Show file tree
Hide file tree
Showing 8 changed files with 229 additions and 34 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ jobs:
- name: Install latest nightly rust
uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly-2023-04-07
toolchain: nightly-2023-10-12
targets: wasm32-unknown-unknown
components: rustfmt, clippy, rust-src

Expand Down Expand Up @@ -325,8 +325,11 @@ jobs:
###############
# WebAssembly #
###############

- name: WebAssembly Lint
run: yarn lint
env:
PSP_PROJECT: js

- name: WebAssembly Build
run: yarn build_js --ci
Expand Down Expand Up @@ -524,6 +527,7 @@ jobs:
run: yarn lint
env:
PYTHON_VERSION: ${{ matrix.python-version }}
PSP_PROJECT: python

##########################################################################################################################
##########################################################################################################################
Expand Down Expand Up @@ -650,7 +654,7 @@ jobs:
- name: Install latest nightly rust
uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly-2023-04-07
toolchain: nightly-2023-10-12
targets: wasm32-unknown-unknown
components: rustfmt, clippy, rust-src

Expand Down
3 changes: 3 additions & 0 deletions rust/perspective-viewer/.cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ runner = 'wasm-bindgen-test-runner'

[future-incompat-report]
frequency = 'never'

[unstable]
bindeps = true
126 changes: 110 additions & 16 deletions rust/perspective-viewer/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion rust/perspective-viewer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ include = [
]

[workspace]
members = ["tasks/bundle", "tasks/bootstrap-runtime", "tasks/bootstrap"]
members = [
"tasks/bundle",
"tasks/bootstrap-runtime",
"tasks/bootstrap",
"tasks/lint",
]

[lib]
crate-type = ["cdylib", "rlib"]
Expand Down
26 changes: 26 additions & 0 deletions rust/perspective-viewer/tasks/lint/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
# ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃
# ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃
# ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄▄ ┃
# ┃ █ ██████ █ ▀█▄ █ ██████ █ ███▌▐███ ███████▄ █ ┃
# ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
# ┃ 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). ┃
# ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

[package]
name = "perspective-lint"
description = "A CLI utility to lint rust code"
version = "2.7.1"
edition = "2021"

[[bin]]
name = "lint"
path = "main.rs"
bench = false

[dependencies]
yew-fmt = { version = "0.3.0", artifact = "bin" }
glob = "0.3.1"
48 changes: 48 additions & 0 deletions rust/perspective-viewer/tasks/lint/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
// ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃
// ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃
// ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄▄ ┃
// ┃ █ ██████ █ ▀█▄ █ ██████ █ ███▌▐███ ███████▄ █ ┃
// ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
// ┃ 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). ┃
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

use glob::glob;
pub fn main() {
let mut args = std::env::args();
args.next();
let mut args = args.collect::<Vec<String>>();
let mut check = false;
if let Some((i, _)) = args.iter().enumerate().find(|(_i, val)| **val == "--check") {
args.remove(i);
check = true;
}
let check_args = if check {
vec!["--check".into()]
} else {
vec![]
};

let mut paths = vec![];
for arg in args {
let glob = glob(&arg)
.unwrap()
.filter_map(Result::ok)
.map(|buf| buf.to_string_lossy().to_string())
.collect::<Vec<String>>();
paths.push(glob);
}
let paths = paths.concat();
let fmt_args = vec!["--edition".into(), "2021".into()];
let fmt_args = [fmt_args, check_args, paths].concat();
let exit_code = std::process::Command::new(env!("CARGO_BIN_FILE_YEW_FMT"))
.args(fmt_args)
.spawn()
.expect("Could not spawn process")
.wait()
.expect("Process did not start");
std::process::exit(exit_code.code().unwrap())
}
13 changes: 9 additions & 4 deletions tools/perspective-scripts/fix.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,20 @@
// ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

import sh from "./sh.mjs";
import * as url from "url";
import { lint } from "./lint.mjs";
import * as dotenv from "dotenv";
import { lint_js } from "./lint.mjs";

if (import.meta.url.startsWith("file:")) {
if (process.argv[1] === url.fileURLToPath(import.meta.url)) {
await import("./fix_python.mjs");
const { default: run } = await import("./lint_headers.mjs");
await run(true);
lint(sh`--write`);

dotenv.config({ path: "./.perspectiverc" });
if (process.env.PSP_PROJECT === "python") {
await import("./fix_python.mjs");
} else {
lint_js(true);
}
}
}
Loading

0 comments on commit 29fc54c

Please sign in to comment.