summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/flags.rs2
-rw-r--r--cli/fmt.rs24
-rw-r--r--cli/lint.rs27
-rw-r--r--cli/tests/fmt/expected_fmt_check_formatted_files.out1
-rw-r--r--cli/tests/fmt/expected_fmt_check_ignore.out1
-rw-r--r--cli/tests/fmt/expected_fmt_check_tests_dir.out2
-rw-r--r--cli/tests/fmt/expected_fmt_check_verbose_formatted_files.out1
-rw-r--r--cli/tests/fmt/expected_fmt_check_verbose_tests_dir.out2
-rw-r--r--cli/tests/fmt/formatted1.js5
-rw-r--r--cli/tests/fmt/formatted2.ts5
-rw-r--r--cli/tests/fmt_check_tests_dir.out2
-rw-r--r--cli/tests/integration_tests.rs14
-rw-r--r--cli/tests/lint/expected.out1
-rw-r--r--cli/tests/lint/expected_from_stdin.out1
-rw-r--r--cli/tests/lint/expected_glob.out1
-rw-r--r--cli/tests/lint/expected_ignore.out1
-rw-r--r--cli/tests/lint/expected_verbose.out3
-rw-r--r--docs/tools/linter.md5
18 files changed, 79 insertions, 19 deletions
diff --git a/cli/flags.rs b/cli/flags.rs
index 835be0041..443411bc3 100644
--- a/cli/flags.rs
+++ b/cli/flags.rs
@@ -1732,7 +1732,7 @@ mod tests {
subcommand: DenoSubcommand::Fmt {
ignore: vec![],
check: false,
- files: vec!["script_1.ts".to_string(), "script_2.ts".to_string()]
+ files: vec!["script_1.ts".to_string(), "script_2.ts".to_string()],
},
..Flags::default()
}
diff --git a/cli/fmt.rs b/cli/fmt.rs
index 0a9727f7a..28fdf9e66 100644
--- a/cli/fmt.rs
+++ b/cli/fmt.rs
@@ -58,13 +58,16 @@ async fn check_source_files(
paths: Vec<PathBuf>,
) -> Result<(), ErrBox> {
let not_formatted_files_count = Arc::new(AtomicUsize::new(0));
+ let checked_files_count = Arc::new(AtomicUsize::new(0));
// prevent threads outputting at the same time
let output_lock = Arc::new(Mutex::new(0));
run_parallelized(paths, {
let not_formatted_files_count = not_formatted_files_count.clone();
+ let checked_files_count = checked_files_count.clone();
move |file_path| {
+ checked_files_count.fetch_add(1, Ordering::Relaxed);
let file_text = read_file_contents(&file_path)?.text;
let r = dprint::format_text(&file_path, &file_text, &config);
match r {
@@ -105,13 +108,17 @@ async fn check_source_files(
let not_formatted_files_count =
not_formatted_files_count.load(Ordering::Relaxed);
+ let checked_files_count = checked_files_count.load(Ordering::Relaxed);
+ let checked_files_str =
+ format!("{} {}", checked_files_count, files_str(checked_files_count));
if not_formatted_files_count == 0 {
+ println!("Checked {}", checked_files_str);
Ok(())
} else {
+ let not_formatted_files_str = files_str(not_formatted_files_count);
Err(ErrBox::error(format!(
- "Found {} not formatted {}",
- not_formatted_files_count,
- files_str(not_formatted_files_count),
+ "Found {} not formatted {} in {}",
+ not_formatted_files_count, not_formatted_files_str, checked_files_str,
)))
}
}
@@ -121,11 +128,14 @@ async fn format_source_files(
paths: Vec<PathBuf>,
) -> Result<(), ErrBox> {
let formatted_files_count = Arc::new(AtomicUsize::new(0));
+ let checked_files_count = Arc::new(AtomicUsize::new(0));
let output_lock = Arc::new(Mutex::new(0)); // prevent threads outputting at the same time
run_parallelized(paths, {
let formatted_files_count = formatted_files_count.clone();
+ let checked_files_count = checked_files_count.clone();
move |file_path| {
+ checked_files_count.fetch_add(1, Ordering::Relaxed);
let file_contents = read_file_contents(&file_path)?;
let r = dprint::format_text(&file_path, &file_contents.text, &config);
match r {
@@ -160,6 +170,14 @@ async fn format_source_files(
formatted_files_count,
files_str(formatted_files_count),
);
+
+ let checked_files_count = checked_files_count.load(Ordering::Relaxed);
+ println!(
+ "Checked {} {}",
+ checked_files_count,
+ files_str(checked_files_count)
+ );
+
Ok(())
}
diff --git a/cli/lint.rs b/cli/lint.rs
index bbb9a73ad..c52aff408 100644
--- a/cli/lint.rs
+++ b/cli/lint.rs
@@ -55,6 +55,7 @@ pub async fn lint_files(
target_files.retain(|f| !ignore_files.contains(&f));
}
debug!("Found {} files", target_files.len());
+ let target_files_len = target_files.len();
let has_error = Arc::new(AtomicBool::new(false));
@@ -77,7 +78,7 @@ pub async fn lint_files(
sort_diagnostics(&mut file_diagnostics);
for d in file_diagnostics.iter() {
has_error.store(true, Ordering::Relaxed);
- reporter.visit(&d, source.split('\n').collect());
+ reporter.visit_diagnostic(&d, source.split('\n').collect());
}
}
Err(err) => {
@@ -92,7 +93,7 @@ pub async fn lint_files(
let has_error = has_error.load(Ordering::Relaxed);
- reporter_lock.lock().unwrap().close();
+ reporter_lock.lock().unwrap().close(target_files_len);
if has_error {
std::process::exit(1);
@@ -168,7 +169,7 @@ fn lint_stdin(json: bool) -> Result<(), ErrBox> {
Ok(diagnostics) => {
for d in diagnostics {
has_error = true;
- reporter.visit(&d, source.split('\n').collect());
+ reporter.visit_diagnostic(&d, source.split('\n').collect());
}
}
Err(err) => {
@@ -177,7 +178,7 @@ fn lint_stdin(json: bool) -> Result<(), ErrBox> {
}
}
- reporter.close();
+ reporter.close(1);
if has_error {
std::process::exit(1);
@@ -187,9 +188,9 @@ fn lint_stdin(json: bool) -> Result<(), ErrBox> {
}
trait LintReporter {
- fn visit(&mut self, d: &LintDiagnostic, source_lines: Vec<&str>);
+ fn visit_diagnostic(&mut self, d: &LintDiagnostic, source_lines: Vec<&str>);
fn visit_error(&mut self, file_path: &str, err: &ErrBox);
- fn close(&mut self);
+ fn close(&mut self, check_count: usize);
}
#[derive(Serialize)]
@@ -209,7 +210,7 @@ impl PrettyLintReporter {
}
impl LintReporter for PrettyLintReporter {
- fn visit(&mut self, d: &LintDiagnostic, source_lines: Vec<&str>) {
+ fn visit_diagnostic(&mut self, d: &LintDiagnostic, source_lines: Vec<&str>) {
self.lint_count += 1;
let pretty_message =
@@ -234,12 +235,18 @@ impl LintReporter for PrettyLintReporter {
eprintln!(" {}", err);
}
- fn close(&mut self) {
+ fn close(&mut self, check_count: usize) {
match self.lint_count {
1 => eprintln!("Found 1 problem"),
n if n > 1 => eprintln!("Found {} problems", self.lint_count),
_ => (),
}
+
+ match check_count {
+ 1 => println!("Checked 1 file"),
+ n if n > 1 => println!("Checked {} files", n),
+ _ => (),
+ }
}
}
@@ -299,7 +306,7 @@ impl JsonLintReporter {
}
impl LintReporter for JsonLintReporter {
- fn visit(&mut self, d: &LintDiagnostic, _source_lines: Vec<&str>) {
+ fn visit_diagnostic(&mut self, d: &LintDiagnostic, _source_lines: Vec<&str>) {
self.diagnostics.push(d.clone());
}
@@ -310,7 +317,7 @@ impl LintReporter for JsonLintReporter {
});
}
- fn close(&mut self) {
+ fn close(&mut self, _check_count: usize) {
sort_diagnostics(&mut self.diagnostics);
let json = serde_json::to_string_pretty(&self);
eprintln!("{}", json.unwrap());
diff --git a/cli/tests/fmt/expected_fmt_check_formatted_files.out b/cli/tests/fmt/expected_fmt_check_formatted_files.out
new file mode 100644
index 000000000..158c556c2
--- /dev/null
+++ b/cli/tests/fmt/expected_fmt_check_formatted_files.out
@@ -0,0 +1 @@
+Checked 2 files
diff --git a/cli/tests/fmt/expected_fmt_check_ignore.out b/cli/tests/fmt/expected_fmt_check_ignore.out
new file mode 100644
index 000000000..c05ac45a1
--- /dev/null
+++ b/cli/tests/fmt/expected_fmt_check_ignore.out
@@ -0,0 +1 @@
+Checked 1 file
diff --git a/cli/tests/fmt/expected_fmt_check_tests_dir.out b/cli/tests/fmt/expected_fmt_check_tests_dir.out
new file mode 100644
index 000000000..04cd5ec64
--- /dev/null
+++ b/cli/tests/fmt/expected_fmt_check_tests_dir.out
@@ -0,0 +1,2 @@
+[WILDCARD]
+error: Found 1 not formatted file in [WILDCARD] files
diff --git a/cli/tests/fmt/expected_fmt_check_verbose_formatted_files.out b/cli/tests/fmt/expected_fmt_check_verbose_formatted_files.out
new file mode 100644
index 000000000..158c556c2
--- /dev/null
+++ b/cli/tests/fmt/expected_fmt_check_verbose_formatted_files.out
@@ -0,0 +1 @@
+Checked 2 files
diff --git a/cli/tests/fmt/expected_fmt_check_verbose_tests_dir.out b/cli/tests/fmt/expected_fmt_check_verbose_tests_dir.out
new file mode 100644
index 000000000..04cd5ec64
--- /dev/null
+++ b/cli/tests/fmt/expected_fmt_check_verbose_tests_dir.out
@@ -0,0 +1,2 @@
+[WILDCARD]
+error: Found 1 not formatted file in [WILDCARD] files
diff --git a/cli/tests/fmt/formatted1.js b/cli/tests/fmt/formatted1.js
new file mode 100644
index 000000000..587aa5b96
--- /dev/null
+++ b/cli/tests/fmt/formatted1.js
@@ -0,0 +1,5 @@
+function foo() {
+ return 42;
+}
+
+foo();
diff --git a/cli/tests/fmt/formatted2.ts b/cli/tests/fmt/formatted2.ts
new file mode 100644
index 000000000..4a8036806
--- /dev/null
+++ b/cli/tests/fmt/formatted2.ts
@@ -0,0 +1,5 @@
+function bar(): number {
+ return 42;
+}
+
+bar();
diff --git a/cli/tests/fmt_check_tests_dir.out b/cli/tests/fmt_check_tests_dir.out
deleted file mode 100644
index 060f2f17a..000000000
--- a/cli/tests/fmt_check_tests_dir.out
+++ /dev/null
@@ -1,2 +0,0 @@
-[WILDCARD]
-error: Found 1 not formatted file
diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs
index 2f70cf050..e00c7a865 100644
--- a/cli/tests/integration_tests.rs
+++ b/cli/tests/integration_tests.rs
@@ -1720,10 +1720,22 @@ itest!(bundle {
itest!(fmt_check_tests_dir {
args: "fmt --check ./",
- output: "fmt_check_tests_dir.out",
+ output: "fmt/expected_fmt_check_tests_dir.out",
exit_code: 1,
});
+itest!(fmt_check_formatted_files {
+ args: "fmt --check fmt/formatted1.js fmt/formatted2.ts",
+ output: "fmt/expected_fmt_check_formatted_files.out",
+ exit_code: 0,
+});
+
+itest!(fmt_check_ignore {
+ args: "fmt --check --unstable --ignore=fmt/formatted1.js fmt/",
+ output: "fmt/expected_fmt_check_ignore.out",
+ exit_code: 0,
+});
+
itest!(fmt_stdin {
args: "fmt -",
input: Some("const a = 1\n"),
diff --git a/cli/tests/lint/expected.out b/cli/tests/lint/expected.out
index a85c90859..eb8a2651a 100644
--- a/cli/tests/lint/expected.out
+++ b/cli/tests/lint/expected.out
@@ -1,2 +1,3 @@
[WILDCARD]
Found 3 problems
+Checked 3 files
diff --git a/cli/tests/lint/expected_from_stdin.out b/cli/tests/lint/expected_from_stdin.out
index 02b9d917c..90f455fdc 100644
--- a/cli/tests/lint/expected_from_stdin.out
+++ b/cli/tests/lint/expected_from_stdin.out
@@ -1,2 +1,3 @@
[WILDCARD]
Found 1 problem
+Checked 1 file
diff --git a/cli/tests/lint/expected_glob.out b/cli/tests/lint/expected_glob.out
index a85c90859..eb8a2651a 100644
--- a/cli/tests/lint/expected_glob.out
+++ b/cli/tests/lint/expected_glob.out
@@ -1,2 +1,3 @@
[WILDCARD]
Found 3 problems
+Checked 3 files
diff --git a/cli/tests/lint/expected_ignore.out b/cli/tests/lint/expected_ignore.out
index 02b9d917c..b5f78ee04 100644
--- a/cli/tests/lint/expected_ignore.out
+++ b/cli/tests/lint/expected_ignore.out
@@ -1,2 +1,3 @@
[WILDCARD]
Found 1 problem
+Checked 2 files
diff --git a/cli/tests/lint/expected_verbose.out b/cli/tests/lint/expected_verbose.out
new file mode 100644
index 000000000..eb8a2651a
--- /dev/null
+++ b/cli/tests/lint/expected_verbose.out
@@ -0,0 +1,3 @@
+[WILDCARD]
+Found 3 problems
+Checked 3 files
diff --git a/docs/tools/linter.md b/docs/tools/linter.md
index 9f3400682..f5af1543b 100644
--- a/docs/tools/linter.md
+++ b/docs/tools/linter.md
@@ -52,6 +52,7 @@ For more detail, run `deno lint --help`.
- `no-extra-non-null-assertion`
- `no-extra-semi`
- `no-func-assign`
+- `no-inner-declarations`
- `no-inferrable-types`
- `no-invalid-regexp`
- `no-irregular-whitespace`
@@ -59,7 +60,7 @@ For more detail, run `deno lint --help`.
- `no-mixed-spaces-and-tabs`
- `no-namespace`
- `no-new-symbol`
-- `no-obj-call`
+- `no-obj-calls`
- `no-octal`
- `no-prototype-builtins`
- `no-regex-spaces`
@@ -68,7 +69,7 @@ For more detail, run `deno lint --help`.
- `no-shadow-restricted-names`
- `no-this-alias`
- `no-this-before-super`
-- `no-unexpected-multiline`
+- `no-unreachable`
- `no-unsafe-finally`
- `no-unsafe-negation`
- `no-unused-labels`