Skip to content

Commit

Permalink
feat: remove support for rome-ignore (#4252)
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico committed Nov 7, 2024
1 parent 3fe9193 commit fd9c3b6
Show file tree
Hide file tree
Showing 70 changed files with 301 additions and 601 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
cli: major
---

# Remove support for `rome-ignore` suppression comment

Use the `biome-ignore` suppression comment instead.
5 changes: 5 additions & 0 deletions .changeset/remove_support_for_romejson.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
cli: major
---

# Remove support for `rome.json`
3 changes: 2 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 5 additions & 26 deletions crates/biome_analyze/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,13 @@ pub use crate::signals::{
};
pub use crate::syntax::{Ast, SyntaxVisitor};
pub use crate::visitor::{NodeVisitor, Visitor, VisitorContext, VisitorFinishContext};
pub use suppression_action::{ApplySuppression, SuppressionAction};

use biome_console::markup;
use biome_diagnostics::{
category, Applicability, Diagnostic, DiagnosticExt, DiagnosticTags, Severity,
};
use biome_diagnostics::{category, Applicability, Diagnostic, DiagnosticExt, DiagnosticTags};
use biome_rowan::{
AstNode, BatchMutation, Direction, Language, SyntaxElement, SyntaxToken, TextLen, TextRange,
TextSize, TokenAtOffset, TriviaPiece, TriviaPieceKind, WalkEvent,
AstNode, BatchMutation, Direction, Language, SyntaxElement, SyntaxToken, TextRange, TextSize,
TokenAtOffset, TriviaPieceKind, WalkEvent,
};
pub use suppression_action::{ApplySuppression, SuppressionAction};

/// The analyzer is the main entry point into the `biome_analyze` infrastructure.
/// Its role is to run a collection of [Visitor]s over a syntax tree, with each
Expand Down Expand Up @@ -475,27 +472,11 @@ where
}
};

if matches!(kind, SuppressionKind::Deprecated) {
let signal = DiagnosticSignal::new(move || {
SuppressionDiagnostic::new(
category!("suppressions/deprecatedSuppressionComment"),
range,
"// rome-ignore is deprecated, use // biome-ignore instead",
)
.with_tags(DiagnosticTags::DEPRECATED_CODE)
.with_severity(Severity::Information)
})
.with_action(move || create_suppression_comment_action(token));

(self.emit_signal)(&signal)?;
}

let (rule, instance) = match kind {
SuppressionKind::Everything => (None, None),
SuppressionKind::Rule(rule) => (Some(rule), None),
SuppressionKind::RuleInstance(rule, instance) => (Some(rule), Some(instance)),
SuppressionKind::MaybeLegacy(rule) => (Some(rule), None),
SuppressionKind::Deprecated => (None, None),
};

if let Some(rule) = rule {
Expand Down Expand Up @@ -718,8 +699,6 @@ pub enum SuppressionKind<'a> {
RuleInstance(&'a str, &'a str),
/// A suppression using the legacy syntax to disable a specific rule eg. `// biome-ignore lint(style/useWhile)`
MaybeLegacy(&'a str),
/// `rome-ignore` is legacy
Deprecated,
}

fn update_suppression<L: Language>(
Expand Down Expand Up @@ -783,7 +762,7 @@ pub struct SuppressionCommentEmitterPayload<'a, L: Language> {
pub token_offset: TokenAtOffset<SyntaxToken<L>>,
/// A [BatchMutation] where the consumer can apply the suppression comment
pub mutation: &'a mut BatchMutation<L>,
/// A string equals to "rome-ignore: lint(<RULE_GROUP>/<RULE_NAME>)"
/// A string equals to "biome-ignore: lint(<RULE_GROUP>/<RULE_NAME>)"
pub suppression_text: &'a str,
/// The original range of the diagnostic where the rule was triggered
pub diagnostic_text_range: &'a TextRange,
Expand Down
19 changes: 2 additions & 17 deletions crates/biome_cli/src/commands/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::changed::{get_changed_files, get_staged_files};
use crate::cli_options::{cli_options, CliOptions, CliReporter, ColorsArg};
use crate::diagnostics::{DeprecatedArgument, DeprecatedConfigurationFile};
use crate::diagnostics::DeprecatedArgument;
use crate::execute::Stdin;
use crate::logging::LoggingKind;
use crate::{
Expand All @@ -22,7 +22,7 @@ use biome_configuration::{
};
use biome_configuration::{BiomeDiagnostic, PartialConfiguration};
use biome_console::{markup, Console, ConsoleExt};
use biome_diagnostics::{Diagnostic, PrintDiagnostic};
use biome_diagnostics::PrintDiagnostic;
use biome_fs::{BiomePath, FileSystem};
use biome_service::configuration::{
load_configuration, load_editorconfig, LoadedConfiguration, PartialConfigurationExt,
Expand Down Expand Up @@ -626,21 +626,6 @@ pub(crate) fn validate_configuration_diagnostics(
console: &mut dyn Console,
verbose: bool,
) -> Result<(), CliDiagnostic> {
if let Some(file_path) = loaded_configuration
.file_path
.as_ref()
.and_then(|f| f.file_name())
.and_then(|f| f.to_str())
{
if file_path == "rome.json" {
let diagnostic = DeprecatedConfigurationFile::new(file_path);
if diagnostic.tags().is_verbose() && verbose {
console.error(markup! {{PrintDiagnostic::verbose(&diagnostic)}})
} else {
console.error(markup! {{PrintDiagnostic::simple(&diagnostic)}})
}
}
}
let diagnostics = loaded_configuration.as_diagnostics_iter();
for diagnostic in diagnostics {
if diagnostic.tags().is_verbose() && verbose {
Expand Down
20 changes: 0 additions & 20 deletions crates/biome_cli/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,26 +475,6 @@ impl Termination for CliDiagnostic {
}
}

#[derive(Debug, Diagnostic)]
#[diagnostic(
category = "internalError/fs",
severity = Warning,
message(
description = "The configuration file {path} is deprecated. Use biome.json instead.",
message("The configuration file "<Emphasis>{self.path}</Emphasis>" is deprecated. Use "<Emphasis>"biome.json"</Emphasis>" instead."),
)
)]
pub struct DeprecatedConfigurationFile {
#[location(resource)]
pub path: String,
}

impl DeprecatedConfigurationFile {
pub fn new(path: impl Into<String>) -> Self {
Self { path: path.into() }
}
}

#[derive(Debug, Default, Diagnostic)]
#[diagnostic(
severity = Error,
Expand Down
6 changes: 3 additions & 3 deletions crates/biome_cli/tests/commands/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,7 @@ fn fs_files_ignore_symlink() {
check_windows_symlink!(symlink_dir(&testcase2_path, symlink_testcase2_path));
}

let config_path = root_path.join("rome.json");
let config_path = root_path.join("biome.json");
let mut config_file = File::create(config_path).unwrap();
config_file
.write_all(CONFIG_IGNORE_SYMLINK.as_bytes())
Expand Down Expand Up @@ -1383,7 +1383,7 @@ fn deprecated_suppression_comment() {
let file_path = Path::new("file.js");
fs.insert(
file_path.into(),
*b"// rome-ignore lint(suspicious/noDoubleEquals): test
*b"// biome-ignore lint(suspicious/noDoubleEquals): test
a == b;",
);

Expand Down Expand Up @@ -1530,7 +1530,7 @@ fn suppression_syntax_error() {
let mut console = BufferConsole::default();

let file_path = Path::new("check.js");
fs.insert(file_path.into(), *b"// rome-ignore(:\n");
fs.insert(file_path.into(), *b"// biome-ignore(:\n");

let result = run_cli(
DynRef::Borrowed(&mut fs),
Expand Down
2 changes: 1 addition & 1 deletion crates/biome_cli/tests/commands/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ fn custom_config_file_path() {
let mut fs = MemoryFileSystem::default();
let mut console = BufferConsole::default();

let config_path = Path::new("/test/rome.json");
let config_path = Path::new("/test/biome.json");
fs.insert(config_path.into(), CONFIG_FORMAT.as_bytes());

let file_path = Path::new("file.js");
Expand Down
6 changes: 3 additions & 3 deletions crates/biome_cli/tests/commands/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,7 @@ fn fs_files_ignore_symlink() {
check_windows_symlink!(symlink_dir(&testcase2_path, symlink_testcase2_path));
}

let config_path = root_path.join("rome.json");
let config_path = root_path.join("biome.json");
let mut config_file = File::create(config_path).unwrap();
config_file
.write_all(CONFIG_IGNORE_SYMLINK.as_bytes())
Expand Down Expand Up @@ -1564,7 +1564,7 @@ fn deprecated_suppression_comment() {
let file_path = Path::new("file.js");
fs.insert(
file_path.into(),
*b"// rome-ignore lint(suspicious/noDoubleEquals): test
*b"// biome-ignore lint(suspicious/noDoubleEquals): test
a == b;",
);

Expand Down Expand Up @@ -1678,7 +1678,7 @@ fn suppression_syntax_error() {
let mut console = BufferConsole::default();

let file_path = Path::new("check.js");
fs.insert(file_path.into(), *b"// rome-ignore(:\n");
fs.insert(file_path.into(), *b"// biome-ignore(:\n");

let result = run_cli(
DynRef::Borrowed(&mut fs),
Expand Down
54 changes: 0 additions & 54 deletions crates/biome_cli/tests/commands/migrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,60 +79,6 @@ fn missing_configuration_file() {
));
}

#[test]
fn emit_diagnostic_for_rome_json() {
let mut fs = MemoryFileSystem::default();
let mut console = BufferConsole::default();

let configuration = r#"{ "linter": { "enabled": true } }"#;

let configuration_path = Path::new("rome.json");
fs.insert(configuration_path.into(), configuration.as_bytes());

let result = run_cli(
DynRef::Borrowed(&mut fs),
&mut console,
Args::from([("migrate")].as_slice()),
);

assert!(result.is_ok(), "run_cli returned {result:?}");

assert_cli_snapshot(SnapshotPayload::new(
module_path!(),
"emit_diagnostic_for_rome_json",
fs,
console,
result,
));
}

#[test]
fn should_create_biome_json_file() {
let mut fs = MemoryFileSystem::default();
let mut console = BufferConsole::default();

let configuration = r#"{ "linter": { "enabled": true } }"#;

let configuration_path = Path::new("rome.json");
fs.insert(configuration_path.into(), configuration.as_bytes());

let result = run_cli(
DynRef::Borrowed(&mut 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_create_biome_json_file",
fs,
console,
result,
));
}

#[test]
fn should_emit_incompatible_arguments_error() {
let mut fs = MemoryFileSystem::default();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ expression: content
## `file.js`

```js
// rome-ignore lint(suspicious/noDoubleEquals): test
// biome-ignore lint(suspicious/noDoubleEquals): test
a == b;
```

Expand All @@ -25,16 +25,16 @@ check ━━━━━━━━━━━━━━━━━━━━━━━━
```block
file.js:1:1 suppressions/deprecatedSuppressionComment FIXABLE DEPRECATED ━━━━━━━━━━━━━━━━━━━━━━━
i // rome-ignore is deprecated, use // biome-ignore instead
! Suppression is using a deprecated syntax
> 1 │ // rome-ignore lint(suspicious/noDoubleEquals): test
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 1 │ // biome-ignore lint(suspicious/noDoubleEquals): test
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │ a == b;
i Unsafe fix: Use // biome-ignore instead
i Safe fix: Rewrite suppression to use the newer syntax
1 │ - //·rome-ignore·lint(suspicious/noDoubleEquals):·test
1 │ + //·biome-ignore·lint(suspicious/noDoubleEquals):·test
1 │ - //·biome-ignore·lint(suspicious/noDoubleEquals):·test
1 │ + //·biome-ignore·lint/suspicious/noDoubleEquals:·test
2 2 │ a == b;
Expand All @@ -45,8 +45,20 @@ file.js organizeImports ━━━━━━━━━━━━━━━━━━
× Import statements could be sorted:
1 │ - //·rome-ignore·lint(suspicious/noDoubleEquals):·test
1 │ + //·biome-ignore·lint(suspicious/noDoubleEquals):·test
1 │ - //·biome-ignore·lint(suspicious/noDoubleEquals):·test
1 │ + //·biome-ignore·lint/suspicious/noDoubleEquals:·test
2 2 │ a == b;
```

```block
file.js assists ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
× Not all assists were applied:
1 │ - //·biome-ignore·lint(suspicious/noDoubleEquals):·test
1 │ + //·biome-ignore·lint/suspicious/noDoubleEquals:·test
2 2 │ a == b;
Expand All @@ -55,16 +67,16 @@ file.js organizeImports ━━━━━━━━━━━━━━━━━━
```block
file.js:1:1 suppressions/deprecatedSuppressionComment FIXABLE DEPRECATED ━━━━━━━━━━━━━━━━━━━━━━━
i // rome-ignore is deprecated, use // biome-ignore instead
! Suppression is using a deprecated syntax
> 1 │ // rome-ignore lint(suspicious/noDoubleEquals): test
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 1 │ // biome-ignore lint(suspicious/noDoubleEquals): test
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │ a == b;
i Unsafe fix: Use // biome-ignore instead
i Safe fix: Rewrite suppression to use the newer syntax
1 │ - //·rome-ignore·lint(suspicious/noDoubleEquals):·test
1 │ + //·biome-ignore·lint(suspicious/noDoubleEquals):·test
1 │ - //·biome-ignore·lint(suspicious/noDoubleEquals):·test
1 │ + //·biome-ignore·lint/suspicious/noDoubleEquals:·test
2 2 │ a == b;
Expand All @@ -75,21 +87,16 @@ file.js format ━━━━━━━━━━━━━━━━━━━━━
× Formatter would have printed the following content:
1 1 │ // rome-ignore lint(suspicious/noDoubleEquals): test
1 1 │ // biome-ignore lint(suspicious/noDoubleEquals): test
2 │ - a·==·b;
2 │ + a·==·b;
3 │ +
```

```block
Skipped 1 suggested fixes.
If you wish to apply the suggested (unsafe) fixes, use the command biome check --fix --unsafe
```

```block
Checked 1 file in <TIME>. No fixes applied.
Found 2 errors.
Found 3 errors.
Found 2 warnings.
```
Loading

0 comments on commit fd9c3b6

Please sign in to comment.