From 22c31cef3f39d55a682da2960e7e06ca5e16e63c Mon Sep 17 00:00:00 2001 From: Boshen Date: Mon, 30 Oct 2023 16:11:37 +0800 Subject: [PATCH] fix(linter/no_empty_file): point to start of file instead of the entire file (#1105) Since it may contain lots of comments, which gives us a screenful of comments --- .../src/rules/unicorn/no_empty_file.rs | 2 +- .../src/snapshots/no_empty_file.snap | 45 ++++++++++--------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/crates/oxc_linter/src/rules/unicorn/no_empty_file.rs b/crates/oxc_linter/src/rules/unicorn/no_empty_file.rs index 719328a54..e372f987e 100644 --- a/crates/oxc_linter/src/rules/unicorn/no_empty_file.rs +++ b/crates/oxc_linter/src/rules/unicorn/no_empty_file.rs @@ -49,7 +49,7 @@ impl Rule for NoEmptyFile { return; } - ctx.diagnostic(NoEmptyFileDiagnostic(program.span)); + ctx.diagnostic(NoEmptyFileDiagnostic(Span::new(0, 0))); } } diff --git a/crates/oxc_linter/src/snapshots/no_empty_file.snap b/crates/oxc_linter/src/snapshots/no_empty_file.snap index cb5d16a4c..cfc53e1c9 100644 --- a/crates/oxc_linter/src/snapshots/no_empty_file.snap +++ b/crates/oxc_linter/src/snapshots/no_empty_file.snap @@ -10,141 +10,142 @@ expression: no_empty_file ⚠ eslint-plugin-unicorn(no-empty-file): Empty files are not allowed. ╭─[no_empty_file.tsx:1:1] 1 │ - · ─ + · ▲ ╰──── help: Delete this file or add some code to it. ⚠ eslint-plugin-unicorn(no-empty-file): Empty files are not allowed. ╭─[no_empty_file.tsx:1:1] 1 │ - · ──── + · ▲ ╰──── help: Delete this file or add some code to it. ⚠ eslint-plugin-unicorn(no-empty-file): Empty files are not allowed. ╭─[no_empty_file.tsx:1:1] 1 │ - · ─ + · ▲ ╰──── help: Delete this file or add some code to it. ⚠ eslint-plugin-unicorn(no-empty-file): Empty files are not allowed. ╭─[no_empty_file.tsx:1:1] 0 │ - · ─ + · ▲ ╰──── help: Delete this file or add some code to it. ⚠ eslint-plugin-unicorn(no-empty-file): Empty files are not allowed. ╭─[no_empty_file.tsx:1:1] 1 │ - · ─ + · ▲ ╰──── help: Delete this file or add some code to it. ⚠ eslint-plugin-unicorn(no-empty-file): Empty files are not allowed. ╭─[no_empty_file.tsx:1:1] - 1 │ ╭─▶ - 2 │ │ - 3 │ ╰─▶ + 1 │ + · ▲ + 2 │ + 3 │ ╰──── help: Delete this file or add some code to it. ⚠ eslint-plugin-unicorn(no-empty-file): Empty files are not allowed. ╭─[no_empty_file.tsx:1:1] 1 │ // comment - · ────────── + · ▲ ╰──── help: Delete this file or add some code to it. ⚠ eslint-plugin-unicorn(no-empty-file): Empty files are not allowed. ╭─[no_empty_file.tsx:1:1] 1 │ /* comment */ - · ───────────── + · ▲ ╰──── help: Delete this file or add some code to it. ⚠ eslint-plugin-unicorn(no-empty-file): Empty files are not allowed. ╭─[no_empty_file.tsx:1:1] 1 │ #!/usr/bin/env node - · ─────────────────── + · ▲ ╰──── help: Delete this file or add some code to it. ⚠ eslint-plugin-unicorn(no-empty-file): Empty files are not allowed. ╭─[no_empty_file.tsx:1:1] 1 │ 'use asm'; - · ────────── + · ▲ ╰──── help: Delete this file or add some code to it. ⚠ eslint-plugin-unicorn(no-empty-file): Empty files are not allowed. ╭─[no_empty_file.tsx:1:1] 1 │ 'use strict'; - · ───────────── + · ▲ ╰──── help: Delete this file or add some code to it. ⚠ eslint-plugin-unicorn(no-empty-file): Empty files are not allowed. ╭─[no_empty_file.tsx:1:1] 1 │ "use strict" - · ──────────── + · ▲ ╰──── help: Delete this file or add some code to it. ⚠ eslint-plugin-unicorn(no-empty-file): Empty files are not allowed. ╭─[no_empty_file.tsx:1:1] 1 │ "" - · ── + · ▲ ╰──── help: Delete this file or add some code to it. ⚠ eslint-plugin-unicorn(no-empty-file): Empty files are not allowed. ╭─[no_empty_file.tsx:1:1] 1 │ ; - · ─ + · ▲ ╰──── help: Delete this file or add some code to it. ⚠ eslint-plugin-unicorn(no-empty-file): Empty files are not allowed. ╭─[no_empty_file.tsx:1:1] 1 │ ;; - · ── + · ▲ ╰──── help: Delete this file or add some code to it. ⚠ eslint-plugin-unicorn(no-empty-file): Empty files are not allowed. ╭─[no_empty_file.tsx:1:1] 1 │ {} - · ── + · ▲ ╰──── help: Delete this file or add some code to it. ⚠ eslint-plugin-unicorn(no-empty-file): Empty files are not allowed. ╭─[no_empty_file.tsx:1:1] 1 │ {;;} - · ──── + · ▲ ╰──── help: Delete this file or add some code to it. ⚠ eslint-plugin-unicorn(no-empty-file): Empty files are not allowed. ╭─[no_empty_file.tsx:1:1] 1 │ {{}} - · ──── + · ▲ ╰──── help: Delete this file or add some code to it. ⚠ eslint-plugin-unicorn(no-empty-file): Empty files are not allowed. ╭─[no_empty_file.tsx:1:1] 1 │ ""; - · ─── + · ▲ ╰──── help: Delete this file or add some code to it. ⚠ eslint-plugin-unicorn(no-empty-file): Empty files are not allowed. ╭─[no_empty_file.tsx:1:1] 1 │ "use strict"; - · ───────────── + · ▲ ╰──── help: Delete this file or add some code to it.