Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/tools/tidy/src/extra_checks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ fn check_impl(
}

if js_lint {
rustdoc_js::lint(outdir, librustdoc_path, tools_path)?;
rustdoc_js::lint(outdir, librustdoc_path, tools_path, bless)?;
rustdoc_js::es_check(outdir, librustdoc_path)?;
}

Expand Down
30 changes: 21 additions & 9 deletions src/tools/tidy/src/extra_checks/rustdoc_js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,18 @@ fn rustdoc_js_files(librustdoc_path: &Path) -> Vec<PathBuf> {
return files;
}

fn run_eslint(outdir: &Path, args: &[PathBuf], config_folder: PathBuf) -> Result<(), super::Error> {
let mut child = spawn_cmd(
Command::new(node_module_bin(outdir, "eslint"))
.arg("-c")
.arg(config_folder.join(".eslintrc.js"))
.args(args),
)?;
fn run_eslint(
outdir: &Path,
args: &[PathBuf],
config_folder: PathBuf,
bless: bool,
) -> Result<(), super::Error> {
let mut cmd = Command::new(node_module_bin(outdir, "eslint"));
if bless {
cmd.arg("--fix");
}
cmd.arg("-c").arg(config_folder.join(".eslintrc.js")).args(args);
let mut child = spawn_cmd(&mut cmd)?;
match child.wait() {
Ok(exit_status) => {
if exit_status.success() {
Expand All @@ -62,16 +67,23 @@ pub(super) fn lint(
outdir: &Path,
librustdoc_path: &Path,
tools_path: &Path,
bless: bool,
) -> Result<(), super::Error> {
let files_to_check = rustdoc_js_files(librustdoc_path);
println!("Running eslint on rustdoc JS files");
run_eslint(outdir, &files_to_check, librustdoc_path.join("html/static"))?;
run_eslint(outdir, &files_to_check, librustdoc_path.join("html/static"), bless)?;

run_eslint(outdir, &[tools_path.join("rustdoc-js/tester.js")], tools_path.join("rustdoc-js"))?;
run_eslint(
outdir,
&[tools_path.join("rustdoc-js/tester.js")],
tools_path.join("rustdoc-js"),
bless,
)?;
run_eslint(
outdir,
&[tools_path.join("rustdoc-gui/tester.js")],
tools_path.join("rustdoc-gui"),
bless,
)?;
Ok(())
}
Expand Down
Loading