diff --git a/.changeset/enable_rule_with_default_severity.md b/.changeset/enable_rule_with_default_severity.md new file mode 100644 index 000000000000..70c8c821d8c6 --- /dev/null +++ b/.changeset/enable_rule_with_default_severity.md @@ -0,0 +1,35 @@ +--- +cli: minor +--- + +# Enable rule with default severity + +You can now enable lint rules using the default severity suggested by Biome using the new variant `"on"`, when enabling a rule. + +For example, the default severity of the rule `style.noVar` is `error`, so you would use `"on"`, and then linting a code that uses `var`, will result in an error: + +```json +{ + "linter": { + "recommended": false, + "rules": { + "style": { + "noVar": "on" + } + } + } +} +``` + +```js +// main.js +var name = "tobias" +``` + +The command `biome lint main.js` will result in an error due to the default severity assigned to `noVar`. + +Refer to the documentation page of each rule to know their suggested diagnostic severity, or use the command `biome explain `: + +```shell +biome explain noVar +``` \ No newline at end of file diff --git a/.changeset/style_rules_arent_recommended_anymore_.md b/.changeset/style_rules_arent_recommended_anymore_.md new file mode 100644 index 000000000000..862f1642eb2b --- /dev/null +++ b/.changeset/style_rules_arent_recommended_anymore_.md @@ -0,0 +1,33 @@ +--- +cli: major +--- + +# `style` rules aren't recommended anymore + +Linting rules that belong to the group `style` aren't recommended anymore. Here's the list of rules that aren't recommended anymore: + +- `useNumberNamespace` +- `noNonnullAssertion` +- `useAsConstAssertion` +- `noParameterAssign` +- `noInferrableTypes` +- `useNodejsImportProtocol` +- `useExportType` +- `useDefaultParameterLast` +- `noUnusedTemplateLiteral` +- `useExponentiationOperator` +- `useEnumInitializers` +- `useShorthandFunctionType` +- `useLiteralEnumMembers` +- `noVar` +- `noUselessElse` +- `useNumericLiterals` +- `noCommaOperator` +- `useConst` +- `noArguments` +- `useSelfClosingElements` +- `useImportType` +- `useTemplate` +- `useSingleVarDeclarator` +- `useWhile` +- `use_while` \ No newline at end of file diff --git a/biome.json b/biome.json index db4022722192..6fc96527c948 100644 --- a/biome.json +++ b/biome.json @@ -53,7 +53,8 @@ "rules": { "recommended": true, "style": { - "noNonNullAssertion": "off" + "noNonNullAssertion": "off", + "noVar": "on" } } }, diff --git a/crates/biome_analyze/src/rule.rs b/crates/biome_analyze/src/rule.rs index 408331bfd217..795d951504ea 100644 --- a/crates/biome_analyze/src/rule.rs +++ b/crates/biome_analyze/src/rule.rs @@ -5,7 +5,7 @@ use crate::{ Phase, Phases, Queryable, SourceActionKind, SuppressionAction, SuppressionCommentEmitterPayload, }; use biome_console::fmt::{Display, Formatter}; -use biome_console::{markup, MarkupBuf}; +use biome_console::{markup, MarkupBuf, Padding}; use biome_diagnostics::advice::CodeSuggestionAdvice; use biome_diagnostics::location::AsSpan; use biome_diagnostics::{ @@ -47,6 +47,155 @@ pub struct RuleMetadata { pub domains: &'static [RuleDomain], } +impl biome_console::fmt::Display for RuleMetadata { + fn fmt(&self, fmt: &mut Formatter) -> std::io::Result<()> { + fmt.write_markup(markup! { + "Summary" + })?; + fmt.write_str("\n")?; + fmt.write_str("\n")?; + + fmt.write_markup(markup! { + "- Name: "{self.name} + })?; + fmt.write_str("\n")?; + match self.fix_kind { + FixKind::None => { + fmt.write_markup(markup! { + "- No fix available." + })?; + } + kind => { + fmt.write_markup(markup! { + "- Fix: "{kind} + })?; + } + } + fmt.write_str("\n")?; + + fmt.write_markup(markup! { + "- Default severity: "{self.severity} + })?; + fmt.write_str("\n")?; + + fmt.write_markup(markup! { + "- Available from version: "{self.version} + })?; + fmt.write_str("\n")?; + + if self.domains.is_empty() && self.recommended { + fmt.write_markup(markup! { + "- This rule is not recommended" + })?; + } + + let domains = DisplayDomains(self.domains, self.recommended); + + fmt.write_str("\n")?; + + fmt.write_markup(markup!({ domains }))?; + + fmt.write_str("\n")?; + + fmt.write_markup(markup! { + "Description" + })?; + fmt.write_str("\n")?; + fmt.write_str("\n")?; + + for line in self.docs.lines() { + if let Some((_, remainder)) = line.split_once("## ") { + fmt.write_markup(markup! { + {remainder.trim_start()} + })?; + } else if let Some((_, remainder)) = line.split_once("### ") { + fmt.write_markup(markup! { + {remainder.trim_start()} + })?; + } else { + fmt.write_str(line)?; + } + + fmt.write_str("\n")?; + } + + Ok(()) + } +} + +struct DisplayDomains(&'static [RuleDomain], bool); + +impl Display for DisplayDomains { + fn fmt(&self, fmt: &mut Formatter) -> std::io::Result<()> { + let domains = self.0; + let recommended = self.1; + + if domains.is_empty() { + return Ok(()); + } + + fmt.write_markup(markup!( + "Domains" + ))?; + fmt.write_str("\n")?; + fmt.write_str("\n")?; + + for domain in domains { + let dependencies = domain.manifest_dependencies(); + + fmt.write_markup(markup! { + "- Name: "{domain} + })?; + fmt.write_str("\n")?; + + if recommended { + fmt.write_markup(markup! { + "- The rule is recommended for this domain" + })?; + fmt.write_str("\n")?; + } + + if !dependencies.is_empty() { + fmt.write_markup(markup! { + "- The rule is enabled when one of these dependencies are detected:" + })?; + fmt.write_str("\n")?; + let padding = Padding::new(2); + for (index, (dep, range)) in dependencies.iter().enumerate() { + fmt.write_markup( + markup! { {padding}"- "{dep}"@"{range} }, + )?; + if index + 1 < dependencies.len() { + fmt.write_str("\n")?; + } + } + fmt.write_str("\n")?; + } + + let globals = domain.globals(); + + if !globals.is_empty() { + fmt.write_markup(markup! { + "- The rule adds the following globals: " + })?; + fmt.write_str("\n")?; + + let padding = Padding::new(2); + for (index, global) in globals.iter().enumerate() { + fmt.write_markup(markup! { {padding}"- "{global} })?; + if index + 1 < globals.len() { + fmt.write_str("\n")?; + } + } + fmt.write_str("\n")?; + } + fmt.write_str("\n")?; + } + + Ok(()) + } +} + #[derive(Clone, Copy, Debug, Default, Eq, PartialEq)] #[cfg_attr( feature = "serde", @@ -73,9 +222,9 @@ pub enum FixKind { impl Display for FixKind { fn fmt(&self, fmt: &mut biome_console::fmt::Formatter) -> std::io::Result<()> { match self { - FixKind::None => fmt.write_str("None"), - FixKind::Safe => fmt.write_str("Safe"), - FixKind::Unsafe => fmt.write_str("Unsafe"), + FixKind::None => fmt.write_markup(markup!("none")), + FixKind::Safe => fmt.write_markup(markup!("safe")), + FixKind::Unsafe => fmt.write_markup(markup!("unsafe")), } } } @@ -338,6 +487,18 @@ pub enum RuleDomain { Next, } +impl Display for RuleDomain { + fn fmt(&self, fmt: &mut Formatter) -> std::io::Result<()> { + // use lower case naming, it needs to match the name of the configuration + match self { + RuleDomain::React => fmt.write_str("react"), + RuleDomain::Test => fmt.write_str("test"), + RuleDomain::Solid => fmt.write_str("solid"), + RuleDomain::Next => fmt.write_str("next"), + } + } +} + impl RuleDomain { /// If the project has one of these dependencies, the domain will be automatically enabled, unless it's explicitly disabled by the configuration. /// @@ -352,7 +513,7 @@ impl RuleDomain { &("vitest", ">=1.0.0"), ], RuleDomain::Solid => &[&("solid", ">=1.0.0")], - RuleDomain::Next => &[&("react", ">=16.0.0"), &("next", ">=14.0.0")], + RuleDomain::Next => &[&("next", ">=14.0.0")], } } @@ -378,17 +539,6 @@ impl RuleDomain { } } -impl Display for RuleDomain { - fn fmt(&self, fmt: &mut Formatter) -> std::io::Result<()> { - match self { - RuleDomain::React => fmt.write_str("React"), - RuleDomain::Test => fmt.write_str("Test"), - RuleDomain::Solid => fmt.write_str("Solid"), - RuleDomain::Next => fmt.write_str("Next.js"), - } - } -} - impl RuleMetadata { pub const fn new( version: &'static str, diff --git a/crates/biome_cli/src/commands/explain.rs b/crates/biome_cli/src/commands/explain.rs index 81a69e07650a..d7a2628469fe 100644 --- a/crates/biome_cli/src/commands/explain.rs +++ b/crates/biome_cli/src/commands/explain.rs @@ -1,4 +1,4 @@ -use biome_analyze::{FixKind, RuleMetadata}; +use biome_analyze::RuleMetadata; use biome_console::{markup, ConsoleExt}; use biome_flags::biome_env; use biome_service::documentation::Doc; @@ -8,34 +8,7 @@ use crate::{CliDiagnostic, CliSession}; fn print_rule(session: CliSession, metadata: &RuleMetadata) { session.app.console.log(markup! { - "# "{metadata.name}"\n" - }); - - match metadata.fix_kind { - FixKind::None => { - session.app.console.log(markup! { - "No fix available.\n" - }); - } - kind => { - session.app.console.log(markup! { - "Fix is "{kind}".\n" - }); - } - } - - let docs = metadata - .docs - .lines() - .map(|line| line.trim_start()) - .collect::>() - .join("\n"); - - session.app.console.log(markup! { - "This rule is "{if metadata.recommended {"recommended."} else {"not recommended."}} - "\n\n" - "# Description\n" - {docs} + {metadata} }); } diff --git a/crates/biome_cli/tests/cases/handle_astro_files.rs b/crates/biome_cli/tests/cases/handle_astro_files.rs index f1130fb473be..891140e684d7 100644 --- a/crates/biome_cli/tests/cases/handle_astro_files.rs +++ b/crates/biome_cli/tests/cases/handle_astro_files.rs @@ -1,7 +1,5 @@ use crate::run_cli; -use crate::snap_test::{ - assert_cli_snapshot, assert_file_contents, markup_to_string, SnapshotPayload, -}; +use crate::snap_test::{assert_cli_snapshot, markup_to_string, SnapshotPayload}; use biome_console::{markup, BufferConsole}; use biome_fs::MemoryFileSystem; use bpaf::Args; @@ -56,12 +54,6 @@ if (foo) { ---
"#; -const ASTRO_FILE_IMPORTS_AFTER: &str = r#"--- -import { Code } from "astro:components"; -import { getLocale } from "astro:i18n"; ---- -
"#; - const ASTRO_CARRIAGE_RETURN_LINE_FEED_FILE_UNFORMATTED: &str = "---\r\n const a = \"b\";\r\n---\r\n
"; @@ -74,23 +66,6 @@ var foo: string = ""; ---
"#; -const ASTRO_FILE_CHECK_APPLY_AFTER: &str = r#"--- -import { something } from "file.astro"; -import { a } from "mod"; -debugger; -statement(); -var foo = ""; ---- -
"#; - -const ASTRO_FILE_CHECK_APPLY_UNSAFE_AFTER: &str = r#"--- -import { something } from "file.astro"; -import { a } from "mod"; -statement(); -const foo = ""; ---- -
"#; - const ASTRO_FILE_ASTRO_GLOBAL_OBJECT: &str = r#"--- const { some } = Astro.props --- @@ -112,8 +87,6 @@ fn format_astro_files() { assert!(result.is_err(), "run_cli returned {result:?}"); - assert_file_contents(&fs, astro_file_path, ASTRO_FILE_UNFORMATTED); - assert_cli_snapshot(SnapshotPayload::new( module_path!(), "format_astro_files", @@ -146,8 +119,6 @@ fn format_astro_files_write() { assert!(result.is_ok(), "run_cli returned {result:?}"); - assert_file_contents(&fs, astro_file_path, ASTRO_FILE_FORMATTED); - assert_cli_snapshot(SnapshotPayload::new( module_path!(), "format_astro_files_write", @@ -180,8 +151,6 @@ fn format_empty_astro_files_write() { assert!(result.is_ok(), "run_cli returned {result:?}"); - assert_file_contents(&fs, astro_file_path, "
"); - assert_cli_snapshot(SnapshotPayload::new( module_path!(), "format_empty_astro_files_write", @@ -210,12 +179,6 @@ fn format_astro_carriage_return_line_feed_files() { assert!(result.is_err(), "run_cli returned {result:?}"); - assert_file_contents( - &fs, - astro_file_path, - ASTRO_CARRIAGE_RETURN_LINE_FEED_FILE_UNFORMATTED, - ); - assert_cli_snapshot(SnapshotPayload::new( module_path!(), "format_astro_carriage_return_line_feed_files", @@ -280,8 +243,6 @@ fn lint_and_fix_astro_files() { assert!(result.is_ok(), "run_cli returned {result:?}"); - assert_file_contents(&fs, astro_file_path, ASTRO_FILE_DEBUGGER_AFTER); - assert_cli_snapshot(SnapshotPayload::new( module_path!(), "lint_and_fix_astro_files", @@ -315,8 +276,6 @@ fn sorts_imports_check() { assert!(result.is_err(), "run_cli returned {result:?}"); - assert_file_contents(&fs, astro_file_path, ASTRO_FILE_IMPORTS_BEFORE); - assert_cli_snapshot(SnapshotPayload::new( module_path!(), "sorts_imports_check", @@ -351,8 +310,6 @@ fn sorts_imports_write() { assert!(result.is_ok(), "run_cli returned {result:?}"); - assert_file_contents(&fs, astro_file_path, ASTRO_FILE_IMPORTS_AFTER); - assert_cli_snapshot(SnapshotPayload::new( module_path!(), "sorts_imports_write", @@ -627,17 +584,6 @@ fn check_stdin_write_successfully() { assert!(result.is_ok(), "run_cli returned {result:?}"); - let message = console - .out_buffer - .first() - .expect("Console should have written a message"); - - let content = markup_to_string(markup! { - {message.content} - }); - - assert_eq!(content, ASTRO_FILE_CHECK_APPLY_AFTER); - assert_cli_snapshot(SnapshotPayload::new( module_path!(), "check_stdin_write_successfully", @@ -671,17 +617,6 @@ fn check_stdin_write_unsafe_successfully() { assert!(result.is_ok(), "run_cli returned {result:?}"); - let message = console - .out_buffer - .first() - .expect("Console should have written a message"); - - let content = markup_to_string(markup! { - {message.content} - }); - - assert_eq!(content, ASTRO_FILE_CHECK_APPLY_UNSAFE_AFTER); - assert_cli_snapshot(SnapshotPayload::new( module_path!(), "check_stdin_write_unsafe_successfully", @@ -710,8 +645,6 @@ fn astro_global_object() { assert!(result.is_ok(), "run_cli returned {result:?}"); - assert_file_contents(&fs, astro_file_path, ASTRO_FILE_ASTRO_GLOBAL_OBJECT); - assert_cli_snapshot(SnapshotPayload::new( module_path!(), "astro_global", diff --git a/crates/biome_cli/tests/cases/handle_svelte_files.rs b/crates/biome_cli/tests/cases/handle_svelte_files.rs index 5dc6c35c67c3..d18bbf95868e 100644 --- a/crates/biome_cli/tests/cases/handle_svelte_files.rs +++ b/crates/biome_cli/tests/cases/handle_svelte_files.rs @@ -1,8 +1,6 @@ use crate::run_cli; -use crate::snap_test::{ - assert_cli_snapshot, assert_file_contents, markup_to_string, SnapshotPayload, -}; -use biome_console::{markup, BufferConsole}; +use crate::snap_test::{assert_cli_snapshot, assert_file_contents, SnapshotPayload}; +use biome_console::BufferConsole; use biome_fs::MemoryFileSystem; use bpaf::Args; use std::path::Path; @@ -39,16 +37,6 @@ var foo: string = "";
"#; -const SVELTE_TS_FILE_LINT_APPLY_AFTER: &str = r#" -
"#; - -const SVELTE_TS_FILE_LINT_APPLY_UNSAFE_AFTER: &str = r#" -
"#; - const SVELTE_TS_FILE_CHECK_BEFORE: &str = r#"
"#; -const SVELTE_TS_FILE_CHECK_APPLY_AFTER: &str = r#" -
"#; - -const SVELTE_TS_FILE_CHECK_APPLY_UNSAFE_AFTER: &str = r#" -
"#; - #[test] fn sorts_imports_check() { let mut fs = MemoryFileSystem::default(); @@ -278,17 +249,6 @@ fn format_stdin_successfully() { assert!(result.is_ok(), "run_cli returned {result:?}"); - let message = console - .out_buffer - .first() - .expect("Console should have written a message"); - - let content = markup_to_string(markup! { - {message.content} - }); - - assert_eq!(content, SVELTE_TS_CONTEXT_MODULE_FILE_FORMATTED); - assert_cli_snapshot(SnapshotPayload::new( module_path!(), "format_stdin_successfully", @@ -315,17 +275,6 @@ fn format_stdin_write_successfully() { assert!(result.is_ok(), "run_cli returned {result:?}"); - let message = console - .out_buffer - .first() - .expect("Console should have written a message"); - - let content = markup_to_string(markup! { - {message.content} - }); - - assert_eq!(content, SVELTE_TS_CONTEXT_MODULE_FILE_FORMATTED); - assert_cli_snapshot(SnapshotPayload::new( module_path!(), "format_stdin_write_successfully", @@ -352,17 +301,6 @@ fn lint_stdin_successfully() { assert!(result.is_err(), "run_cli returned {result:?}"); - let message = console - .out_buffer - .first() - .expect("Console should have written a message"); - - let content = markup_to_string(markup! { - {message.content} - }); - - assert_eq!(content, SVELTE_TS_FILE_LINT_BEFORE); - assert_cli_snapshot(SnapshotPayload::new( module_path!(), "lint_stdin_successfully", @@ -389,17 +327,6 @@ fn lint_stdin_write_successfully() { assert!(result.is_ok(), "run_cli returned {result:?}"); - let message = console - .out_buffer - .first() - .expect("Console should have written a message"); - - let content = markup_to_string(markup! { - {message.content} - }); - - assert_eq!(content, SVELTE_TS_FILE_LINT_APPLY_AFTER); - assert_cli_snapshot(SnapshotPayload::new( module_path!(), "lint_stdin_write_successfully", @@ -435,17 +362,6 @@ fn lint_stdin_write_unsafe_successfully() { assert!(result.is_ok(), "run_cli returned {result:?}"); - let message = console - .out_buffer - .first() - .expect("Console should have written a message"); - - let content = markup_to_string(markup! { - {message.content} - }); - - assert_eq!(content, SVELTE_TS_FILE_LINT_APPLY_UNSAFE_AFTER); - assert_cli_snapshot(SnapshotPayload::new( module_path!(), "lint_stdin_write_unsafe_successfully", @@ -472,17 +388,6 @@ fn check_stdin_successfully() { assert!(result.is_err(), "run_cli returned {result:?}"); - let message = console - .out_buffer - .first() - .expect("Console should have written a message"); - - let content = markup_to_string(markup! { - {message.content} - }); - - assert_eq!(content, SVELTE_TS_FILE_CHECK_BEFORE); - assert_cli_snapshot(SnapshotPayload::new( module_path!(), "check_stdin_successfully", @@ -509,17 +414,6 @@ fn check_stdin_write_successfully() { assert!(result.is_ok(), "run_cli returned {result:?}"); - let message = console - .out_buffer - .first() - .expect("Console should have written a message"); - - let content = markup_to_string(markup! { - {message.content} - }); - - assert_eq!(content, SVELTE_TS_FILE_CHECK_APPLY_AFTER); - assert_cli_snapshot(SnapshotPayload::new( module_path!(), "check_stdin_write_successfully", @@ -555,17 +449,6 @@ fn check_stdin_write_unsafe_successfully() { assert!(result.is_ok(), "run_cli returned {result:?}"); - let message = console - .out_buffer - .first() - .expect("Console should have written a message"); - - let content = markup_to_string(markup! { - {message.content} - }); - - assert_eq!(content, SVELTE_TS_FILE_CHECK_APPLY_UNSAFE_AFTER); - assert_cli_snapshot(SnapshotPayload::new( module_path!(), "check_stdin_write_unsafe_successfully", diff --git a/crates/biome_cli/tests/cases/handle_vue_files.rs b/crates/biome_cli/tests/cases/handle_vue_files.rs index 33b7d7dec42d..f03621ea5297 100644 --- a/crates/biome_cli/tests/cases/handle_vue_files.rs +++ b/crates/biome_cli/tests/cases/handle_vue_files.rs @@ -1,8 +1,6 @@ use crate::run_cli; -use crate::snap_test::{ - assert_cli_snapshot, assert_file_contents, markup_to_string, SnapshotPayload, -}; -use biome_console::{markup, BufferConsole}; +use crate::snap_test::{assert_cli_snapshot, assert_file_contents, SnapshotPayload}; +use biome_console::BufferConsole; use biome_fs::MemoryFileSystem; use bpaf::Args; use std::path::Path; @@ -59,22 +57,6 @@ var foo: string = ""; "#; -const VUE_TS_FILE_SAFE_LINTED: &str = r#" -"#; - -const VUE_TS_FILE_UNSAFE_LINTED: &str = r#" -"#; - const VUE_FILE_IMPORTS_BEFORE: &str = r#" "#; -const VUE_TS_FILE_CHECK_APPLY_AFTER: &str = r#" -"#; - -const VUE_TS_FILE_CHECK_APPLY_UNSAFE_AFTER: &str = r#" -"#; - const VUE_TS_FILE_SETUP_GLOBALS: &str = r#"
``` diff --git a/crates/biome_cli/tests/snapshots/main_cases_handle_svelte_files/check_stdin_write_unsafe_successfully.snap b/crates/biome_cli/tests/snapshots/main_cases_handle_svelte_files/check_stdin_write_unsafe_successfully.snap index 0a98c5fcd685..7cf98f1404e3 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_handle_svelte_files/check_stdin_write_unsafe_successfully.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_handle_svelte_files/check_stdin_write_unsafe_successfully.snap @@ -1,6 +1,7 @@ --- source: crates/biome_cli/tests/snap_test.rs expression: content +snapshot_kind: text --- # Input messages @@ -22,7 +23,7 @@ var foo: string = ""; import Button from "./components/Button.svelte"; import { Form } from "./components/Form.svelte"; statement(); -const foo = ""; +var foo: string = "";
``` diff --git a/crates/biome_cli/tests/snapshots/main_cases_handle_svelte_files/lint_stdin_write_successfully.snap b/crates/biome_cli/tests/snapshots/main_cases_handle_svelte_files/lint_stdin_write_successfully.snap index 2d0ed2d990fc..84c51eb6a9c1 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_handle_svelte_files/lint_stdin_write_successfully.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_handle_svelte_files/lint_stdin_write_successfully.snap @@ -1,6 +1,7 @@ --- source: crates/biome_cli/tests/snap_test.rs expression: content +snapshot_kind: text --- # Input messages @@ -15,7 +16,7 @@ var foo: string = ""; ```block
``` diff --git a/crates/biome_cli/tests/snapshots/main_cases_handle_svelte_files/lint_stdin_write_unsafe_successfully.snap b/crates/biome_cli/tests/snapshots/main_cases_handle_svelte_files/lint_stdin_write_unsafe_successfully.snap index 0dc49a8449e6..84c51eb6a9c1 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_handle_svelte_files/lint_stdin_write_unsafe_successfully.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_handle_svelte_files/lint_stdin_write_unsafe_successfully.snap @@ -1,6 +1,7 @@ --- source: crates/biome_cli/tests/snap_test.rs expression: content +snapshot_kind: text --- # Input messages @@ -15,7 +16,7 @@ var foo: string = ""; ```block
``` diff --git a/crates/biome_cli/tests/snapshots/main_cases_handle_vue_files/lint_stdin_write_successfully.snap b/crates/biome_cli/tests/snapshots/main_cases_handle_vue_files/lint_stdin_write_successfully.snap index 974af3363c36..1d3412d13497 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_handle_vue_files/lint_stdin_write_successfully.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_handle_vue_files/lint_stdin_write_successfully.snap @@ -1,6 +1,7 @@ --- source: crates/biome_cli/tests/snap_test.rs expression: content +snapshot_kind: text --- # Input messages @@ -21,7 +22,7 @@ var foo: string = ""; a == b; delete a.c; -var foo = ""; +var foo: string = ""; ``` diff --git a/crates/biome_cli/tests/snapshots/main_cases_handle_vue_files/lint_stdin_write_unsafe_successfully.snap b/crates/biome_cli/tests/snapshots/main_cases_handle_vue_files/lint_stdin_write_unsafe_successfully.snap index cb97f85e05a2..c96e463df16a 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_handle_vue_files/lint_stdin_write_unsafe_successfully.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_handle_vue_files/lint_stdin_write_unsafe_successfully.snap @@ -1,6 +1,7 @@ --- source: crates/biome_cli/tests/snap_test.rs expression: content +snapshot_kind: text --- # Input messages @@ -21,7 +22,7 @@ var foo: string = ""; a === b; a.c = undefined; -const foo = ""; +var foo: string = ""; ``` diff --git a/crates/biome_cli/tests/snapshots/main_cases_handle_vue_files/lint_vue_js_files.snap b/crates/biome_cli/tests/snapshots/main_cases_handle_vue_files/lint_vue_js_files.snap index 3f6424daa4b6..bef9edfe5b10 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_handle_vue_files/lint_vue_js_files.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_handle_vue_files/lint_vue_js_files.snap @@ -1,6 +1,7 @@ --- source: crates/biome_cli/tests/snap_test.rs expression: content +snapshot_kind: text --- ## `file.vue` @@ -75,36 +76,9 @@ file.vue:3:1 lint/performance/noDelete FIXABLE ━━━━━━━━━━ 4 4 │ var foo = ""; -``` - -```block -file.vue:5:1 lint/style/noVar FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × Use let or const instead of var. - - 3 │ delete a.c; - 4 │ - > 5 │ var foo = ""; - │ ^^^^^^^^^^^^ - 6 │ - 7 │ - - i A variable declared with var is accessible in the whole module. Thus, the variable can be accessed before its initialization and outside the block where it is declared. - - i See MDN web docs for more details. - - i Unsafe fix: Use 'const' instead. - - 2 2 │ delete a.c; - 3 3 │ - 4 │ - var·foo·=·""; - 4 │ + const·foo·=·""; - 5 5 │ - - ``` ```block Checked 1 file in