fix(rome_service): correctly compute rules
MODIFY
crates/rome_cli/tests/main.rs
crates/rome_cli/tests/main.rs
@@ -522,6 +522,17 @@ mod check {
.count(),
1
);
+ assert_eq!(
+ messages
+ .iter()
+ .filter(|m| m.level == LogLevel::Error)
+ .filter(|m| {
+ let content = format!("{:?}", m.content);
+ content.contains("js/noUnusedVariables")
+ })
+ .count(),
+ 1
+ );
assert_cli_snapshot(module_path!(), "upgrade_severity", fs, console);
}

MODIFY
crates/rome_cli/tests/snap_test.rs
crates/rome_cli/tests/snap_test.rs
@@ -128,7 +128,6 @@ pub fn assert_cli_snapshot(
}
for message in &console.out_buffer {
- dbg!(&message);
let content = markup_to_string(markup! {
{message.content}
});

MODIFY
crates/rome_cli/tests/snapshots/main_check/should_disable_a_rule_group.snap
crates/rome_cli/tests/snapshots/main_check/should_disable_a_rule_group.snap
---
source: crates/rome_cli/tests/snap_test.rs
-assertion_line: 147
expression: content
---
## `rome.json`

MODIFY
crates/rome_service/src/configuration/linter/rules.rs
crates/rome_service/src/configuration/linter/rules.rs
@@ -312,7 +312,7 @@ impl Js {
RuleFilter::Rule("js", Self::CATEGORY_RULES[28]),
RuleFilter::Rule("js", Self::CATEGORY_RULES[29]),
];
- pub(crate) fn is_recommended(&self) -> bool { matches!(self.recommended, Some(true)) }
+ pub(crate) fn is_recommended(&self) -> bool { !matches!(self.recommended, Some(false)) }
pub(crate) fn get_enabled_rules(&self) -> IndexSet<RuleFilter> {
IndexSet::from_iter(self.rules.iter().filter_map(|(key, conf)| {
if conf.is_enabled() {
@@ -391,7 +391,7 @@ impl Jsx {
RuleFilter::Rule("jsx", Self::CATEGORY_RULES[1]),
RuleFilter::Rule("jsx", Self::CATEGORY_RULES[2]),
];
- pub(crate) fn is_recommended(&self) -> bool { matches!(self.recommended, Some(true)) }
+ pub(crate) fn is_recommended(&self) -> bool { !matches!(self.recommended, Some(false)) }
pub(crate) fn get_enabled_rules(&self) -> IndexSet<RuleFilter> {
IndexSet::from_iter(self.rules.iter().filter_map(|(key, conf)| {
if conf.is_enabled() {
@@ -460,7 +460,7 @@ impl Regex {
const RECOMMENDED_RULES: [&'static str; 1] = ["noMultipleSpacesInRegularExpressionLiterals"];
const RECOMMENDED_RULES_AS_FILTERS: [RuleFilter<'static>; 1] =
[RuleFilter::Rule("regex", Self::CATEGORY_RULES[0])];
- pub(crate) fn is_recommended(&self) -> bool { matches!(self.recommended, Some(true)) }
+ pub(crate) fn is_recommended(&self) -> bool { !matches!(self.recommended, Some(false)) }
pub(crate) fn get_enabled_rules(&self) -> IndexSet<RuleFilter> {
IndexSet::from_iter(self.rules.iter().filter_map(|(key, conf)| {
if conf.is_enabled() {
@@ -528,7 +528,7 @@ impl Ts {
const RECOMMENDED_RULES: [&'static str; 1] = ["useShorthandArrayType"];
const RECOMMENDED_RULES_AS_FILTERS: [RuleFilter<'static>; 1] =
[RuleFilter::Rule("ts", Self::CATEGORY_RULES[0])];
- pub(crate) fn is_recommended(&self) -> bool { matches!(self.recommended, Some(true)) }
+ pub(crate) fn is_recommended(&self) -> bool { !matches!(self.recommended, Some(false)) }
pub(crate) fn get_enabled_rules(&self) -> IndexSet<RuleFilter> {
IndexSet::from_iter(self.rules.iter().filter_map(|(key, conf)| {
if conf.is_enabled() {

ADD
rome.json
+{
+ "linter": {
+ "rules": {
+ "recommended": true,
+ "js": {
+ "noDeadCode": "error",
+ "useCamelCase": "off"
+ }
+ }
+ }
+}

MODIFY
xtask/codegen/src/generate_configuration.rs
xtask/codegen/src/generate_configuration.rs
@@ -103,7 +103,7 @@ pub(crate) fn generate_rules_configuration(mode: Mode) -> Result<()> {
pub(crate) fn is_recommended(&self) -> bool {
- matches!(self.recommended, Some(true))
+ !matches!(self.recommended, Some(false))
}

fix(rome_service): correctly compute rules (#3159)