diff --git a/biome.json b/biome.json index ded692c24334..58cab944909f 100644 --- a/biome.json +++ b/biome.json @@ -1,72 +1,85 @@ { - "$schema": "./packages/@biomejs/biome/configuration_schema.json", - "assist": { - "enabled": true, - "ignore": [ - "./packages/@biomejs/biome/configuration_schema.json" - ], - "actions": { - "source": { - "useSortedKeys": "off" - } - } - }, - "css": { - "linter": { - "enabled": true - } - }, - "files": { - "ignore": [ - "crates/**", - "dist/**", - ".astro/**", - "assets/**", - "packages/@biomejs/backend-jsonrpc/src/workspace.ts", - "public/**", - "**/__snapshots__", - "**/undefined/**", - "_fonts/**", - "packages/@biomejs/wasm-*", - "benchmark/target/**" - ], - "include": [ - "packages/aria-data/*.js", - "packages/@biomejs/**", - "packages/tailwindcss-config-analyzer/**", - "benchmark/**" - ] - }, - "formatter": { - "ignore": [ - "configuration_schema.json" - ] - }, - "json": { - "formatter": { - "indentStyle": "space", - "lineWidth": 1 - } - }, - "linter": { - "enabled": true, - "rules": { - "recommended": true, - "correctness": { - "noUndeclaredDependencies": "error" - }, - "style": { - "noNonNullAssertion": "off", - "useNodejsImportProtocol": "error" - }, - "suspicious": { - "noVar": "on" - } - } - }, - "vcs": { - "clientKind": "git", - "enabled": true, - "useIgnoreFile": true - } + "$schema": "./packages/@biomejs/biome/configuration_schema.json", + "assist": { + "enabled": true, + "ignore": ["./packages/@biomejs/biome/configuration_schema.json"], + "actions": { + "source": { + "useSortedKeys": "off" + } + } + }, + "css": { + "linter": { + "enabled": true + } + }, + "files": { + "includes": [ + "**/packages/aria-data/*.js", + "**/packages/@biomejs/**", + "**/packages/tailwindcss-config-analyzer/**", + "**/benchmark/**", + "!**/crates/**", + "!**/dist/**", + "!**/.astro/**", + "!**/assets/**", + "!**/packages/@biomejs/backend-jsonrpc/src/workspace.ts", + "!**/public/**", + "!**/__snapshots__", + "!**/undefined/**", + "!**/_fonts/**", + "!**/packages/@biomejs/wasm-*", + "!**/benchmark/target/**" + ] + }, + "formatter": { + "includes": ["**", "!**/configuration_schema.json"] + }, + "json": { + "formatter": { + "indentStyle": "space", + "lineWidth": 1 + } + }, + "linter": { + "enabled": true, + "rules": { + "style": { + "noNonNullAssertion": "off", + "useNodejsImportProtocol": "error", + "useLiteralEnumMembers": "error", + "noArguments": "error", + "noParameterAssign": "error", + "useShorthandFunctionType": "error", + "useExportType": "error", + "useDefaultParameterLast": "error", + "noCommaOperator": "error", + "useSingleVarDeclarator": "error", + "useConst": "error", + "noInferrableTypes": "error", + "useExponentiationOperator": "error", + "noUselessElse": "error", + "useSelfClosingElements": "error", + "useImportType": "error", + "useNumberNamespace": "error", + "useAsConstAssertion": "error", + "noUnusedTemplateLiteral": "error", + "useNumericLiterals": "error", + "useTemplate": "error", + "useEnumInitializers": "error" + }, + "correctness": { + "noUndeclaredDependencies": "error" + }, + "suspicious": { + "noVar": "on" + } + } + }, + "vcs": { + "clientKind": "git", + "enabled": true, + "useIgnoreFile": true + } } diff --git a/crates/biome_cli/src/commands/migrate.rs b/crates/biome_cli/src/commands/migrate.rs index 971facc13eea..bf64b11ae4fd 100644 --- a/crates/biome_cli/src/commands/migrate.rs +++ b/crates/biome_cli/src/commands/migrate.rs @@ -59,15 +59,11 @@ impl CommandRunner for MigrateCommandPayload { _workspace: &dyn Workspace, project_key: ProjectKey, ) -> Result { - if let (Some(path), Some(directory_path)) = ( - self.configuration_file_path.clone(), - self.configuration_directory_path.clone(), - ) { + if let Some(path) = self.configuration_file_path.clone() { Ok(Execution::new(TraversalMode::Migrate { project_key, write: self.should_write(), configuration_file_path: path, - configuration_directory_path: directory_path, sub_command: self.sub_command.clone(), })) } else { diff --git a/crates/biome_cli/src/execute/migrate.rs b/crates/biome_cli/src/execute/migrate.rs index b2fca5718a88..d9889c6731ee 100644 --- a/crates/biome_cli/src/execute/migrate.rs +++ b/crates/biome_cli/src/execute/migrate.rs @@ -10,7 +10,9 @@ use biome_deserialize::Merge; use biome_diagnostics::Diagnostic; use biome_diagnostics::{category, PrintDiagnostic}; use biome_formatter::ParseFormatNumberError; -use biome_fs::{BiomePath, ConfigName, FileSystemExt, OpenOptions}; +use biome_fs::{BiomePath, OpenOptions}; +use biome_json_formatter::context::JsonFormatOptions; +use biome_json_formatter::format_node; use biome_json_parser::{parse_json_with_cache, JsonParserOptions}; use biome_json_syntax::{JsonFileSource, JsonRoot}; use biome_migrate::{migrate_configuration, ControlFlow}; @@ -38,7 +40,6 @@ pub(crate) struct MigratePayload<'a> { pub(crate) project_key: ProjectKey, pub(crate) write: bool, pub(crate) configuration_file_path: Utf8PathBuf, - pub(crate) configuration_directory_path: Utf8PathBuf, pub(crate) verbose: bool, pub(crate) sub_command: Option, } @@ -49,7 +50,6 @@ pub(crate) fn run(migrate_payload: MigratePayload) -> Result<(), CliDiagnostic> project_key, write, configuration_file_path, - configuration_directory_path, verbose, sub_command, } = migrate_payload; @@ -69,6 +69,12 @@ pub(crate) fn run(migrate_payload: MigratePayload) -> Result<(), CliDiagnostic> biome_config_file.read_to_string(&mut biome_config_content)?; let biome_path = BiomePath::new(configuration_file_path.as_path()); + let parse_options = match configuration_file_path.extension() { + Some("jsonc") => JsonParserOptions::default() + .with_allow_comments() + .with_allow_trailing_commas(), + _ => JsonParserOptions::default(), + }; workspace.open_file(OpenFileParams { project_key, path: biome_path.clone(), @@ -77,11 +83,7 @@ pub(crate) fn run(migrate_payload: MigratePayload) -> Result<(), CliDiagnostic> document_file_source: Some(JsonFileSource::json().into()), persist_node_cache: false, })?; - let parsed = parse_json_with_cache( - &biome_config_content, - &mut cache, - JsonParserOptions::default(), - ); + let parsed = parse_json_with_cache(&biome_config_content, &mut cache, parse_options); match sub_command { Some(MigrateSubCommand::Prettier) => { @@ -250,9 +252,6 @@ pub(crate) fn run(migrate_payload: MigratePayload) -> Result<(), CliDiagnostic> } } None => { - let has_deprecated_configuration = - configuration_file_path.file_name() == Some("rome.json"); - let mut errors = 0; let mut tree = parsed.tree(); let mut actions = Vec::new(); @@ -261,7 +260,6 @@ pub(crate) fn run(migrate_payload: MigratePayload) -> Result<(), CliDiagnostic> &tree, AnalysisFilter::default(), configuration_file_path.as_path(), - biome_configuration::VERSION.to_string(), |signal| { let current_diagnostic = signal.diagnostic(); if current_diagnostic.is_some() { @@ -299,16 +297,20 @@ pub(crate) fn run(migrate_payload: MigratePayload) -> Result<(), CliDiagnostic> } let new_configuration_content = tree.to_string(); - if biome_config_content != new_configuration_content || has_deprecated_configuration { + if biome_config_content != new_configuration_content { if write { - let mut configuration_file = if has_deprecated_configuration { - let biome_file_path = - configuration_directory_path.join(ConfigName::biome_json()); - fs.create_new(biome_file_path.as_path())? + let mut configuration_file = biome_config_file; + let format_options = JsonFormatOptions::default(); + let formatted = format_node(format_options, tree.syntax()) + .ok() + .map(|formatted| formatted.print()) + .and_then(|printed| printed.ok()); + + if let Some(formatted) = formatted { + configuration_file.set_content(formatted.as_code().as_bytes())?; } else { - biome_config_file - }; - configuration_file.set_content(tree.to_string().as_bytes())?; + configuration_file.set_content(new_configuration_content.as_bytes())?; + } console.log(markup!{ "The configuration "{{configuration_file_path.to_string()}}" has been successfully migrated." }) diff --git a/crates/biome_cli/src/execute/mod.rs b/crates/biome_cli/src/execute/mod.rs index 538e89946c74..3c6d76756865 100644 --- a/crates/biome_cli/src/execute/mod.rs +++ b/crates/biome_cli/src/execute/mod.rs @@ -164,8 +164,6 @@ pub enum TraversalMode { write: bool, /// The path to `biome.json` configuration_file_path: Utf8PathBuf, - /// The path directory where `biome.json` is placed - configuration_directory_path: Utf8PathBuf, sub_command: Option, }, /// This mode is enabled when running the command `biome search` @@ -509,7 +507,6 @@ pub fn execute_mode( project_key, write, configuration_file_path, - configuration_directory_path, sub_command, } = execution.traversal_mode { @@ -518,7 +515,6 @@ pub fn execute_mode( project_key, write, configuration_file_path, - configuration_directory_path, verbose: cli_options.verbose, sub_command, }; diff --git a/crates/biome_cli/tests/cases/migrate_v2.rs b/crates/biome_cli/tests/cases/migrate_v2.rs new file mode 100644 index 000000000000..28d01b19c8c3 --- /dev/null +++ b/crates/biome_cli/tests/cases/migrate_v2.rs @@ -0,0 +1,465 @@ +//! Migrations for Biome v2 + +use crate::run_cli; +use crate::snap_test::{assert_cli_snapshot, SnapshotPayload}; +use biome_console::BufferConsole; +use biome_fs::MemoryFileSystem; +use bpaf::Args; +use camino::Utf8Path; + +#[test] +fn should_successfully_migrate_knip() { + let mut fs = MemoryFileSystem::default(); + let mut console = BufferConsole::default(); + + let configuration_path = Utf8Path::new("biome.json"); + fs.insert( + configuration_path.into(), + r#"{ + "$schema": "https://biomejs.dev/schemas/1.8.3/schema.json", + "files": { + "ignore": [ + "**/dist", + "**/fixtures", + "packages/knip/package.json", + "packages/knip/vendor/bash-parser/index.js", + "packages/docs/.astro" + ] + }, + "organizeImports": { + "enabled": true + }, + "linter": { + "enabled": true, + "rules": { + "recommended": true, + "correctness": { + "noUnusedVariables": "error", + "noUnusedImports": "error" + }, + "complexity": { + "useLiteralKeys": "off" + }, + "nursery": { + "noRestrictedImports": { + "level": "error", + "options": { + "paths": { + "node:path": "Please use src/util/path.js instead.", + "path": "Please use src/util/path.js instead." + } + } + } + }, + "style": { + "noParameterAssign": "off", + "useNodeAssertStrict": "error" + }, + "suspicious": { + "noConsoleLog": "error", + "noExplicitAny": "off" + } + } + }, + "formatter": { + "enabled": true, + "lineWidth": 120, + "indentStyle": "space", + "formatWithErrors": true + }, + "javascript": { + "formatter": { + "quoteStyle": "single", + "arrowParentheses": "asNeeded", + "trailingCommas": "es5" + } + }, + "json": { + "formatter": { + "lineWidth": 80 + } + }, + "css": { + "formatter": { + "quoteStyle": "single" + } + }, + "overrides": [ + { + "include": ["*.astro"], + "linter": { + "rules": { + "correctness": { + "noUnusedVariables": "off", + "noUnusedImports": "off" + } + } + } + }, + { + "include": [ + "packages/docs", + "packages/knip/scripts", + "packages/knip/src/cli.ts", + "packages/knip/src/reporters", + "packages/knip/src/util/cli-arguments.ts", + "packages/knip/src/util/debug.ts" + ], + "linter": { + "rules": { + "suspicious": { + "noConsoleLog": "off" + } + } + } + }, + { + "include": ["packages/knip/fixtures"], + "organizeImports": { + "enabled": false + }, + "linter": { + "rules": { + "correctness": { + "noUnusedVariables": "off", + "noUnusedImports": "off" + }, + "style": { + "useImportType": "off" + } + } + } + }, + { + "include": ["packages/knip/test/util/get-inputs-from-scripts.test.ts"], + "formatter": { + "lineWidth": 200 + } + } + ] +}"# + .as_bytes(), + ); + + let (fs, result) = run_cli( + fs, + &mut console, + Args::from(["migrate", "--write"].as_slice()), + ); + + assert!(result.is_ok(), "run_cli returned {result:?}"); + + assert_cli_snapshot(SnapshotPayload::new( + module_path!(), + "should_successfully_migrate_knip", + fs, + console, + result, + )); +} + +#[test] +fn should_successfully_migrate_ariakit() { + let mut fs = MemoryFileSystem::default(); + let mut console = BufferConsole::default(); + + let configuration_path = Utf8Path::new("biome.json"); + fs.insert( + configuration_path.into(), + r#"{ + "$schema": "./node_modules/@biomejs/biome/configuration_schema.json", + "vcs": { + "enabled": true, + "clientKind": "git", + "useIgnoreFile": true + }, + "files": { + "ignoreUnknown": true, + "ignore": ["website/.next/**", "website/.pages/**", "**/*.css"] + }, + "organizeImports": { + "enabled": true + }, + "formatter": { + "enabled": true, + "indentStyle": "space" + }, + "linter": { + "enabled": true, + "rules": { + "recommended": true, + "security": { + "noDangerouslySetInnerHtml": "off" + }, + "a11y": { + "noSvgWithoutTitle": "off", + "useButtonType": "off", + "useAnchorContent": "off", + "useValidAnchor": "off", + "useKeyWithClickEvents": "off", + "noAutofocus": "off", + "noLabelWithoutControl": "off", + "useSemanticElements": "off", + "useFocusableInteractive": "off" + }, + "suspicious": { + "noExplicitAny": "off", + "noShadowRestrictedNames": "off", + "noConfusingVoidType": "off", + "noArrayIndexKey": "off", + "noAssignInExpressions": "off" + }, + "correctness": { + "useExhaustiveDependencies": "off", + "useJsxKeyInIterable": "off" + }, + "style": { + "noParameterAssign": "off", + "noUnusedTemplateLiteral": "off", + "noNonNullAssertion": "off", + "noUselessElse": "off" + } + } + } +} +"# + .as_bytes(), + ); + + let (fs, result) = run_cli( + fs, + &mut console, + Args::from(["migrate", "--write"].as_slice()), + ); + + assert!(result.is_ok(), "run_cli returned {result:?}"); + + assert_cli_snapshot(SnapshotPayload::new( + module_path!(), + "should_successfully_migrate_ariakit", + fs, + console, + result, + )); +} + +#[test] +fn should_successfully_migrate_sentry() { + let mut fs = MemoryFileSystem::default(); + let mut console = BufferConsole::default(); + + let configuration_path = Utf8Path::new("biome.json"); + fs.insert( + configuration_path.into(), + r#"{ + "$schema": "./node_modules/@biomejs/biome/configuration_schema.json", + "vcs": { + "enabled": true, + "clientKind": "git", + "useIgnoreFile": true, + "defaultBranch": "master" + }, + "organizeImports": { + "enabled": false + }, + "linter": { + "enabled": true, + "rules": { + "recommended": false, + "a11y": { + "noBlankTarget": "error" + }, + "correctness": { + "noGlobalObjectCalls": "error", + "noUnreachable": "error", + "useIsNan": "error", + "noUnusedPrivateClassMembers": "error", + "noInvalidUseBeforeDeclaration": "error", + "noNodejsModules": "error" + }, + "complexity": { + "useFlatMap": "error", + "useOptionalChain": "error", + "noEmptyTypeParameters": "error", + "noUselessLoneBlockStatements": "error", + "noUselessEmptyExport": "error", + "noUselessConstructor": "error", + "noUselessTypeConstraint": "error", + "noExcessiveNestedTestSuites": "error" + }, + "nursery": { + "noRestrictedImports": { + "level": "warn", + "options": { + "paths": {} + } + } + }, + "performance": { + "noBarrelFile": "error" + }, + "security": { + "noDangerouslySetInnerHtmlWithChildren": "error" + }, + "suspicious": { + "noDebugger": "error", + "noDoubleEquals": "error", + "noDuplicateJsxProps": "error", + "noDuplicateObjectKeys": "error", + "noDuplicateParameters": "error", + "noDuplicateCase": "error", + "noFallthroughSwitchClause": "error", + "noRedeclare": "error", + "noSparseArray": "error", + "noUnsafeDeclarationMerging": "error", + "noUnsafeNegation": "error", + "useIsArray": "error", + "noApproximativeNumericConstant": "error", + "noMisrefactoredShorthandAssign": "error", + "useAwait": "error", + "useNamespaceKeyword": "error", + "noFocusedTests": "error", + "noDuplicateTestHooks": "error" + }, + "style": { + "noCommaOperator": "error", + "noShoutyConstants": "error", + "noParameterProperties": "error", + "noVar": "error", + "useConst": "error", + "useShorthandFunctionType": "error", + "useExportType": "error", + "useImportType": "error", + "useNodejsImportProtocol": "error", + "useLiteralEnumMembers": "error", + "useEnumInitializers": "error", + "useAsConstAssertion": "error", + "useBlockStatements": "error" + } + } + }, + "files": { + "ignoreUnknown": true, + "ignore": [ + "**/*/trace.json", + "static/app/data/world.json", + "**/*.sourcemap.js", + "**/*.min.js", + "fixtures", + ".devenv", + "package.json" + ] + }, + "css": { + "formatter": { + "enabled": false + }, + "linter": { + "enabled": false + } + }, + "formatter": { + "enabled": true, + "formatWithErrors": true, + "indentStyle": "space", + "indentWidth": 2, + "lineEnding": "lf", + "ignore": ["tests/**/*.json"] + }, + "javascript": { + "formatter": { + "enabled": false, + "lineWidth": 90, + "quoteStyle": "single", + "jsxQuoteStyle": "double", + "quoteProperties": "asNeeded", + "trailingCommas": "es5", + "semicolons": "always", + "arrowParentheses": "asNeeded", + "bracketSpacing": false, + "bracketSameLine": false + } + }, + "json": { + "formatter": { + "enabled": true + }, + "parser": { + "allowComments": true, + "allowTrailingCommas": true + } + }, + "overrides": [ + { + "include": [ + "api-docs/*.ts", + "build-utils/*.ts", + "config/*.ts", + "scripts", + "tests/js/sentry-test/loadFixtures.ts", + "tests/js/jest-pegjs-transform.js", + "tests/js/setup.ts", + "tests/js/test-balancer/index.js", + "*.config.ts" + ], + "linter": { + "rules": { + "correctness": { + "noNodejsModules": "off" + } + } + } + }, + { + "include": ["src/sentry/templates/sentry/error-page-embed.js"], + "linter": { + "rules": { + "style": { + "noVar": "off" + } + } + } + }, + { + "include": [ + "static/app/utils/replays/types.tsx", + "static/app/utils/queryClient.tsx", + "static/app/views/performance/traceDetails/styles.tsx", + "static/app/icons/index.tsx", + "static/app/components/tabs/index.tsx", + "static/app/components/sparklines/line.tsx", + "static/app/types/index.tsx", + "tests/js/sentry-test/reactTestingLibrary.tsx", + "tests/js/sentry-test/index.tsx" + ], + "linter": { + "rules": { + "performance": { + "noBarrelFile": "off" + } + } + } + } + ] +} + +"# + .as_bytes(), + ); + + let (fs, result) = run_cli( + fs, + &mut console, + Args::from(["migrate", "--write"].as_slice()), + ); + + assert!(result.is_ok(), "run_cli returned {result:?}"); + + assert_cli_snapshot(SnapshotPayload::new( + module_path!(), + "should_successfully_migrate_sentry", + fs, + console, + result, + )); +} diff --git a/crates/biome_cli/tests/cases/mod.rs b/crates/biome_cli/tests/cases/mod.rs index 4db122b013e8..fc6f7361cd0b 100644 --- a/crates/biome_cli/tests/cases/mod.rs +++ b/crates/biome_cli/tests/cases/mod.rs @@ -16,6 +16,7 @@ mod handle_vue_files; mod included_files; mod linter_domains; mod linter_groups_plain; +mod migrate_v2; mod overrides_formatter; mod overrides_linter; mod overrides_organize_imports; diff --git a/crates/biome_cli/tests/snapshots/main_cases_migrate_v2/should_successfully_migrate_ariakit.snap b/crates/biome_cli/tests/snapshots/main_cases_migrate_v2/should_successfully_migrate_ariakit.snap new file mode 100644 index 000000000000..a2f2fb200349 --- /dev/null +++ b/crates/biome_cli/tests/snapshots/main_cases_migrate_v2/should_successfully_migrate_ariakit.snap @@ -0,0 +1,93 @@ +--- +source: crates/biome_cli/tests/snap_test.rs +expression: redactor(content) +snapshot_kind: text +--- +## `biome.json` + +```json +{ + "$schema": "./node_modules/@biomejs/biome/configuration_schema.json", + "vcs": { + "enabled": true, + "clientKind": "git", + "useIgnoreFile": true + }, + "files": { + "ignoreUnknown": true, + "includes": [ + "**", + "!**/website/.next/**", + "!**/website/.pages/**", + "!**/*.css" + ] + }, + "organizeImports": { + "enabled": true + }, + "formatter": { + "enabled": true, + "indentStyle": "space" + }, + "linter": { + "enabled": true, + "rules": { + "style": { + "noParameterAssign": "off", + "noUnusedTemplateLiteral": "off", + "noNonNullAssertion": "off", + "noUselessElse": "off", + "useLiteralEnumMembers": "error", + "noArguments": "error", + "useShorthandFunctionType": "error", + "useExportType": "error", + "useDefaultParameterLast": "error", + "noCommaOperator": "error", + "useSingleVarDeclarator": "error", + "useNodejsImportProtocol": "error", + "useConst": "error", + "noInferrableTypes": "error", + "useExponentiationOperator": "error", + "useSelfClosingElements": "error", + "useImportType": "error", + "useNumberNamespace": "error", + "useAsConstAssertion": "error", + "useNumericLiterals": "error", + "useTemplate": "error", + "useEnumInitializers": "error" + }, + "security": { + "noDangerouslySetInnerHtml": "off" + }, + "suspicious": { + "noExplicitAny": "off", + "noShadowRestrictedNames": "off", + "noConfusingVoidType": "off", + "noArrayIndexKey": "off", + "noAssignInExpressions": "off" + }, + "a11y": { + "noSvgWithoutTitle": "off", + "useButtonType": "off", + "useAnchorContent": "off", + "useValidAnchor": "off", + "useKeyWithClickEvents": "off", + "noAutofocus": "off", + "noLabelWithoutControl": "off", + "useSemanticElements": "off", + "useFocusableInteractive": "off" + }, + "correctness": { + "useExhaustiveDependencies": "off", + "useJsxKeyInIterable": "off" + } + } + } +} +``` + +# Emitted Messages + +```block +The configuration biome.json has been successfully migrated. +``` diff --git a/crates/biome_cli/tests/snapshots/main_cases_migrate_v2/should_successfully_migrate_knip.snap b/crates/biome_cli/tests/snapshots/main_cases_migrate_v2/should_successfully_migrate_knip.snap new file mode 100644 index 000000000000..f2ad3c2c2b20 --- /dev/null +++ b/crates/biome_cli/tests/snapshots/main_cases_migrate_v2/should_successfully_migrate_knip.snap @@ -0,0 +1,174 @@ +--- +source: crates/biome_cli/tests/snap_test.rs +expression: redactor(content) +snapshot_kind: text +--- +## `biome.json` + +```json +{ + "$schema": "https://biomejs.dev/schemas/1.8.3/schema.json", + "files": { + "includes": [ + "**", + "!**/dist", + "!**/fixtures", + "!**/packages/knip/package.json", + "!**/packages/knip/vendor/bash-parser/index.js", + "!**/packages/docs/.astro" + ] + }, + "organizeImports": { + "enabled": true + }, + "linter": { + "enabled": true, + "rules": { + "style": { + "noParameterAssign": "off", + "useNodeAssertStrict": "error", + "useLiteralEnumMembers": "error", + "noArguments": "error", + "useShorthandFunctionType": "error", + "useExportType": "error", + "useDefaultParameterLast": "error", + "noCommaOperator": "error", + "useSingleVarDeclarator": "error", + "useNodejsImportProtocol": "error", + "useConst": "error", + "noNonNullAssertion": "error", + "noInferrableTypes": "error", + "useExponentiationOperator": "error", + "noUselessElse": "error", + "useSelfClosingElements": "error", + "useNumberNamespace": "error", + "useAsConstAssertion": "error", + "noUnusedTemplateLiteral": "error", + "useNumericLiterals": "error", + "useTemplate": "error", + "useEnumInitializers": "error" + }, + "nursery": { + "noRestrictedImports": { + "level": "error", + "options": { + "paths": { + "node:path": "Please use src/util/path.js instead.", + "path": "Please use src/util/path.js instead." + } + } + } + }, + "complexity": { + "useLiteralKeys": "off" + }, + "suspicious": { + "noConsole": { + "level": "error", + "options": { + "allow": ["log"] + } + }, + "noExplicitAny": "off" + }, + "correctness": { + "noUnusedVariables": "error", + "noUnusedImports": "error" + } + } + }, + "formatter": { + "enabled": true, + "lineWidth": 120, + "indentStyle": "space", + "formatWithErrors": true + }, + "javascript": { + "formatter": { + "quoteStyle": "single", + "arrowParentheses": "asNeeded", + "trailingCommas": "es5" + } + }, + "json": { + "formatter": { + "lineWidth": 80 + } + }, + "css": { + "formatter": { + "quoteStyle": "single" + } + }, + "overrides": [ + { + "includes": ["**/*.astro"], + "linter": { + "rules": { + "correctness": { + "noUnusedVariables": "off", + "noUnusedImports": "off" + } + } + } + }, + { + "includes": [ + "**/packages/docs/**", + "**/packages/knip/scripts/**", + "**/packages/knip/src/cli.ts", + "**/packages/knip/src/reporters/**", + "**/packages/knip/src/util/cli-arguments.ts", + "**/packages/knip/src/util/debug.ts" + ], + "linter": { + "rules": { + "suspicious": { + "noConsole": { + "level": "off", + "options": { + "allow": ["log"] + } + } + } + } + } + }, + { + "includes": ["**/packages/knip/fixtures/**"], + "assist": { + "actions": { + "source": { + "organizeImports": "off" + } + } + }, + "linter": { + "rules": { + "correctness": { + "noUnusedVariables": "off", + "noUnusedImports": "off" + }, + "style": { + "useImportType": "off" + } + } + } + }, + { + "includes": [ + "**/packages/knip/test/util/get-inputs-from-scripts.test.ts" + ], + "formatter": { + "lineWidth": 200 + } + } + ] +} +``` + +# Emitted Messages + +```block +The configuration biome.json has been successfully migrated. +``` diff --git a/crates/biome_cli/tests/snapshots/main_cases_migrate_v2/should_successfully_migrate_sentry.snap b/crates/biome_cli/tests/snapshots/main_cases_migrate_v2/should_successfully_migrate_sentry.snap new file mode 100644 index 000000000000..0e13eb29618c --- /dev/null +++ b/crates/biome_cli/tests/snapshots/main_cases_migrate_v2/should_successfully_migrate_sentry.snap @@ -0,0 +1,187 @@ +--- +source: crates/biome_cli/tests/snap_test.rs +expression: redactor(content) +snapshot_kind: text +--- +## `biome.json` + +```json +{ + "$schema": "./node_modules/@biomejs/biome/configuration_schema.json", + "vcs": { + "enabled": true, + "clientKind": "git", + "useIgnoreFile": true, + "defaultBranch": "master" + }, + "assist": { + "actions": { + "source": { + "organizeImports": "off" + } + } + }, + "linter": { + "enabled": true, + "rules": { + "style": { + "useLiteralEnumMembers": "error", + "noArguments": "error", + "noParameterAssign": "error", + "useShorthandFunctionType": "error", + "useExportType": "error", + "useDefaultParameterLast": "error", + "noCommaOperator": "error", + "useSingleVarDeclarator": "error", + "useNodejsImportProtocol": "error", + "useConst": "error", + "noNonNullAssertion": "error", + "noInferrableTypes": "error", + "useExponentiationOperator": "error", + "noUselessElse": "error", + "useSelfClosingElements": "error", + "useImportType": "error", + "useNumberNamespace": "error", + "useAsConstAssertion": "error", + "noUnusedTemplateLiteral": "error", + "useNumericLiterals": "error", + "useTemplate": "error", + "useEnumInitializers": "error" + }, + "suspicious": { + "noDebugger": "error", + "noDoubleEquals": "error", + "noDuplicateJsxProps": "error", + "noDuplicateObjectKeys": "error", + "noDuplicateParameters": "error", + "noDuplicateCase": "error", + "noFallthroughSwitchClause": "error", + "noRedeclare": "error", + "noSparseArray": "error", + "noUnsafeDeclarationMerging": "error", + "noUnsafeNegation": "error", + "useIsArray": "error", + "noApproximativeNumericConstant": "error", + "noMisrefactoredShorthandAssign": "error", + "useAwait": "error", + "useNamespaceKeyword": "error", + "noFocusedTests": "error", + "noDuplicateTestHooks": "error",,,,,,,,, + } + } + }, + "files": { + "ignoreUnknown": true, + "includes": [ + "**", + "!**/*/trace.json", + "!**/static/app/data/world.json", + "!**/*.sourcemap.js", + "!**/*.min.js", + "!**/fixtures", + "!**/.devenv", + "!**/package.json" + ] + }, + "css": { + "formatter": { + "enabled": false + }, + "linter": { + "enabled": false + } + }, + "formatter": { + "enabled": true, + "formatWithErrors": true, + "indentStyle": "space", + "indentWidth": 2, + "lineEnding": "lf", + "includes": ["**", "!**/tests/**/*.json"] + }, + "javascript": { + "formatter": { + "enabled": false, + "lineWidth": 90, + "quoteStyle": "single", + "jsxQuoteStyle": "double", + "quoteProperties": "asNeeded", + "trailingCommas": "es5", + "semicolons": "always", + "arrowParentheses": "asNeeded", + "bracketSpacing": false, + "bracketSameLine": false + } + }, + "json": { + "formatter": { + "enabled": true + }, + "parser": { + "allowComments": true, + "allowTrailingCommas": true + } + }, + "overrides": [ + { + "includes": [ + "**/api-docs/*.ts", + "**/build-utils/*.ts", + "**/config/*.ts", + "**/scripts/**", + "**/tests/js/sentry-test/loadFixtures.ts", + "**/tests/js/jest-pegjs-transform.js", + "**/tests/js/setup.ts", + "**/tests/js/test-balancer/index.js", + "**/*.config.ts" + ], + "linter": { + "rules": { + "correctness": { + "noNodejsModules": "off" + } + } + } + }, + { + "includes": ["**/src/sentry/templates/sentry/error-page-embed.js"], + "linter": { + "rules": { + "suspicious": { + "noVar": "off" + }, + "suspicious": { + "noVar": "off" + } + } + } + }, + { + "includes": [ + "**/static/app/utils/replays/types.tsx", + "**/static/app/utils/queryClient.tsx", + "**/static/app/views/performance/traceDetails/styles.tsx", + "**/static/app/icons/index.tsx", + "**/static/app/components/tabs/index.tsx", + "**/static/app/components/sparklines/line.tsx", + "**/static/app/types/index.tsx", + "**/tests/js/sentry-test/reactTestingLibrary.tsx", + "**/tests/js/sentry-test/index.tsx" + ], + "linter": { + "rules": { + "performance": { + "noBarrelFile": "off" + } + } + } + } + ] +} +``` + +# Emitted Messages + +```block +The configuration biome.json has been successfully migrated. +``` diff --git a/crates/biome_cli/tests/snapshots/main_commands_migrate/migrate_config_up_to_date.snap b/crates/biome_cli/tests/snapshots/main_commands_migrate/migrate_config_up_to_date.snap index 010e28c8f900..216c87b0fb2c 100644 --- a/crates/biome_cli/tests/snapshots/main_commands_migrate/migrate_config_up_to_date.snap +++ b/crates/biome_cli/tests/snapshots/main_commands_migrate/migrate_config_up_to_date.snap @@ -1,6 +1,7 @@ --- source: crates/biome_cli/tests/snap_test.rs -expression: content +expression: redactor(content) +snapshot_kind: text --- ## `biome.json` @@ -11,7 +12,43 @@ expression: content # Emitted Messages ```block -Your configuration file is up to date. -``` +biome.json migrate ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + i Configuration file can be updated. + + 1 │ - {·"linter":·{·"enabled":·true·}·} + 1 │ + {·"linter":·{"enabled":·true·, + 2 │ + ····"rules":·{ + 3 │ + ······"style":·{ + 4 │ + ········"useLiteralEnumMembers":·"error", + 5 │ + ········"noArguments":·"error", + 6 │ + ········"noParameterAssign":·"error", + 7 │ + ········"useShorthandFunctionType":·"error", + 8 │ + ········"useExportType":·"error", + 9 │ + ········"useDefaultParameterLast":·"error", + 10 │ + ········"noCommaOperator":·"error", + 11 │ + ········"useSingleVarDeclarator":·"error", + 12 │ + ········"useNodejsImportProtocol":·"error", + 13 │ + ········"useConst":·"error", + 14 │ + ········"noNonNullAssertion":·"error", + 15 │ + ········"noInferrableTypes":·"error", + 16 │ + ········"useExponentiationOperator":·"error", + 17 │ + ········"noUselessElse":·"error", + 18 │ + ········"useSelfClosingElements":·"error", + 19 │ + ········"useImportType":·"error", + 20 │ + ········"useNumberNamespace":·"error", + 21 │ + ········"useAsConstAssertion":·"error", + 22 │ + ········"noUnusedTemplateLiteral":·"error", + 23 │ + ········"useNumericLiterals":·"error", + 24 │ + ········"useTemplate":·"error", + 25 │ + ········"useEnumInitializers":·"error" + 26 │ + ······} + 27 │ + ····} + 28 │ + ··}·} + +``` +```block +Run the command with the option --write to apply the changes. +``` diff --git a/crates/biome_json_syntax/src/member_ext.rs b/crates/biome_json_syntax/src/member_ext.rs index 1fbf57a8aaed..6f7973b740ae 100644 --- a/crates/biome_json_syntax/src/member_ext.rs +++ b/crates/biome_json_syntax/src/member_ext.rs @@ -1,8 +1,23 @@ -use crate::{inner_string_text, JsonMemberName}; -use biome_rowan::{SyntaxResult, TokenText}; +use crate::{inner_string_text, AnyJsonValue, JsonMember, JsonMemberName, JsonSyntaxToken}; +use biome_rowan::{AstSeparatedList, SyntaxResult, TokenText}; impl JsonMemberName { pub fn inner_string_text(&self) -> SyntaxResult { Ok(inner_string_text(&self.value_token()?)) } } + +impl JsonMember { + /// If the value of the member is a [JsonObjectValue](crate::JsonObjectValue), it returns a tuple + /// that contains a list of [JsonMember] and of its separators. Returns [None] otherwise + pub fn unzip_elements(&self) -> Option<(Vec, Vec)> { + let value = self.value().ok()?; + let AnyJsonValue::JsonObjectValue(value) = value else { + return None; + }; + + let members = value.json_member_list().iter().flatten().collect(); + let separators = value.json_member_list().separators().flatten().collect(); + Some((members, separators)) + } +} diff --git a/crates/biome_migrate/src/analyzers.rs b/crates/biome_migrate/src/analyzers.rs index c4f154cd2a8f..89af0c9a526b 100644 --- a/crates/biome_migrate/src/analyzers.rs +++ b/crates/biome_migrate/src/analyzers.rs @@ -6,6 +6,7 @@ use crate::analyzers::nursery_rules::NurseryRules; use crate::analyzers::organize_imports::OrganizeImports; use crate::analyzers::schema::Schema; use crate::analyzers::style_rules::StyleRules; +use crate::analyzers::trailing_comma::TrailingComma; use crate::analyzers::use_while::UseWhile; use biome_analyze::{GroupCategory, RegistryVisitor, RuleCategory, RuleGroup}; use biome_json_syntax::JsonLanguage; @@ -18,6 +19,7 @@ mod nursery_rules; mod organize_imports; mod schema; mod style_rules; +mod trailing_comma; mod use_while; pub(crate) struct MigrationGroup; @@ -42,6 +44,7 @@ impl RuleGroup for MigrationGroup { registry.record_rule::(); registry.record_rule::(); registry.record_rule::(); + registry.record_rule::(); } } diff --git a/crates/biome_migrate/src/analyzers/deleted_rules.rs b/crates/biome_migrate/src/analyzers/deleted_rules.rs index b8e61acc48a4..c44b3ab7c584 100644 --- a/crates/biome_migrate/src/analyzers/deleted_rules.rs +++ b/crates/biome_migrate/src/analyzers/deleted_rules.rs @@ -1,8 +1,6 @@ -use crate::rule_mover::AnalyzerMover; -use crate::version_services::Version; use crate::{declare_migration, MigrationAction}; use biome_analyze::context::RuleContext; -use biome_analyze::{Rule, RuleAction, RuleDiagnostic}; +use biome_analyze::{Ast, Rule, RuleAction, RuleDiagnostic}; use biome_console::markup; use biome_diagnostics::{category, Applicability}; use biome_json_factory::make::{ @@ -10,7 +8,7 @@ use biome_json_factory::make::{ json_object_value, json_string_literal, json_string_value, token, }; use biome_json_syntax::{AnyJsonValue, JsonMember, JsonRoot, JsonStringValue, T}; -use biome_rowan::{AstNode, TriviaPieceKind, WalkEvent}; +use biome_rowan::{AstNode, BatchMutationExt, TriviaPieceKind, WalkEvent}; use std::collections::HashMap; use std::sync::LazyLock; @@ -36,7 +34,7 @@ pub(crate) struct RuleState { } impl Rule for DeletedRules { - type Query = Version; + type Query = Ast; type State = RuleState; type Signals = Vec; type Options = (); @@ -86,10 +84,9 @@ impl Rule for DeletedRules { } fn action(ctx: &RuleContext, state: &Self::State) -> Option { - let mut rule_mover = AnalyzerMover::from_root(ctx.root()); - let member = &state.rule_member; + let mut mutation = ctx.root().begin(); - let value = member.value().ok()?; + let value = state.rule_member.value().ok()?; let value = match value { AnyJsonValue::JsonStringValue(json_string_value) => Some(json_string_value), AnyJsonValue::JsonObjectValue(json_object_value) => { @@ -108,27 +105,29 @@ impl Rule for DeletedRules { } _ => None, }; - - if REMOVED_RULES.contains_key(state.rule_name.as_ref()) { - let (member, group) = match state.rule_name.as_ref() { - "noConsoleLog" => (create_console_log_member(value), "suspicious"), - "useSingleCaseStatement" => (create_no_switch_declarations(value), "correctness"), - "useShorthandArrayType" => (create_consistent_array_type(value), "style"), - "noNewSymbol" | "noInvalidNewBuiltin" => { - (create_no_invalid_builtin(value), "correctness") - } - _ => return None, - }; - rule_mover.replace_rule(state.rule_name.as_ref(), member, group); + match state.rule_name.as_ref() { + "noConsoleLog" => { + mutation.replace_node(state.rule_member.clone(), create_console_log_member(value)) + } + "useSingleCaseStatement" => mutation.replace_node( + state.rule_member.clone(), + create_no_switch_declarations(value), + ), + "useShorthandArrayType" => mutation.replace_node( + state.rule_member.clone(), + create_consistent_array_type(value), + ), + "noNewSymbol" | "noInvalidNewBuiltin" => { + mutation.replace_node(state.rule_member.clone(), create_no_invalid_builtin(value)) + } + _ => return None, } - let mutation = rule_mover.run_queries()?; - Some(RuleAction::new( ctx.metadata().action_category(ctx.category(), ctx.group()), Applicability::Always, markup! { - "Use the rule ""useConsole"" instead." + "Use the rule "{state.rule_name}" instead." } .to_owned(), mutation, diff --git a/crates/biome_migrate/src/analyzers/includes.rs b/crates/biome_migrate/src/analyzers/includes.rs index 9fddf37f6314..ff7b80adc251 100644 --- a/crates/biome_migrate/src/analyzers/includes.rs +++ b/crates/biome_migrate/src/analyzers/includes.rs @@ -1,9 +1,8 @@ use std::str::FromStr; -use crate::version_services::Version; use crate::{declare_migration, MigrationAction}; use biome_analyze::context::RuleContext; -use biome_analyze::{Rule, RuleAction, RuleDiagnostic}; +use biome_analyze::{Ast, Rule, RuleAction, RuleDiagnostic}; use biome_console::markup; use biome_diagnostics::{category, Applicability}; use biome_json_factory::make; @@ -18,7 +17,7 @@ declare_migration! { } impl Rule for Includes { - type Query = Version; + type Query = Ast; type State = State; type Signals = Vec; type Options = (); diff --git a/crates/biome_migrate/src/analyzers/no_var.rs b/crates/biome_migrate/src/analyzers/no_var.rs index 1cd7ccbbe195..1a53199dd671 100644 --- a/crates/biome_migrate/src/analyzers/no_var.rs +++ b/crates/biome_migrate/src/analyzers/no_var.rs @@ -1,12 +1,13 @@ -use crate::rule_mover::AnalyzerMover; -use crate::version_services::Version; use crate::{declare_migration, MigrationAction}; use biome_analyze::context::RuleContext; -use biome_analyze::{Rule, RuleAction, RuleDiagnostic}; +use biome_analyze::{Ast, Rule, RuleAction, RuleDiagnostic}; use biome_console::markup; use biome_diagnostics::{category, Applicability}; -use biome_json_syntax::JsonMember; -use biome_rowan::{AstNode, TextRange}; +use biome_json_factory::make::{ + json_member, json_member_list, json_member_name, json_object_value, json_string_literal, token, +}; +use biome_json_syntax::{AnyJsonValue, JsonMember, T}; +use biome_rowan::{AstNode, AstSeparatedList, BatchMutationExt, TriviaPieceKind}; declare_migration! { pub(crate) NoVar { @@ -16,8 +17,8 @@ declare_migration! { } impl Rule for NoVar { - type Query = Version; - type State = TextRange; + type Query = Ast; + type State = JsonMember; type Signals = Option; type Options = (); @@ -27,25 +28,26 @@ impl Rule for NoVar { let name = node.name().ok()?; let text = name.inner_string_text().ok()?; + let mut no_var_member = None; if text.text() == "style" { - if let Some(object) = node.value().ok()?.as_json_object_value() { - for item in object.json_member_list().into_iter().flatten() { - let name = item.name().ok()?; - let text = name.inner_string_text().ok()?; - if text.text() == "noVar" { - return Some(name.range()); - } + let object = node.value().ok()?; + let object = object.as_json_object_value()?; + for item in object.json_member_list().into_iter().flatten() { + let name = item.name().ok()?; + let text = name.inner_string_text().ok()?; + if text.text() == "noVar" { + no_var_member = Some(item); } } } - None + no_var_member } fn diagnostic(_ctx: &RuleContext, state: &Self::State) -> Option { Some(RuleDiagnostic::new( category!("migrate"), - state, + state.range(), markup! { "The rule ""style/noVar"" has ben moved to the ""suspicious"" group." } @@ -53,13 +55,140 @@ impl Rule for NoVar { )) } - fn action(ctx: &RuleContext, _state: &Self::State) -> Option { - let root = ctx.root(); - let mut rule_mover = AnalyzerMover::from_root(root.clone()); - rule_mover.move_rule("noVar", "style", "suspicious"); - let mutation = rule_mover.run_queries()?; + fn action(ctx: &RuleContext, state: &Self::State) -> Option { + let mut mutation = ctx.root().begin(); + let no_var_member = state; + let style_member = ctx.query(); + + let style_member_list = style_member + .value() + .ok()? + .as_json_object_value()? + .json_member_list() + .iter() + .flatten() + .filter_map(|member| { + let name = member.name().ok()?; + let text = name.inner_string_text().ok()?; + if text.text() == "noVar" { + None + } else { + Some(member) + } + }) + .collect::>(); + + let mut separators = vec![]; + for _ in 0..style_member_list.len().saturating_sub(1) { + separators.push(token(T![,])) + } + + let rules_member = style_member.syntax().ancestors().find_map(|node| { + let member = JsonMember::cast(node)?; + let name = member.name().ok()?; + let text = name.inner_string_text().ok()?; + if text.text() == "rules" { + Some(member) + } else { + None + } + })?; + + let style_member = json_member( + style_member.name().ok()?, + style_member.colon_token().ok()?, + AnyJsonValue::JsonObjectValue(json_object_value( + token(T!['{']).with_leading_trivia(vec![(TriviaPieceKind::Whitespace, " ")]), + json_member_list(style_member_list, separators), + token(T!['}']).with_leading_trivia(vec![ + (TriviaPieceKind::Newline, "\n"), + (TriviaPieceKind::Whitespace, " ".repeat(6).as_str()), + ]), + )), + ); + + let linter_member_list = rules_member + .value() + .ok()? + .as_json_object_value()? + .json_member_list(); + + let suspicious_member = linter_member_list + .iter() + .flatten() + .find_map(|member| { + let name = member.name().ok()?.inner_string_text().ok()?; + if name.text() == "suspicious" { + Some(member) + } else { + None + } + }) + .and_then(|suspicious_member| { + // we inject the new member here + let (list, mut separators) = suspicious_member.unzip_elements()?; + for _ in 0..list.len().saturating_sub(1) { + separators.push(token(T![,])) + } + + Some(json_member( + suspicious_member.name().ok()?, + suspicious_member.colon_token().ok()?, + AnyJsonValue::JsonObjectValue(json_object_value( + suspicious_member + .value() + .ok()? + .as_json_object_value()? + .l_curly_token() + .ok()?, + json_member_list(list, separators), + suspicious_member + .value() + .ok()? + .as_json_object_value()? + .r_curly_token() + .ok()?, + )), + )) + }) + .unwrap_or(json_member( + json_member_name(json_string_literal("suspicious").with_leading_trivia(vec![ + (TriviaPieceKind::Newline, "\n"), + (TriviaPieceKind::Whitespace, " ".repeat(4).as_str()), + ])), + token(T![:]).with_trailing_trivia(vec![(TriviaPieceKind::Whitespace, " ")]), + AnyJsonValue::JsonObjectValue(json_object_value( + token(T!['{']).with_leading_trivia(vec![(TriviaPieceKind::Whitespace, " ")]), + json_member_list(vec![no_var_member.clone()], vec![]), + token(T!['}']).with_leading_trivia(vec![ + (TriviaPieceKind::Newline, "\n"), + (TriviaPieceKind::Whitespace, " ".repeat(4).as_str()), + ]), + )), + )); + + let mut separators = vec![]; + let mut new_members = vec![]; + for item in linter_member_list.iter().flatten() { + let name = item.name().ok()?.inner_string_text().ok()?; + if name.text() != "suspicious" { + new_members.push(suspicious_member.clone()); + } else if name.text() == "style" { + new_members.push(style_member.clone()); + } else { + new_members.push(item); + } + } + new_members.push(suspicious_member); + for _ in 0..new_members.len().saturating_sub(1) { + separators.push(token(T![,])) + } + + mutation.replace_node( + linter_member_list, + json_member_list(new_members, separators), + ); - // mutation.replace_node(state.clone(), new_list); Some(RuleAction::new( ctx.metadata().action_category(ctx.category(), ctx.group()), Applicability::Always, diff --git a/crates/biome_migrate/src/analyzers/organize_imports.rs b/crates/biome_migrate/src/analyzers/organize_imports.rs index 8dad24f8fdf0..0e707b0c9cdd 100644 --- a/crates/biome_migrate/src/analyzers/organize_imports.rs +++ b/crates/biome_migrate/src/analyzers/organize_imports.rs @@ -1,15 +1,14 @@ -use crate::rule_mover::AnalyzerMover; -use crate::version_services::Version; use crate::{declare_migration, MigrationAction}; use biome_analyze::context::RuleContext; -use biome_analyze::{Rule, RuleAction, RuleDiagnostic}; +use biome_analyze::{Ast, Rule, RuleAction, RuleDiagnostic}; use biome_console::markup; use biome_diagnostics::{category, Applicability}; use biome_json_factory::make::{ - json_member, json_member_name, json_string_literal, json_string_value, token, + json_member, json_member_list, json_member_name, json_object_value, json_string_literal, + json_string_value, token, }; use biome_json_syntax::{AnyJsonValue, JsonMember, T}; -use biome_rowan::{AstNode, TextRange, TriviaPieceKind}; +use biome_rowan::{AstNode, BatchMutationExt, TextRange, TriviaPieceKind}; declare_migration! { pub(crate) OrganizeImports { @@ -19,7 +18,7 @@ declare_migration! { } impl Rule for OrganizeImports { - type Query = Version; + type Query = Ast; type State = TextRange; type Signals = Option; type Options = (); @@ -67,8 +66,8 @@ impl Rule for OrganizeImports { } fn action(ctx: &RuleContext, _state: &Self::State) -> Option { - let root = ctx.root(); - let mut rule_mover = AnalyzerMover::from_root(root.clone()); + let query = ctx.query(); + let mut mutation = ctx.root().begin(); let action_member = json_member( json_member_name( json_string_literal("organizeImports").with_leading_trivia(vec![ @@ -79,9 +78,54 @@ impl Rule for OrganizeImports { token(T![:]).with_trailing_trivia(vec![(TriviaPieceKind::Whitespace, " ")]), AnyJsonValue::JsonStringValue(json_string_value(json_string_literal("off"))), ); - rule_mover.insert_rule("organizeImports", action_member, "source"); - rule_mover.add_filters(&["organizeImports"]); - let mutation = rule_mover.run_queries()?; + let source_member = json_member( + json_member_name(json_string_literal("source").with_leading_trivia(vec![ + (TriviaPieceKind::Newline, "\n"), + (TriviaPieceKind::Whitespace, " ".repeat(6).as_str()), + ])), + token(T![:]).with_trailing_trivia(vec![(TriviaPieceKind::Whitespace, " ")]), + AnyJsonValue::JsonObjectValue(json_object_value( + token(T!['{']).with_leading_trivia(vec![(TriviaPieceKind::Whitespace, " ")]), + json_member_list(vec![action_member], vec![]), + token(T!['}']).with_leading_trivia(vec![ + (TriviaPieceKind::Newline, "\n"), + (TriviaPieceKind::Whitespace, " ".repeat(6).as_str()), + ]), + )), + ); + + let actions_member = json_member( + json_member_name(json_string_literal("actions").with_leading_trivia(vec![ + (TriviaPieceKind::Newline, "\n"), + (TriviaPieceKind::Whitespace, " ".repeat(4).as_str()), + ])), + token(T![:]).with_trailing_trivia(vec![(TriviaPieceKind::Whitespace, " ")]), + AnyJsonValue::JsonObjectValue(json_object_value( + token(T!['{']).with_leading_trivia(vec![(TriviaPieceKind::Whitespace, " ")]), + json_member_list(vec![source_member], vec![]), + token(T!['}']).with_leading_trivia(vec![ + (TriviaPieceKind::Newline, "\n"), + (TriviaPieceKind::Whitespace, " ".repeat(4).as_str()), + ]), + )), + ); + let assist_member = json_member( + json_member_name(json_string_literal("assist").with_leading_trivia(vec![ + (TriviaPieceKind::Newline, "\n"), + (TriviaPieceKind::Whitespace, " ".repeat(2).as_str()), + ])), + token(T![:]).with_trailing_trivia(vec![(TriviaPieceKind::Whitespace, " ")]), + AnyJsonValue::JsonObjectValue(json_object_value( + token(T!['{']).with_leading_trivia(vec![(TriviaPieceKind::Whitespace, " ")]), + json_member_list(vec![actions_member], vec![]), + token(T!['}']).with_leading_trivia(vec![ + (TriviaPieceKind::Newline, "\n"), + (TriviaPieceKind::Whitespace, " ".repeat(2).as_str()), + ]), + )), + ); + + mutation.replace_node(query.clone(), assist_member); Some(RuleAction::new( ctx.metadata().action_category(ctx.category(), ctx.group()), diff --git a/crates/biome_migrate/src/analyzers/schema.rs b/crates/biome_migrate/src/analyzers/schema.rs index 7b2c861f8705..749a1eca028c 100644 --- a/crates/biome_migrate/src/analyzers/schema.rs +++ b/crates/biome_migrate/src/analyzers/schema.rs @@ -1,7 +1,6 @@ -use crate::version_services::Version; use crate::{declare_migration, MigrationAction}; use biome_analyze::context::RuleContext; -use biome_analyze::{Rule, RuleAction, RuleDiagnostic}; +use biome_analyze::{Ast, Rule, RuleAction, RuleDiagnostic}; use biome_console::markup; use biome_diagnostics::{category, Applicability}; use biome_json_factory::make::{ident, json_string_value}; @@ -17,7 +16,7 @@ declare_migration! { } impl Rule for Schema { - type Query = Version; + type Query = Ast; type State = TextRange; type Signals = Option; type Options = (); diff --git a/crates/biome_migrate/src/analyzers/style_rules.rs b/crates/biome_migrate/src/analyzers/style_rules.rs index 8fe474d630c4..9d172c739649 100644 --- a/crates/biome_migrate/src/analyzers/style_rules.rs +++ b/crates/biome_migrate/src/analyzers/style_rules.rs @@ -1,8 +1,7 @@ use crate::rule_mover::AnalyzerMover; -use crate::version_services::Version; use crate::{declare_migration, MigrationAction}; use biome_analyze::context::RuleContext; -use biome_analyze::{Rule, RuleAction, RuleDiagnostic}; +use biome_analyze::{Ast, Rule, RuleAction, RuleDiagnostic}; use biome_console::markup; use biome_diagnostics::{category, Applicability}; use biome_json_factory::make::{ @@ -19,9 +18,9 @@ declare_migration! { } } -const STYLE_RULES_THAT_WERE_ERROR: [&str; 23] = [ +const STYLE_RULES_THAT_WERE_ERROR: [&str; 22] = [ "useNumberNamespace", - "noNonnullAssertion", + "noNonNullAssertion", "useAsConstAssertion", "noParameterAssign", "noInferrableTypes", @@ -42,13 +41,12 @@ const STYLE_RULES_THAT_WERE_ERROR: [&str; 23] = [ "useImportType", "useTemplate", "useSingleVarDeclarator", - "useWhile", ]; impl Rule for StyleRules { - type Query = Version; - type State = FxHashSet>; - type Signals = Option; + type Query = Ast; + type State = Box; + type Signals = Vec; type Options = (); fn run(ctx: &RuleContext) -> Self::Signals { @@ -98,16 +96,16 @@ impl Rule for StyleRules { } } - Some(nodes) + nodes.into_iter().collect() } - fn diagnostic(_ctx: &RuleContext, _node: &Self::State) -> Option { - let root = _ctx.root(); + fn diagnostic(ctx: &RuleContext, state: &Self::State) -> Option { + let root = ctx.root(); Some(RuleDiagnostic::new( category!("migrate"), root.range(), markup! { - "Biome style rules aren't recommended anymore." + "Biome style rule "{state}" isn't recommended anymore." } .to_owned(), ).note(markup!{ @@ -115,22 +113,23 @@ impl Rule for StyleRules { })) } - fn action(ctx: &RuleContext, state: &Self::State) -> Option { + fn action(ctx: &RuleContext, rule_to_move: &Self::State) -> Option { let mut rule_mover = AnalyzerMover::from_root(ctx.root()); - for rule_to_move in state { - let member = json_member( - json_member_name( - json_string_literal(rule_to_move.as_ref()).with_leading_trivia(vec![ - (TriviaPieceKind::Newline, "\n"), - (TriviaPieceKind::Whitespace, " ".repeat(8).as_str()), - ]), - ), - token(T![:]), - AnyJsonValue::JsonStringValue(json_string_value(json_string_literal("error"))), - ); - rule_mover.replace_rule(rule_to_move.as_ref(), member, "style"); - } + let member = json_member( + json_member_name( + json_string_literal(rule_to_move.as_ref()).with_leading_trivia(vec![ + (TriviaPieceKind::Newline, "\n"), + (TriviaPieceKind::Whitespace, " ".repeat(8).as_str()), + ]), + ), + token(T![:]), + AnyJsonValue::JsonStringValue(json_string_value( + json_string_literal("error") + .with_leading_trivia(vec![(TriviaPieceKind::Whitespace, " ")]), + )), + ); + rule_mover.replace_rule(rule_to_move.as_ref(), member, "style"); let mutation = rule_mover.run_queries()?; diff --git a/crates/biome_migrate/src/analyzers/trailing_comma.rs b/crates/biome_migrate/src/analyzers/trailing_comma.rs new file mode 100644 index 000000000000..4b945bc42721 --- /dev/null +++ b/crates/biome_migrate/src/analyzers/trailing_comma.rs @@ -0,0 +1,61 @@ +use crate::{declare_migration, MigrationAction}; +use biome_analyze::context::RuleContext; +use biome_analyze::{Ast, Rule, RuleAction, RuleDiagnostic}; +use biome_console::markup; +use biome_diagnostics::{category, Applicability}; +use biome_json_factory::make::{json_member_name, json_string_literal}; +use biome_json_syntax::{JsonMember, JsonMemberName}; +use biome_rowan::{AstNode, BatchMutationExt}; + +declare_migration! { + pub(crate) TrailingComma { + version: "2.0.0", + name: "trailingComma", + } +} + +impl Rule for TrailingComma { + type Query = Ast; + type State = JsonMemberName; + type Signals = Option; + type Options = (); + + fn run(ctx: &RuleContext) -> Self::Signals { + let node = ctx.query(); + + let name = node.name().ok()?; + let node_text = name.inner_string_text().ok()?; + if node_text.text() == "trailingComma" { + return Some(name); + } + + None + } + + fn diagnostic(_ctx: &RuleContext, state: &Self::State) -> Option { + Some(RuleDiagnostic::new( + category!("migrate"), + state.range(), + markup! { + "The option trailingComma is removed. " + } + .to_owned(), + )) + } + + fn action(ctx: &RuleContext, state: &Self::State) -> Option { + let mut mutation = ctx.root().begin(); + let new_name = json_member_name(json_string_literal("trailingCommas")); + mutation.replace_node(state.clone(), new_name); + + Some(RuleAction::new( + ctx.metadata().action_category(ctx.category(), ctx.group()), + Applicability::Always, + markup! { + "Use the option trailingCommas instead." + } + .to_owned(), + mutation, + )) + } +} diff --git a/crates/biome_migrate/src/analyzers/use_while.rs b/crates/biome_migrate/src/analyzers/use_while.rs index 32f577084637..53460f0b74e4 100644 --- a/crates/biome_migrate/src/analyzers/use_while.rs +++ b/crates/biome_migrate/src/analyzers/use_while.rs @@ -1,8 +1,7 @@ use crate::rule_mover::AnalyzerMover; -use crate::version_services::Version; use crate::{declare_migration, MigrationAction}; use biome_analyze::context::RuleContext; -use biome_analyze::{Rule, RuleAction, RuleDiagnostic}; +use biome_analyze::{Ast, Rule, RuleAction, RuleDiagnostic}; use biome_console::markup; use biome_diagnostics::{category, Applicability}; use biome_json_syntax::JsonMember; @@ -16,7 +15,7 @@ declare_migration! { } impl Rule for UseWhile { - type Query = Version; + type Query = Ast; type State = TextRange; type Signals = Option; type Options = (); @@ -24,10 +23,6 @@ impl Rule for UseWhile { fn run(ctx: &RuleContext) -> Self::Signals { let node = ctx.query(); - if !ctx.satisfies(">=2.0.0") { - return None; - } - let name = node.name().ok()?; let text = name.inner_string_text().ok()?; diff --git a/crates/biome_migrate/src/lib.rs b/crates/biome_migrate/src/lib.rs index 2f33646377db..3df442bb0076 100644 --- a/crates/biome_migrate/src/lib.rs +++ b/crates/biome_migrate/src/lib.rs @@ -2,10 +2,8 @@ mod analyzers; mod macros; mod registry; mod rule_mover; -mod version_services; use crate::registry::visit_migration_registry; -use crate::version_services::TheVersion; pub use biome_analyze::ControlFlow; use biome_analyze::{ AnalysisFilter, Analyzer, AnalyzerContext, AnalyzerOptions, AnalyzerSignal, ApplySuppression, @@ -18,7 +16,7 @@ use biome_rowan::{BatchMutation, SyntaxToken}; use camino::Utf8Path; use std::convert::Infallible; use std::ops::Deref; -use std::sync::{Arc, LazyLock}; +use std::sync::LazyLock; /// Return the static [MetadataRegistry] for the JS analyzer rules static METADATA: LazyLock = LazyLock::new(|| { @@ -37,7 +35,6 @@ pub fn analyze_with_inspect_matcher<'a, V, F, B>( root: &LanguageRoot, filter: AnalysisFilter, configuration_file_path: &'a Utf8Path, - version: String, inspect_matcher: V, mut emit_signal: F, ) -> (Option, Vec) @@ -50,7 +47,7 @@ where let mut registry = RuleRegistry::builder(&filter, root); visit_migration_registry(&mut registry); - let (migration_registry, mut services, diagnostics, visitors) = registry.build(); + let (migration_registry, services, diagnostics, visitors) = registry.build(); // Bail if we can't parse a rule option if !diagnostics.is_empty() { @@ -97,8 +94,6 @@ where analyzer.add_visitor(phase, visitor); } - services.insert_service(Arc::new(TheVersion::new(version.as_str()))); - ( analyzer.run(AnalyzerContext { root: root.clone(), @@ -114,21 +109,13 @@ pub fn migrate_configuration<'a, F, B>( root: &LanguageRoot, filter: AnalysisFilter, configuration_file_path: &'a Utf8Path, - version: String, emit_signal: F, ) -> (Option, Vec) where F: FnMut(&dyn AnalyzerSignal) -> ControlFlow + 'a, B: 'a, { - analyze_with_inspect_matcher( - root, - filter, - configuration_file_path, - version, - |_| {}, - emit_signal, - ) + analyze_with_inspect_matcher(root, filter, configuration_file_path, |_| {}, emit_signal) } pub(crate) type MigrationAction = RuleAction; @@ -184,7 +171,6 @@ mod test { &parsed.tree(), AnalysisFilter::default(), Utf8Path::new(""), - "1.5.0".to_string(), |signal| { if let Some(diag) = signal.diagnostic() { let error = diag diff --git a/crates/biome_migrate/src/rule_mover.rs b/crates/biome_migrate/src/rule_mover.rs index 27dc31e16df2..39fba7b03600 100644 --- a/crates/biome_migrate/src/rule_mover.rs +++ b/crates/biome_migrate/src/rule_mover.rs @@ -6,9 +6,7 @@ use biome_json_syntax::{ AnyJsonValue, JsonLanguage, JsonMember, JsonMemberList, JsonObjectValue, JsonRoot, JsonSyntaxToken, T, }; -use biome_rowan::{ - AstNode, AstSeparatedList, BatchMutation, BatchMutationExt, TriviaPieceKind, WalkEvent, -}; +use biome_rowan::{AstNode, AstSeparatedList, BatchMutation, BatchMutationExt, TriviaPieceKind}; use rustc_hash::FxHashMap; use std::str::FromStr; @@ -126,7 +124,8 @@ pub(crate) struct AnalyzerMover { groups: FxHashMap, root: JsonRoot, queries: Vec, - filters: Vec>, + linter_member: Option, + assist_member: Option, } pub(crate) struct Query { @@ -135,64 +134,97 @@ pub(crate) struct Query { rule_member: Option, } +#[derive(Debug)] enum QueryKind { Move(Category, Category), Replace(Category), Remove(Category), - Insert(Category), } impl AnalyzerMover { /// Attempts to find `linter`, `linter.rules` or `linter.rules.` pub(crate) fn from_root(root: JsonRoot) -> Self { - let events = root.syntax().preorder(); let mut groups = FxHashMap::default(); + let mut linter_member = None; + let mut assist_member = None; - for event in events { - match event { - WalkEvent::Enter(node) => { - if let Some(member) = JsonMember::cast(node) { - let Some(name) = - member.name().ok().and_then(|n| n.inner_string_text().ok()) - else { - continue; - }; - - if let Ok(group) = Category::from_str(name.text()) { - groups.insert(group, member); - } - } + let object = root + .value() + .ok() + .and_then(|n| n.as_json_object_value().cloned()); + + if let Some(object) = object { + for member in object.json_member_list().iter().flatten() { + let Some(name) = member.name().ok().and_then(|n| n.inner_string_text().ok()) else { + continue; + }; + + if name.text() == "linter" { + linter_member = Some(member); + } else if name.text() == "assist" { + assist_member = Some(member); } - WalkEvent::Leave(_) => {} } + }; + + if let Some(member) = &linter_member { + Self::track_groups(member, &mut groups, "rules"); + } + + if let Some(member) = &assist_member { + Self::track_groups(member, &mut groups, "actions"); } Self { root, groups, queries: vec![], - filters: vec![], + assist_member, + linter_member, } } - /// Register a query where it adds a new rule to a group - /// - /// ## Panics - /// - /// It panics if the group doesn't exist. This usually means that the developer must add the new group - pub(crate) fn insert_rule( - &mut self, - rule_name: impl ToString, - rule_member: JsonMember, - group: &str, - ) { - let category = Category::from_str(group).expect("to be a valid group"); + fn track_groups( + linter_member: &JsonMember, + groups: &mut FxHashMap, + parent_group_name: &str, + ) -> Option<()> { + let rules_list = linter_member + .value() + .ok() + .and_then(|n| n.as_json_object_value().cloned())? + .json_member_list() + .iter() + .flatten() + .find_map(|member| { + let name = member + .name() + .ok() + .and_then(|n| n.inner_string_text().ok())?; + if name.text() == parent_group_name { + Some(member) + } else { + None + } + }) + .and_then(|member| { + Some( + member + .value() + .ok()? + .as_json_object_value()? + .json_member_list(), + ) + })?; - self.queries.push(Query { - rule_name: rule_name.to_string(), - kind: QueryKind::Insert(category), - rule_member: Some(rule_member), - }) + for item in rules_list.iter().flatten() { + let name = item.name().ok().and_then(|n| n.inner_string_text().ok())?; + if let Ok(group) = Category::from_str(name.text()) { + groups.insert(group, item); + } + } + + Some(()) } /// Register a query where it adds a new rule to a group @@ -275,6 +307,44 @@ impl AnalyzerMover { }) } + fn replace_rule_in_group( + groups: &mut FxHashMap, + rule_name: &str, + rule_member: JsonMember, + group: &Category, + ) -> Option<()> { + if let Some(member) = groups.get_mut(group) { + let list = member + .value() + .ok()? + .as_json_object_value()? + .json_member_list(); + + let mut new_members = Vec::with_capacity(list.len()); + let mut new_separators = Vec::with_capacity(list.len()); + let mut rule_member_added = false; + for member in list.iter().flatten() { + if rule_name == member.name().ok()?.inner_string_text().ok()?.text() { + new_members.push(rule_member.clone()); + rule_member_added = true; + } else { + new_members.push(member); + } + } + + if !rule_member_added { + new_members.push(rule_member); + } + for _ in 0..new_members.len().saturating_sub(1) { + new_separators.push(token(T![,])); + } + + *member = group_member(new_members, new_separators, group.as_str()); + } + + Some(()) + } + /// Removes a rule from a group, and returns the new member list /// /// ## Panics @@ -294,17 +364,14 @@ impl AnalyzerMover { let mut new_members = Vec::with_capacity(list.len()); let mut new_separators = Vec::with_capacity(list.len()); - for item in list.iter() { - let item = item.ok()?; + for item in list.iter().flatten() { if rule_name != item.name().ok()?.inner_string_text().ok()?.text() { new_members.push(item); } } - for index in 0..new_members.len() { - if index + 1 < new_members.len() { - new_separators.push(token(T![,])); - } + for _ in 0..new_members.len().saturating_sub(1) { + new_separators.push(token(T![,])); } new_members.shrink_to_fit(); @@ -355,11 +422,6 @@ impl AnalyzerMover { Some(()) } - - pub(crate) fn add_filters(&mut self, filters: &[&str]) { - self.filters = filters.iter().map(|s| Box::from(*s)).collect(); - } - pub(crate) fn run_queries(mut self) -> Option> { let mut mutation = self.root.clone().begin(); for group in ALL_GROUPS { @@ -391,15 +453,16 @@ impl AnalyzerMover { AnalyzerMover::add_rule_to_group(&mut groups, rule_member, &to)? } QueryKind::Replace(group) => { - AnalyzerMover::remove_rule_from_group(&mut groups, rule_name.as_str(), &group)?; - AnalyzerMover::add_rule_to_group(&mut groups, rule_member, &group)? + AnalyzerMover::replace_rule_in_group( + &mut groups, + rule_name.as_str(), + rule_member, + &group, + )?; } QueryKind::Remove(group) => { AnalyzerMover::remove_rule_from_group(&mut groups, rule_name.as_str(), &group)?; } - QueryKind::Insert(group) => { - AnalyzerMover::add_rule_to_group(&mut groups, rule_member, &group)? - } } } @@ -427,6 +490,18 @@ impl AnalyzerMover { } } + if linter_members.len() > 1 { + for _ in 0..linter_members.len().saturating_sub(1) { + linter_separators.push(token(T![,])); + } + } + + if assist_members.len() > 1 { + for _ in 0..assist_members.len().saturating_sub(1) { + assist_separators.push(token(T![,])); + } + } + let list = self .root .value() @@ -434,49 +509,80 @@ impl AnalyzerMover { .as_json_object_value()? .json_member_list(); - let mut members: Vec<_> = list - .iter() - .filter_map(|el| { - let el = el.ok()?; - let token_text = el.name().ok()?.inner_string_text().ok()?; - if token_text.text() == "linter" - || token_text.text() == "assist" - || self.filters.iter().any(|s| s.as_ref() == token_text.text()) - { - None + let mut separators = vec![]; + let mut top_level_members = vec![]; + + // AKAK: linter: {} + let linter_member = + self.linter_member + .unwrap_or(create_new_linter_member(vec![], vec![], 4)); + + // AKAK: assist: {} + let assist_memebr = self + .assist_member + .unwrap_or(create_new_assist_member(vec![], vec![])); + + let mut linter_member_added = false; + let mut assist_member_added = false; + + for top_level_member in list.iter().flatten() { + let name = top_level_member + .name() + .ok() + .and_then(|n| n.inner_string_text().ok()); + + if let Some(name) = name { + if name.text() == "linter" { + if linter_members.is_empty() { + top_level_members.push(top_level_member.clone()); + } else { + let new_linter_member = add_members_to_linter_member( + &linter_member, + linter_members.clone(), + linter_separators.clone(), + ); + top_level_members.push(new_linter_member); + } + linter_member_added = true; + } else if name.text() == "assist" { + if assist_members.is_empty() { + top_level_members.push(top_level_member.clone()); + } else { + let new_assist_member = add_members_to_assist_member( + &assist_memebr, + assist_members.clone(), + assist_separators.clone(), + ); + top_level_members.push(new_assist_member); + } + assist_member_added = true; } else { - Some(el) + top_level_members.push(top_level_member.clone()); } - }) - .collect(); - let mut separators: Vec<_> = list.separators().filter_map(|el| el.ok()).collect(); - - if !linter_members.is_empty() { - for _ in 0..linter_members.len() - 1 { - linter_separators.push(token(T![,])) - } - - let new_linter_member = create_new_linter_member(linter_members, linter_separators); - members.push(new_linter_member); - if members.len() > 1 { - separators.push(token(T![,])); } } - if !assist_members.is_empty() { - for _ in 0..assist_members.len() - 1 { - assist_separators.push(token(T![,])) - } + if !assist_member_added && !assist_members.is_empty() { + top_level_members.push(add_members_to_assist_member( + &assist_memebr, + assist_members.clone(), + assist_separators.clone(), + )); + } - let new_assist_member = create_new_assist_member(assist_members, assist_separators); + if !linter_member_added && !linter_members.is_empty() { + top_level_members.push(add_members_to_linter_member( + &linter_member, + linter_members.clone(), + linter_separators.clone(), + )); + } - members.push(new_assist_member); - if members.len() > 1 { - separators.push(token(T![,])); - } + for _ in 0..top_level_members.len().saturating_sub(1) { + separators.push(token(T![,])); } - mutation.replace_node(list, json_member_list(members, separators)); + mutation.replace_node(list, json_member_list(top_level_members, separators)); Some(mutation) } @@ -514,10 +620,14 @@ fn group_member( create_member(group_name, AnyJsonValue::JsonObjectValue(object), 6) } -fn rules_member(members: Vec, separators: Vec) -> JsonMember { +fn rules_member( + members: Vec, + separators: Vec, + white_space: usize, +) -> JsonMember { let list = json_member_list(members, separators); - let object = create_object(list, 4); - create_member("rules", AnyJsonValue::JsonObjectValue(object), 4) + let object = create_object(list, white_space); + create_member("rules", AnyJsonValue::JsonObjectValue(object), white_space) } fn actions_member(members: Vec, separators: Vec) -> JsonMember { @@ -526,10 +636,14 @@ fn actions_member(members: Vec, separators: Vec) -> create_member("actions", AnyJsonValue::JsonObjectValue(object), 4) } -fn linter_member(members: Vec, separators: Vec) -> JsonMember { +fn linter_member( + members: Vec, + separators: Vec, + white_space: usize, +) -> JsonMember { let list = json_member_list(members, separators); - let object = create_object(list, 2); - create_member("linter", AnyJsonValue::JsonObjectValue(object), 2) + let object = create_object(list, white_space); + create_member("linter", AnyJsonValue::JsonObjectValue(object), white_space) } fn assist_member(members: Vec, separators: Vec) -> JsonMember { @@ -541,9 +655,110 @@ fn assist_member(members: Vec, separators: Vec) -> fn create_new_linter_member( members: Vec, separators: Vec, + white_space: usize, +) -> JsonMember { + let rules = rules_member(members, separators, white_space + 2); + linter_member(vec![rules], vec![], white_space) +} + +fn add_members_to_linter_member( + linter_member: &JsonMember, + members: Vec, + separators: Vec, +) -> JsonMember { + let mut new_list = vec![]; + let mut new_separators = vec![]; + let mut has_rules_member = false; + + let rules_member_indentation = linter_member + .syntax() + .first_token() + .map(|token| token.leading_trivia().pieces()) + .and_then(|mut pieces| pieces.find(|piece| piece.kind() == TriviaPieceKind::Whitespace)) + .map_or(4, |piece| piece.text().len() + 2); + + let list = linter_member + .value() + .ok() + .and_then(|value| value.as_json_object_value().cloned()) + .map(|o| o.json_member_list()); + if let Some(list) = list { + for item in list.iter().flatten() { + let name = item.name().ok().and_then(|n| n.inner_string_text().ok()); + if !matches!(name.as_deref(), Some("rules")) { + new_list.push(item); + } else { + let rules_members = rules_member( + members.clone(), + separators.clone(), + rules_member_indentation, + ); + new_list.push(rules_members); + has_rules_member = true; + } + } + } + + if !has_rules_member { + let rules_members = rules_member( + members.clone(), + separators.clone(), + rules_member_indentation, + ); + new_list.push(rules_members); + } + + for _ in 0..new_list.len().saturating_sub(1) { + new_separators.push(token(T![,])); + } + + create_member( + "linter", + AnyJsonValue::JsonObjectValue(create_object(json_member_list(new_list, new_separators), 2)), + 2, + ) +} + +fn add_members_to_assist_member( + assist_member: &JsonMember, + members: Vec, + separators: Vec, ) -> JsonMember { - let rules = rules_member(members, separators); - linter_member(vec![rules], vec![]) + let mut new_list = vec![]; + let mut new_separators = vec![]; + let mut has_actions_member = false; + let list = assist_member + .value() + .ok() + .and_then(|value| value.as_json_object_value().cloned()) + .map(|o| o.json_member_list()); + if let Some(list) = list { + for item in list.iter().flatten() { + let name = item.name().ok().and_then(|n| n.inner_string_text().ok()); + if !matches!(name.as_deref(), Some("actions")) { + new_list.push(item); + } else { + let actions_member = actions_member(members.clone(), separators.clone()); + new_list.push(actions_member); + has_actions_member = true; + } + } + } + + if !has_actions_member { + let actions_member = actions_member(members.clone(), separators.clone()); + new_list.push(actions_member); + } + + for _ in 0..new_list.len().saturating_sub(1) { + new_separators.push(token(T![,])); + } + + create_member( + "assist", + AnyJsonValue::JsonObjectValue(create_object(json_member_list(new_list, new_separators), 2)), + 2, + ) } fn create_new_assist_member( @@ -585,6 +800,8 @@ mod tests { .print() .expect("Should be able to format"); + eprintln!("{}", result.as_code()); + buffer.push_str(result.as_code()); buffer.push_str("\n```"); @@ -596,6 +813,7 @@ mod tests { let source = r#" { "linter": { + "includes": [""], "rules": { "style": { "noVar": "error" diff --git a/crates/biome_migrate/src/snapshots/biome_migrate__rule_mover__tests__move_rule_to_new_group.snap b/crates/biome_migrate/src/snapshots/biome_migrate__rule_mover__tests__move_rule_to_new_group.snap index 7f4aa8be8b5b..54c9a96aa5d2 100644 --- a/crates/biome_migrate/src/snapshots/biome_migrate__rule_mover__tests__move_rule_to_new_group.snap +++ b/crates/biome_migrate/src/snapshots/biome_migrate__rule_mover__tests__move_rule_to_new_group.snap @@ -8,6 +8,7 @@ snapshot_kind: text ```json { "linter": { + "includes": [""], "rules": { "style": { "noVar": "error" @@ -23,6 +24,7 @@ snapshot_kind: text ``` { "linter": { + "includes": [""], "rules": { "suspicious": { "noVar": "error" diff --git a/crates/biome_migrate/src/version_services.rs b/crates/biome_migrate/src/version_services.rs deleted file mode 100644 index d2c8a1bff785..000000000000 --- a/crates/biome_migrate/src/version_services.rs +++ /dev/null @@ -1,74 +0,0 @@ -use biome_analyze::{ - AddVisitor, FromServices, MissingServicesDiagnostic, Phase, Phases, QueryKey, Queryable, - RuleKey, ServiceBag, SyntaxVisitor, -}; -use biome_json_syntax::{JsonLanguage, JsonRoot, JsonSyntaxNode}; -use biome_rowan::AstNode; -use std::sync::Arc; - -#[derive(Debug, Clone)] -pub(crate) struct VersionServices { - version: Arc, -} - -#[derive(Debug, Clone)] -pub(crate) struct TheVersion(pub(crate) biome_package::Version); - -impl TheVersion { - pub fn new(range: &str) -> Self { - Self(biome_package::Version::from(range)) - } -} - -impl VersionServices { - pub fn satisfies(&self, version: &str) -> bool { - self.version.0.satisfies(version) - } -} - -impl FromServices for VersionServices { - fn from_services( - rule_key: &RuleKey, - services: &ServiceBag, - ) -> Result { - let version: &Arc = services - .get_service() - .ok_or_else(|| MissingServicesDiagnostic::new(rule_key.rule_name(), &["TheVersion"]))?; - Ok(Self { - version: version.clone(), - }) - } -} - -impl Phase for VersionServices { - fn phase() -> Phases { - Phases::Syntax - } -} - -/// Query type usable by lint rules **that uses the semantic model** to match on specific [AstNode] types -#[derive(Clone)] -pub(crate) struct Version(pub N); - -impl Queryable for Version -where - N: AstNode + 'static, -{ - type Input = JsonSyntaxNode; - type Output = N; - - type Language = JsonLanguage; - type Services = VersionServices; - - fn build_visitor(analyzer: &mut impl AddVisitor, _: &JsonRoot) { - analyzer.add_visitor(Phases::Syntax, SyntaxVisitor::default); - } - - fn key() -> QueryKey { - QueryKey::Syntax(N::KIND_SET) - } - - fn unwrap_match(_: &ServiceBag, node: &Self::Input) -> Self::Output { - N::unwrap_cast(node.clone()) - } -} diff --git a/crates/biome_migrate/tests/spec_tests.rs b/crates/biome_migrate/tests/spec_tests.rs index fff3e5d89f6c..2d86a8af4679 100644 --- a/crates/biome_migrate/tests/spec_tests.rs +++ b/crates/biome_migrate/tests/spec_tests.rs @@ -62,56 +62,47 @@ pub(crate) fn analyze_and_snap( input_file: &Utf8Path, directory_path: PathBuf, ) -> usize { - let parsed = parse_json( - input_code, + let parse_options = if file_name.ends_with(".jsonc") { JsonParserOptions::default() .with_allow_comments() - .with_allow_trailing_commas(), - ); + .with_allow_trailing_commas() + } else { + JsonParserOptions::default() + }; + let parsed = parse_json(input_code, parse_options); let root = parsed.tree(); let mut diagnostics = Vec::new(); let mut code_fixes = Vec::new(); - let input_version_file = input_file.with_extension("version.txt"); - let version = read_to_string(&input_version_file).ok().map_or_else( - || panic!("missing {input_version_file} file"), - |v| v.trim().to_string(), - ); let rule_name = directory_path.file_name().unwrap().to_str().unwrap(); let rule_filter = RuleFilter::Rule("migrations", rule_name); let filter = AnalysisFilter { enabled_rules: Some(slice::from_ref(&rule_filter)), ..Default::default() }; - let (_, errors) = biome_migrate::migrate_configuration( - &root, - filter, - input_file, - version.to_string(), - |event| { - if let Some(mut diag) = event.diagnostic() { - for action in event.actions() { - if !action.is_suppression() { - check_code_action(input_file, input_code, &action); - diag = diag.add_code_suggestion(CodeSuggestionAdvice::from(action)); - } - } - - let error = diag.with_severity(Severity::Warning); - diagnostics.push(diagnostic_to_string(file_name, input_code, error)); - return ControlFlow::Continue(()); - } - + let (_, errors) = biome_migrate::migrate_configuration(&root, filter, input_file, |event| { + if let Some(mut diag) = event.diagnostic() { for action in event.actions() { if !action.is_suppression() { - check_code_action(input_file, input_code, &action); - code_fixes.push(code_fix_to_string(input_code, action)); + check_code_action(input_file, input_code, &action, parse_options); + diag = diag.add_code_suggestion(CodeSuggestionAdvice::from(action)); } } - ControlFlow::::Continue(()) - }, - ); + let error = diag.with_severity(Severity::Warning); + diagnostics.push(diagnostic_to_string(file_name, input_code, error)); + return ControlFlow::Continue(()); + } + + for action in event.actions() { + if !action.is_suppression() { + check_code_action(input_file, input_code, &action, parse_options); + code_fixes.push(code_fix_to_string(input_code, action)); + } + } + + ControlFlow::::Continue(()) + }); for error in errors { diagnostics.push(diagnostic_to_string(file_name, input_code, error)); @@ -127,7 +118,12 @@ pub(crate) fn analyze_and_snap( diagnostics.len() } -fn check_code_action(path: &Utf8Path, source: &str, action: &AnalyzerAction) { +fn check_code_action( + path: &Utf8Path, + source: &str, + action: &AnalyzerAction, + parse_options: JsonParserOptions, +) { let (new_tree, text_edit) = match action .mutation .clone() @@ -153,11 +149,6 @@ fn check_code_action(path: &Utf8Path, source: &str, action: &AnalyzerAction 5 │ "noVar": "error" - │ ^^^^^^^ + │ ^^^^^^^^^^^^^^^^ 6 │ } 7 │ } @@ -35,9 +35,15 @@ invalid.json:5:9 migrate FIXABLE ━━━━━━━━━━━━━━━ 2 2 │ "linter": { 3 3 │ "rules": { 4 │ - ······"style":·{ - 4 │ + ······"suspicious":·{ - 5 5 │ "noVar": "error" - 6 6 │ } + 4 │ + ······"suspicious":··{ + 5 │ + ········"noVar":·"error" + 6 │ + ····}, + 7 │ + ····"suspicious":··{ + 5 8 │ "noVar": "error" + 6 │ - ······} + 9 │ + ····} + 7 10 │ } + 8 11 │ } ``` diff --git a/crates/biome_migrate/tests/specs/migrations/noVar/invalid.version.txt b/crates/biome_migrate/tests/specs/migrations/noVar/invalid.version.txt deleted file mode 100644 index 227cea215648..000000000000 --- a/crates/biome_migrate/tests/specs/migrations/noVar/invalid.version.txt +++ /dev/null @@ -1 +0,0 @@ -2.0.0 diff --git a/crates/biome_migrate/tests/specs/migrations/noVar/invalid_with_group.json b/crates/biome_migrate/tests/specs/migrations/noVar/invalid_with_group.json new file mode 100644 index 000000000000..46a350d75aec --- /dev/null +++ b/crates/biome_migrate/tests/specs/migrations/noVar/invalid_with_group.json @@ -0,0 +1,13 @@ +{ + "linter": { + "rules": { + "suspicious": { + "foo": "bar" + }, + "style": { + "lorem": "ipsum", + "noVar": "error" + } + } + } +} diff --git a/crates/biome_migrate/tests/specs/migrations/noVar/invalid_with_group.json.snap b/crates/biome_migrate/tests/specs/migrations/noVar/invalid_with_group.json.snap new file mode 100644 index 000000000000..b59b6befbeec --- /dev/null +++ b/crates/biome_migrate/tests/specs/migrations/noVar/invalid_with_group.json.snap @@ -0,0 +1,53 @@ +--- +source: crates/biome_migrate/tests/spec_tests.rs +expression: invalid_with_group.json +snapshot_kind: text +--- +# Input +```json +{ + "linter": { + "rules": { + "suspicious": { + "foo": "bar" + }, + "style": { + "lorem": "ipsum", + "noVar": "error" + } + } + } +} + +``` + +# Diagnostics +``` +invalid_with_group.json:9:9 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! The rule style/noVar has ben moved to the suspicious group. + + 7 │ "style": { + 8 │ "lorem": "ipsum", + > 9 │ "noVar": "error" + │ ^^^^^^^^^^^^^^^^ + 10 │ } + 11 │ } + + i Safe fix: Move the rule in the correct group. + + 5 5 │ "foo": "bar" + 6 6 │ }, + 7 │ - ······"style":·{ + 8 │ - ········"lorem":·"ipsum", + 9 │ - ········"noVar":·"error" + 7 │ + ······"suspicious":·{ + 8 │ + ········"foo":·"bar" + 9 │ + ······}, + 10 │ + ······"suspicious":·{ + 11 │ + ········"foo":·"bar" + 10 12 │ } + 11 13 │ } + + +``` diff --git a/crates/biome_migrate/tests/specs/migrations/nurseryRules/complexCase.version.txt b/crates/biome_migrate/tests/specs/migrations/nurseryRules/complexCase.version.txt deleted file mode 100644 index 3e1ad720b13d..000000000000 --- a/crates/biome_migrate/tests/specs/migrations/nurseryRules/complexCase.version.txt +++ /dev/null @@ -1 +0,0 @@ -1.5.0 \ No newline at end of file diff --git a/crates/biome_migrate/tests/specs/migrations/nurseryRules/existingGroupWithExistingRule.version.txt b/crates/biome_migrate/tests/specs/migrations/nurseryRules/existingGroupWithExistingRule.version.txt deleted file mode 100644 index 3e1ad720b13d..000000000000 --- a/crates/biome_migrate/tests/specs/migrations/nurseryRules/existingGroupWithExistingRule.version.txt +++ /dev/null @@ -1 +0,0 @@ -1.5.0 \ No newline at end of file diff --git a/crates/biome_migrate/tests/specs/migrations/nurseryRules/firstToExistingGroup.version.txt b/crates/biome_migrate/tests/specs/migrations/nurseryRules/firstToExistingGroup.version.txt deleted file mode 100644 index 3e1ad720b13d..000000000000 --- a/crates/biome_migrate/tests/specs/migrations/nurseryRules/firstToExistingGroup.version.txt +++ /dev/null @@ -1 +0,0 @@ -1.5.0 \ No newline at end of file diff --git a/crates/biome_migrate/tests/specs/migrations/nurseryRules/lastToExistingGroup.version.txt b/crates/biome_migrate/tests/specs/migrations/nurseryRules/lastToExistingGroup.version.txt deleted file mode 100644 index 3e1ad720b13d..000000000000 --- a/crates/biome_migrate/tests/specs/migrations/nurseryRules/lastToExistingGroup.version.txt +++ /dev/null @@ -1 +0,0 @@ -1.5.0 \ No newline at end of file diff --git a/crates/biome_migrate/tests/specs/migrations/nurseryRules/middleToExistingGroup.version.txt b/crates/biome_migrate/tests/specs/migrations/nurseryRules/middleToExistingGroup.version.txt deleted file mode 100644 index 3e1ad720b13d..000000000000 --- a/crates/biome_migrate/tests/specs/migrations/nurseryRules/middleToExistingGroup.version.txt +++ /dev/null @@ -1 +0,0 @@ -1.5.0 \ No newline at end of file diff --git a/crates/biome_migrate/tests/specs/migrations/nurseryRules/noNewGroup.version.txt b/crates/biome_migrate/tests/specs/migrations/nurseryRules/noNewGroup.version.txt deleted file mode 100644 index 3e1ad720b13d..000000000000 --- a/crates/biome_migrate/tests/specs/migrations/nurseryRules/noNewGroup.version.txt +++ /dev/null @@ -1 +0,0 @@ -1.5.0 \ No newline at end of file diff --git a/crates/biome_migrate/tests/specs/migrations/nurseryRules/renamedRule.version.txt b/crates/biome_migrate/tests/specs/migrations/nurseryRules/renamedRule.version.txt deleted file mode 100644 index 3e1ad720b13d..000000000000 --- a/crates/biome_migrate/tests/specs/migrations/nurseryRules/renamedRule.version.txt +++ /dev/null @@ -1 +0,0 @@ -1.5.0 \ No newline at end of file diff --git a/crates/biome_migrate/tests/specs/migrations/nurseryRules/renamedRuleAndNewRule.version.txt b/crates/biome_migrate/tests/specs/migrations/nurseryRules/renamedRuleAndNewRule.version.txt deleted file mode 100644 index 3e1ad720b13d..000000000000 --- a/crates/biome_migrate/tests/specs/migrations/nurseryRules/renamedRuleAndNewRule.version.txt +++ /dev/null @@ -1 +0,0 @@ -1.5.0 \ No newline at end of file diff --git a/crates/biome_migrate/tests/specs/migrations/nurseryRules/singleToExistingGroup.version.txt b/crates/biome_migrate/tests/specs/migrations/nurseryRules/singleToExistingGroup.version.txt deleted file mode 100644 index 3e1ad720b13d..000000000000 --- a/crates/biome_migrate/tests/specs/migrations/nurseryRules/singleToExistingGroup.version.txt +++ /dev/null @@ -1 +0,0 @@ -1.5.0 \ No newline at end of file diff --git a/crates/biome_migrate/tests/specs/migrations/organizeImports/invalid.json.snap b/crates/biome_migrate/tests/specs/migrations/organizeImports/invalid.json.snap index 54cc6b07a90b..777394a69c4f 100644 --- a/crates/biome_migrate/tests/specs/migrations/organizeImports/invalid.json.snap +++ b/crates/biome_migrate/tests/specs/migrations/organizeImports/invalid.json.snap @@ -32,9 +32,9 @@ invalid.json:3:5 migrate FIXABLE ━━━━━━━━━━━━━━━ 1 1 │ { 2 │ - ··"organizeImports":·{ 3 │ - ····"enabled":·false - 2 │ + ··"assist":·{ - 3 │ + ····"actions":·{ - 4 │ + ······"source":·{ + 2 │ + ··"assist":··{ + 3 │ + ····"actions":··{ + 4 │ + ······"source":··{ 5 │ + ········"organizeImports":·"off" 6 │ + ······} 7 │ + ····} diff --git a/crates/biome_migrate/tests/specs/migrations/organizeImports/invalid.version.txt b/crates/biome_migrate/tests/specs/migrations/organizeImports/invalid.version.txt deleted file mode 100644 index 227cea215648..000000000000 --- a/crates/biome_migrate/tests/specs/migrations/organizeImports/invalid.version.txt +++ /dev/null @@ -1 +0,0 @@ -2.0.0 diff --git a/crates/biome_migrate/tests/specs/migrations/styleRules/empty.json.snap b/crates/biome_migrate/tests/specs/migrations/styleRules/empty.json.snap index b9ff1fed4662..219f61a8f45c 100644 --- a/crates/biome_migrate/tests/specs/migrations/styleRules/empty.json.snap +++ b/crates/biome_migrate/tests/specs/migrations/styleRules/empty.json.snap @@ -15,7 +15,7 @@ snapshot_kind: text ``` empty.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - ! Biome style rules aren't recommended anymore. + ! Biome style rule useLiteralEnumMembers isn't recommended anymore. > 1 │ { │ ^ @@ -33,35 +33,685 @@ empty.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━ 3 │ - ··"javascript":·{} 3 │ + ··"javascript":·{}, 4 │ + ··"linter":·{ - 5 │ + ····"rules":·{ + 5 │ + ······"rules":·{ 6 │ + ······"style":·{ - 7 │ + ········"useLiteralEnumMembers":"error", - 8 │ + ········"noArguments":"error", - 9 │ + ········"noParameterAssign":"error", - 10 │ + ········"useShorthandFunctionType":"error", - 11 │ + ········"useExportType":"error", - 12 │ + ········"useDefaultParameterLast":"error", - 13 │ + ········"noCommaOperator":"error", - 14 │ + ········"useSingleVarDeclarator":"error", - 15 │ + ········"noNonnullAssertion":"error", - 16 │ + ········"useNodejsImportProtocol":"error", - 17 │ + ········"useConst":"error", - 18 │ + ········"noInferrableTypes":"error", - 19 │ + ········"useExponentiationOperator":"error", - 20 │ + ········"noUselessElse":"error", - 21 │ + ········"useSelfClosingElements":"error", - 22 │ + ········"useImportType":"error", - 23 │ + ········"useNumberNamespace":"error", - 24 │ + ········"useWhile":"error", - 25 │ + ········"useAsConstAssertion":"error", - 26 │ + ········"noUnusedTemplateLiteral":"error", - 27 │ + ········"useNumericLiterals":"error", - 28 │ + ········"useTemplate":"error", - 29 │ + ········"useEnumInitializers":"error" - 30 │ + ······} - 31 │ + ····} - 32 │ + ··} - 4 33 │ } + 7 │ + ········"useLiteralEnumMembers":·"error" + 8 │ + ······} + 9 │ + ······} + 10 │ + ··} + 4 11 │ } + + +``` + +``` +empty.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule noParameterAssign isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "formatter": {}, + > 3 │ "javascript": {} + > 4 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 1 1 │ { + 2 2 │ "formatter": {}, + 3 │ - ··"javascript":·{} + 3 │ + ··"javascript":·{}, + 4 │ + ··"linter":·{ + 5 │ + ······"rules":·{ + 6 │ + ······"style":·{ + 7 │ + ········"noParameterAssign":·"error" + 8 │ + ······} + 9 │ + ······} + 10 │ + ··} + 4 11 │ } + + +``` + +``` +empty.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule noCommaOperator isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "formatter": {}, + > 3 │ "javascript": {} + > 4 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 1 1 │ { + 2 2 │ "formatter": {}, + 3 │ - ··"javascript":·{} + 3 │ + ··"javascript":·{}, + 4 │ + ··"linter":·{ + 5 │ + ······"rules":·{ + 6 │ + ······"style":·{ + 7 │ + ········"noCommaOperator":·"error" + 8 │ + ······} + 9 │ + ······} + 10 │ + ··} + 4 11 │ } + + +``` + +``` +empty.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useSelfClosingElements isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "formatter": {}, + > 3 │ "javascript": {} + > 4 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 1 1 │ { + 2 2 │ "formatter": {}, + 3 │ - ··"javascript":·{} + 3 │ + ··"javascript":·{}, + 4 │ + ··"linter":·{ + 5 │ + ······"rules":·{ + 6 │ + ······"style":·{ + 7 │ + ········"useSelfClosingElements":·"error" + 8 │ + ······} + 9 │ + ······} + 10 │ + ··} + 4 11 │ } + + +``` + +``` +empty.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useEnumInitializers isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "formatter": {}, + > 3 │ "javascript": {} + > 4 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 1 1 │ { + 2 2 │ "formatter": {}, + 3 │ - ··"javascript":·{} + 3 │ + ··"javascript":·{}, + 4 │ + ··"linter":·{ + 5 │ + ······"rules":·{ + 6 │ + ······"style":·{ + 7 │ + ········"useEnumInitializers":·"error" + 8 │ + ······} + 9 │ + ······} + 10 │ + ··} + 4 11 │ } + + +``` + +``` +empty.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useTemplate isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "formatter": {}, + > 3 │ "javascript": {} + > 4 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 1 1 │ { + 2 2 │ "formatter": {}, + 3 │ - ··"javascript":·{} + 3 │ + ··"javascript":·{}, + 4 │ + ··"linter":·{ + 5 │ + ······"rules":·{ + 6 │ + ······"style":·{ + 7 │ + ········"useTemplate":·"error" + 8 │ + ······} + 9 │ + ······} + 10 │ + ··} + 4 11 │ } + + +``` + +``` +empty.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useNumericLiterals isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "formatter": {}, + > 3 │ "javascript": {} + > 4 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 1 1 │ { + 2 2 │ "formatter": {}, + 3 │ - ··"javascript":·{} + 3 │ + ··"javascript":·{}, + 4 │ + ··"linter":·{ + 5 │ + ······"rules":·{ + 6 │ + ······"style":·{ + 7 │ + ········"useNumericLiterals":·"error" + 8 │ + ······} + 9 │ + ······} + 10 │ + ··} + 4 11 │ } + + +``` + +``` +empty.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule noUnusedTemplateLiteral isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "formatter": {}, + > 3 │ "javascript": {} + > 4 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 1 1 │ { + 2 2 │ "formatter": {}, + 3 │ - ··"javascript":·{} + 3 │ + ··"javascript":·{}, + 4 │ + ··"linter":·{ + 5 │ + ······"rules":·{ + 6 │ + ······"style":·{ + 7 │ + ········"noUnusedTemplateLiteral":·"error" + 8 │ + ······} + 9 │ + ······} + 10 │ + ··} + 4 11 │ } + + +``` + +``` +empty.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useAsConstAssertion isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "formatter": {}, + > 3 │ "javascript": {} + > 4 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 1 1 │ { + 2 2 │ "formatter": {}, + 3 │ - ··"javascript":·{} + 3 │ + ··"javascript":·{}, + 4 │ + ··"linter":·{ + 5 │ + ······"rules":·{ + 6 │ + ······"style":·{ + 7 │ + ········"useAsConstAssertion":·"error" + 8 │ + ······} + 9 │ + ······} + 10 │ + ··} + 4 11 │ } + + +``` + +``` +empty.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useNumberNamespace isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "formatter": {}, + > 3 │ "javascript": {} + > 4 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 1 1 │ { + 2 2 │ "formatter": {}, + 3 │ - ··"javascript":·{} + 3 │ + ··"javascript":·{}, + 4 │ + ··"linter":·{ + 5 │ + ······"rules":·{ + 6 │ + ······"style":·{ + 7 │ + ········"useNumberNamespace":·"error" + 8 │ + ······} + 9 │ + ······} + 10 │ + ··} + 4 11 │ } + + +``` + +``` +empty.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule noUselessElse isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "formatter": {}, + > 3 │ "javascript": {} + > 4 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 1 1 │ { + 2 2 │ "formatter": {}, + 3 │ - ··"javascript":·{} + 3 │ + ··"javascript":·{}, + 4 │ + ··"linter":·{ + 5 │ + ······"rules":·{ + 6 │ + ······"style":·{ + 7 │ + ········"noUselessElse":·"error" + 8 │ + ······} + 9 │ + ······} + 10 │ + ··} + 4 11 │ } + + +``` + +``` +empty.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useImportType isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "formatter": {}, + > 3 │ "javascript": {} + > 4 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 1 1 │ { + 2 2 │ "formatter": {}, + 3 │ - ··"javascript":·{} + 3 │ + ··"javascript":·{}, + 4 │ + ··"linter":·{ + 5 │ + ······"rules":·{ + 6 │ + ······"style":·{ + 7 │ + ········"useImportType":·"error" + 8 │ + ······} + 9 │ + ······} + 10 │ + ··} + 4 11 │ } + + +``` + +``` +empty.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useExponentiationOperator isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "formatter": {}, + > 3 │ "javascript": {} + > 4 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 1 1 │ { + 2 2 │ "formatter": {}, + 3 │ - ··"javascript":·{} + 3 │ + ··"javascript":·{}, + 4 │ + ··"linter":·{ + 5 │ + ······"rules":·{ + 6 │ + ······"style":·{ + 7 │ + ········"useExponentiationOperator":·"error" + 8 │ + ······} + 9 │ + ······} + 10 │ + ··} + 4 11 │ } + + +``` + +``` +empty.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule noInferrableTypes isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "formatter": {}, + > 3 │ "javascript": {} + > 4 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 1 1 │ { + 2 2 │ "formatter": {}, + 3 │ - ··"javascript":·{} + 3 │ + ··"javascript":·{}, + 4 │ + ··"linter":·{ + 5 │ + ······"rules":·{ + 6 │ + ······"style":·{ + 7 │ + ········"noInferrableTypes":·"error" + 8 │ + ······} + 9 │ + ······} + 10 │ + ··} + 4 11 │ } + + +``` + +``` +empty.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule noNonNullAssertion isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "formatter": {}, + > 3 │ "javascript": {} + > 4 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 1 1 │ { + 2 2 │ "formatter": {}, + 3 │ - ··"javascript":·{} + 3 │ + ··"javascript":·{}, + 4 │ + ··"linter":·{ + 5 │ + ······"rules":·{ + 6 │ + ······"style":·{ + 7 │ + ········"noNonNullAssertion":·"error" + 8 │ + ······} + 9 │ + ······} + 10 │ + ··} + 4 11 │ } + + +``` + +``` +empty.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useConst isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "formatter": {}, + > 3 │ "javascript": {} + > 4 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 1 1 │ { + 2 2 │ "formatter": {}, + 3 │ - ··"javascript":·{} + 3 │ + ··"javascript":·{}, + 4 │ + ··"linter":·{ + 5 │ + ······"rules":·{ + 6 │ + ······"style":·{ + 7 │ + ········"useConst":·"error" + 8 │ + ······} + 9 │ + ······} + 10 │ + ··} + 4 11 │ } + + +``` + +``` +empty.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useNodejsImportProtocol isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "formatter": {}, + > 3 │ "javascript": {} + > 4 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 1 1 │ { + 2 2 │ "formatter": {}, + 3 │ - ··"javascript":·{} + 3 │ + ··"javascript":·{}, + 4 │ + ··"linter":·{ + 5 │ + ······"rules":·{ + 6 │ + ······"style":·{ + 7 │ + ········"useNodejsImportProtocol":·"error" + 8 │ + ······} + 9 │ + ······} + 10 │ + ··} + 4 11 │ } + + +``` + +``` +empty.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useDefaultParameterLast isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "formatter": {}, + > 3 │ "javascript": {} + > 4 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 1 1 │ { + 2 2 │ "formatter": {}, + 3 │ - ··"javascript":·{} + 3 │ + ··"javascript":·{}, + 4 │ + ··"linter":·{ + 5 │ + ······"rules":·{ + 6 │ + ······"style":·{ + 7 │ + ········"useDefaultParameterLast":·"error" + 8 │ + ······} + 9 │ + ······} + 10 │ + ··} + 4 11 │ } + + +``` + +``` +empty.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useSingleVarDeclarator isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "formatter": {}, + > 3 │ "javascript": {} + > 4 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 1 1 │ { + 2 2 │ "formatter": {}, + 3 │ - ··"javascript":·{} + 3 │ + ··"javascript":·{}, + 4 │ + ··"linter":·{ + 5 │ + ······"rules":·{ + 6 │ + ······"style":·{ + 7 │ + ········"useSingleVarDeclarator":·"error" + 8 │ + ······} + 9 │ + ······} + 10 │ + ··} + 4 11 │ } + + +``` + +``` +empty.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useExportType isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "formatter": {}, + > 3 │ "javascript": {} + > 4 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 1 1 │ { + 2 2 │ "formatter": {}, + 3 │ - ··"javascript":·{} + 3 │ + ··"javascript":·{}, + 4 │ + ··"linter":·{ + 5 │ + ······"rules":·{ + 6 │ + ······"style":·{ + 7 │ + ········"useExportType":·"error" + 8 │ + ······} + 9 │ + ······} + 10 │ + ··} + 4 11 │ } + + +``` + +``` +empty.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule noArguments isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "formatter": {}, + > 3 │ "javascript": {} + > 4 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 1 1 │ { + 2 2 │ "formatter": {}, + 3 │ - ··"javascript":·{} + 3 │ + ··"javascript":·{}, + 4 │ + ··"linter":·{ + 5 │ + ······"rules":·{ + 6 │ + ······"style":·{ + 7 │ + ········"noArguments":·"error" + 8 │ + ······} + 9 │ + ······} + 10 │ + ··} + 4 11 │ } + + +``` + +``` +empty.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useShorthandFunctionType isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "formatter": {}, + > 3 │ "javascript": {} + > 4 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 1 1 │ { + 2 2 │ "formatter": {}, + 3 │ - ··"javascript":·{} + 3 │ + ··"javascript":·{}, + 4 │ + ··"linter":·{ + 5 │ + ······"rules":·{ + 6 │ + ······"style":·{ + 7 │ + ········"useShorthandFunctionType":·"error" + 8 │ + ······} + 9 │ + ······} + 10 │ + ··} + 4 11 │ } ``` diff --git a/crates/biome_migrate/tests/specs/migrations/styleRules/empty.version.txt b/crates/biome_migrate/tests/specs/migrations/styleRules/empty.version.txt deleted file mode 100644 index 359a5b952d49..000000000000 --- a/crates/biome_migrate/tests/specs/migrations/styleRules/empty.version.txt +++ /dev/null @@ -1 +0,0 @@ -2.0.0 \ No newline at end of file diff --git a/crates/biome_migrate/tests/specs/migrations/styleRules/realCase.json b/crates/biome_migrate/tests/specs/migrations/styleRules/realCase.json new file mode 100644 index 000000000000..ded692c24334 --- /dev/null +++ b/crates/biome_migrate/tests/specs/migrations/styleRules/realCase.json @@ -0,0 +1,72 @@ +{ + "$schema": "./packages/@biomejs/biome/configuration_schema.json", + "assist": { + "enabled": true, + "ignore": [ + "./packages/@biomejs/biome/configuration_schema.json" + ], + "actions": { + "source": { + "useSortedKeys": "off" + } + } + }, + "css": { + "linter": { + "enabled": true + } + }, + "files": { + "ignore": [ + "crates/**", + "dist/**", + ".astro/**", + "assets/**", + "packages/@biomejs/backend-jsonrpc/src/workspace.ts", + "public/**", + "**/__snapshots__", + "**/undefined/**", + "_fonts/**", + "packages/@biomejs/wasm-*", + "benchmark/target/**" + ], + "include": [ + "packages/aria-data/*.js", + "packages/@biomejs/**", + "packages/tailwindcss-config-analyzer/**", + "benchmark/**" + ] + }, + "formatter": { + "ignore": [ + "configuration_schema.json" + ] + }, + "json": { + "formatter": { + "indentStyle": "space", + "lineWidth": 1 + } + }, + "linter": { + "enabled": true, + "rules": { + "recommended": true, + "correctness": { + "noUndeclaredDependencies": "error" + }, + "style": { + "noNonNullAssertion": "off", + "useNodejsImportProtocol": "error" + }, + "suspicious": { + "noVar": "on" + } + } + }, + "vcs": { + "clientKind": "git", + "enabled": true, + "useIgnoreFile": true + } +} diff --git a/crates/biome_migrate/tests/specs/migrations/styleRules/realCase.json.snap b/crates/biome_migrate/tests/specs/migrations/styleRules/realCase.json.snap new file mode 100644 index 000000000000..892ee7e4c543 --- /dev/null +++ b/crates/biome_migrate/tests/specs/migrations/styleRules/realCase.json.snap @@ -0,0 +1,922 @@ +--- +source: crates/biome_migrate/tests/spec_tests.rs +expression: realCase.json +snapshot_kind: text +--- +# Input +```json +{ + "$schema": "./packages/@biomejs/biome/configuration_schema.json", + "assist": { + "enabled": true, + "ignore": [ + "./packages/@biomejs/biome/configuration_schema.json" + ], + "actions": { + "source": { + "useSortedKeys": "off" + } + } + }, + "css": { + "linter": { + "enabled": true + } + }, + "files": { + "ignore": [ + "crates/**", + "dist/**", + ".astro/**", + "assets/**", + "packages/@biomejs/backend-jsonrpc/src/workspace.ts", + "public/**", + "**/__snapshots__", + "**/undefined/**", + "_fonts/**", + "packages/@biomejs/wasm-*", + "benchmark/target/**" + ], + "include": [ + "packages/aria-data/*.js", + "packages/@biomejs/**", + "packages/tailwindcss-config-analyzer/**", + "benchmark/**" + ] + }, + "formatter": { + "ignore": [ + "configuration_schema.json" + ] + }, + "json": { + "formatter": { + "indentStyle": "space", + "lineWidth": 1 + } + }, + "linter": { + "enabled": true, + "rules": { + "recommended": true, + "correctness": { + "noUndeclaredDependencies": "error" + }, + "style": { + "noNonNullAssertion": "off", + "useNodejsImportProtocol": "error" + }, + "suspicious": { + "noVar": "on" + } + } + }, + "vcs": { + "clientKind": "git", + "enabled": true, + "useIgnoreFile": true + } +} + +``` + +# Diagnostics +``` +realCase.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useLiteralEnumMembers isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "$schema": "./packages/@biomejs/biome/configuration_schema.json", + > 3 │ "assist": { + > 4 │ "enabled": true, + ... + > 70 │ "useIgnoreFile": true + > 71 │ } + > 72 │ } + │ ^ + 73 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 52 52 │ "enabled": true, + 53 53 │ "rules": { + 54 │ - ······"recommended":·true, + 55 │ - ······"correctness":·{ + 56 │ - ········"noUndeclaredDependencies":·"error" + 54 │ + ······"style":·{ + 55 │ + ········"noNonNullAssertion":·"off", + 56 │ + ········"useNodejsImportProtocol":·"error", + 57 │ + ········"useLiteralEnumMembers":·"error" + 57 58 │ }, + 58 │ - ······"style":·{ + 59 │ - ········"noNonNullAssertion":·"off", + 60 │ - ········"useNodejsImportProtocol":·"error" + 59 │ + ······"correctness":·{ + 60 │ + ········"noUndeclaredDependencies":·"error" + 61 61 │ }, + 62 62 │ "suspicious": { + + +``` + +``` +realCase.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule noParameterAssign isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "$schema": "./packages/@biomejs/biome/configuration_schema.json", + > 3 │ "assist": { + > 4 │ "enabled": true, + ... + > 70 │ "useIgnoreFile": true + > 71 │ } + > 72 │ } + │ ^ + 73 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 52 52 │ "enabled": true, + 53 53 │ "rules": { + 54 │ - ······"recommended":·true, + 55 │ - ······"correctness":·{ + 56 │ - ········"noUndeclaredDependencies":·"error" + 54 │ + ······"style":·{ + 55 │ + ········"noNonNullAssertion":·"off", + 56 │ + ········"useNodejsImportProtocol":·"error", + 57 │ + ········"noParameterAssign":·"error" + 57 58 │ }, + 58 │ - ······"style":·{ + 59 │ - ········"noNonNullAssertion":·"off", + 60 │ - ········"useNodejsImportProtocol":·"error" + 59 │ + ······"correctness":·{ + 60 │ + ········"noUndeclaredDependencies":·"error" + 61 61 │ }, + 62 62 │ "suspicious": { + + +``` + +``` +realCase.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule noCommaOperator isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "$schema": "./packages/@biomejs/biome/configuration_schema.json", + > 3 │ "assist": { + > 4 │ "enabled": true, + ... + > 70 │ "useIgnoreFile": true + > 71 │ } + > 72 │ } + │ ^ + 73 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 52 52 │ "enabled": true, + 53 53 │ "rules": { + 54 │ - ······"recommended":·true, + 55 │ - ······"correctness":·{ + 56 │ - ········"noUndeclaredDependencies":·"error" + 54 │ + ······"style":·{ + 55 │ + ········"noNonNullAssertion":·"off", + 56 │ + ········"useNodejsImportProtocol":·"error", + 57 │ + ········"noCommaOperator":·"error" + 57 58 │ }, + 58 │ - ······"style":·{ + 59 │ - ········"noNonNullAssertion":·"off", + 60 │ - ········"useNodejsImportProtocol":·"error" + 59 │ + ······"correctness":·{ + 60 │ + ········"noUndeclaredDependencies":·"error" + 61 61 │ }, + 62 62 │ "suspicious": { + + +``` + +``` +realCase.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useNumberNamespace isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "$schema": "./packages/@biomejs/biome/configuration_schema.json", + > 3 │ "assist": { + > 4 │ "enabled": true, + ... + > 70 │ "useIgnoreFile": true + > 71 │ } + > 72 │ } + │ ^ + 73 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 52 52 │ "enabled": true, + 53 53 │ "rules": { + 54 │ - ······"recommended":·true, + 55 │ - ······"correctness":·{ + 56 │ - ········"noUndeclaredDependencies":·"error" + 54 │ + ······"style":·{ + 55 │ + ········"noNonNullAssertion":·"off", + 56 │ + ········"useNodejsImportProtocol":·"error", + 57 │ + ········"useNumberNamespace":·"error" + 57 58 │ }, + 58 │ - ······"style":·{ + 59 │ - ········"noNonNullAssertion":·"off", + 60 │ - ········"useNodejsImportProtocol":·"error" + 59 │ + ······"correctness":·{ + 60 │ + ········"noUndeclaredDependencies":·"error" + 61 61 │ }, + 62 62 │ "suspicious": { + + +``` + +``` +realCase.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useEnumInitializers isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "$schema": "./packages/@biomejs/biome/configuration_schema.json", + > 3 │ "assist": { + > 4 │ "enabled": true, + ... + > 70 │ "useIgnoreFile": true + > 71 │ } + > 72 │ } + │ ^ + 73 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 52 52 │ "enabled": true, + 53 53 │ "rules": { + 54 │ - ······"recommended":·true, + 55 │ - ······"correctness":·{ + 56 │ - ········"noUndeclaredDependencies":·"error" + 54 │ + ······"style":·{ + 55 │ + ········"noNonNullAssertion":·"off", + 56 │ + ········"useNodejsImportProtocol":·"error", + 57 │ + ········"useEnumInitializers":·"error" + 57 58 │ }, + 58 │ - ······"style":·{ + 59 │ - ········"noNonNullAssertion":·"off", + 60 │ - ········"useNodejsImportProtocol":·"error" + 59 │ + ······"correctness":·{ + 60 │ + ········"noUndeclaredDependencies":·"error" + 61 61 │ }, + 62 62 │ "suspicious": { + + +``` + +``` +realCase.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useTemplate isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "$schema": "./packages/@biomejs/biome/configuration_schema.json", + > 3 │ "assist": { + > 4 │ "enabled": true, + ... + > 70 │ "useIgnoreFile": true + > 71 │ } + > 72 │ } + │ ^ + 73 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 52 52 │ "enabled": true, + 53 53 │ "rules": { + 54 │ - ······"recommended":·true, + 55 │ - ······"correctness":·{ + 56 │ - ········"noUndeclaredDependencies":·"error" + 54 │ + ······"style":·{ + 55 │ + ········"noNonNullAssertion":·"off", + 56 │ + ········"useNodejsImportProtocol":·"error", + 57 │ + ········"useTemplate":·"error" + 57 58 │ }, + 58 │ - ······"style":·{ + 59 │ - ········"noNonNullAssertion":·"off", + 60 │ - ········"useNodejsImportProtocol":·"error" + 59 │ + ······"correctness":·{ + 60 │ + ········"noUndeclaredDependencies":·"error" + 61 61 │ }, + 62 62 │ "suspicious": { + + +``` + +``` +realCase.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useNumericLiterals isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "$schema": "./packages/@biomejs/biome/configuration_schema.json", + > 3 │ "assist": { + > 4 │ "enabled": true, + ... + > 70 │ "useIgnoreFile": true + > 71 │ } + > 72 │ } + │ ^ + 73 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 52 52 │ "enabled": true, + 53 53 │ "rules": { + 54 │ - ······"recommended":·true, + 55 │ - ······"correctness":·{ + 56 │ - ········"noUndeclaredDependencies":·"error" + 54 │ + ······"style":·{ + 55 │ + ········"noNonNullAssertion":·"off", + 56 │ + ········"useNodejsImportProtocol":·"error", + 57 │ + ········"useNumericLiterals":·"error" + 57 58 │ }, + 58 │ - ······"style":·{ + 59 │ - ········"noNonNullAssertion":·"off", + 60 │ - ········"useNodejsImportProtocol":·"error" + 59 │ + ······"correctness":·{ + 60 │ + ········"noUndeclaredDependencies":·"error" + 61 61 │ }, + 62 62 │ "suspicious": { + + +``` + +``` +realCase.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule noUnusedTemplateLiteral isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "$schema": "./packages/@biomejs/biome/configuration_schema.json", + > 3 │ "assist": { + > 4 │ "enabled": true, + ... + > 70 │ "useIgnoreFile": true + > 71 │ } + > 72 │ } + │ ^ + 73 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 52 52 │ "enabled": true, + 53 53 │ "rules": { + 54 │ - ······"recommended":·true, + 55 │ - ······"correctness":·{ + 56 │ - ········"noUndeclaredDependencies":·"error" + 54 │ + ······"style":·{ + 55 │ + ········"noNonNullAssertion":·"off", + 56 │ + ········"useNodejsImportProtocol":·"error", + 57 │ + ········"noUnusedTemplateLiteral":·"error" + 57 58 │ }, + 58 │ - ······"style":·{ + 59 │ - ········"noNonNullAssertion":·"off", + 60 │ - ········"useNodejsImportProtocol":·"error" + 59 │ + ······"correctness":·{ + 60 │ + ········"noUndeclaredDependencies":·"error" + 61 61 │ }, + 62 62 │ "suspicious": { + + +``` + +``` +realCase.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useImportType isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "$schema": "./packages/@biomejs/biome/configuration_schema.json", + > 3 │ "assist": { + > 4 │ "enabled": true, + ... + > 70 │ "useIgnoreFile": true + > 71 │ } + > 72 │ } + │ ^ + 73 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 52 52 │ "enabled": true, + 53 53 │ "rules": { + 54 │ - ······"recommended":·true, + 55 │ - ······"correctness":·{ + 56 │ - ········"noUndeclaredDependencies":·"error" + 54 │ + ······"style":·{ + 55 │ + ········"noNonNullAssertion":·"off", + 56 │ + ········"useNodejsImportProtocol":·"error", + 57 │ + ········"useImportType":·"error" + 57 58 │ }, + 58 │ - ······"style":·{ + 59 │ - ········"noNonNullAssertion":·"off", + 60 │ - ········"useNodejsImportProtocol":·"error" + 59 │ + ······"correctness":·{ + 60 │ + ········"noUndeclaredDependencies":·"error" + 61 61 │ }, + 62 62 │ "suspicious": { + + +``` + +``` +realCase.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useAsConstAssertion isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "$schema": "./packages/@biomejs/biome/configuration_schema.json", + > 3 │ "assist": { + > 4 │ "enabled": true, + ... + > 70 │ "useIgnoreFile": true + > 71 │ } + > 72 │ } + │ ^ + 73 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 52 52 │ "enabled": true, + 53 53 │ "rules": { + 54 │ - ······"recommended":·true, + 55 │ - ······"correctness":·{ + 56 │ - ········"noUndeclaredDependencies":·"error" + 54 │ + ······"style":·{ + 55 │ + ········"noNonNullAssertion":·"off", + 56 │ + ········"useNodejsImportProtocol":·"error", + 57 │ + ········"useAsConstAssertion":·"error" + 57 58 │ }, + 58 │ - ······"style":·{ + 59 │ - ········"noNonNullAssertion":·"off", + 60 │ - ········"useNodejsImportProtocol":·"error" + 59 │ + ······"correctness":·{ + 60 │ + ········"noUndeclaredDependencies":·"error" + 61 61 │ }, + 62 62 │ "suspicious": { + + +``` + +``` +realCase.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useSelfClosingElements isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "$schema": "./packages/@biomejs/biome/configuration_schema.json", + > 3 │ "assist": { + > 4 │ "enabled": true, + ... + > 70 │ "useIgnoreFile": true + > 71 │ } + > 72 │ } + │ ^ + 73 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 52 52 │ "enabled": true, + 53 53 │ "rules": { + 54 │ - ······"recommended":·true, + 55 │ - ······"correctness":·{ + 56 │ - ········"noUndeclaredDependencies":·"error" + 54 │ + ······"style":·{ + 55 │ + ········"noNonNullAssertion":·"off", + 56 │ + ········"useNodejsImportProtocol":·"error", + 57 │ + ········"useSelfClosingElements":·"error" + 57 58 │ }, + 58 │ - ······"style":·{ + 59 │ - ········"noNonNullAssertion":·"off", + 60 │ - ········"useNodejsImportProtocol":·"error" + 59 │ + ······"correctness":·{ + 60 │ + ········"noUndeclaredDependencies":·"error" + 61 61 │ }, + 62 62 │ "suspicious": { + + +``` + +``` +realCase.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule noUselessElse isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "$schema": "./packages/@biomejs/biome/configuration_schema.json", + > 3 │ "assist": { + > 4 │ "enabled": true, + ... + > 70 │ "useIgnoreFile": true + > 71 │ } + > 72 │ } + │ ^ + 73 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 52 52 │ "enabled": true, + 53 53 │ "rules": { + 54 │ - ······"recommended":·true, + 55 │ - ······"correctness":·{ + 56 │ - ········"noUndeclaredDependencies":·"error" + 54 │ + ······"style":·{ + 55 │ + ········"noNonNullAssertion":·"off", + 56 │ + ········"useNodejsImportProtocol":·"error", + 57 │ + ········"noUselessElse":·"error" + 57 58 │ }, + 58 │ - ······"style":·{ + 59 │ - ········"noNonNullAssertion":·"off", + 60 │ - ········"useNodejsImportProtocol":·"error" + 59 │ + ······"correctness":·{ + 60 │ + ········"noUndeclaredDependencies":·"error" + 61 61 │ }, + 62 62 │ "suspicious": { + + +``` + +``` +realCase.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useExponentiationOperator isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "$schema": "./packages/@biomejs/biome/configuration_schema.json", + > 3 │ "assist": { + > 4 │ "enabled": true, + ... + > 70 │ "useIgnoreFile": true + > 71 │ } + > 72 │ } + │ ^ + 73 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 52 52 │ "enabled": true, + 53 53 │ "rules": { + 54 │ - ······"recommended":·true, + 55 │ - ······"correctness":·{ + 56 │ - ········"noUndeclaredDependencies":·"error" + 54 │ + ······"style":·{ + 55 │ + ········"noNonNullAssertion":·"off", + 56 │ + ········"useNodejsImportProtocol":·"error", + 57 │ + ········"useExponentiationOperator":·"error" + 57 58 │ }, + 58 │ - ······"style":·{ + 59 │ - ········"noNonNullAssertion":·"off", + 60 │ - ········"useNodejsImportProtocol":·"error" + 59 │ + ······"correctness":·{ + 60 │ + ········"noUndeclaredDependencies":·"error" + 61 61 │ }, + 62 62 │ "suspicious": { + + +``` + +``` +realCase.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule noInferrableTypes isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "$schema": "./packages/@biomejs/biome/configuration_schema.json", + > 3 │ "assist": { + > 4 │ "enabled": true, + ... + > 70 │ "useIgnoreFile": true + > 71 │ } + > 72 │ } + │ ^ + 73 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 52 52 │ "enabled": true, + 53 53 │ "rules": { + 54 │ - ······"recommended":·true, + 55 │ - ······"correctness":·{ + 56 │ - ········"noUndeclaredDependencies":·"error" + 54 │ + ······"style":·{ + 55 │ + ········"noNonNullAssertion":·"off", + 56 │ + ········"useNodejsImportProtocol":·"error", + 57 │ + ········"noInferrableTypes":·"error" + 57 58 │ }, + 58 │ - ······"style":·{ + 59 │ - ········"noNonNullAssertion":·"off", + 60 │ - ········"useNodejsImportProtocol":·"error" + 59 │ + ······"correctness":·{ + 60 │ + ········"noUndeclaredDependencies":·"error" + 61 61 │ }, + 62 62 │ "suspicious": { + + +``` + +``` +realCase.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useConst isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "$schema": "./packages/@biomejs/biome/configuration_schema.json", + > 3 │ "assist": { + > 4 │ "enabled": true, + ... + > 70 │ "useIgnoreFile": true + > 71 │ } + > 72 │ } + │ ^ + 73 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 52 52 │ "enabled": true, + 53 53 │ "rules": { + 54 │ - ······"recommended":·true, + 55 │ - ······"correctness":·{ + 56 │ - ········"noUndeclaredDependencies":·"error" + 54 │ + ······"style":·{ + 55 │ + ········"noNonNullAssertion":·"off", + 56 │ + ········"useNodejsImportProtocol":·"error", + 57 │ + ········"useConst":·"error" + 57 58 │ }, + 58 │ - ······"style":·{ + 59 │ - ········"noNonNullAssertion":·"off", + 60 │ - ········"useNodejsImportProtocol":·"error" + 59 │ + ······"correctness":·{ + 60 │ + ········"noUndeclaredDependencies":·"error" + 61 61 │ }, + 62 62 │ "suspicious": { + + +``` + +``` +realCase.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useDefaultParameterLast isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "$schema": "./packages/@biomejs/biome/configuration_schema.json", + > 3 │ "assist": { + > 4 │ "enabled": true, + ... + > 70 │ "useIgnoreFile": true + > 71 │ } + > 72 │ } + │ ^ + 73 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 52 52 │ "enabled": true, + 53 53 │ "rules": { + 54 │ - ······"recommended":·true, + 55 │ - ······"correctness":·{ + 56 │ - ········"noUndeclaredDependencies":·"error" + 54 │ + ······"style":·{ + 55 │ + ········"noNonNullAssertion":·"off", + 56 │ + ········"useNodejsImportProtocol":·"error", + 57 │ + ········"useDefaultParameterLast":·"error" + 57 58 │ }, + 58 │ - ······"style":·{ + 59 │ - ········"noNonNullAssertion":·"off", + 60 │ - ········"useNodejsImportProtocol":·"error" + 59 │ + ······"correctness":·{ + 60 │ + ········"noUndeclaredDependencies":·"error" + 61 61 │ }, + 62 62 │ "suspicious": { + + +``` + +``` +realCase.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useSingleVarDeclarator isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "$schema": "./packages/@biomejs/biome/configuration_schema.json", + > 3 │ "assist": { + > 4 │ "enabled": true, + ... + > 70 │ "useIgnoreFile": true + > 71 │ } + > 72 │ } + │ ^ + 73 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 52 52 │ "enabled": true, + 53 53 │ "rules": { + 54 │ - ······"recommended":·true, + 55 │ - ······"correctness":·{ + 56 │ - ········"noUndeclaredDependencies":·"error" + 54 │ + ······"style":·{ + 55 │ + ········"noNonNullAssertion":·"off", + 56 │ + ········"useNodejsImportProtocol":·"error", + 57 │ + ········"useSingleVarDeclarator":·"error" + 57 58 │ }, + 58 │ - ······"style":·{ + 59 │ - ········"noNonNullAssertion":·"off", + 60 │ - ········"useNodejsImportProtocol":·"error" + 59 │ + ······"correctness":·{ + 60 │ + ········"noUndeclaredDependencies":·"error" + 61 61 │ }, + 62 62 │ "suspicious": { + + +``` + +``` +realCase.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useExportType isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "$schema": "./packages/@biomejs/biome/configuration_schema.json", + > 3 │ "assist": { + > 4 │ "enabled": true, + ... + > 70 │ "useIgnoreFile": true + > 71 │ } + > 72 │ } + │ ^ + 73 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 52 52 │ "enabled": true, + 53 53 │ "rules": { + 54 │ - ······"recommended":·true, + 55 │ - ······"correctness":·{ + 56 │ - ········"noUndeclaredDependencies":·"error" + 54 │ + ······"style":·{ + 55 │ + ········"noNonNullAssertion":·"off", + 56 │ + ········"useNodejsImportProtocol":·"error", + 57 │ + ········"useExportType":·"error" + 57 58 │ }, + 58 │ - ······"style":·{ + 59 │ - ········"noNonNullAssertion":·"off", + 60 │ - ········"useNodejsImportProtocol":·"error" + 59 │ + ······"correctness":·{ + 60 │ + ········"noUndeclaredDependencies":·"error" + 61 61 │ }, + 62 62 │ "suspicious": { + + +``` + +``` +realCase.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule noArguments isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "$schema": "./packages/@biomejs/biome/configuration_schema.json", + > 3 │ "assist": { + > 4 │ "enabled": true, + ... + > 70 │ "useIgnoreFile": true + > 71 │ } + > 72 │ } + │ ^ + 73 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 52 52 │ "enabled": true, + 53 53 │ "rules": { + 54 │ - ······"recommended":·true, + 55 │ - ······"correctness":·{ + 56 │ - ········"noUndeclaredDependencies":·"error" + 54 │ + ······"style":·{ + 55 │ + ········"noNonNullAssertion":·"off", + 56 │ + ········"useNodejsImportProtocol":·"error", + 57 │ + ········"noArguments":·"error" + 57 58 │ }, + 58 │ - ······"style":·{ + 59 │ - ········"noNonNullAssertion":·"off", + 60 │ - ········"useNodejsImportProtocol":·"error" + 59 │ + ······"correctness":·{ + 60 │ + ········"noUndeclaredDependencies":·"error" + 61 61 │ }, + 62 62 │ "suspicious": { + + +``` + +``` +realCase.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useShorthandFunctionType isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "$schema": "./packages/@biomejs/biome/configuration_schema.json", + > 3 │ "assist": { + > 4 │ "enabled": true, + ... + > 70 │ "useIgnoreFile": true + > 71 │ } + > 72 │ } + │ ^ + 73 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 52 52 │ "enabled": true, + 53 53 │ "rules": { + 54 │ - ······"recommended":·true, + 55 │ - ······"correctness":·{ + 56 │ - ········"noUndeclaredDependencies":·"error" + 54 │ + ······"style":·{ + 55 │ + ········"noNonNullAssertion":·"off", + 56 │ + ········"useNodejsImportProtocol":·"error", + 57 │ + ········"useShorthandFunctionType":·"error" + 57 58 │ }, + 58 │ - ······"style":·{ + 59 │ - ········"noNonNullAssertion":·"off", + 60 │ - ········"useNodejsImportProtocol":·"error" + 59 │ + ······"correctness":·{ + 60 │ + ········"noUndeclaredDependencies":·"error" + 61 61 │ }, + 62 62 │ "suspicious": { + + +``` diff --git a/crates/biome_migrate/tests/specs/migrations/styleRules/valid.json b/crates/biome_migrate/tests/specs/migrations/styleRules/valid.json new file mode 100644 index 000000000000..8745d0a3c238 --- /dev/null +++ b/crates/biome_migrate/tests/specs/migrations/styleRules/valid.json @@ -0,0 +1,16 @@ +{ + "files": { + "ignore": ["./src/**/*.graphql.ts"] + }, + "formatter": { + "indentStyle": "space", + "indentWidth": 2, + "lineWidth": 80 + }, + "javascript": { + "formatter": { + "trailingCommas": "es5" + }, + "jsxRuntime": "reactClassic" + } +} diff --git a/crates/biome_migrate/tests/specs/migrations/styleRules/valid.json.snap b/crates/biome_migrate/tests/specs/migrations/styleRules/valid.json.snap new file mode 100644 index 000000000000..1eaa127e80df --- /dev/null +++ b/crates/biome_migrate/tests/specs/migrations/styleRules/valid.json.snap @@ -0,0 +1,862 @@ +--- +source: crates/biome_migrate/tests/spec_tests.rs +expression: valid.json +snapshot_kind: text +--- +# Input +```json +{ + "files": { + "ignore": ["./src/**/*.graphql.ts"] + }, + "formatter": { + "indentStyle": "space", + "indentWidth": 2, + "lineWidth": 80 + }, + "javascript": { + "formatter": { + "trailingCommas": "es5" + }, + "jsxRuntime": "reactClassic" + } +} + +``` + +# Diagnostics +``` +valid.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useLiteralEnumMembers isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "files": { + > 3 │ "ignore": ["./src/**/*.graphql.ts"] + > 4 │ }, + ... + > 14 │ "jsxRuntime": "reactClassic" + > 15 │ } + > 16 │ } + │ ^ + 17 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 13 13 │ }, + 14 14 │ "jsxRuntime": "reactClassic" + 15 │ - ··} + 15 │ + ··}, + 16 │ + ··"linter":·{ + 17 │ + ······"rules":·{ + 18 │ + ······"style":·{ + 19 │ + ········"useLiteralEnumMembers":·"error" + 20 │ + ······} + 21 │ + ······} + 22 │ + ··} + 16 23 │ } + 17 24 │ + + +``` + +``` +valid.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule noParameterAssign isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "files": { + > 3 │ "ignore": ["./src/**/*.graphql.ts"] + > 4 │ }, + ... + > 14 │ "jsxRuntime": "reactClassic" + > 15 │ } + > 16 │ } + │ ^ + 17 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 13 13 │ }, + 14 14 │ "jsxRuntime": "reactClassic" + 15 │ - ··} + 15 │ + ··}, + 16 │ + ··"linter":·{ + 17 │ + ······"rules":·{ + 18 │ + ······"style":·{ + 19 │ + ········"noParameterAssign":·"error" + 20 │ + ······} + 21 │ + ······} + 22 │ + ··} + 16 23 │ } + 17 24 │ + + +``` + +``` +valid.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule noCommaOperator isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "files": { + > 3 │ "ignore": ["./src/**/*.graphql.ts"] + > 4 │ }, + ... + > 14 │ "jsxRuntime": "reactClassic" + > 15 │ } + > 16 │ } + │ ^ + 17 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 13 13 │ }, + 14 14 │ "jsxRuntime": "reactClassic" + 15 │ - ··} + 15 │ + ··}, + 16 │ + ··"linter":·{ + 17 │ + ······"rules":·{ + 18 │ + ······"style":·{ + 19 │ + ········"noCommaOperator":·"error" + 20 │ + ······} + 21 │ + ······} + 22 │ + ··} + 16 23 │ } + 17 24 │ + + +``` + +``` +valid.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useSelfClosingElements isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "files": { + > 3 │ "ignore": ["./src/**/*.graphql.ts"] + > 4 │ }, + ... + > 14 │ "jsxRuntime": "reactClassic" + > 15 │ } + > 16 │ } + │ ^ + 17 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 13 13 │ }, + 14 14 │ "jsxRuntime": "reactClassic" + 15 │ - ··} + 15 │ + ··}, + 16 │ + ··"linter":·{ + 17 │ + ······"rules":·{ + 18 │ + ······"style":·{ + 19 │ + ········"useSelfClosingElements":·"error" + 20 │ + ······} + 21 │ + ······} + 22 │ + ··} + 16 23 │ } + 17 24 │ + + +``` + +``` +valid.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useEnumInitializers isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "files": { + > 3 │ "ignore": ["./src/**/*.graphql.ts"] + > 4 │ }, + ... + > 14 │ "jsxRuntime": "reactClassic" + > 15 │ } + > 16 │ } + │ ^ + 17 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 13 13 │ }, + 14 14 │ "jsxRuntime": "reactClassic" + 15 │ - ··} + 15 │ + ··}, + 16 │ + ··"linter":·{ + 17 │ + ······"rules":·{ + 18 │ + ······"style":·{ + 19 │ + ········"useEnumInitializers":·"error" + 20 │ + ······} + 21 │ + ······} + 22 │ + ··} + 16 23 │ } + 17 24 │ + + +``` + +``` +valid.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useTemplate isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "files": { + > 3 │ "ignore": ["./src/**/*.graphql.ts"] + > 4 │ }, + ... + > 14 │ "jsxRuntime": "reactClassic" + > 15 │ } + > 16 │ } + │ ^ + 17 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 13 13 │ }, + 14 14 │ "jsxRuntime": "reactClassic" + 15 │ - ··} + 15 │ + ··}, + 16 │ + ··"linter":·{ + 17 │ + ······"rules":·{ + 18 │ + ······"style":·{ + 19 │ + ········"useTemplate":·"error" + 20 │ + ······} + 21 │ + ······} + 22 │ + ··} + 16 23 │ } + 17 24 │ + + +``` + +``` +valid.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useNumericLiterals isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "files": { + > 3 │ "ignore": ["./src/**/*.graphql.ts"] + > 4 │ }, + ... + > 14 │ "jsxRuntime": "reactClassic" + > 15 │ } + > 16 │ } + │ ^ + 17 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 13 13 │ }, + 14 14 │ "jsxRuntime": "reactClassic" + 15 │ - ··} + 15 │ + ··}, + 16 │ + ··"linter":·{ + 17 │ + ······"rules":·{ + 18 │ + ······"style":·{ + 19 │ + ········"useNumericLiterals":·"error" + 20 │ + ······} + 21 │ + ······} + 22 │ + ··} + 16 23 │ } + 17 24 │ + + +``` + +``` +valid.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule noUnusedTemplateLiteral isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "files": { + > 3 │ "ignore": ["./src/**/*.graphql.ts"] + > 4 │ }, + ... + > 14 │ "jsxRuntime": "reactClassic" + > 15 │ } + > 16 │ } + │ ^ + 17 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 13 13 │ }, + 14 14 │ "jsxRuntime": "reactClassic" + 15 │ - ··} + 15 │ + ··}, + 16 │ + ··"linter":·{ + 17 │ + ······"rules":·{ + 18 │ + ······"style":·{ + 19 │ + ········"noUnusedTemplateLiteral":·"error" + 20 │ + ······} + 21 │ + ······} + 22 │ + ··} + 16 23 │ } + 17 24 │ + + +``` + +``` +valid.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useAsConstAssertion isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "files": { + > 3 │ "ignore": ["./src/**/*.graphql.ts"] + > 4 │ }, + ... + > 14 │ "jsxRuntime": "reactClassic" + > 15 │ } + > 16 │ } + │ ^ + 17 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 13 13 │ }, + 14 14 │ "jsxRuntime": "reactClassic" + 15 │ - ··} + 15 │ + ··}, + 16 │ + ··"linter":·{ + 17 │ + ······"rules":·{ + 18 │ + ······"style":·{ + 19 │ + ········"useAsConstAssertion":·"error" + 20 │ + ······} + 21 │ + ······} + 22 │ + ··} + 16 23 │ } + 17 24 │ + + +``` + +``` +valid.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useNumberNamespace isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "files": { + > 3 │ "ignore": ["./src/**/*.graphql.ts"] + > 4 │ }, + ... + > 14 │ "jsxRuntime": "reactClassic" + > 15 │ } + > 16 │ } + │ ^ + 17 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 13 13 │ }, + 14 14 │ "jsxRuntime": "reactClassic" + 15 │ - ··} + 15 │ + ··}, + 16 │ + ··"linter":·{ + 17 │ + ······"rules":·{ + 18 │ + ······"style":·{ + 19 │ + ········"useNumberNamespace":·"error" + 20 │ + ······} + 21 │ + ······} + 22 │ + ··} + 16 23 │ } + 17 24 │ + + +``` + +``` +valid.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule noUselessElse isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "files": { + > 3 │ "ignore": ["./src/**/*.graphql.ts"] + > 4 │ }, + ... + > 14 │ "jsxRuntime": "reactClassic" + > 15 │ } + > 16 │ } + │ ^ + 17 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 13 13 │ }, + 14 14 │ "jsxRuntime": "reactClassic" + 15 │ - ··} + 15 │ + ··}, + 16 │ + ··"linter":·{ + 17 │ + ······"rules":·{ + 18 │ + ······"style":·{ + 19 │ + ········"noUselessElse":·"error" + 20 │ + ······} + 21 │ + ······} + 22 │ + ··} + 16 23 │ } + 17 24 │ + + +``` + +``` +valid.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useImportType isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "files": { + > 3 │ "ignore": ["./src/**/*.graphql.ts"] + > 4 │ }, + ... + > 14 │ "jsxRuntime": "reactClassic" + > 15 │ } + > 16 │ } + │ ^ + 17 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 13 13 │ }, + 14 14 │ "jsxRuntime": "reactClassic" + 15 │ - ··} + 15 │ + ··}, + 16 │ + ··"linter":·{ + 17 │ + ······"rules":·{ + 18 │ + ······"style":·{ + 19 │ + ········"useImportType":·"error" + 20 │ + ······} + 21 │ + ······} + 22 │ + ··} + 16 23 │ } + 17 24 │ + + +``` + +``` +valid.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useExponentiationOperator isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "files": { + > 3 │ "ignore": ["./src/**/*.graphql.ts"] + > 4 │ }, + ... + > 14 │ "jsxRuntime": "reactClassic" + > 15 │ } + > 16 │ } + │ ^ + 17 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 13 13 │ }, + 14 14 │ "jsxRuntime": "reactClassic" + 15 │ - ··} + 15 │ + ··}, + 16 │ + ··"linter":·{ + 17 │ + ······"rules":·{ + 18 │ + ······"style":·{ + 19 │ + ········"useExponentiationOperator":·"error" + 20 │ + ······} + 21 │ + ······} + 22 │ + ··} + 16 23 │ } + 17 24 │ + + +``` + +``` +valid.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule noInferrableTypes isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "files": { + > 3 │ "ignore": ["./src/**/*.graphql.ts"] + > 4 │ }, + ... + > 14 │ "jsxRuntime": "reactClassic" + > 15 │ } + > 16 │ } + │ ^ + 17 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 13 13 │ }, + 14 14 │ "jsxRuntime": "reactClassic" + 15 │ - ··} + 15 │ + ··}, + 16 │ + ··"linter":·{ + 17 │ + ······"rules":·{ + 18 │ + ······"style":·{ + 19 │ + ········"noInferrableTypes":·"error" + 20 │ + ······} + 21 │ + ······} + 22 │ + ··} + 16 23 │ } + 17 24 │ + + +``` + +``` +valid.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule noNonNullAssertion isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "files": { + > 3 │ "ignore": ["./src/**/*.graphql.ts"] + > 4 │ }, + ... + > 14 │ "jsxRuntime": "reactClassic" + > 15 │ } + > 16 │ } + │ ^ + 17 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 13 13 │ }, + 14 14 │ "jsxRuntime": "reactClassic" + 15 │ - ··} + 15 │ + ··}, + 16 │ + ··"linter":·{ + 17 │ + ······"rules":·{ + 18 │ + ······"style":·{ + 19 │ + ········"noNonNullAssertion":·"error" + 20 │ + ······} + 21 │ + ······} + 22 │ + ··} + 16 23 │ } + 17 24 │ + + +``` + +``` +valid.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useConst isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "files": { + > 3 │ "ignore": ["./src/**/*.graphql.ts"] + > 4 │ }, + ... + > 14 │ "jsxRuntime": "reactClassic" + > 15 │ } + > 16 │ } + │ ^ + 17 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 13 13 │ }, + 14 14 │ "jsxRuntime": "reactClassic" + 15 │ - ··} + 15 │ + ··}, + 16 │ + ··"linter":·{ + 17 │ + ······"rules":·{ + 18 │ + ······"style":·{ + 19 │ + ········"useConst":·"error" + 20 │ + ······} + 21 │ + ······} + 22 │ + ··} + 16 23 │ } + 17 24 │ + + +``` + +``` +valid.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useNodejsImportProtocol isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "files": { + > 3 │ "ignore": ["./src/**/*.graphql.ts"] + > 4 │ }, + ... + > 14 │ "jsxRuntime": "reactClassic" + > 15 │ } + > 16 │ } + │ ^ + 17 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 13 13 │ }, + 14 14 │ "jsxRuntime": "reactClassic" + 15 │ - ··} + 15 │ + ··}, + 16 │ + ··"linter":·{ + 17 │ + ······"rules":·{ + 18 │ + ······"style":·{ + 19 │ + ········"useNodejsImportProtocol":·"error" + 20 │ + ······} + 21 │ + ······} + 22 │ + ··} + 16 23 │ } + 17 24 │ + + +``` + +``` +valid.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useDefaultParameterLast isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "files": { + > 3 │ "ignore": ["./src/**/*.graphql.ts"] + > 4 │ }, + ... + > 14 │ "jsxRuntime": "reactClassic" + > 15 │ } + > 16 │ } + │ ^ + 17 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 13 13 │ }, + 14 14 │ "jsxRuntime": "reactClassic" + 15 │ - ··} + 15 │ + ··}, + 16 │ + ··"linter":·{ + 17 │ + ······"rules":·{ + 18 │ + ······"style":·{ + 19 │ + ········"useDefaultParameterLast":·"error" + 20 │ + ······} + 21 │ + ······} + 22 │ + ··} + 16 23 │ } + 17 24 │ + + +``` + +``` +valid.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useSingleVarDeclarator isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "files": { + > 3 │ "ignore": ["./src/**/*.graphql.ts"] + > 4 │ }, + ... + > 14 │ "jsxRuntime": "reactClassic" + > 15 │ } + > 16 │ } + │ ^ + 17 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 13 13 │ }, + 14 14 │ "jsxRuntime": "reactClassic" + 15 │ - ··} + 15 │ + ··}, + 16 │ + ··"linter":·{ + 17 │ + ······"rules":·{ + 18 │ + ······"style":·{ + 19 │ + ········"useSingleVarDeclarator":·"error" + 20 │ + ······} + 21 │ + ······} + 22 │ + ··} + 16 23 │ } + 17 24 │ + + +``` + +``` +valid.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useExportType isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "files": { + > 3 │ "ignore": ["./src/**/*.graphql.ts"] + > 4 │ }, + ... + > 14 │ "jsxRuntime": "reactClassic" + > 15 │ } + > 16 │ } + │ ^ + 17 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 13 13 │ }, + 14 14 │ "jsxRuntime": "reactClassic" + 15 │ - ··} + 15 │ + ··}, + 16 │ + ··"linter":·{ + 17 │ + ······"rules":·{ + 18 │ + ······"style":·{ + 19 │ + ········"useExportType":·"error" + 20 │ + ······} + 21 │ + ······} + 22 │ + ··} + 16 23 │ } + 17 24 │ + + +``` + +``` +valid.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule noArguments isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "files": { + > 3 │ "ignore": ["./src/**/*.graphql.ts"] + > 4 │ }, + ... + > 14 │ "jsxRuntime": "reactClassic" + > 15 │ } + > 16 │ } + │ ^ + 17 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 13 13 │ }, + 14 14 │ "jsxRuntime": "reactClassic" + 15 │ - ··} + 15 │ + ··}, + 16 │ + ··"linter":·{ + 17 │ + ······"rules":·{ + 18 │ + ······"style":·{ + 19 │ + ········"noArguments":·"error" + 20 │ + ······} + 21 │ + ······} + 22 │ + ··} + 16 23 │ } + 17 24 │ + + +``` + +``` +valid.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useShorthandFunctionType isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "files": { + > 3 │ "ignore": ["./src/**/*.graphql.ts"] + > 4 │ }, + ... + > 14 │ "jsxRuntime": "reactClassic" + > 15 │ } + > 16 │ } + │ ^ + 17 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 13 13 │ }, + 14 14 │ "jsxRuntime": "reactClassic" + 15 │ - ··} + 15 │ + ··}, + 16 │ + ··"linter":·{ + 17 │ + ······"rules":·{ + 18 │ + ······"style":·{ + 19 │ + ········"useShorthandFunctionType":·"error" + 20 │ + ······} + 21 │ + ······} + 22 │ + ··} + 16 23 │ } + 17 24 │ + + +``` diff --git a/crates/biome_migrate/tests/specs/migrations/styleRules/valid_existing_not_related_group.json b/crates/biome_migrate/tests/specs/migrations/styleRules/valid_existing_not_related_group.json new file mode 100644 index 000000000000..52bfec5cb1db --- /dev/null +++ b/crates/biome_migrate/tests/specs/migrations/styleRules/valid_existing_not_related_group.json @@ -0,0 +1,140 @@ +{ + "$schema": "https://biomejs.dev/schemas/1.8.3/schema.json", + "files": { + "ignore": [ + "**/dist", + "**/tmp", + "**/fixtures", + "packages/knip/package.json", + "packages/knip/vendor/bash-parser/index.js", + "packages/docs/.astro" + ] + }, + "organizeImports": { + "enabled": true + }, + "linter": { + "rules": { + "style": { + "useImportType": "off", + "useLiteralEnumMembers": "error", + "noArguments": "error", + "useShorthandFunctionType": "error", + "useExportType": "error", + "useDefaultParameterLast": "error", + "noCommaOperator": "error", + "useSingleVarDeclarator": "error", + "useNodejsImportProtocol": "error", + "useConst": "error", + "noNonNullAssertion": "error", + "noInferrableTypes": "error", + "useExponentiationOperator": "error", + "noUselessElse": "error", + "useSelfClosingElements": "error", + "useNumberNamespace": "error", + "useAsConstAssertion": "error", + "noUnusedTemplateLiteral": "error", + "useNumericLiterals": "error", + "useTemplate": "error", + "useEnumInitializers": "error" + }, + "nursery": { + "noRestrictedImports": { + "level": "error", + "options": { + "paths": { + "node:path": "Please use src/util/path.js instead.", + "path": "Please use src/util/path.js instead." + } + } + } + }, + "complexity": { + "useLiteralKeys": "off" + }, + "suspicious": { + "noConsoleLog": "off" + }, + "correctness": { + "noUnusedVariables": "off", + "noUnusedImports": "off" + } + } + }, + "formatter": { + "enabled": true, + "lineWidth": 120, + "indentStyle": "space", + "formatWithErrors": true + }, + "javascript": { + "formatter": { + "quoteStyle": "single", + "arrowParentheses": "asNeeded", + "trailingCommas": "es5" + } + }, + "json": { + "formatter": { + "lineWidth": 80 + } + }, + "css": { + "formatter": { + "quoteStyle": "single" + } + }, + "overrides": [ + { + "include": ["*.astro"], + "linter": { + "rules": { + "correctness": { + "noUnusedVariables": "off", + "noUnusedImports": "off" + } + } + } + }, + { + "include": [ + "packages/docs", + "packages/knip/scripts", + "packages/knip/src/cli.ts", + "packages/knip/src/reporters", + "packages/knip/src/util/cli-arguments.ts", + "packages/knip/src/util/debug.ts" + ], + "linter": { + "rules": { + "suspicious": { + "noConsoleLog": "off" + } + } + } + }, + { + "include": ["packages/knip/fixtures"], + "organizeImports": { + "enabled": false + }, + "linter": { + "rules": { + "correctness": { + "noUnusedVariables": "off", + "noUnusedImports": "off" + }, + "style": { + "useImportType": "off" + } + } + } + }, + { + "include": ["packages/knip/test/util/get-inputs-from-scripts.test.ts"], + "formatter": { + "lineWidth": 200 + } + } + ] +} diff --git a/crates/biome_migrate/tests/specs/migrations/styleRules/valid_existing_not_related_group.json.snap b/crates/biome_migrate/tests/specs/migrations/styleRules/valid_existing_not_related_group.json.snap new file mode 100644 index 000000000000..0e9c731b7789 --- /dev/null +++ b/crates/biome_migrate/tests/specs/migrations/styleRules/valid_existing_not_related_group.json.snap @@ -0,0 +1,182 @@ +--- +source: crates/biome_migrate/tests/spec_tests.rs +expression: valid_existing_not_related_group.json +snapshot_kind: text +--- +# Input +```json +{ + "$schema": "https://biomejs.dev/schemas/1.8.3/schema.json", + "files": { + "ignore": [ + "**/dist", + "**/tmp", + "**/fixtures", + "packages/knip/package.json", + "packages/knip/vendor/bash-parser/index.js", + "packages/docs/.astro" + ] + }, + "organizeImports": { + "enabled": true + }, + "linter": { + "rules": { + "style": { + "useImportType": "off", + "useLiteralEnumMembers": "error", + "noArguments": "error", + "useShorthandFunctionType": "error", + "useExportType": "error", + "useDefaultParameterLast": "error", + "noCommaOperator": "error", + "useSingleVarDeclarator": "error", + "useNodejsImportProtocol": "error", + "useConst": "error", + "noNonNullAssertion": "error", + "noInferrableTypes": "error", + "useExponentiationOperator": "error", + "noUselessElse": "error", + "useSelfClosingElements": "error", + "useNumberNamespace": "error", + "useAsConstAssertion": "error", + "noUnusedTemplateLiteral": "error", + "useNumericLiterals": "error", + "useTemplate": "error", + "useEnumInitializers": "error" + }, + "nursery": { + "noRestrictedImports": { + "level": "error", + "options": { + "paths": { + "node:path": "Please use src/util/path.js instead.", + "path": "Please use src/util/path.js instead." + } + } + } + }, + "complexity": { + "useLiteralKeys": "off" + }, + "suspicious": { + "noConsoleLog": "off" + }, + "correctness": { + "noUnusedVariables": "off", + "noUnusedImports": "off" + } + } + }, + "formatter": { + "enabled": true, + "lineWidth": 120, + "indentStyle": "space", + "formatWithErrors": true + }, + "javascript": { + "formatter": { + "quoteStyle": "single", + "arrowParentheses": "asNeeded", + "trailingCommas": "es5" + } + }, + "json": { + "formatter": { + "lineWidth": 80 + } + }, + "css": { + "formatter": { + "quoteStyle": "single" + } + }, + "overrides": [ + { + "include": ["*.astro"], + "linter": { + "rules": { + "correctness": { + "noUnusedVariables": "off", + "noUnusedImports": "off" + } + } + } + }, + { + "include": [ + "packages/docs", + "packages/knip/scripts", + "packages/knip/src/cli.ts", + "packages/knip/src/reporters", + "packages/knip/src/util/cli-arguments.ts", + "packages/knip/src/util/debug.ts" + ], + "linter": { + "rules": { + "suspicious": { + "noConsoleLog": "off" + } + } + } + }, + { + "include": ["packages/knip/fixtures"], + "organizeImports": { + "enabled": false + }, + "linter": { + "rules": { + "correctness": { + "noUnusedVariables": "off", + "noUnusedImports": "off" + }, + "style": { + "useImportType": "off" + } + } + } + }, + { + "include": ["packages/knip/test/util/get-inputs-from-scripts.test.ts"], + "formatter": { + "lineWidth": 200 + } + } + ] +} + +``` + +# Diagnostics +``` +valid_existing_not_related_group.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule noParameterAssign isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "$schema": "https://biomejs.dev/schemas/1.8.3/schema.json", + > 3 │ "files": { + > 4 │ "ignore": [ + ... + > 138 │ } + > 139 │ ] + > 140 │ } + │ ^ + 141 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 37 37 │ "useNumericLiterals": "error", + 38 38 │ "useTemplate": "error", + 39 │ - ········"useEnumInitializers":·"error" + 39 │ + ········"useEnumInitializers":·"error", + 40 │ + ········"noParameterAssign":·"error" + 40 41 │ }, + 41 42 │ "nursery": { + + +``` diff --git a/crates/biome_migrate/tests/specs/migrations/styleRules/with_existing_linter.json.snap b/crates/biome_migrate/tests/specs/migrations/styleRules/with_existing_linter.json.snap index 57126237a598..9c1ac4a71bd9 100644 --- a/crates/biome_migrate/tests/specs/migrations/styleRules/with_existing_linter.json.snap +++ b/crates/biome_migrate/tests/specs/migrations/styleRules/with_existing_linter.json.snap @@ -14,7 +14,7 @@ snapshot_kind: text ``` with_existing_linter.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - ! Biome style rules aren't recommended anymore. + ! Biome style rule useLiteralEnumMembers isn't recommended anymore. > 1 │ { │ ^ @@ -26,38 +26,625 @@ with_existing_linter.json:1:1 migrate FIXABLE ━━━━━━━━━━ i Safe fix: Update the configuration to enable these rules. - 1 1 │ { - 2 │ - ··"linter":·{} - 2 │ + ··"linter":·{ - 3 │ + ····"rules":·{ - 4 │ + ······"style":·{ - 5 │ + ········"useLiteralEnumMembers":"error", - 6 │ + ········"noArguments":"error", - 7 │ + ········"noParameterAssign":"error", - 8 │ + ········"useShorthandFunctionType":"error", - 9 │ + ········"useExportType":"error", - 10 │ + ········"useDefaultParameterLast":"error", - 11 │ + ········"noCommaOperator":"error", - 12 │ + ········"useSingleVarDeclarator":"error", - 13 │ + ········"noNonnullAssertion":"error", - 14 │ + ········"useNodejsImportProtocol":"error", - 15 │ + ········"useConst":"error", - 16 │ + ········"noInferrableTypes":"error", - 17 │ + ········"useExponentiationOperator":"error", - 18 │ + ········"noUselessElse":"error", - 19 │ + ········"useSelfClosingElements":"error", - 20 │ + ········"useImportType":"error", - 21 │ + ········"useNumberNamespace":"error", - 22 │ + ········"useWhile":"error", - 23 │ + ········"useAsConstAssertion":"error", - 24 │ + ········"noUnusedTemplateLiteral":"error", - 25 │ + ········"useNumericLiterals":"error", - 26 │ + ········"useTemplate":"error", - 27 │ + ········"useEnumInitializers":"error" - 28 │ + ······} - 29 │ + ····} - 30 │ + ··} - 3 31 │ } + 1 1 │ { + 2 │ - ··"linter":·{} + 2 │ + ··"linter":·{ + 3 │ + ····"rules":·{ + 4 │ + ······"style":·{ + 5 │ + ········"useLiteralEnumMembers":·"error" + 6 │ + ······} + 7 │ + ····} + 8 │ + ··} + 3 9 │ } + + +``` + +``` +with_existing_linter.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule noParameterAssign isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": {} + > 3 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 1 1 │ { + 2 │ - ··"linter":·{} + 2 │ + ··"linter":·{ + 3 │ + ····"rules":·{ + 4 │ + ······"style":·{ + 5 │ + ········"noParameterAssign":·"error" + 6 │ + ······} + 7 │ + ····} + 8 │ + ··} + 3 9 │ } + + +``` + +``` +with_existing_linter.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule noCommaOperator isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": {} + > 3 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 1 1 │ { + 2 │ - ··"linter":·{} + 2 │ + ··"linter":·{ + 3 │ + ····"rules":·{ + 4 │ + ······"style":·{ + 5 │ + ········"noCommaOperator":·"error" + 6 │ + ······} + 7 │ + ····} + 8 │ + ··} + 3 9 │ } + + +``` + +``` +with_existing_linter.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useSelfClosingElements isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": {} + > 3 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 1 1 │ { + 2 │ - ··"linter":·{} + 2 │ + ··"linter":·{ + 3 │ + ····"rules":·{ + 4 │ + ······"style":·{ + 5 │ + ········"useSelfClosingElements":·"error" + 6 │ + ······} + 7 │ + ····} + 8 │ + ··} + 3 9 │ } + + +``` + +``` +with_existing_linter.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useEnumInitializers isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": {} + > 3 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 1 1 │ { + 2 │ - ··"linter":·{} + 2 │ + ··"linter":·{ + 3 │ + ····"rules":·{ + 4 │ + ······"style":·{ + 5 │ + ········"useEnumInitializers":·"error" + 6 │ + ······} + 7 │ + ····} + 8 │ + ··} + 3 9 │ } + + +``` + +``` +with_existing_linter.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useTemplate isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": {} + > 3 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 1 1 │ { + 2 │ - ··"linter":·{} + 2 │ + ··"linter":·{ + 3 │ + ····"rules":·{ + 4 │ + ······"style":·{ + 5 │ + ········"useTemplate":·"error" + 6 │ + ······} + 7 │ + ····} + 8 │ + ··} + 3 9 │ } + + +``` + +``` +with_existing_linter.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useNumericLiterals isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": {} + > 3 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 1 1 │ { + 2 │ - ··"linter":·{} + 2 │ + ··"linter":·{ + 3 │ + ····"rules":·{ + 4 │ + ······"style":·{ + 5 │ + ········"useNumericLiterals":·"error" + 6 │ + ······} + 7 │ + ····} + 8 │ + ··} + 3 9 │ } + + +``` + +``` +with_existing_linter.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule noUnusedTemplateLiteral isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": {} + > 3 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 1 1 │ { + 2 │ - ··"linter":·{} + 2 │ + ··"linter":·{ + 3 │ + ····"rules":·{ + 4 │ + ······"style":·{ + 5 │ + ········"noUnusedTemplateLiteral":·"error" + 6 │ + ······} + 7 │ + ····} + 8 │ + ··} + 3 9 │ } + + +``` + +``` +with_existing_linter.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useAsConstAssertion isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": {} + > 3 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 1 1 │ { + 2 │ - ··"linter":·{} + 2 │ + ··"linter":·{ + 3 │ + ····"rules":·{ + 4 │ + ······"style":·{ + 5 │ + ········"useAsConstAssertion":·"error" + 6 │ + ······} + 7 │ + ····} + 8 │ + ··} + 3 9 │ } + + +``` + +``` +with_existing_linter.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useNumberNamespace isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": {} + > 3 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 1 1 │ { + 2 │ - ··"linter":·{} + 2 │ + ··"linter":·{ + 3 │ + ····"rules":·{ + 4 │ + ······"style":·{ + 5 │ + ········"useNumberNamespace":·"error" + 6 │ + ······} + 7 │ + ····} + 8 │ + ··} + 3 9 │ } + + +``` + +``` +with_existing_linter.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule noUselessElse isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": {} + > 3 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 1 1 │ { + 2 │ - ··"linter":·{} + 2 │ + ··"linter":·{ + 3 │ + ····"rules":·{ + 4 │ + ······"style":·{ + 5 │ + ········"noUselessElse":·"error" + 6 │ + ······} + 7 │ + ····} + 8 │ + ··} + 3 9 │ } + + +``` + +``` +with_existing_linter.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useImportType isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": {} + > 3 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 1 1 │ { + 2 │ - ··"linter":·{} + 2 │ + ··"linter":·{ + 3 │ + ····"rules":·{ + 4 │ + ······"style":·{ + 5 │ + ········"useImportType":·"error" + 6 │ + ······} + 7 │ + ····} + 8 │ + ··} + 3 9 │ } + + +``` + +``` +with_existing_linter.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useExponentiationOperator isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": {} + > 3 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 1 1 │ { + 2 │ - ··"linter":·{} + 2 │ + ··"linter":·{ + 3 │ + ····"rules":·{ + 4 │ + ······"style":·{ + 5 │ + ········"useExponentiationOperator":·"error" + 6 │ + ······} + 7 │ + ····} + 8 │ + ··} + 3 9 │ } + + +``` + +``` +with_existing_linter.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule noInferrableTypes isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": {} + > 3 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 1 1 │ { + 2 │ - ··"linter":·{} + 2 │ + ··"linter":·{ + 3 │ + ····"rules":·{ + 4 │ + ······"style":·{ + 5 │ + ········"noInferrableTypes":·"error" + 6 │ + ······} + 7 │ + ····} + 8 │ + ··} + 3 9 │ } + + +``` + +``` +with_existing_linter.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule noNonNullAssertion isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": {} + > 3 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 1 1 │ { + 2 │ - ··"linter":·{} + 2 │ + ··"linter":·{ + 3 │ + ····"rules":·{ + 4 │ + ······"style":·{ + 5 │ + ········"noNonNullAssertion":·"error" + 6 │ + ······} + 7 │ + ····} + 8 │ + ··} + 3 9 │ } + + +``` + +``` +with_existing_linter.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useConst isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": {} + > 3 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 1 1 │ { + 2 │ - ··"linter":·{} + 2 │ + ··"linter":·{ + 3 │ + ····"rules":·{ + 4 │ + ······"style":·{ + 5 │ + ········"useConst":·"error" + 6 │ + ······} + 7 │ + ····} + 8 │ + ··} + 3 9 │ } + + +``` + +``` +with_existing_linter.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useNodejsImportProtocol isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": {} + > 3 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 1 1 │ { + 2 │ - ··"linter":·{} + 2 │ + ··"linter":·{ + 3 │ + ····"rules":·{ + 4 │ + ······"style":·{ + 5 │ + ········"useNodejsImportProtocol":·"error" + 6 │ + ······} + 7 │ + ····} + 8 │ + ··} + 3 9 │ } + + +``` + +``` +with_existing_linter.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useDefaultParameterLast isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": {} + > 3 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 1 1 │ { + 2 │ - ··"linter":·{} + 2 │ + ··"linter":·{ + 3 │ + ····"rules":·{ + 4 │ + ······"style":·{ + 5 │ + ········"useDefaultParameterLast":·"error" + 6 │ + ······} + 7 │ + ····} + 8 │ + ··} + 3 9 │ } + + +``` + +``` +with_existing_linter.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useSingleVarDeclarator isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": {} + > 3 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 1 1 │ { + 2 │ - ··"linter":·{} + 2 │ + ··"linter":·{ + 3 │ + ····"rules":·{ + 4 │ + ······"style":·{ + 5 │ + ········"useSingleVarDeclarator":·"error" + 6 │ + ······} + 7 │ + ····} + 8 │ + ··} + 3 9 │ } + + +``` + +``` +with_existing_linter.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useExportType isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": {} + > 3 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 1 1 │ { + 2 │ - ··"linter":·{} + 2 │ + ··"linter":·{ + 3 │ + ····"rules":·{ + 4 │ + ······"style":·{ + 5 │ + ········"useExportType":·"error" + 6 │ + ······} + 7 │ + ····} + 8 │ + ··} + 3 9 │ } + + +``` + +``` +with_existing_linter.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule noArguments isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": {} + > 3 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 1 1 │ { + 2 │ - ··"linter":·{} + 2 │ + ··"linter":·{ + 3 │ + ····"rules":·{ + 4 │ + ······"style":·{ + 5 │ + ········"noArguments":·"error" + 6 │ + ······} + 7 │ + ····} + 8 │ + ··} + 3 9 │ } + + +``` + +``` +with_existing_linter.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useShorthandFunctionType isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": {} + > 3 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 1 1 │ { + 2 │ - ··"linter":·{} + 2 │ + ··"linter":·{ + 3 │ + ····"rules":·{ + 4 │ + ······"style":·{ + 5 │ + ········"useShorthandFunctionType":·"error" + 6 │ + ······} + 7 │ + ····} + 8 │ + ··} + 3 9 │ } ``` diff --git a/crates/biome_migrate/tests/specs/migrations/styleRules/with_existing_linter.version.txt b/crates/biome_migrate/tests/specs/migrations/styleRules/with_existing_linter.version.txt deleted file mode 100644 index 359a5b952d49..000000000000 --- a/crates/biome_migrate/tests/specs/migrations/styleRules/with_existing_linter.version.txt +++ /dev/null @@ -1 +0,0 @@ -2.0.0 \ No newline at end of file diff --git a/crates/biome_migrate/tests/specs/migrations/styleRules/with_existing_rules.json.snap b/crates/biome_migrate/tests/specs/migrations/styleRules/with_existing_rules.json.snap index 297378586a02..875ceeebb9d2 100644 --- a/crates/biome_migrate/tests/specs/migrations/styleRules/with_existing_rules.json.snap +++ b/crates/biome_migrate/tests/specs/migrations/styleRules/with_existing_rules.json.snap @@ -18,7 +18,7 @@ snapshot_kind: text ``` with_existing_rules.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - ! Biome style rules aren't recommended anymore. + ! Biome style rule useLiteralEnumMembers isn't recommended anymore. > 1 │ { │ ^ @@ -34,36 +34,665 @@ with_existing_rules.json:1:1 migrate FIXABLE ━━━━━━━━━━━ i Safe fix: Update the configuration to enable these rules. - 2 2 │ "linter": { - 3 3 │ "rules": { - 4 │ - ······"recommended":·true - 4 │ + ······"style":·{ - 5 │ + ········"useLiteralEnumMembers":"error", - 6 │ + ········"noArguments":"error", - 7 │ + ········"noParameterAssign":"error", - 8 │ + ········"useShorthandFunctionType":"error", - 9 │ + ········"useExportType":"error", - 10 │ + ········"useDefaultParameterLast":"error", - 11 │ + ········"noCommaOperator":"error", - 12 │ + ········"useSingleVarDeclarator":"error", - 13 │ + ········"noNonnullAssertion":"error", - 14 │ + ········"useNodejsImportProtocol":"error", - 15 │ + ········"useConst":"error", - 16 │ + ········"noInferrableTypes":"error", - 17 │ + ········"useExponentiationOperator":"error", - 18 │ + ········"noUselessElse":"error", - 19 │ + ········"useSelfClosingElements":"error", - 20 │ + ········"useImportType":"error", - 21 │ + ········"useNumberNamespace":"error", - 22 │ + ········"useWhile":"error", - 23 │ + ········"useAsConstAssertion":"error", - 24 │ + ········"noUnusedTemplateLiteral":"error", - 25 │ + ········"useNumericLiterals":"error", - 26 │ + ········"useTemplate":"error", - 27 │ + ········"useEnumInitializers":"error" - 28 │ + ······} - 5 29 │ } - 6 30 │ } + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true + 4 │ + ······"style":·{ + 5 │ + ········"useLiteralEnumMembers":·"error" + 6 │ + ······} + 5 7 │ } + 6 8 │ } + + +``` + +``` +with_existing_rules.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule noParameterAssign isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true + > 5 │ } + > 6 │ } + > 7 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true + 4 │ + ······"style":·{ + 5 │ + ········"noParameterAssign":·"error" + 6 │ + ······} + 5 7 │ } + 6 8 │ } + + +``` + +``` +with_existing_rules.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule noCommaOperator isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true + > 5 │ } + > 6 │ } + > 7 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true + 4 │ + ······"style":·{ + 5 │ + ········"noCommaOperator":·"error" + 6 │ + ······} + 5 7 │ } + 6 8 │ } + + +``` + +``` +with_existing_rules.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useSelfClosingElements isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true + > 5 │ } + > 6 │ } + > 7 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true + 4 │ + ······"style":·{ + 5 │ + ········"useSelfClosingElements":·"error" + 6 │ + ······} + 5 7 │ } + 6 8 │ } + + +``` + +``` +with_existing_rules.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useEnumInitializers isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true + > 5 │ } + > 6 │ } + > 7 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true + 4 │ + ······"style":·{ + 5 │ + ········"useEnumInitializers":·"error" + 6 │ + ······} + 5 7 │ } + 6 8 │ } + + +``` + +``` +with_existing_rules.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useTemplate isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true + > 5 │ } + > 6 │ } + > 7 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true + 4 │ + ······"style":·{ + 5 │ + ········"useTemplate":·"error" + 6 │ + ······} + 5 7 │ } + 6 8 │ } + + +``` + +``` +with_existing_rules.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useNumericLiterals isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true + > 5 │ } + > 6 │ } + > 7 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true + 4 │ + ······"style":·{ + 5 │ + ········"useNumericLiterals":·"error" + 6 │ + ······} + 5 7 │ } + 6 8 │ } + + +``` + +``` +with_existing_rules.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule noUnusedTemplateLiteral isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true + > 5 │ } + > 6 │ } + > 7 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true + 4 │ + ······"style":·{ + 5 │ + ········"noUnusedTemplateLiteral":·"error" + 6 │ + ······} + 5 7 │ } + 6 8 │ } + + +``` + +``` +with_existing_rules.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useAsConstAssertion isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true + > 5 │ } + > 6 │ } + > 7 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true + 4 │ + ······"style":·{ + 5 │ + ········"useAsConstAssertion":·"error" + 6 │ + ······} + 5 7 │ } + 6 8 │ } + + +``` + +``` +with_existing_rules.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useNumberNamespace isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true + > 5 │ } + > 6 │ } + > 7 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true + 4 │ + ······"style":·{ + 5 │ + ········"useNumberNamespace":·"error" + 6 │ + ······} + 5 7 │ } + 6 8 │ } + + +``` + +``` +with_existing_rules.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule noUselessElse isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true + > 5 │ } + > 6 │ } + > 7 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true + 4 │ + ······"style":·{ + 5 │ + ········"noUselessElse":·"error" + 6 │ + ······} + 5 7 │ } + 6 8 │ } + + +``` + +``` +with_existing_rules.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useImportType isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true + > 5 │ } + > 6 │ } + > 7 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true + 4 │ + ······"style":·{ + 5 │ + ········"useImportType":·"error" + 6 │ + ······} + 5 7 │ } + 6 8 │ } + + +``` + +``` +with_existing_rules.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useExponentiationOperator isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true + > 5 │ } + > 6 │ } + > 7 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true + 4 │ + ······"style":·{ + 5 │ + ········"useExponentiationOperator":·"error" + 6 │ + ······} + 5 7 │ } + 6 8 │ } + + +``` + +``` +with_existing_rules.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule noInferrableTypes isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true + > 5 │ } + > 6 │ } + > 7 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true + 4 │ + ······"style":·{ + 5 │ + ········"noInferrableTypes":·"error" + 6 │ + ······} + 5 7 │ } + 6 8 │ } + + +``` + +``` +with_existing_rules.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule noNonNullAssertion isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true + > 5 │ } + > 6 │ } + > 7 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true + 4 │ + ······"style":·{ + 5 │ + ········"noNonNullAssertion":·"error" + 6 │ + ······} + 5 7 │ } + 6 8 │ } + + +``` + +``` +with_existing_rules.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useConst isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true + > 5 │ } + > 6 │ } + > 7 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true + 4 │ + ······"style":·{ + 5 │ + ········"useConst":·"error" + 6 │ + ······} + 5 7 │ } + 6 8 │ } + + +``` + +``` +with_existing_rules.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useNodejsImportProtocol isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true + > 5 │ } + > 6 │ } + > 7 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true + 4 │ + ······"style":·{ + 5 │ + ········"useNodejsImportProtocol":·"error" + 6 │ + ······} + 5 7 │ } + 6 8 │ } + + +``` + +``` +with_existing_rules.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useDefaultParameterLast isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true + > 5 │ } + > 6 │ } + > 7 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true + 4 │ + ······"style":·{ + 5 │ + ········"useDefaultParameterLast":·"error" + 6 │ + ······} + 5 7 │ } + 6 8 │ } + + +``` + +``` +with_existing_rules.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useSingleVarDeclarator isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true + > 5 │ } + > 6 │ } + > 7 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true + 4 │ + ······"style":·{ + 5 │ + ········"useSingleVarDeclarator":·"error" + 6 │ + ······} + 5 7 │ } + 6 8 │ } + + +``` + +``` +with_existing_rules.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useExportType isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true + > 5 │ } + > 6 │ } + > 7 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true + 4 │ + ······"style":·{ + 5 │ + ········"useExportType":·"error" + 6 │ + ······} + 5 7 │ } + 6 8 │ } + + +``` + +``` +with_existing_rules.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule noArguments isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true + > 5 │ } + > 6 │ } + > 7 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true + 4 │ + ······"style":·{ + 5 │ + ········"noArguments":·"error" + 6 │ + ······} + 5 7 │ } + 6 8 │ } + + +``` + +``` +with_existing_rules.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useShorthandFunctionType isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true + > 5 │ } + > 6 │ } + > 7 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true + 4 │ + ······"style":·{ + 5 │ + ········"useShorthandFunctionType":·"error" + 6 │ + ······} + 5 7 │ } + 6 8 │ } ``` diff --git a/crates/biome_migrate/tests/specs/migrations/styleRules/with_existing_rules.version.txt b/crates/biome_migrate/tests/specs/migrations/styleRules/with_existing_rules.version.txt deleted file mode 100644 index 359a5b952d49..000000000000 --- a/crates/biome_migrate/tests/specs/migrations/styleRules/with_existing_rules.version.txt +++ /dev/null @@ -1 +0,0 @@ -2.0.0 \ No newline at end of file diff --git a/crates/biome_migrate/tests/specs/migrations/styleRules/with_existing_style_rule.json.snap b/crates/biome_migrate/tests/specs/migrations/styleRules/with_existing_style_rule.json.snap index d758486f55ce..051ccb139e56 100644 --- a/crates/biome_migrate/tests/specs/migrations/styleRules/with_existing_style_rule.json.snap +++ b/crates/biome_migrate/tests/specs/migrations/styleRules/with_existing_style_rule.json.snap @@ -27,7 +27,7 @@ snapshot_kind: text ``` with_existing_style_rule.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - ! Biome style rules aren't recommended anymore. + ! Biome style rule noCommaOperator isn't recommended anymore. > 1 │ { │ ^ @@ -57,25 +57,609 @@ with_existing_style_rule.json:1:1 migrate FIXABLE ━━━━━━━━━ 10 9 │ "useExportType": "warn", 11 │ - ········"useDefaultParameterLast":·"warn" 10 │ + ········"useDefaultParameterLast":·"warn", - 11 │ + ········"noCommaOperator":"error", - 12 │ + ········"useSingleVarDeclarator":"error", - 13 │ + ········"noNonnullAssertion":"error", - 14 │ + ········"useNodejsImportProtocol":"error", - 15 │ + ········"useConst":"error", - 16 │ + ········"noInferrableTypes":"error", - 17 │ + ········"useExponentiationOperator":"error", - 18 │ + ········"noUselessElse":"error", - 19 │ + ········"useSelfClosingElements":"error", - 20 │ + ········"useImportType":"error", - 21 │ + ········"useNumberNamespace":"error", - 22 │ + ········"useWhile":"error", - 23 │ + ········"useAsConstAssertion":"error", - 24 │ + ········"noUnusedTemplateLiteral":"error", - 25 │ + ········"useNumericLiterals":"error", - 26 │ + ········"useTemplate":"error", - 27 │ + ········"useEnumInitializers":"error" - 12 28 │ } - 13 29 │ } + 11 │ + ········"noCommaOperator":·"error" + 12 12 │ } + 13 13 │ } + + +``` + +``` +with_existing_style_rule.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useNodejsImportProtocol isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true, + ... + > 13 │ } + > 14 │ } + > 15 │ } + │ ^ + 16 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true, + 5 │ - ······"style":·{ + 4 │ + ······"style":·{ + 6 5 │ "useLiteralEnumMembers": "warn", + 7 6 │ "noArguments": "warn", + ····· │ + 9 8 │ "useShorthandFunctionType": "warn", + 10 9 │ "useExportType": "warn", + 11 │ - ········"useDefaultParameterLast":·"warn" + 10 │ + ········"useDefaultParameterLast":·"warn", + 11 │ + ········"useNodejsImportProtocol":·"error" + 12 12 │ } + 13 13 │ } + + +``` + +``` +with_existing_style_rule.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useExponentiationOperator isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true, + ... + > 13 │ } + > 14 │ } + > 15 │ } + │ ^ + 16 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true, + 5 │ - ······"style":·{ + 4 │ + ······"style":·{ + 6 5 │ "useLiteralEnumMembers": "warn", + 7 6 │ "noArguments": "warn", + ····· │ + 9 8 │ "useShorthandFunctionType": "warn", + 10 9 │ "useExportType": "warn", + 11 │ - ········"useDefaultParameterLast":·"warn" + 10 │ + ········"useDefaultParameterLast":·"warn", + 11 │ + ········"useExponentiationOperator":·"error" + 12 12 │ } + 13 13 │ } + + +``` + +``` +with_existing_style_rule.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useTemplate isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true, + ... + > 13 │ } + > 14 │ } + > 15 │ } + │ ^ + 16 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true, + 5 │ - ······"style":·{ + 4 │ + ······"style":·{ + 6 5 │ "useLiteralEnumMembers": "warn", + 7 6 │ "noArguments": "warn", + ····· │ + 9 8 │ "useShorthandFunctionType": "warn", + 10 9 │ "useExportType": "warn", + 11 │ - ········"useDefaultParameterLast":·"warn" + 10 │ + ········"useDefaultParameterLast":·"warn", + 11 │ + ········"useTemplate":·"error" + 12 12 │ } + 13 13 │ } + + +``` + +``` +with_existing_style_rule.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useNumericLiterals isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true, + ... + > 13 │ } + > 14 │ } + > 15 │ } + │ ^ + 16 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true, + 5 │ - ······"style":·{ + 4 │ + ······"style":·{ + 6 5 │ "useLiteralEnumMembers": "warn", + 7 6 │ "noArguments": "warn", + ····· │ + 9 8 │ "useShorthandFunctionType": "warn", + 10 9 │ "useExportType": "warn", + 11 │ - ········"useDefaultParameterLast":·"warn" + 10 │ + ········"useDefaultParameterLast":·"warn", + 11 │ + ········"useNumericLiterals":·"error" + 12 12 │ } + 13 13 │ } + + +``` + +``` +with_existing_style_rule.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useEnumInitializers isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true, + ... + > 13 │ } + > 14 │ } + > 15 │ } + │ ^ + 16 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true, + 5 │ - ······"style":·{ + 4 │ + ······"style":·{ + 6 5 │ "useLiteralEnumMembers": "warn", + 7 6 │ "noArguments": "warn", + ····· │ + 9 8 │ "useShorthandFunctionType": "warn", + 10 9 │ "useExportType": "warn", + 11 │ - ········"useDefaultParameterLast":·"warn" + 10 │ + ········"useDefaultParameterLast":·"warn", + 11 │ + ········"useEnumInitializers":·"error" + 12 12 │ } + 13 13 │ } + + +``` + +``` +with_existing_style_rule.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule noUnusedTemplateLiteral isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true, + ... + > 13 │ } + > 14 │ } + > 15 │ } + │ ^ + 16 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true, + 5 │ - ······"style":·{ + 4 │ + ······"style":·{ + 6 5 │ "useLiteralEnumMembers": "warn", + 7 6 │ "noArguments": "warn", + ····· │ + 9 8 │ "useShorthandFunctionType": "warn", + 10 9 │ "useExportType": "warn", + 11 │ - ········"useDefaultParameterLast":·"warn" + 10 │ + ········"useDefaultParameterLast":·"warn", + 11 │ + ········"noUnusedTemplateLiteral":·"error" + 12 12 │ } + 13 13 │ } + + +``` + +``` +with_existing_style_rule.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useAsConstAssertion isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true, + ... + > 13 │ } + > 14 │ } + > 15 │ } + │ ^ + 16 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true, + 5 │ - ······"style":·{ + 4 │ + ······"style":·{ + 6 5 │ "useLiteralEnumMembers": "warn", + 7 6 │ "noArguments": "warn", + ····· │ + 9 8 │ "useShorthandFunctionType": "warn", + 10 9 │ "useExportType": "warn", + 11 │ - ········"useDefaultParameterLast":·"warn" + 10 │ + ········"useDefaultParameterLast":·"warn", + 11 │ + ········"useAsConstAssertion":·"error" + 12 12 │ } + 13 13 │ } + + +``` + +``` +with_existing_style_rule.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useNumberNamespace isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true, + ... + > 13 │ } + > 14 │ } + > 15 │ } + │ ^ + 16 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true, + 5 │ - ······"style":·{ + 4 │ + ······"style":·{ + 6 5 │ "useLiteralEnumMembers": "warn", + 7 6 │ "noArguments": "warn", + ····· │ + 9 8 │ "useShorthandFunctionType": "warn", + 10 9 │ "useExportType": "warn", + 11 │ - ········"useDefaultParameterLast":·"warn" + 10 │ + ········"useDefaultParameterLast":·"warn", + 11 │ + ········"useNumberNamespace":·"error" + 12 12 │ } + 13 13 │ } + + +``` + +``` +with_existing_style_rule.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useImportType isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true, + ... + > 13 │ } + > 14 │ } + > 15 │ } + │ ^ + 16 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true, + 5 │ - ······"style":·{ + 4 │ + ······"style":·{ + 6 5 │ "useLiteralEnumMembers": "warn", + 7 6 │ "noArguments": "warn", + ····· │ + 9 8 │ "useShorthandFunctionType": "warn", + 10 9 │ "useExportType": "warn", + 11 │ - ········"useDefaultParameterLast":·"warn" + 10 │ + ········"useDefaultParameterLast":·"warn", + 11 │ + ········"useImportType":·"error" + 12 12 │ } + 13 13 │ } + + +``` + +``` +with_existing_style_rule.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useSelfClosingElements isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true, + ... + > 13 │ } + > 14 │ } + > 15 │ } + │ ^ + 16 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true, + 5 │ - ······"style":·{ + 4 │ + ······"style":·{ + 6 5 │ "useLiteralEnumMembers": "warn", + 7 6 │ "noArguments": "warn", + ····· │ + 9 8 │ "useShorthandFunctionType": "warn", + 10 9 │ "useExportType": "warn", + 11 │ - ········"useDefaultParameterLast":·"warn" + 10 │ + ········"useDefaultParameterLast":·"warn", + 11 │ + ········"useSelfClosingElements":·"error" + 12 12 │ } + 13 13 │ } + + +``` + +``` +with_existing_style_rule.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule noInferrableTypes isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true, + ... + > 13 │ } + > 14 │ } + > 15 │ } + │ ^ + 16 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true, + 5 │ - ······"style":·{ + 4 │ + ······"style":·{ + 6 5 │ "useLiteralEnumMembers": "warn", + 7 6 │ "noArguments": "warn", + ····· │ + 9 8 │ "useShorthandFunctionType": "warn", + 10 9 │ "useExportType": "warn", + 11 │ - ········"useDefaultParameterLast":·"warn" + 10 │ + ········"useDefaultParameterLast":·"warn", + 11 │ + ········"noInferrableTypes":·"error" + 12 12 │ } + 13 13 │ } + + +``` + +``` +with_existing_style_rule.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule noUselessElse isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true, + ... + > 13 │ } + > 14 │ } + > 15 │ } + │ ^ + 16 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true, + 5 │ - ······"style":·{ + 4 │ + ······"style":·{ + 6 5 │ "useLiteralEnumMembers": "warn", + 7 6 │ "noArguments": "warn", + ····· │ + 9 8 │ "useShorthandFunctionType": "warn", + 10 9 │ "useExportType": "warn", + 11 │ - ········"useDefaultParameterLast":·"warn" + 10 │ + ········"useDefaultParameterLast":·"warn", + 11 │ + ········"noUselessElse":·"error" + 12 12 │ } + 13 13 │ } + + +``` + +``` +with_existing_style_rule.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule noNonNullAssertion isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true, + ... + > 13 │ } + > 14 │ } + > 15 │ } + │ ^ + 16 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true, + 5 │ - ······"style":·{ + 4 │ + ······"style":·{ + 6 5 │ "useLiteralEnumMembers": "warn", + 7 6 │ "noArguments": "warn", + ····· │ + 9 8 │ "useShorthandFunctionType": "warn", + 10 9 │ "useExportType": "warn", + 11 │ - ········"useDefaultParameterLast":·"warn" + 10 │ + ········"useDefaultParameterLast":·"warn", + 11 │ + ········"noNonNullAssertion":·"error" + 12 12 │ } + 13 13 │ } + + +``` + +``` +with_existing_style_rule.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useSingleVarDeclarator isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true, + ... + > 13 │ } + > 14 │ } + > 15 │ } + │ ^ + 16 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true, + 5 │ - ······"style":·{ + 4 │ + ······"style":·{ + 6 5 │ "useLiteralEnumMembers": "warn", + 7 6 │ "noArguments": "warn", + ····· │ + 9 8 │ "useShorthandFunctionType": "warn", + 10 9 │ "useExportType": "warn", + 11 │ - ········"useDefaultParameterLast":·"warn" + 10 │ + ········"useDefaultParameterLast":·"warn", + 11 │ + ········"useSingleVarDeclarator":·"error" + 12 12 │ } + 13 13 │ } + + +``` + +``` +with_existing_style_rule.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useConst isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true, + ... + > 13 │ } + > 14 │ } + > 15 │ } + │ ^ + 16 │ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true, + 5 │ - ······"style":·{ + 4 │ + ······"style":·{ + 6 5 │ "useLiteralEnumMembers": "warn", + 7 6 │ "noArguments": "warn", + ····· │ + 9 8 │ "useShorthandFunctionType": "warn", + 10 9 │ "useExportType": "warn", + 11 │ - ········"useDefaultParameterLast":·"warn" + 10 │ + ········"useDefaultParameterLast":·"warn", + 11 │ + ········"useConst":·"error" + 12 12 │ } + 13 13 │ } ``` diff --git a/crates/biome_migrate/tests/specs/migrations/styleRules/with_existing_style_rule.version.txt b/crates/biome_migrate/tests/specs/migrations/styleRules/with_existing_style_rule.version.txt deleted file mode 100644 index 359a5b952d49..000000000000 --- a/crates/biome_migrate/tests/specs/migrations/styleRules/with_existing_style_rule.version.txt +++ /dev/null @@ -1 +0,0 @@ -2.0.0 \ No newline at end of file diff --git a/crates/biome_migrate/tests/specs/migrations/styleRules/with_existing_styles.json.snap b/crates/biome_migrate/tests/specs/migrations/styleRules/with_existing_styles.json.snap index 29835e595ff0..ca7ecfdd15fe 100644 --- a/crates/biome_migrate/tests/specs/migrations/styleRules/with_existing_styles.json.snap +++ b/crates/biome_migrate/tests/specs/migrations/styleRules/with_existing_styles.json.snap @@ -19,7 +19,7 @@ snapshot_kind: text ``` with_existing_styles.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - ! Biome style rules aren't recommended anymore. + ! Biome style rule useLiteralEnumMembers isn't recommended anymore. > 1 │ { │ ^ @@ -36,37 +36,708 @@ with_existing_styles.json:1:1 migrate FIXABLE ━━━━━━━━━━ i Safe fix: Update the configuration to enable these rules. - 2 2 │ "linter": { - 3 3 │ "rules": { - 4 │ - ······"recommended":·true, - 5 │ - ······"style":·{} - 4 │ + ······"style":·{ - 5 │ + ········"useLiteralEnumMembers":"error", - 6 │ + ········"noArguments":"error", - 7 │ + ········"noParameterAssign":"error", - 8 │ + ········"useShorthandFunctionType":"error", - 9 │ + ········"useExportType":"error", - 10 │ + ········"useDefaultParameterLast":"error", - 11 │ + ········"noCommaOperator":"error", - 12 │ + ········"useSingleVarDeclarator":"error", - 13 │ + ········"noNonnullAssertion":"error", - 14 │ + ········"useNodejsImportProtocol":"error", - 15 │ + ········"useConst":"error", - 16 │ + ········"noInferrableTypes":"error", - 17 │ + ········"useExponentiationOperator":"error", - 18 │ + ········"noUselessElse":"error", - 19 │ + ········"useSelfClosingElements":"error", - 20 │ + ········"useImportType":"error", - 21 │ + ········"useNumberNamespace":"error", - 22 │ + ········"useWhile":"error", - 23 │ + ········"useAsConstAssertion":"error", - 24 │ + ········"noUnusedTemplateLiteral":"error", - 25 │ + ········"useNumericLiterals":"error", - 26 │ + ········"useTemplate":"error", - 27 │ + ········"useEnumInitializers":"error" - 28 │ + ······} - 6 29 │ } - 7 30 │ } + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true, + 5 │ - ······"style":·{} + 4 │ + ······"style":·{ + 5 │ + ········"useLiteralEnumMembers":·"error" + 6 │ + ······} + 6 7 │ } + 7 8 │ } + + +``` + +``` +with_existing_styles.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule noParameterAssign isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true, + > 5 │ "style": {} + > 6 │ } + > 7 │ } + > 8 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true, + 5 │ - ······"style":·{} + 4 │ + ······"style":·{ + 5 │ + ········"noParameterAssign":·"error" + 6 │ + ······} + 6 7 │ } + 7 8 │ } + + +``` + +``` +with_existing_styles.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule noCommaOperator isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true, + > 5 │ "style": {} + > 6 │ } + > 7 │ } + > 8 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true, + 5 │ - ······"style":·{} + 4 │ + ······"style":·{ + 5 │ + ········"noCommaOperator":·"error" + 6 │ + ······} + 6 7 │ } + 7 8 │ } + + +``` + +``` +with_existing_styles.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useSelfClosingElements isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true, + > 5 │ "style": {} + > 6 │ } + > 7 │ } + > 8 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true, + 5 │ - ······"style":·{} + 4 │ + ······"style":·{ + 5 │ + ········"useSelfClosingElements":·"error" + 6 │ + ······} + 6 7 │ } + 7 8 │ } + + +``` + +``` +with_existing_styles.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useEnumInitializers isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true, + > 5 │ "style": {} + > 6 │ } + > 7 │ } + > 8 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true, + 5 │ - ······"style":·{} + 4 │ + ······"style":·{ + 5 │ + ········"useEnumInitializers":·"error" + 6 │ + ······} + 6 7 │ } + 7 8 │ } + + +``` + +``` +with_existing_styles.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useTemplate isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true, + > 5 │ "style": {} + > 6 │ } + > 7 │ } + > 8 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true, + 5 │ - ······"style":·{} + 4 │ + ······"style":·{ + 5 │ + ········"useTemplate":·"error" + 6 │ + ······} + 6 7 │ } + 7 8 │ } + + +``` + +``` +with_existing_styles.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useNumericLiterals isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true, + > 5 │ "style": {} + > 6 │ } + > 7 │ } + > 8 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true, + 5 │ - ······"style":·{} + 4 │ + ······"style":·{ + 5 │ + ········"useNumericLiterals":·"error" + 6 │ + ······} + 6 7 │ } + 7 8 │ } + + +``` + +``` +with_existing_styles.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule noUnusedTemplateLiteral isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true, + > 5 │ "style": {} + > 6 │ } + > 7 │ } + > 8 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true, + 5 │ - ······"style":·{} + 4 │ + ······"style":·{ + 5 │ + ········"noUnusedTemplateLiteral":·"error" + 6 │ + ······} + 6 7 │ } + 7 8 │ } + + +``` + +``` +with_existing_styles.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useAsConstAssertion isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true, + > 5 │ "style": {} + > 6 │ } + > 7 │ } + > 8 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true, + 5 │ - ······"style":·{} + 4 │ + ······"style":·{ + 5 │ + ········"useAsConstAssertion":·"error" + 6 │ + ······} + 6 7 │ } + 7 8 │ } + + +``` + +``` +with_existing_styles.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useNumberNamespace isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true, + > 5 │ "style": {} + > 6 │ } + > 7 │ } + > 8 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true, + 5 │ - ······"style":·{} + 4 │ + ······"style":·{ + 5 │ + ········"useNumberNamespace":·"error" + 6 │ + ······} + 6 7 │ } + 7 8 │ } + + +``` + +``` +with_existing_styles.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule noUselessElse isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true, + > 5 │ "style": {} + > 6 │ } + > 7 │ } + > 8 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true, + 5 │ - ······"style":·{} + 4 │ + ······"style":·{ + 5 │ + ········"noUselessElse":·"error" + 6 │ + ······} + 6 7 │ } + 7 8 │ } + + +``` + +``` +with_existing_styles.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useImportType isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true, + > 5 │ "style": {} + > 6 │ } + > 7 │ } + > 8 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true, + 5 │ - ······"style":·{} + 4 │ + ······"style":·{ + 5 │ + ········"useImportType":·"error" + 6 │ + ······} + 6 7 │ } + 7 8 │ } + + +``` + +``` +with_existing_styles.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useExponentiationOperator isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true, + > 5 │ "style": {} + > 6 │ } + > 7 │ } + > 8 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true, + 5 │ - ······"style":·{} + 4 │ + ······"style":·{ + 5 │ + ········"useExponentiationOperator":·"error" + 6 │ + ······} + 6 7 │ } + 7 8 │ } + + +``` + +``` +with_existing_styles.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule noInferrableTypes isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true, + > 5 │ "style": {} + > 6 │ } + > 7 │ } + > 8 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true, + 5 │ - ······"style":·{} + 4 │ + ······"style":·{ + 5 │ + ········"noInferrableTypes":·"error" + 6 │ + ······} + 6 7 │ } + 7 8 │ } + + +``` + +``` +with_existing_styles.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule noNonNullAssertion isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true, + > 5 │ "style": {} + > 6 │ } + > 7 │ } + > 8 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true, + 5 │ - ······"style":·{} + 4 │ + ······"style":·{ + 5 │ + ········"noNonNullAssertion":·"error" + 6 │ + ······} + 6 7 │ } + 7 8 │ } + + +``` + +``` +with_existing_styles.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useConst isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true, + > 5 │ "style": {} + > 6 │ } + > 7 │ } + > 8 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true, + 5 │ - ······"style":·{} + 4 │ + ······"style":·{ + 5 │ + ········"useConst":·"error" + 6 │ + ······} + 6 7 │ } + 7 8 │ } + + +``` + +``` +with_existing_styles.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useNodejsImportProtocol isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true, + > 5 │ "style": {} + > 6 │ } + > 7 │ } + > 8 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true, + 5 │ - ······"style":·{} + 4 │ + ······"style":·{ + 5 │ + ········"useNodejsImportProtocol":·"error" + 6 │ + ······} + 6 7 │ } + 7 8 │ } + + +``` + +``` +with_existing_styles.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useDefaultParameterLast isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true, + > 5 │ "style": {} + > 6 │ } + > 7 │ } + > 8 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true, + 5 │ - ······"style":·{} + 4 │ + ······"style":·{ + 5 │ + ········"useDefaultParameterLast":·"error" + 6 │ + ······} + 6 7 │ } + 7 8 │ } + + +``` + +``` +with_existing_styles.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useSingleVarDeclarator isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true, + > 5 │ "style": {} + > 6 │ } + > 7 │ } + > 8 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true, + 5 │ - ······"style":·{} + 4 │ + ······"style":·{ + 5 │ + ········"useSingleVarDeclarator":·"error" + 6 │ + ······} + 6 7 │ } + 7 8 │ } + + +``` + +``` +with_existing_styles.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useExportType isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true, + > 5 │ "style": {} + > 6 │ } + > 7 │ } + > 8 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true, + 5 │ - ······"style":·{} + 4 │ + ······"style":·{ + 5 │ + ········"useExportType":·"error" + 6 │ + ······} + 6 7 │ } + 7 8 │ } + + +``` + +``` +with_existing_styles.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule noArguments isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true, + > 5 │ "style": {} + > 6 │ } + > 7 │ } + > 8 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true, + 5 │ - ······"style":·{} + 4 │ + ······"style":·{ + 5 │ + ········"noArguments":·"error" + 6 │ + ······} + 6 7 │ } + 7 8 │ } + + +``` + +``` +with_existing_styles.json:1:1 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Biome style rule useShorthandFunctionType isn't recommended anymore. + + > 1 │ { + │ ^ + > 2 │ "linter": { + > 3 │ "rules": { + > 4 │ "recommended": true, + > 5 │ "style": {} + > 6 │ } + > 7 │ } + > 8 │ } + │ ^ + + i To avoid regressions with your code base, Biome will update the configuration file to maintain the compatibility with your current setup. + + i Safe fix: Update the configuration to enable these rules. + + 2 2 │ "linter": { + 3 3 │ "rules": { + 4 │ - ······"recommended":·true, + 5 │ - ······"style":·{} + 4 │ + ······"style":·{ + 5 │ + ········"useShorthandFunctionType":·"error" + 6 │ + ······} + 6 7 │ } + 7 8 │ } ``` diff --git a/crates/biome_migrate/tests/specs/migrations/styleRules/with_existing_styles.version.txt b/crates/biome_migrate/tests/specs/migrations/styleRules/with_existing_styles.version.txt deleted file mode 100644 index 359a5b952d49..000000000000 --- a/crates/biome_migrate/tests/specs/migrations/styleRules/with_existing_styles.version.txt +++ /dev/null @@ -1 +0,0 @@ -2.0.0 \ No newline at end of file diff --git a/crates/biome_migrate/tests/specs/migrations/trailingComma/invalid.json b/crates/biome_migrate/tests/specs/migrations/trailingComma/invalid.json new file mode 100644 index 000000000000..2719317f96e8 --- /dev/null +++ b/crates/biome_migrate/tests/specs/migrations/trailingComma/invalid.json @@ -0,0 +1,12 @@ +{ + "javascript": { + "formatter": { + "trailingComma": "always" + } + }, + "json": { + "formatter": { + "trailingComma": "always" + } + } +} diff --git a/crates/biome_migrate/tests/specs/migrations/trailingComma/invalid.json.snap b/crates/biome_migrate/tests/specs/migrations/trailingComma/invalid.json.snap new file mode 100644 index 000000000000..497e6f5d3c23 --- /dev/null +++ b/crates/biome_migrate/tests/specs/migrations/trailingComma/invalid.json.snap @@ -0,0 +1,70 @@ +--- +source: crates/biome_migrate/tests/spec_tests.rs +expression: invalid.json +snapshot_kind: text +--- +# Input +```json +{ + "javascript": { + "formatter": { + "trailingComma": "always" + } + }, + "json": { + "formatter": { + "trailingComma": "always" + } + } +} + +``` + +# Diagnostics +``` +invalid.json:4:7 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! The option trailingComma is removed. + + 2 │ "javascript": { + 3 │ "formatter": { + > 4 │ "trailingComma": "always" + │ ^^^^^^^^^^^^^^^ + 5 │ } + 6 │ }, + + i Safe fix: Use the option trailingCommas instead. + + 2 2 │ "javascript": { + 3 3 │ "formatter": { + 4 │ - ······"trailingComma":·"always" + 4 │ + ······"trailingCommas":·"always" + 5 5 │ } + 6 6 │ }, + + +``` + +``` +invalid.json:9:7 migrate FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! The option trailingComma is removed. + + 7 │ "json": { + 8 │ "formatter": { + > 9 │ "trailingComma": "always" + │ ^^^^^^^^^^^^^^^ + 10 │ } + 11 │ } + + i Safe fix: Use the option trailingCommas instead. + + 7 7 │ "json": { + 8 8 │ "formatter": { + 9 │ - ······"trailingComma":·"always" + 9 │ + ······"trailingCommas":·"always" + 10 10 │ } + 11 11 │ } + + +``` diff --git a/crates/biome_migrate/tests/specs/migrations/useWhile/invalid.version.txt b/crates/biome_migrate/tests/specs/migrations/useWhile/invalid.version.txt deleted file mode 100644 index 227cea215648..000000000000 --- a/crates/biome_migrate/tests/specs/migrations/useWhile/invalid.version.txt +++ /dev/null @@ -1 +0,0 @@ -2.0.0