Closed chekrd closed 7 months ago
This sounds like a nasty bug, I wonder what changed in these versions...
Thank you for taking the time to show us possible combinations/cases, they will help us to identify the problem.
Hi! I tried to reproduce your issue, however I got the expected behavior:
❯ cat biome.json
{
"linter": {
"enabled": true,
"rules": {
"recommended": false,
"complexity": {
"useFlatMap": "error"
}
}
}
}
❯ cat index.js
debugger; // should trigger noDebugger
new RegExp("abc", "u"); // should trigger useRegexLiterals
❯ npx @biomejs/biome@1.5.3 lint index.js
Checked 1 file(s) in 347µs
Could you provide a reproduction?
Hi @Conaclos, my bad, I didn’t specify before, that the issue appears when using ci command:
❯ cat biome.json
{
"linter": {
"enabled": true,
"rules": {
"recommended": false,
"complexity": {
"useFlatMap": "error"
}
}
}
}
❯ cat index.js
debugger; // should trigger noDebugger
new RegExp("abc", "u"); // should trigger useRegexLiterals
[].map((i) => i).flat(); // should trigger useFlatMap
❯ npx @biomejs/biome@1.5.3 ci index.js
index.js:1:1 lint/suspicious/noDebugger FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ This is an unexpected use of the debugger statement.
> 1 │ debugger; // should trigger noDebugger
│ ^^^^^^^^^
2 │ new RegExp("abc", "u"); // should trigger useRegexLiterals
3 │ [].map((i) => i).flat(); // should trigger useFlatMap
ℹ Unsafe fix: Remove debugger statement
1 │ debugger;·//·should·trigger·noDebugger
│ --------------------------------------
index.js:3:1 lint/complexity/useFlatMap FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ The call chain .map().flat() can be replaced with a single .flatMap() call.
1 │ debugger; // should trigger noDebugger
2 │ new RegExp("abc", "u"); // should trigger useRegexLiterals
> 3 │ [].map((i) => i).flat(); // should trigger useFlatMap
│ ^^^^^^^^^^^^^^^^^^^^^^^
ℹ Safe fix: Replace the chain with .flatMap().
1 1 │ debugger; // should trigger noDebugger
2 2 │ new RegExp("abc", "u"); // should trigger useRegexLiterals
3 │ - [].map((i)·=>·i).flat();·//·should·trigger·useFlatMap
3 │ + [].flatMap((i)·=>·i);·//·should·trigger·useFlatMap
index.js:2:1 lint/complexity/useRegexLiterals FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Use a regular expression literal instead of the RegExp constructor.
1 │ debugger; // should trigger noDebugger
> 2 │ new RegExp("abc", "u"); // should trigger useRegexLiterals
│ ^^^^^^^^^^^^^^^^^^^^^^
3 │ [].map((i) => i).flat(); // should trigger useFlatMap
ℹ Regular expression literals avoid some escaping required in a string literal, and are easier to analyze statically.
ℹ Safe fix: Use a literal notation instead.
1 1 │ debugger; // should trigger noDebugger
2 │ - new·RegExp("abc",·"u");·//·should·trigger·useRegexLiterals
2 │ + /abc/u;·//·should·trigger·useRegexLiterals
3 3 │ [].map((i) => i).flat(); // should trigger useFlatMap
index.js lint ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ The file contains diagnostics that needs to be addressed.
index.js format ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ File content differs from formatting output
1 1 │ debugger; // should trigger noDebugger
2 2 │ new RegExp("abc", "u"); // should trigger useRegexLiterals
3 │ - [].map((i)·=>·i).flat();·//·should·trigger·useFlatMap
3 │ + [].map((i)·=>·i).flat();·//·should·trigger·useFlatMap
4 │ +
index.js ci ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ The file contains diagnostics that needs to be addressed.
Checked 1 file(s) in 17ms
Found 6 error(s)
ci ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Some errors were emitted while running checks.
Lint command output looks fine:
❯ cat biome.json
{
"linter": {
"enabled": true,
"rules": {
"recommended": false,
"complexity": {
"useFlatMap": "error"
}
}
}
}
❯ cat index.js
debugger; // should trigger noDebugger
new RegExp("abc", "u"); // should trigger useRegexLiterals
[].map((i) => i).flat(); // should trigger useFlatMap
❯ npx @biomejs/biome@1.5.3 lint index.js
index.js:3:1 lint/complexity/useFlatMap FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ The call chain .map().flat() can be replaced with a single .flatMap() call.
1 │ debugger; // should trigger noDebugger
2 │ new RegExp("abc", "u"); // should trigger useRegexLiterals
> 3 │ [].map((i) => i).flat(); // should trigger useFlatMap
│ ^^^^^^^^^^^^^^^^^^^^^^^
ℹ Safe fix: Replace the chain with .flatMap().
1 1 │ debugger; // should trigger noDebugger
2 2 │ new RegExp("abc", "u"); // should trigger useRegexLiterals
3 │ - [].map((i)·=>·i).flat();·//·should·trigger·useFlatMap
3 │ + [].flatMap((i)·=>·i);·//·should·trigger·useFlatMap
index.js lint ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ The file contains diagnostics that needs to be addressed.
Checked 1 file(s) in 5ms
Found 2 error(s)
lint ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Some errors were emitted while running checks.
NOTE: This doesn't affect biome check
.
Environment information
Rule name
All lint rules
Playground link
No link, because it is not possible to enable just one lint rule in the playground.
Expected result
Hi, thanks for you work!
How can I enable just a specific set of lint rules and disable all the others? Our usecase is that we manually pick what rules are enabled (reasons are that we are migrating a very large codebase from ESLint to Biome + some Biome recommended lint rules are buggy right now). I have created this as a bug, because in @1.4.1 following did what we needed:
But in Biome @1.5.3 this does not work anymore. What I have tried (but nothing worked):
All rules are applied:
All rules of complexity group are applied:
No rule is applied:
Scary workaround
The only way we can enable what we need is to toggle all rules within a touched group. But this is kind of crazy as we have at least one rule enabled in every group, so we must copy paste the whole "rules" schema and disable unwanted rules one by one:
Adding an example to the docs page about how to disable all recommended rules and enable just a few would be great! 🙂
Code of Conduct