Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(config): group-level lint rules calculation #2204

Merged
merged 4 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,28 @@ New entries must be placed in a section entitled `Unreleased`.
Read
our [guidelines for writing a good changelog entry](https://github.com/biomejs/biome/blob/main/CONTRIBUTING.md#changelog).

## Unreleased

### Analyzer

### CLI

### Configuration

#### Bug fixes

- Correctly calculate enabled rules in lint rule groups. Now a specific rule belonging to a group can be enabled even if its group-level preset option `recommended` or `all` is `false` ([#2191](https://github.com/biomejs/biome/issues/2191)). Contributed by @Sec-ant

### Editors

### Formatter

### JavaScript APIs

### Linter

### Parser

## 1.6.3 (2024-03-25)

### Analyzer
Expand Down
46 changes: 46 additions & 0 deletions crates/biome_cli/tests/commands/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1918,6 +1918,52 @@ fn top_level_all_down_level_empty() {
));
}

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

// useButtonType should be enabled.
let biome_json = r#"{
"linter": {
"rules": {
"a11y": {
"recommended": false,
"useButtonType": "error"
}
}
}
}"#;

let code = r#"
function SubmitButton() {
return <button>Submit</button>;
}
"#;

let file_path = Path::new("fix.jsx");
fs.insert(file_path.into(), code.as_bytes());

let config_path = Path::new("biome.json");
fs.insert(config_path.into(), biome_json.as_bytes());

let result = run_cli(
DynRef::Borrowed(&mut fs),
&mut console,
Args::from([("lint"), file_path.as_os_str().to_str().unwrap()].as_slice()),
);

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

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

#[test]
fn ignore_configured_globals() {
let mut fs = MemoryFileSystem::default();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
source: crates/biome_cli/tests/snap_test.rs
expression: content
---
## `biome.json`

```json
{
"linter": {
"rules": {
"a11y": {
"recommended": false,
"useButtonType": "error"
}
}
}
}
```

## `fix.jsx`

```jsx

function SubmitButton() {
return <button>Submit</button>;
}

```

# Termination Message

```block
lint ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

× Some errors were emitted while running checks.



```

# Emitted Messages

```block
fix.jsx:3:16 lint/a11y/useButtonType ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

× Provide an explicit type prop for the button element.

2 │ function SubmitButton() {
> 3 │ return <button>Submit</button>;
│ ^^^^^^^^
4 │ }····
5 │

i The default type of a button is submit, which causes the submission of a form when placed inside a `form` element. This is likely not the behaviour that you want inside a React application.

i Allowed button types are: submit, button or reset


```

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