From d0c544eeb3c1feb9400ea42016a1db942e895fcb Mon Sep 17 00:00:00 2001 From: Dhiraj Arun Date: Mon, 26 Dec 2022 22:01:58 +0530 Subject: [PATCH 1/8] add use_simple_number_keys --- .../src/categories.rs | 1 + .../rome_js_analyze/src/analyzers/nursery.rs | 3 +- .../nursery/use_simple_number_keys.rs | 212 ++++++++++++++++++ .../nursery/useSimpleNumberKeys/invalid.js | 9 + .../useSimpleNumberKeys/invalid.js.snap.new | 153 +++++++++++++ .../nursery/useSimpleNumberKeys/valid.js | 9 + .../useSimpleNumberKeys/valid.js.snap.new | 20 ++ crates/rome_js_unicode_table/src/tables.rs | 8 +- .../src/configuration/linter/rules.rs | 7 +- editors/vscode/configuration_schema.json | 11 + npm/backend-jsonrpc/src/workspace.ts | 17 +- npm/rome/configuration_schema.json | 13 +- website/src/pages/lint/rules/index.mdx | 15 +- .../pages/lint/rules/useSimpleNumberKeys.md | 36 +++ 14 files changed, 497 insertions(+), 17 deletions(-) create mode 100644 crates/rome_js_analyze/src/analyzers/nursery/use_simple_number_keys.rs create mode 100644 crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys/invalid.js create mode 100644 crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys/invalid.js.snap.new create mode 100644 crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys/valid.js create mode 100644 crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys/valid.js.snap.new create mode 100644 website/src/pages/lint/rules/useSimpleNumberKeys.md diff --git a/crates/rome_diagnostics_categories/src/categories.rs b/crates/rome_diagnostics_categories/src/categories.rs index 2ea8b3e4cbe..b102e109c3c 100644 --- a/crates/rome_diagnostics_categories/src/categories.rs +++ b/crates/rome_diagnostics_categories/src/categories.rs @@ -90,6 +90,7 @@ define_dategories! { "lint/nursery/noNoninteractiveElementToInteractiveRole": "https://docs.rome.tools/lint/rules/noNoninteractiveElementToInteractiveRole", "lint/nursery/useValidForDirection": "https://docs.rome.tools/lint/rules/useValidForDirection", "lint/nursery/useHookAtTopLevel": "https://docs.rome.tools/lint/rules/useHookAtTopLevel", + "lint/nursery/useSimpleNumberKeys": "https://docs.rome.tools/lint/rules/useSimpleNumberKeys", // Insert new nursery rule here // performance diff --git a/crates/rome_js_analyze/src/analyzers/nursery.rs b/crates/rome_js_analyze/src/analyzers/nursery.rs index 4573049d2b0..a1146d7673a 100644 --- a/crates/rome_js_analyze/src/analyzers/nursery.rs +++ b/crates/rome_js_analyze/src/analyzers/nursery.rs @@ -34,4 +34,5 @@ mod use_exponentiation_operator; mod use_is_nan; mod use_media_caption; mod use_numeric_literals; -declare_group! { pub (crate) Nursery { name : "nursery" , rules : [self :: no_access_key :: NoAccessKey , self :: no_assign_in_expressions :: NoAssignInExpressions , self :: no_banned_types :: NoBannedTypes , self :: no_comma_operator :: NoCommaOperator , self :: no_const_enum :: NoConstEnum , self :: no_constructor_return :: NoConstructorReturn , self :: no_distracting_elements :: NoDistractingElements , self :: no_duplicate_case :: NoDuplicateCase , self :: no_duplicate_object_keys :: NoDuplicateObjectKeys , self :: no_empty_interface :: NoEmptyInterface , self :: no_extra_non_null_assertion :: NoExtraNonNullAssertion , self :: no_extra_semicolons :: NoExtraSemicolons , self :: no_header_scope :: NoHeaderScope , self :: no_invalid_constructor_super :: NoInvalidConstructorSuper , self :: no_non_null_assertion :: NoNonNullAssertion , self :: no_precision_loss :: NoPrecisionLoss , self :: no_redundant_alt :: NoRedundantAlt , self :: no_redundant_use_strict :: NoRedundantUseStrict , self :: no_self_compare :: NoSelfCompare , self :: no_setter_return :: NoSetterReturn , self :: no_string_case_mismatch :: NoStringCaseMismatch , self :: no_unreachable_super :: NoUnreachableSuper , self :: no_unsafe_finally :: NoUnsafeFinally , self :: no_useless_switch_case :: NoUselessSwitchCase , self :: no_void_type_return :: NoVoidTypeReturn , self :: no_with :: NoWith , self :: use_default_parameter_last :: UseDefaultParameterLast , self :: use_default_switch_clause_last :: UseDefaultSwitchClauseLast , self :: use_enum_initializers :: UseEnumInitializers , self :: use_exponentiation_operator :: UseExponentiationOperator , self :: use_is_nan :: UseIsNan , self :: use_media_caption :: UseMediaCaption , self :: use_numeric_literals :: UseNumericLiterals ,] } } +mod use_simple_number_keys; +declare_group! { pub (crate) Nursery { name : "nursery" , rules : [self :: no_access_key :: NoAccessKey , self :: no_assign_in_expressions :: NoAssignInExpressions , self :: no_banned_types :: NoBannedTypes , self :: no_comma_operator :: NoCommaOperator , self :: no_const_enum :: NoConstEnum , self :: no_constructor_return :: NoConstructorReturn , self :: no_distracting_elements :: NoDistractingElements , self :: no_duplicate_case :: NoDuplicateCase , self :: no_duplicate_object_keys :: NoDuplicateObjectKeys , self :: no_empty_interface :: NoEmptyInterface , self :: no_extra_non_null_assertion :: NoExtraNonNullAssertion , self :: no_extra_semicolons :: NoExtraSemicolons , self :: no_header_scope :: NoHeaderScope , self :: no_invalid_constructor_super :: NoInvalidConstructorSuper , self :: no_non_null_assertion :: NoNonNullAssertion , self :: no_precision_loss :: NoPrecisionLoss , self :: no_redundant_alt :: NoRedundantAlt , self :: no_redundant_use_strict :: NoRedundantUseStrict , self :: no_self_compare :: NoSelfCompare , self :: no_setter_return :: NoSetterReturn , self :: no_string_case_mismatch :: NoStringCaseMismatch , self :: no_unreachable_super :: NoUnreachableSuper , self :: no_unsafe_finally :: NoUnsafeFinally , self :: no_useless_switch_case :: NoUselessSwitchCase , self :: no_void_type_return :: NoVoidTypeReturn , self :: no_with :: NoWith , self :: use_default_parameter_last :: UseDefaultParameterLast , self :: use_default_switch_clause_last :: UseDefaultSwitchClauseLast , self :: use_enum_initializers :: UseEnumInitializers , self :: use_exponentiation_operator :: UseExponentiationOperator , self :: use_is_nan :: UseIsNan , self :: use_media_caption :: UseMediaCaption , self :: use_numeric_literals :: UseNumericLiterals , self :: use_simple_number_keys :: UseSimpleNumberKeys ,] } } diff --git a/crates/rome_js_analyze/src/analyzers/nursery/use_simple_number_keys.rs b/crates/rome_js_analyze/src/analyzers/nursery/use_simple_number_keys.rs new file mode 100644 index 00000000000..8566dbe7107 --- /dev/null +++ b/crates/rome_js_analyze/src/analyzers/nursery/use_simple_number_keys.rs @@ -0,0 +1,212 @@ +use rome_analyze::{ + context::RuleContext, declare_rule, Rule, Ast, RuleDiagnostic +}; +use rome_js_syntax::JsLiteralMemberName; +use rome_js_syntax::JsSyntaxKind; +use rome_js_syntax::JsSyntaxToken; +use rome_rowan::AstNode; + +declare_rule! { + /// Put your description here + /// + /// ## Examples + /// + /// ### Invalid + /// + /// ```js,expect_diagnostic + /// var a = 1; + /// a = 2; + /// ``` + /// + /// ## Valid + /// + /// ```js + /// var a = 1; + /// ``` + /// + pub(crate) UseSimpleNumberKeys { + version: "next", + name: "useSimpleNumberKeys", + recommended: false, + } +} + +#[derive(Clone)] +pub enum NumberLiteral { + Binary{value: String, big_int: bool}, + Decimal{value: String, big_int: bool, dashed: bool}, + Octal{value: String, big_int: bool}, + Hexadecimal{value: String, big_int: bool}, + FloatingPoint{value: String, exponent: bool, dashed: bool} +} + +pub struct NumberLiteralError; + +impl TryFrom for NumberLiteral { + + type Error = NumberLiteralError; + + + fn try_from(token: JsSyntaxToken) -> Result { + match token.kind() { + JsSyntaxKind::JS_NUMBER_LITERAL | JsSyntaxKind::JS_BIG_INT_LITERAL => { + let chars: Vec = token.to_string().chars().collect(); + let mut value = String::new(); + + let mut is_first_char_zero: bool = false; + let mut is_second_char_a_letter: Option = None; + let mut contains_dot: bool = false; + let mut exponent: bool = false; + let mut largest_digit: char = '0'; + let mut dashed: bool = false; + let mut big_int: bool = false; + + + for i in 0..chars.len() { + if i == 0 && chars[i] == '0' && chars.len() > 1 { + is_first_char_zero = true; + continue; + } + + if chars[i] == 'n' { + big_int = true; + break; + } + + if i == 1 && chars[i].is_alphabetic() { + is_second_char_a_letter = Some(chars[i]); + continue; + } + + if chars[i] == '_' { + dashed = true; + } + + if chars[i] == '.' { + contains_dot = true; + } + + if contains_dot && (chars[i] == 'e' || chars[i] == 'E') { + exponent = true; + } + + if largest_digit < chars[i] { + largest_digit = chars[i]; + } + + value.push(chars[i]) + } + + if contains_dot {return Ok(Self::FloatingPoint{value, exponent, dashed})}; + if !is_first_char_zero {return Ok(Self::Decimal{value, big_int, dashed})}; + + match is_second_char_a_letter { + Some('b' | 'B') => {return Ok(Self::Binary{value, big_int})}, + Some('o' | 'O') => {return Ok(Self::Octal{value, big_int})}, + Some('x' | 'X' ) => {return Ok(Self::Hexadecimal{value, big_int})}, + _ => () + } + + if largest_digit < '8' { + return Ok(Self::Octal{value, big_int}) + } + + Ok(Self::Decimal{value, big_int, dashed}) + + } + _ => Err(NumberLiteralError) + } + } +} + +impl NumberLiteral { + fn value(self: &Self) -> &String { + return match self { + Self::Decimal { value, .. } => value, + Self::Binary { value, .. } => value, + Self::FloatingPoint { value,.. } => value, + Self::Octal { value, .. } => value, + Self::Hexadecimal { value, .. } => value + } + + } +} + +impl NumberLiteral { + fn to_base_ten(self: &Self) -> String { + let result = match self { + Self::Binary { value, .. } => { + i32::from_str_radix(value, 2).ok() + } + Self::Octal { value,.. } => { + i32::from_str_radix(value, 7).ok() + } + Self::Hexadecimal { value, ..} => {i32::from_str_radix(value, 16).ok()}, + _ => None + }; + + match result { + Some(value) => {return value.to_string();}, + None => {return self.value().to_string()} + } + } +} + +impl Rule for UseSimpleNumberKeys { + type Query = Ast; + type State = NumberLiteral; + type Signals = Vec; + type Options = (); + + fn run(ctx: &RuleContext) -> Self::Signals { + let mut signals: Self::Signals = Vec::new(); + let node = ctx.query(); + + if let Some(token) = node.value().ok() { + + let number_literal = NumberLiteral::try_from(token).ok(); + + match number_literal { + Some(number_literal) => { + match number_literal { + NumberLiteral::Decimal { big_int: true, .. } | NumberLiteral::Decimal { dashed: true, .. } => {signals.push(number_literal)}, + NumberLiteral::FloatingPoint { dashed: true, .. } => {signals.push(number_literal)}, + NumberLiteral::Binary { .. } => {signals.push(number_literal)} + NumberLiteral::Hexadecimal { .. } => {signals.push(number_literal)} + NumberLiteral::Octal { .. } => {signals.push(number_literal)} + _ => () + } + }, + None => (), + } + } + + signals + } + + fn diagnostic( + _ctx: &RuleContext, + number_literal: &Self::State + ) -> Option { + + + let title = match number_literal { + NumberLiteral::Decimal { big_int: true, .. } => { "Bigint is not allowed"}, + NumberLiteral::Decimal { dashed: true, .. } => { "Dashed number literal is not allowed"}, + NumberLiteral::FloatingPoint { dashed: true, .. } => { "Dashed number literal is not allowed" }, + NumberLiteral::Binary { .. } => { "Number literal in binary format is not allowed" }, + NumberLiteral::Hexadecimal { .. } => { "Number literal in hexadecimal format is not allowed"}, + NumberLiteral::Octal { .. } => { "Number literal in octal format is not allowed"}, + _ => {""} + }; + + let diagnostic = RuleDiagnostic::new( + rule_category!(), + _ctx.query().range(), + format!("{}", title), + ); + + Some(diagnostic) + } + +} diff --git a/crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys/invalid.js b/crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys/invalid.js new file mode 100644 index 00000000000..3bf9c74f6f3 --- /dev/null +++ b/crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys/invalid.js @@ -0,0 +1,9 @@ +({ 1n: 1 }); +({ 0x1: 1 }); +({ 012: 1 }); +({ 0b1: 1 }); +({ 0o1: 1 }); +({ 1_0: 1 }); +({ .1e1_2: "ee" }); +({ 11_1.11: "ee" }); + diff --git a/crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys/invalid.js.snap.new b/crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys/invalid.js.snap.new new file mode 100644 index 00000000000..072687bb19e --- /dev/null +++ b/crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys/invalid.js.snap.new @@ -0,0 +1,153 @@ +--- +source: crates/rome_js_analyze/tests/spec_tests.rs +assertion_line: 92 +expression: invalid.js +--- +# Input +```js +({ 1n: 1 }); +({ 0x1: 1 }); +({ 012: 1 }); +({ 0b1: 1 }); +({ 0o1: 1 }); +({ 1_0: 1 }); +({ .1e1_2: "ee" }); +({ 11_1.11: "ee" }); +({ 11_1.11: "ee" }); + + +``` + +# Diagnostics +``` +invalid.js:1:4 lint/nursery/useSimpleNumberKeys ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Bigint is not allowed + + > 1 │ ({ 1n: 1 }); + │ ^^ + 2 │ ({ 0x1: 1 }); + 3 │ ({ 012: 1 }); + + +``` + +``` +invalid.js:2:4 lint/nursery/useSimpleNumberKeys ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Number literal in hexadecimal format is not allowed + + 1 │ ({ 1n: 1 }); + > 2 │ ({ 0x1: 1 }); + │ ^^^ + 3 │ ({ 012: 1 }); + 4 │ ({ 0b1: 1 }); + + +``` + +``` +invalid.js:3:4 lint/nursery/useSimpleNumberKeys ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Number literal in octal format is not allowed + + 1 │ ({ 1n: 1 }); + 2 │ ({ 0x1: 1 }); + > 3 │ ({ 012: 1 }); + │ ^^^ + 4 │ ({ 0b1: 1 }); + 5 │ ({ 0o1: 1 }); + + +``` + +``` +invalid.js:4:4 lint/nursery/useSimpleNumberKeys ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Number literal in binary format is not allowed + + 2 │ ({ 0x1: 1 }); + 3 │ ({ 012: 1 }); + > 4 │ ({ 0b1: 1 }); + │ ^^^ + 5 │ ({ 0o1: 1 }); + 6 │ ({ 1_0: 1 }); + + +``` + +``` +invalid.js:5:4 lint/nursery/useSimpleNumberKeys ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Number literal in octal format is not allowed + + 3 │ ({ 012: 1 }); + 4 │ ({ 0b1: 1 }); + > 5 │ ({ 0o1: 1 }); + │ ^^^ + 6 │ ({ 1_0: 1 }); + 7 │ ({ .1e1_2: "ee" }); + + +``` + +``` +invalid.js:6:4 lint/nursery/useSimpleNumberKeys ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Dashed number literal is not allowed + + 4 │ ({ 0b1: 1 }); + 5 │ ({ 0o1: 1 }); + > 6 │ ({ 1_0: 1 }); + │ ^^^ + 7 │ ({ .1e1_2: "ee" }); + 8 │ ({ 11_1.11: "ee" }); + + +``` + +``` +invalid.js:7:4 lint/nursery/useSimpleNumberKeys ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Dashed number literal is not allowed + + 5 │ ({ 0o1: 1 }); + 6 │ ({ 1_0: 1 }); + > 7 │ ({ .1e1_2: "ee" }); + │ ^^^^^^ + 8 │ ({ 11_1.11: "ee" }); + 9 │ ({ 11_1.11: "ee" }); + + +``` + +``` +invalid.js:8:4 lint/nursery/useSimpleNumberKeys ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Dashed number literal is not allowed + + 6 │ ({ 1_0: 1 }); + 7 │ ({ .1e1_2: "ee" }); + > 8 │ ({ 11_1.11: "ee" }); + │ ^^^^^^^ + 9 │ ({ 11_1.11: "ee" }); + 10 │ + + +``` + +``` +invalid.js:9:4 lint/nursery/useSimpleNumberKeys ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Dashed number literal is not allowed + + 7 │ ({ .1e1_2: "ee" }); + 8 │ ({ 11_1.11: "ee" }); + > 9 │ ({ 11_1.11: "ee" }); + │ ^^^^^^^ + 10 │ + + +``` + + diff --git a/crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys/valid.js b/crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys/valid.js new file mode 100644 index 00000000000..cdf441f6ad0 --- /dev/null +++ b/crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys/valid.js @@ -0,0 +1,9 @@ +/* should not generate diagnostics */ + +({ name: 1, monkey: 2 }); + +({ 0: "zero" }); +({ 1: "one" }); +({ 1.2: "12" }); +({ 3.1e12: "12" }); +({ .1e12: "ee" }); diff --git a/crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys/valid.js.snap.new b/crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys/valid.js.snap.new new file mode 100644 index 00000000000..e4f38304543 --- /dev/null +++ b/crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys/valid.js.snap.new @@ -0,0 +1,20 @@ +--- +source: crates/rome_js_analyze/tests/spec_tests.rs +assertion_line: 92 +expression: valid.js +--- +# Input +```js +/* should not generate diagnostics */ + +({ name: 1, monkey: 2 }); + +({ 0: "zero" }); +({ 1: "one" }); +({ 1.2: "12" }); +({ 3.1e12: "12" }); +({ .1e12: "ee" }); + +``` + + diff --git a/crates/rome_js_unicode_table/src/tables.rs b/crates/rome_js_unicode_table/src/tables.rs index 7f67057597c..eb783866c93 100644 --- a/crates/rome_js_unicode_table/src/tables.rs +++ b/crates/rome_js_unicode_table/src/tables.rs @@ -787,9 +787,7 @@ pub mod derived_property { ('\u{31350}', '\u{323af}'), ('\u{e0100}', '\u{e01ef}'), ]; - pub fn ID_Continue(c: char) -> bool { - super::bsearch_range_table(c, ID_Continue_table) - } + pub fn ID_Continue(c: char) -> bool { super::bsearch_range_table(c, ID_Continue_table) } pub const ID_Start_table: &[(char, char)] = &[ ('A', 'Z'), ('a', 'z'), @@ -1451,7 +1449,5 @@ pub mod derived_property { ('𰀀', '𱍊'), ('\u{31350}', '\u{323af}'), ]; - pub fn ID_Start(c: char) -> bool { - super::bsearch_range_table(c, ID_Start_table) - } + pub fn ID_Start(c: char) -> bool { super::bsearch_range_table(c, ID_Start_table) } } diff --git a/crates/rome_service/src/configuration/linter/rules.rs b/crates/rome_service/src/configuration/linter/rules.rs index 44a929d89ac..d3ec4d1d7c8 100644 --- a/crates/rome_service/src/configuration/linter/rules.rs +++ b/crates/rome_service/src/configuration/linter/rules.rs @@ -819,6 +819,8 @@ struct NurserySchema { use_media_caption: Option, #[doc = "Disallow parseInt() and Number.parseInt() in favor of binary, octal, and hexadecimal literals"] use_numeric_literals: Option, + #[doc = "Disallow use of number literal in format other than decimal as object member name"] + use_simple_number_keys: Option, #[doc = "Ensures that ARIA properties aria-* are all valid."] use_valid_aria_props: Option, #[doc = "Ensure that the attribute passed to the lang attribute is a correct ISO language and/or country."] @@ -826,7 +828,7 @@ struct NurserySchema { } impl Nursery { const CATEGORY_NAME: &'static str = "nursery"; - pub(crate) const CATEGORY_RULES: [&'static str; 46] = [ + pub(crate) const CATEGORY_RULES: [&'static str; 47] = [ "noAccessKey", "noAssignInExpressions", "noBannedTypes", @@ -871,6 +873,7 @@ impl Nursery { "useIsNan", "useMediaCaption", "useNumericLiterals", + "useSimpleNumberKeys", "useValidAriaProps", "useValidLang", ]; @@ -949,8 +952,8 @@ impl Nursery { RuleFilter::Rule("nursery", Self::CATEGORY_RULES[41]), RuleFilter::Rule("nursery", Self::CATEGORY_RULES[42]), RuleFilter::Rule("nursery", Self::CATEGORY_RULES[43]), - RuleFilter::Rule("nursery", Self::CATEGORY_RULES[44]), RuleFilter::Rule("nursery", Self::CATEGORY_RULES[45]), + RuleFilter::Rule("nursery", Self::CATEGORY_RULES[46]), ]; pub(crate) fn is_recommended(&self) -> bool { !matches!(self.recommended, Some(false)) } pub(crate) fn get_enabled_rules(&self) -> IndexSet { diff --git a/editors/vscode/configuration_schema.json b/editors/vscode/configuration_schema.json index a06ae3c2278..d5c5736e9f8 100644 --- a/editors/vscode/configuration_schema.json +++ b/editors/vscode/configuration_schema.json @@ -1079,6 +1079,17 @@ } ] }, + "useSimpleNumberKeys": { + "description": "Disallow use of number literal in format other than decimal as object member name", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, "useValidAriaProps": { "description": "Ensures that ARIA properties aria-* are all valid.", "anyOf": [ diff --git a/npm/backend-jsonrpc/src/workspace.ts b/npm/backend-jsonrpc/src/workspace.ts index 743c47bfdc4..9093dd8ab89 100644 --- a/npm/backend-jsonrpc/src/workspace.ts +++ b/npm/backend-jsonrpc/src/workspace.ts @@ -89,7 +89,7 @@ export interface JavascriptConfiguration { /** * A list of global bindings that should be ignored by the analyzers -If defined here, they should not emit diagnostics. +If defined here, they should not emit diagnostics. */ globals?: string[]; } @@ -111,7 +111,7 @@ export type PlainIndentStyle = "tab" | "space"; /** * Validated value for the `line_width` formatter options -The allowed range of values is 1..=320 +The allowed range of values is 1..=320 */ export type LineWidth = number; export interface JavascriptFormatter { @@ -469,6 +469,10 @@ export interface Nursery { * Disallow parseInt() and Number.parseInt() in favor of binary, octal, and hexadecimal literals */ useNumericLiterals?: RuleConfiguration; + /** + * Disallow use of number literal in format other than decimal as object member name + */ + useSimpleNumberKeys?: RuleConfiguration; /** * Ensures that ARIA properties aria-* are all valid. */ @@ -794,6 +798,7 @@ export type Category = | "lint/nursery/noNoninteractiveElementToInteractiveRole" | "lint/nursery/useValidForDirection" | "lint/nursery/useHookAtTopLevel" + | "lint/nursery/useSimpleNumberKeys" | "lint/performance/noDelete" | "lint/security/noDangerouslySetInnerHtml" | "lint/security/noDangerouslySetInnerHtmlWithChildren" @@ -866,7 +871,7 @@ export type DiagnosticTags = DiagnosticTag[]; /** * Serializable representation of a [Diagnostic](super::Diagnostic) advice -See the [Visitor] trait for additional documentation on all the supported advice types. +See the [Visitor] trait for additional documentation on all the supported advice types. */ export type Advice = | { Log: [LogCategory, MarkupBuf] } @@ -964,7 +969,7 @@ export interface CodeAction { /** * The category of a code action, this type maps directly to the [CodeActionKind] type in the Language Server Protocol specification -[CodeActionKind]: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#codeActionKind +[CodeActionKind]: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#codeActionKind */ export type ActionCategory = | "QuickFix" @@ -1091,7 +1096,7 @@ export interface RenameResult { } export interface Workspace { supportsFeature( - params: SupportsFeatureParams, + params: SupportsFeatureParams ): Promise; updateSettings(params: UpdateSettingsParams): Promise; openFile(params: OpenFileParams): Promise; @@ -1101,7 +1106,7 @@ export interface Workspace { getControlFlowGraph(params: GetControlFlowGraphParams): Promise; getFormatterIr(params: GetFormatterIRParams): Promise; pullDiagnostics( - params: PullDiagnosticsParams, + params: PullDiagnosticsParams ): Promise; pullActions(params: PullActionsParams): Promise; formatFile(params: FormatFileParams): Promise; diff --git a/npm/rome/configuration_schema.json b/npm/rome/configuration_schema.json index a06ae3c2278..989a9373149 100644 --- a/npm/rome/configuration_schema.json +++ b/npm/rome/configuration_schema.json @@ -1079,6 +1079,17 @@ } ] }, + "useSimpleNumberKeys": { + "description": "Disallow use of number literal in format other than decimal as object member name", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, "useValidAriaProps": { "description": "Ensures that ARIA properties aria-* are all valid.", "anyOf": [ @@ -1669,4 +1680,4 @@ ] } } -} \ No newline at end of file +} diff --git a/website/src/pages/lint/rules/index.mdx b/website/src/pages/lint/rules/index.mdx index ca627211659..47280e79391 100644 --- a/website/src/pages/lint/rules/index.mdx +++ b/website/src/pages/lint/rules/index.mdx @@ -9,10 +9,10 @@ mainClass: rules # Rules - ## Accessibility Rules focused on preventing accessibility problems. +

@@ -93,6 +93,7 @@ Enforce that all anchors are valid, and they are navigable elements. ## Complexity Rules that focus on inspecting complex code that could be simplified. +

@@ -141,6 +142,7 @@ Discard redundant terms from logical expressions. ## Correctness Rules that detect code that is guaranteed to be incorrect or useless. +

@@ -223,6 +225,7 @@ Enforce "for" loop update clause moving the counter in the right direc ## Performance Rules catching ways your code could be written to run faster, or generally be more efficient. +

@@ -237,6 +240,7 @@ Disallow the use of the delete operator ## Security Rules that detect potential security flaws. +

@@ -258,6 +262,7 @@ Report when a DOM element or a component uses both children and

@@ -352,6 +357,7 @@ initializer and update expressions are not needed ## Suspicious Rules that detect code that is likely to be incorrect or useless. +

@@ -480,6 +486,7 @@ warning, depending on whether we intend for the rule to be recommended or not wh Nursery rules get promoted to other groups once they become stable or may be removed. Rules that belong to this group are not subject to semantic version. +

@@ -753,6 +760,12 @@ Enforces that audio and video elements must have a parseInt() and Number.parseInt() in favor of binary, octal, and hexadecimal literals

+

+ useSimpleNumberKeys +

+Disallow use of number literal in format other than decimal as object member name +
+

useValidAriaProps

diff --git a/website/src/pages/lint/rules/useSimpleNumberKeys.md b/website/src/pages/lint/rules/useSimpleNumberKeys.md new file mode 100644 index 00000000000..4c216e8bb34 --- /dev/null +++ b/website/src/pages/lint/rules/useSimpleNumberKeys.md @@ -0,0 +1,36 @@ +--- +title: Lint Rule useSimpleNumberKeys +parent: lint/rules/index +--- + +# useSimpleNumberKeys (since vnext) + +Disallow use of number literal in format other than decimal as object member name + +## Examples + +### Invalid + +```jsx +var a = 1; +a = 2; +``` + +
nursery/useSimpleNumberKeys.js:2:1 lint/nursery/useSimpleNumberKeys ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+
+   Variable is read here
+
+    1 │ var a = 1;
+  > 2 │ a = 2;
+   ^
+    3 │ 
+
+   This note will give you more information
+
+
+ +## Valid + +```jsx +var a = 1; +``` From 3873fe3c24cb0b786a520f8c9ac2d2a129deb010 Mon Sep 17 00:00:00 2001 From: Dhiraj Arun Date: Tue, 27 Dec 2022 22:16:29 +0530 Subject: [PATCH 2/8] done --- .../nursery/use_simple_number_keys.rs | 384 ++++++++++-------- .../specs/nursery/noDuplicateObjectKeys.js | 8 - .../nursery/noDuplicateObjectKeys.js.snap | 8 - .../specs/nursery/useSimpleNumberKeys.js | 18 + .../specs/nursery/useSimpleNumberKeys.js.snap | 220 ++++++++++ .../nursery/useSimpleNumberKeys/invalid.js | 9 - .../useSimpleNumberKeys/invalid.js.snap.new | 153 ------- .../nursery/useSimpleNumberKeys/valid.js | 9 - .../useSimpleNumberKeys/valid.js.snap.new | 20 - crates/rome_js_unicode_table/src/tables.rs | 8 +- 10 files changed, 465 insertions(+), 372 deletions(-) create mode 100644 crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys.js create mode 100644 crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys.js.snap delete mode 100644 crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys/invalid.js delete mode 100644 crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys/invalid.js.snap.new delete mode 100644 crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys/valid.js delete mode 100644 crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys/valid.js.snap.new diff --git a/crates/rome_js_analyze/src/analyzers/nursery/use_simple_number_keys.rs b/crates/rome_js_analyze/src/analyzers/nursery/use_simple_number_keys.rs index 8566dbe7107..f1009b7152a 100644 --- a/crates/rome_js_analyze/src/analyzers/nursery/use_simple_number_keys.rs +++ b/crates/rome_js_analyze/src/analyzers/nursery/use_simple_number_keys.rs @@ -1,27 +1,32 @@ -use rome_analyze::{ - context::RuleContext, declare_rule, Rule, Ast, RuleDiagnostic -}; -use rome_js_syntax::JsLiteralMemberName; -use rome_js_syntax::JsSyntaxKind; -use rome_js_syntax::JsSyntaxToken; -use rome_rowan::AstNode; +use crate::JsRuleAction; +use rome_analyze::{context::RuleContext, declare_rule, ActionCategory, Ast, Rule, RuleDiagnostic}; +use rome_console::markup; +use rome_diagnostics::Applicability; +use rome_js_factory::make; +use rome_js_syntax::{JsLiteralMemberName, JsSyntaxKind, JsSyntaxToken}; +use rome_rowan::{AstNode, BatchMutationExt}; +use std::str::FromStr; declare_rule! { - /// Put your description here + /// Disallow number literal object member names which are not base10 or uses underscore as separator /// /// ## Examples /// /// ### Invalid /// /// ```js,expect_diagnostic - /// var a = 1; - /// a = 2; + /// ({ 0x1: 1 }); + /// ({ 11_1.11: "ee" }); + /// ({ 0o1: 1 }); + /// ({ 1n: 1 }); + /// ({ 11_1.11: "ee" }); /// ``` /// /// ## Valid /// /// ```js - /// var a = 1; + /// ({ 0: "zero" }); + /// ({ 3.1e12: "12" }); /// ``` /// pub(crate) UseSimpleNumberKeys { @@ -33,180 +38,233 @@ declare_rule! { #[derive(Clone)] pub enum NumberLiteral { - Binary{value: String, big_int: bool}, - Decimal{value: String, big_int: bool, dashed: bool}, - Octal{value: String, big_int: bool}, - Hexadecimal{value: String, big_int: bool}, - FloatingPoint{value: String, exponent: bool, dashed: bool} + Binary { + value: String, + big_int: bool, + }, + Decimal { + value: String, + big_int: bool, + underscore: bool, + }, + Octal { + value: String, + big_int: bool, + }, + Hexadecimal { + value: String, + big_int: bool, + }, + FloatingPoint { + value: String, + exponent: bool, + underscore: bool, + }, } pub struct NumberLiteralError; impl TryFrom for NumberLiteral { - - type Error = NumberLiteralError; - - - fn try_from(token: JsSyntaxToken) -> Result { - match token.kind() { - JsSyntaxKind::JS_NUMBER_LITERAL | JsSyntaxKind::JS_BIG_INT_LITERAL => { - let chars: Vec = token.to_string().chars().collect(); - let mut value = String::new(); - - let mut is_first_char_zero: bool = false; - let mut is_second_char_a_letter: Option = None; - let mut contains_dot: bool = false; - let mut exponent: bool = false; - let mut largest_digit: char = '0'; - let mut dashed: bool = false; - let mut big_int: bool = false; - - - for i in 0..chars.len() { - if i == 0 && chars[i] == '0' && chars.len() > 1 { - is_first_char_zero = true; - continue; - } - - if chars[i] == 'n' { - big_int = true; - break; - } - - if i == 1 && chars[i].is_alphabetic() { - is_second_char_a_letter = Some(chars[i]); - continue; - } - - if chars[i] == '_' { - dashed = true; - } - - if chars[i] == '.' { - contains_dot = true; - } - - if contains_dot && (chars[i] == 'e' || chars[i] == 'E') { - exponent = true; - } - - if largest_digit < chars[i] { - largest_digit = chars[i]; - } - - value.push(chars[i]) - } - - if contains_dot {return Ok(Self::FloatingPoint{value, exponent, dashed})}; - if !is_first_char_zero {return Ok(Self::Decimal{value, big_int, dashed})}; - - match is_second_char_a_letter { - Some('b' | 'B') => {return Ok(Self::Binary{value, big_int})}, - Some('o' | 'O') => {return Ok(Self::Octal{value, big_int})}, - Some('x' | 'X' ) => {return Ok(Self::Hexadecimal{value, big_int})}, - _ => () - } - - if largest_digit < '8' { - return Ok(Self::Octal{value, big_int}) - } - - Ok(Self::Decimal{value, big_int, dashed}) - - } - _ => Err(NumberLiteralError) - } - } + type Error = NumberLiteralError; + + fn try_from(token: JsSyntaxToken) -> Result { + match token.kind() { + JsSyntaxKind::JS_NUMBER_LITERAL | JsSyntaxKind::JS_BIG_INT_LITERAL => { + let chars: Vec = token.to_string().chars().collect(); + let mut value = String::new(); + + let mut is_first_char_zero: bool = false; + let mut is_second_char_a_letter: Option = None; + let mut contains_dot: bool = false; + let mut exponent: bool = false; + let mut largest_digit: char = '0'; + let mut underscore: bool = false; + let mut big_int: bool = false; + + for i in 0..chars.len() { + if i == 0 && chars[i] == '0' && chars.len() > 1 { + is_first_char_zero = true; + continue; + } + + if chars[i] == 'n' { + big_int = true; + break; + } + + if chars[i] == 'e' || chars[i] == 'E' { + exponent = true; + } + + if i == 1 && chars[i].is_alphabetic() && exponent == false { + is_second_char_a_letter = Some(chars[i]); + continue; + } + + if chars[i] == '_' { + underscore = true; + continue; + } + + if chars[i] == '.' { + contains_dot = true; + } + + if largest_digit < chars[i] { + largest_digit = chars[i]; + } + + value.push(chars[i]) + } + + if contains_dot { + return Ok(Self::FloatingPoint { + value, + exponent, + underscore, + }); + }; + if !is_first_char_zero { + return Ok(Self::Decimal { + value, + big_int, + underscore, + }); + }; + + match is_second_char_a_letter { + Some('b' | 'B') => return Ok(Self::Binary { value, big_int }), + Some('o' | 'O') => return Ok(Self::Octal { value, big_int }), + Some('x' | 'X') => return Ok(Self::Hexadecimal { value, big_int }), + _ => (), + } + + if largest_digit < '8' { + return Ok(Self::Octal { value, big_int }); + } + + Ok(Self::Decimal { + value, + big_int, + underscore, + }) + } + _ => Err(NumberLiteralError), + } + } } impl NumberLiteral { - fn value(self: &Self) -> &String { - return match self { - Self::Decimal { value, .. } => value, - Self::Binary { value, .. } => value, - Self::FloatingPoint { value,.. } => value, - Self::Octal { value, .. } => value, - Self::Hexadecimal { value, .. } => value - } - - } + fn value(&self) -> &String { + match self { + Self::Decimal { value, .. } => value, + Self::Binary { value, .. } => value, + Self::FloatingPoint { value, .. } => value, + Self::Octal { value, .. } => value, + Self::Hexadecimal { value, .. } => value, + } + } } impl NumberLiteral { - fn to_base_ten(self: &Self) -> String { - let result = match self { - Self::Binary { value, .. } => { - i32::from_str_radix(value, 2).ok() - } - Self::Octal { value,.. } => { - i32::from_str_radix(value, 7).ok() - } - Self::Hexadecimal { value, ..} => {i32::from_str_radix(value, 16).ok()}, - _ => None - }; - - match result { - Some(value) => {return value.to_string();}, - None => {return self.value().to_string()} - } - } + fn to_base_ten(&self) -> Option { + match self { + Self::Binary { value, .. } => i64::from_str_radix(value, 2).map(|num| num as f64).ok(), + Self::Decimal { value, .. } | Self::FloatingPoint { value, .. } => { + f64::from_str(value).ok() + } + Self::Octal { value, .. } => i64::from_str_radix(value, 7).map(|num| num as f64).ok(), + Self::Hexadecimal { value, .. } => { + i64::from_str_radix(value, 16).map(|num| num as f64).ok() + } + } + } } impl Rule for UseSimpleNumberKeys { type Query = Ast; type State = NumberLiteral; - type Signals = Vec; + type Signals = Vec; type Options = (); fn run(ctx: &RuleContext) -> Self::Signals { - let mut signals: Self::Signals = Vec::new(); - let node = ctx.query(); - - if let Some(token) = node.value().ok() { - - let number_literal = NumberLiteral::try_from(token).ok(); - - match number_literal { - Some(number_literal) => { - match number_literal { - NumberLiteral::Decimal { big_int: true, .. } | NumberLiteral::Decimal { dashed: true, .. } => {signals.push(number_literal)}, - NumberLiteral::FloatingPoint { dashed: true, .. } => {signals.push(number_literal)}, - NumberLiteral::Binary { .. } => {signals.push(number_literal)} - NumberLiteral::Hexadecimal { .. } => {signals.push(number_literal)} - NumberLiteral::Octal { .. } => {signals.push(number_literal)} - _ => () - } - }, - None => (), - } - } - - signals + let mut signals: Self::Signals = Vec::new(); + let node = ctx.query(); + + if let Ok(token) = node.value() { + let number_literal = NumberLiteral::try_from(token).ok(); + + if let Some(number_literal) = number_literal { + match number_literal { + NumberLiteral::Decimal { big_int: true, .. } + | NumberLiteral::Decimal { + underscore: true, .. + } => signals.push(number_literal), + NumberLiteral::FloatingPoint { + underscore: true, .. + } => signals.push(number_literal), + NumberLiteral::Binary { .. } => signals.push(number_literal), + NumberLiteral::Hexadecimal { .. } => signals.push(number_literal), + NumberLiteral::Octal { .. } => signals.push(number_literal), + _ => (), + } + } + } + + signals } - fn diagnostic( + fn diagnostic( _ctx: &RuleContext, - number_literal: &Self::State + number_literal: &Self::State, ) -> Option { + let title = match number_literal { + NumberLiteral::Decimal { big_int: true, .. } => "Bigint is not allowed", + NumberLiteral::Decimal { + underscore: true, .. + } => "Number literal with underscore is not allowed", + NumberLiteral::FloatingPoint { + underscore: true, .. + } => "Number literal with underscore is not allowed", + NumberLiteral::Binary { .. } => "Number literal in binary format is not allowed", + NumberLiteral::Hexadecimal { .. } => { + "Number literal in hexadecimal format is not allowed" + } + NumberLiteral::Octal { .. } => "Number literal in octal format is not allowed", + _ => "", + }; + + let diagnostic = + RuleDiagnostic::new(rule_category!(), _ctx.query().range(), title.to_string()); + + Some(diagnostic) + } - - let title = match number_literal { - NumberLiteral::Decimal { big_int: true, .. } => { "Bigint is not allowed"}, - NumberLiteral::Decimal { dashed: true, .. } => { "Dashed number literal is not allowed"}, - NumberLiteral::FloatingPoint { dashed: true, .. } => { "Dashed number literal is not allowed" }, - NumberLiteral::Binary { .. } => { "Number literal in binary format is not allowed" }, - NumberLiteral::Hexadecimal { .. } => { "Number literal in hexadecimal format is not allowed"}, - NumberLiteral::Octal { .. } => { "Number literal in octal format is not allowed"}, - _ => {""} - }; - - let diagnostic = RuleDiagnostic::new( - rule_category!(), - _ctx.query().range(), - format!("{}", title), - ); - - Some(diagnostic) - } - + fn action(ctx: &RuleContext, number_literal: &Self::State) -> Option { + let mut mutation = ctx.root().begin(); + let node = ctx.query(); + + if let Ok(token) = node.value() { + match number_literal { + NumberLiteral::Binary { .. } + | NumberLiteral::Octal { .. } + | NumberLiteral::Hexadecimal { .. } => mutation.replace_token( + token, + make::js_number_literal(number_literal.to_base_ten()?), + ), + NumberLiteral::FloatingPoint { .. } | NumberLiteral::Decimal { .. } => { + mutation.replace_token(token, make::js_number_literal(number_literal.value())); + } + }; + + return Some(JsRuleAction { + category: ActionCategory::QuickFix, + applicability: Applicability::Always, + message: markup! ("Remove "{ node.to_string() }).to_owned(), + mutation, + }); + } + + None + } } diff --git a/crates/rome_js_analyze/tests/specs/nursery/noDuplicateObjectKeys.js b/crates/rome_js_analyze/tests/specs/nursery/noDuplicateObjectKeys.js index 2537b483313..53a36af7fc4 100644 --- a/crates/rome_js_analyze/tests/specs/nursery/noDuplicateObjectKeys.js +++ b/crates/rome_js_analyze/tests/specs/nursery/noDuplicateObjectKeys.js @@ -16,14 +16,6 @@ // valid for now -// ESLint already catches properties keyed with different-formatted number literals, we haven't implemented it yet. -({ 0x1: 1, 1: 2 }); -({ 012: 1, 10: 2 }); -({ 0b1: 1, 1: 2 }); -({ 0o1: 1, 1: 2 }); -({ 1n: 1, 1: 2 }); -({ 1_0: 1, 10: 2 }); - // This particular simple computed property case with just a string literal would be easy to catch, // but we don't want to open Pandora's static analysis box so we have to draw a line somewhere ({ a: 1, ["a"]: 1 }); diff --git a/crates/rome_js_analyze/tests/specs/nursery/noDuplicateObjectKeys.js.snap b/crates/rome_js_analyze/tests/specs/nursery/noDuplicateObjectKeys.js.snap index 6b597690aa6..8abf6c1eba8 100644 --- a/crates/rome_js_analyze/tests/specs/nursery/noDuplicateObjectKeys.js.snap +++ b/crates/rome_js_analyze/tests/specs/nursery/noDuplicateObjectKeys.js.snap @@ -22,14 +22,6 @@ expression: noDuplicateObjectKeys.js // valid for now -// ESLint already catches properties keyed with different-formatted number literals, we haven't implemented it yet. -({ 0x1: 1, 1: 2 }); -({ 012: 1, 10: 2 }); -({ 0b1: 1, 1: 2 }); -({ 0o1: 1, 1: 2 }); -({ 1n: 1, 1: 2 }); -({ 1_0: 1, 10: 2 }); - // This particular simple computed property case with just a string literal would be easy to catch, // but we don't want to open Pandora's static analysis box so we have to draw a line somewhere ({ a: 1, ["a"]: 1 }); diff --git a/crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys.js b/crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys.js new file mode 100644 index 00000000000..a60a1289263 --- /dev/null +++ b/crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys.js @@ -0,0 +1,18 @@ +// invalid + +({ 1n: 1 }); +({ 0x1: 1 }); +({ 012: 1 }); +({ 0b1: 1 }); +({ 0o1: 1 }); +({ 1_0: 1 }); +({ 0.1e1_2: "ee" }); +({ 11_1.11: "ee" }); + +// valid + +({ 0: "zero" }); +({ 1: "one" }); +({ 1.2: "12" }); +({ 3.1e12: "12" }); +({ 0.1e12: "ee" }); diff --git a/crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys.js.snap b/crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys.js.snap new file mode 100644 index 00000000000..3d976f83cc5 --- /dev/null +++ b/crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys.js.snap @@ -0,0 +1,220 @@ +--- +source: crates/rome_js_analyze/tests/spec_tests.rs +expression: useSimpleNumberKeys.js +--- +# Input +```js +// invalid + +({ 1n: 1 }); +({ 0x1: 1 }); +({ 012: 1 }); +({ 0b1: 1 }); +({ 0o1: 1 }); +({ 1_0: 1 }); +({ 0.1e1_2: "ee" }); +({ 11_1.11: "ee" }); + +// valid + +({ 0: "zero" }); +({ 1: "one" }); +({ 1.2: "12" }); +({ 3.1e12: "12" }); +({ 0.1e12: "ee" }); + +``` + +# Diagnostics +``` +useSimpleNumberKeys.js:3:4 lint/nursery/useSimpleNumberKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Bigint is not allowed + + 1 │ // invalid + 2 │ + > 3 │ ({ 1n: 1 }); + │ ^^ + 4 │ ({ 0x1: 1 }); + 5 │ ({ 012: 1 }); + + i Safe fix: Remove 1n + + 1 1 │ // invalid + 2 2 │ + 3 │ - ({·1n:·1·}); + 3 │ + ({·1:·1·}); + 4 4 │ ({ 0x1: 1 }); + 5 5 │ ({ 012: 1 }); + + +``` + +``` +useSimpleNumberKeys.js:4:4 lint/nursery/useSimpleNumberKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Number literal in hexadecimal format is not allowed + + 3 │ ({ 1n: 1 }); + > 4 │ ({ 0x1: 1 }); + │ ^^^ + 5 │ ({ 012: 1 }); + 6 │ ({ 0b1: 1 }); + + i Safe fix: Remove 0x1 + + 2 2 │ + 3 3 │ ({ 1n: 1 }); + 4 │ - ({·0x1:·1·}); + 4 │ + ({·1:·1·}); + 5 5 │ ({ 012: 1 }); + 6 6 │ ({ 0b1: 1 }); + + +``` + +``` +useSimpleNumberKeys.js:5:4 lint/nursery/useSimpleNumberKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Number literal in octal format is not allowed + + 3 │ ({ 1n: 1 }); + 4 │ ({ 0x1: 1 }); + > 5 │ ({ 012: 1 }); + │ ^^^ + 6 │ ({ 0b1: 1 }); + 7 │ ({ 0o1: 1 }); + + i Safe fix: Remove 012 + + 3 3 │ ({ 1n: 1 }); + 4 4 │ ({ 0x1: 1 }); + 5 │ - ({·012:·1·}); + 5 │ + ({·9:·1·}); + 6 6 │ ({ 0b1: 1 }); + 7 7 │ ({ 0o1: 1 }); + + +``` + +``` +useSimpleNumberKeys.js:6:4 lint/nursery/useSimpleNumberKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Number literal in binary format is not allowed + + 4 │ ({ 0x1: 1 }); + 5 │ ({ 012: 1 }); + > 6 │ ({ 0b1: 1 }); + │ ^^^ + 7 │ ({ 0o1: 1 }); + 8 │ ({ 1_0: 1 }); + + i Safe fix: Remove 0b1 + + 4 4 │ ({ 0x1: 1 }); + 5 5 │ ({ 012: 1 }); + 6 │ - ({·0b1:·1·}); + 6 │ + ({·1:·1·}); + 7 7 │ ({ 0o1: 1 }); + 8 8 │ ({ 1_0: 1 }); + + +``` + +``` +useSimpleNumberKeys.js:7:4 lint/nursery/useSimpleNumberKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Number literal in octal format is not allowed + + 5 │ ({ 012: 1 }); + 6 │ ({ 0b1: 1 }); + > 7 │ ({ 0o1: 1 }); + │ ^^^ + 8 │ ({ 1_0: 1 }); + 9 │ ({ 0.1e1_2: "ee" }); + + i Safe fix: Remove 0o1 + + 5 5 │ ({ 012: 1 }); + 6 6 │ ({ 0b1: 1 }); + 7 │ - ({·0o1:·1·}); + 7 │ + ({·1:·1·}); + 8 8 │ ({ 1_0: 1 }); + 9 9 │ ({ 0.1e1_2: "ee" }); + + +``` + +``` +useSimpleNumberKeys.js:8:4 lint/nursery/useSimpleNumberKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Number literal with underscore is not allowed + + 6 │ ({ 0b1: 1 }); + 7 │ ({ 0o1: 1 }); + > 8 │ ({ 1_0: 1 }); + │ ^^^ + 9 │ ({ 0.1e1_2: "ee" }); + 10 │ ({ 11_1.11: "ee" }); + + i Safe fix: Remove 1_0 + + 6 6 │ ({ 0b1: 1 }); + 7 7 │ ({ 0o1: 1 }); + 8 │ - ({·1_0:·1·}); + 8 │ + ({·10:·1·}); + 9 9 │ ({ 0.1e1_2: "ee" }); + 10 10 │ ({ 11_1.11: "ee" }); + + +``` + +``` +useSimpleNumberKeys.js:9:4 lint/nursery/useSimpleNumberKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Number literal with underscore is not allowed + + 7 │ ({ 0o1: 1 }); + 8 │ ({ 1_0: 1 }); + > 9 │ ({ 0.1e1_2: "ee" }); + │ ^^^^^^^ + 10 │ ({ 11_1.11: "ee" }); + 11 │ + + i Safe fix: Remove 0.1e1_2 + + 7 7 │ ({ 0o1: 1 }); + 8 8 │ ({ 1_0: 1 }); + 9 │ - ({·0.1e1_2:·"ee"·}); + 9 │ + ({·.1e12:·"ee"·}); + 10 10 │ ({ 11_1.11: "ee" }); + 11 11 │ + + +``` + +``` +useSimpleNumberKeys.js:10:4 lint/nursery/useSimpleNumberKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! Number literal with underscore is not allowed + + 8 │ ({ 1_0: 1 }); + 9 │ ({ 0.1e1_2: "ee" }); + > 10 │ ({ 11_1.11: "ee" }); + │ ^^^^^^^ + 11 │ + 12 │ // valid + + i Safe fix: Remove 11_1.11 + + 8 8 │ ({ 1_0: 1 }); + 9 9 │ ({ 0.1e1_2: "ee" }); + 10 │ - ({·11_1.11:·"ee"·}); + 10 │ + ({·111.11:·"ee"·}); + 11 11 │ + 12 12 │ // valid + + +``` + + diff --git a/crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys/invalid.js b/crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys/invalid.js deleted file mode 100644 index 3bf9c74f6f3..00000000000 --- a/crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys/invalid.js +++ /dev/null @@ -1,9 +0,0 @@ -({ 1n: 1 }); -({ 0x1: 1 }); -({ 012: 1 }); -({ 0b1: 1 }); -({ 0o1: 1 }); -({ 1_0: 1 }); -({ .1e1_2: "ee" }); -({ 11_1.11: "ee" }); - diff --git a/crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys/invalid.js.snap.new b/crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys/invalid.js.snap.new deleted file mode 100644 index 072687bb19e..00000000000 --- a/crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys/invalid.js.snap.new +++ /dev/null @@ -1,153 +0,0 @@ ---- -source: crates/rome_js_analyze/tests/spec_tests.rs -assertion_line: 92 -expression: invalid.js ---- -# Input -```js -({ 1n: 1 }); -({ 0x1: 1 }); -({ 012: 1 }); -({ 0b1: 1 }); -({ 0o1: 1 }); -({ 1_0: 1 }); -({ .1e1_2: "ee" }); -({ 11_1.11: "ee" }); -({ 11_1.11: "ee" }); - - -``` - -# Diagnostics -``` -invalid.js:1:4 lint/nursery/useSimpleNumberKeys ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - ! Bigint is not allowed - - > 1 │ ({ 1n: 1 }); - │ ^^ - 2 │ ({ 0x1: 1 }); - 3 │ ({ 012: 1 }); - - -``` - -``` -invalid.js:2:4 lint/nursery/useSimpleNumberKeys ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - ! Number literal in hexadecimal format is not allowed - - 1 │ ({ 1n: 1 }); - > 2 │ ({ 0x1: 1 }); - │ ^^^ - 3 │ ({ 012: 1 }); - 4 │ ({ 0b1: 1 }); - - -``` - -``` -invalid.js:3:4 lint/nursery/useSimpleNumberKeys ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - ! Number literal in octal format is not allowed - - 1 │ ({ 1n: 1 }); - 2 │ ({ 0x1: 1 }); - > 3 │ ({ 012: 1 }); - │ ^^^ - 4 │ ({ 0b1: 1 }); - 5 │ ({ 0o1: 1 }); - - -``` - -``` -invalid.js:4:4 lint/nursery/useSimpleNumberKeys ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - ! Number literal in binary format is not allowed - - 2 │ ({ 0x1: 1 }); - 3 │ ({ 012: 1 }); - > 4 │ ({ 0b1: 1 }); - │ ^^^ - 5 │ ({ 0o1: 1 }); - 6 │ ({ 1_0: 1 }); - - -``` - -``` -invalid.js:5:4 lint/nursery/useSimpleNumberKeys ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - ! Number literal in octal format is not allowed - - 3 │ ({ 012: 1 }); - 4 │ ({ 0b1: 1 }); - > 5 │ ({ 0o1: 1 }); - │ ^^^ - 6 │ ({ 1_0: 1 }); - 7 │ ({ .1e1_2: "ee" }); - - -``` - -``` -invalid.js:6:4 lint/nursery/useSimpleNumberKeys ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - ! Dashed number literal is not allowed - - 4 │ ({ 0b1: 1 }); - 5 │ ({ 0o1: 1 }); - > 6 │ ({ 1_0: 1 }); - │ ^^^ - 7 │ ({ .1e1_2: "ee" }); - 8 │ ({ 11_1.11: "ee" }); - - -``` - -``` -invalid.js:7:4 lint/nursery/useSimpleNumberKeys ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - ! Dashed number literal is not allowed - - 5 │ ({ 0o1: 1 }); - 6 │ ({ 1_0: 1 }); - > 7 │ ({ .1e1_2: "ee" }); - │ ^^^^^^ - 8 │ ({ 11_1.11: "ee" }); - 9 │ ({ 11_1.11: "ee" }); - - -``` - -``` -invalid.js:8:4 lint/nursery/useSimpleNumberKeys ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - ! Dashed number literal is not allowed - - 6 │ ({ 1_0: 1 }); - 7 │ ({ .1e1_2: "ee" }); - > 8 │ ({ 11_1.11: "ee" }); - │ ^^^^^^^ - 9 │ ({ 11_1.11: "ee" }); - 10 │ - - -``` - -``` -invalid.js:9:4 lint/nursery/useSimpleNumberKeys ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - ! Dashed number literal is not allowed - - 7 │ ({ .1e1_2: "ee" }); - 8 │ ({ 11_1.11: "ee" }); - > 9 │ ({ 11_1.11: "ee" }); - │ ^^^^^^^ - 10 │ - - -``` - - diff --git a/crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys/valid.js b/crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys/valid.js deleted file mode 100644 index cdf441f6ad0..00000000000 --- a/crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys/valid.js +++ /dev/null @@ -1,9 +0,0 @@ -/* should not generate diagnostics */ - -({ name: 1, monkey: 2 }); - -({ 0: "zero" }); -({ 1: "one" }); -({ 1.2: "12" }); -({ 3.1e12: "12" }); -({ .1e12: "ee" }); diff --git a/crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys/valid.js.snap.new b/crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys/valid.js.snap.new deleted file mode 100644 index e4f38304543..00000000000 --- a/crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys/valid.js.snap.new +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/rome_js_analyze/tests/spec_tests.rs -assertion_line: 92 -expression: valid.js ---- -# Input -```js -/* should not generate diagnostics */ - -({ name: 1, monkey: 2 }); - -({ 0: "zero" }); -({ 1: "one" }); -({ 1.2: "12" }); -({ 3.1e12: "12" }); -({ .1e12: "ee" }); - -``` - - diff --git a/crates/rome_js_unicode_table/src/tables.rs b/crates/rome_js_unicode_table/src/tables.rs index eb783866c93..7f67057597c 100644 --- a/crates/rome_js_unicode_table/src/tables.rs +++ b/crates/rome_js_unicode_table/src/tables.rs @@ -787,7 +787,9 @@ pub mod derived_property { ('\u{31350}', '\u{323af}'), ('\u{e0100}', '\u{e01ef}'), ]; - pub fn ID_Continue(c: char) -> bool { super::bsearch_range_table(c, ID_Continue_table) } + pub fn ID_Continue(c: char) -> bool { + super::bsearch_range_table(c, ID_Continue_table) + } pub const ID_Start_table: &[(char, char)] = &[ ('A', 'Z'), ('a', 'z'), @@ -1449,5 +1451,7 @@ pub mod derived_property { ('𰀀', '𱍊'), ('\u{31350}', '\u{323af}'), ]; - pub fn ID_Start(c: char) -> bool { super::bsearch_range_table(c, ID_Start_table) } + pub fn ID_Start(c: char) -> bool { + super::bsearch_range_table(c, ID_Start_table) + } } From 49b6cdf81199f9517ac716ef9ce7dd91ea3fbfb4 Mon Sep 17 00:00:00 2001 From: Dhiraj Arun Date: Wed, 28 Dec 2022 19:38:19 +0530 Subject: [PATCH 3/8] feat(rome_js_analyze): implement use_simple_number_keys --- .../nursery/use_simple_number_keys.rs | 4 +- .../src/configuration/linter/rules.rs | 2 +- editors/vscode/configuration_schema.json | 3296 ++++++++--------- npm/backend-jsonrpc/src/workspace.ts | 2 +- npm/rome/configuration_schema.json | 3294 ++++++++-------- website/src/pages/lint/rules/index.mdx | 2 +- .../pages/lint/rules/useSimpleNumberKeys.md | 2 +- 7 files changed, 3233 insertions(+), 3369 deletions(-) diff --git a/crates/rome_js_analyze/src/analyzers/nursery/use_simple_number_keys.rs b/crates/rome_js_analyze/src/analyzers/nursery/use_simple_number_keys.rs index f1009b7152a..3a86260cfd8 100644 --- a/crates/rome_js_analyze/src/analyzers/nursery/use_simple_number_keys.rs +++ b/crates/rome_js_analyze/src/analyzers/nursery/use_simple_number_keys.rs @@ -92,11 +92,11 @@ impl TryFrom for NumberLiteral { break; } - if chars[i] == 'e' || chars[i] == 'E' { + if chars[i] == 'e' || chars[i] == 'E' { exponent = true; } - if i == 1 && chars[i].is_alphabetic() && exponent == false { + if i == 1 && chars[i].is_alphabetic() && !exponent { is_second_char_a_letter = Some(chars[i]); continue; } diff --git a/crates/rome_service/src/configuration/linter/rules.rs b/crates/rome_service/src/configuration/linter/rules.rs index d3ec4d1d7c8..10ed80bc441 100644 --- a/crates/rome_service/src/configuration/linter/rules.rs +++ b/crates/rome_service/src/configuration/linter/rules.rs @@ -819,7 +819,7 @@ struct NurserySchema { use_media_caption: Option, #[doc = "Disallow parseInt() and Number.parseInt() in favor of binary, octal, and hexadecimal literals"] use_numeric_literals: Option, - #[doc = "Disallow use of number literal in format other than decimal as object member name"] + #[doc = "Disallow number literal object member names which are not base10 or uses underscore as separator"] use_simple_number_keys: Option, #[doc = "Ensures that ARIA properties aria-* are all valid."] use_valid_aria_props: Option, diff --git a/editors/vscode/configuration_schema.json b/editors/vscode/configuration_schema.json index d5c5736e9f8..ce4e00a3af2 100644 --- a/editors/vscode/configuration_schema.json +++ b/editors/vscode/configuration_schema.json @@ -1,1683 +1,1615 @@ { - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "Configuration", - "description": "The configuration that is contained inside the file `rome.json`", - "type": "object", - "properties": { - "$schema": { - "description": "A field for the [JSON schema](https://json-schema.org/) specification", - "type": [ - "string", - "null" - ] - }, - "files": { - "description": "The configuration of the filesystem", - "anyOf": [ - { - "$ref": "#/definitions/FilesConfiguration" - }, - { - "type": "null" - } - ] - }, - "formatter": { - "description": "The configuration of the formatter", - "anyOf": [ - { - "$ref": "#/definitions/FormatterConfiguration" - }, - { - "type": "null" - } - ] - }, - "javascript": { - "description": "Specific configuration for the JavaScript language", - "anyOf": [ - { - "$ref": "#/definitions/JavascriptConfiguration" - }, - { - "type": "null" - } - ] - }, - "linter": { - "description": "The configuration for the linter", - "anyOf": [ - { - "$ref": "#/definitions/LinterConfiguration" - }, - { - "type": "null" - } - ] - } - }, - "additionalProperties": false, - "definitions": { - "A11y": { - "description": "A list of rules that belong to this group", - "type": "object", - "properties": { - "noAutofocus": { - "description": "Avoid the autoFocus attribute", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noBlankTarget": { - "description": "Disallow target=\"_blank\" attribute without rel=\"noreferrer\"", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noPositiveTabindex": { - "description": "Prevent the usage of positive integers on tabIndex property", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "recommended": { - "description": "It enables the recommended rules for this group", - "type": [ - "boolean", - "null" - ] - }, - "useAltText": { - "description": "It asserts that alternative text to images or areas, help to rely on to screen readers to understand the purpose and the context of the image.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useAnchorContent": { - "description": "Enforce that anchor elements have content and that the content is accessible to screen readers.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useButtonType": { - "description": "Enforces the usage of the attribute type for the element button", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useHtmlLang": { - "description": "Enforce that html element has lang attribute. This allows users to choose a language other than the default.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useKeyWithClickEvents": { - "description": "Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useKeyWithMouseEvents": { - "description": "Enforce that onMouseOver/onMouseOut are accompanied by onFocus/onBlur for keyboard-only users. It is important to take into account users with physical disabilities who cannot use a mouse, who use assistive technology or screenreader.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useValidAnchor": { - "description": "Enforce that all anchors are valid, and they are navigable elements.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - } - } - }, - "Complexity": { - "description": "A list of rules that belong to this group", - "type": "object", - "properties": { - "noExtraBooleanCast": { - "description": "Disallow unnecessary boolean casts", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noMultipleSpacesInRegularExpressionLiterals": { - "description": "Disallow unclear usage of multiple space characters in regular expression literals", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noUselessFragments": { - "description": "Disallow unnecessary fragments", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "recommended": { - "description": "It enables the recommended rules for this group", - "type": [ - "boolean", - "null" - ] - }, - "useFlatMap": { - "description": "Promotes the use of .flatMap() when map().flat() are used together.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useOptionalChain": { - "description": "Enforce using concise optional chain instead of chained logical expressions.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useSimplifiedLogicExpression": { - "description": "Discard redundant terms from logical expressions.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - } - } - }, - "Correctness": { - "description": "A list of rules that belong to this group", - "type": "object", - "properties": { - "noChildrenProp": { - "description": "Prevent passing of children as props.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noConstAssign": { - "description": "Prevents from having const variables being re-assigned.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noEmptyPattern": { - "description": "Disallows empty destructuring patterns.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noNewSymbol": { - "description": "Disallow new operators with the Symbol object", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noRenderReturnValue": { - "description": "Prevent the usage of the return value of React.render.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noUndeclaredVariables": { - "description": "Prevents the usage of variables that haven't been declared inside the document", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noUnnecessaryContinue": { - "description": "Avoid using unnecessary continue.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noUnreachable": { - "description": "Disallow unreachable code", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noUnusedVariables": { - "description": "Disallow unused variables.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noVoidElementsWithChildren": { - "description": "This rules prevents void elements (AKA self-closing elements) from having children.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "recommended": { - "description": "It enables the recommended rules for this group", - "type": [ - "boolean", - "null" - ] - }, - "useValidForDirection": { - "description": "Enforce \"for\" loop update clause moving the counter in the right direction.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - } - } - }, - "FilesConfiguration": { - "description": "The configuration of the filesystem", - "type": "object", - "properties": { - "ignore": { - "description": "A list of Unix shell style patterns. Rome tools will ignore files/folders that will match these patterns.", - "type": [ - "array", - "null" - ], - "items": { - "type": "string" - }, - "uniqueItems": true - }, - "maxSize": { - "description": "The maximum allowed size for source code files in bytes. Files above this limit will be ignored for performance reason. Defaults to 1 MiB", - "default": null, - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 1.0 - } - }, - "additionalProperties": false - }, - "FormatterConfiguration": { - "type": "object", - "properties": { - "enabled": { - "default": true, - "type": "boolean" - }, - "formatWithErrors": { - "description": "Stores whether formatting should be allowed to proceed if a given file has syntax errors", - "default": false, - "type": "boolean" - }, - "ignore": { - "description": "A list of Unix shell style patterns. The formatter will ignore files/folders that will match these patterns.", - "type": [ - "array", - "null" - ], - "items": { - "type": "string" - }, - "uniqueItems": true - }, - "indentSize": { - "description": "The size of the indentation, 2 by default", - "default": 2, - "type": "integer", - "format": "uint8", - "minimum": 0.0 - }, - "indentStyle": { - "description": "The indent style.", - "default": "tab", - "allOf": [ - { - "$ref": "#/definitions/PlainIndentStyle" - } - ] - }, - "lineWidth": { - "description": "What's the max width of a line. Defaults to 80.", - "default": 80, - "allOf": [ - { - "$ref": "#/definitions/LineWidth" - } - ] - } - }, - "additionalProperties": false - }, - "JavascriptConfiguration": { - "type": "object", - "properties": { - "formatter": { - "anyOf": [ - { - "$ref": "#/definitions/JavascriptFormatter" - }, - { - "type": "null" - } - ] - }, - "globals": { - "description": "A list of global bindings that should be ignored by the analyzers\n\nIf defined here, they should not emit diagnostics.", - "type": [ - "array", - "null" - ], - "items": { - "type": "string" - }, - "uniqueItems": true - } - }, - "additionalProperties": false - }, - "JavascriptFormatter": { - "type": "object", - "properties": { - "quoteProperties": { - "description": "When properties in objects are quoted. Defaults to asNeeded.", - "default": "asNeeded", - "allOf": [ - { - "$ref": "#/definitions/QuoteProperties" - } - ] - }, - "quoteStyle": { - "description": "The style for quotes. Defaults to double.", - "default": "double", - "allOf": [ - { - "$ref": "#/definitions/QuoteStyle" - } - ] - }, - "semicolons": { - "description": "Whether the formatter prints semicolons for all statements or only in for statements where it is necessary because of ASI.", - "default": "always", - "allOf": [ - { - "$ref": "#/definitions/Semicolons" - } - ] - }, - "trailingComma": { - "description": "Print trailing commas wherever possible in multi-line comma-separated syntactic structures. Defaults to \"all\".", - "default": "all", - "allOf": [ - { - "$ref": "#/definitions/TrailingComma" - } - ] - } - }, - "additionalProperties": false - }, - "LineWidth": { - "description": "Validated value for the `line_width` formatter options\n\nThe allowed range of values is 1..=320", - "type": "integer", - "format": "uint16", - "minimum": 0.0 - }, - "LinterConfiguration": { - "type": "object", - "properties": { - "enabled": { - "description": "if `false`, it disables the feature and the linter won't be executed. `true` by default", - "default": true, - "type": "boolean" - }, - "ignore": { - "description": "A list of Unix shell style patterns. The formatter will ignore files/folders that will match these patterns.", - "type": [ - "array", - "null" - ], - "items": { - "type": "string" - }, - "uniqueItems": true - }, - "rules": { - "description": "List of rules", - "default": { - "recommended": true - }, - "anyOf": [ - { - "$ref": "#/definitions/Rules" - }, - { - "type": "null" - } - ] - } - }, - "additionalProperties": false - }, - "Nursery": { - "description": "A list of rules that belong to this group", - "type": "object", - "properties": { - "noAccessKey": { - "description": "Enforce that the accessKey attribute is not used on any HTML element.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noAssignInExpressions": { - "description": "Disallow assignments in expressions.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noBannedTypes": { - "description": "Disallow certain types.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noClassAssign": { - "description": "Disallow reassigning class members.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noCommaOperator": { - "description": "Disallow comma operator.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noConstEnum": { - "description": "Disallow TypeScript const enum", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noConstructorReturn": { - "description": "Disallow returning a value from a constructor.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noDistractingElements": { - "description": "Enforces that no distracting elements are used.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noDuplicateCase": { - "description": "Disallow duplicate case labels. If a switch statement has duplicate test expressions in case clauses, it is likely that a programmer copied a case clause but forgot to change the test expression.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noDuplicateObjectKeys": { - "description": "Prevents object literals having more than one property declaration for the same name. If an object property with the same name is defined multiple times (except when combining a getter with a setter), only the last definition makes it into the object and previous definitions are ignored, which is likely a mistake.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noEmptyInterface": { - "description": "Disallow the declaration of empty interfaces.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noExtraNonNullAssertion": { - "description": "Prevents the wrong usage of the non-null assertion operator (!) in TypeScript files.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noExtraSemicolons": { - "description": "Typing mistakes and misunderstandings about where semicolons are required can lead to semicolons that are unnecessary. While not technically an error, extra semicolons can cause confusion when reading code.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noHeaderScope": { - "description": "Check that the scope attribute is only used on th elements.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noInvalidConstructorSuper": { - "description": "Prevents the incorrect use of super() inside classes. It also checks whether a call super() is missing from classes that extends other constructors.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noNonNullAssertion": { - "description": "Disallow non-null assertions using the ! postfix operator.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noNoninteractiveElementToInteractiveRole": { - "description": "Enforce that interactive ARIA roles are not assigned to non-interactive HTML elements.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noPrecisionLoss": { - "description": "Disallow literal numbers that lose precision", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noRedundantAlt": { - "description": "Enforce img alt prop does not contain the word \"image\", \"picture\", or \"photo\".", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noRedundantUseStrict": { - "description": "Prevents from having redundant \"use strict\".", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noRestrictedGlobals": { - "description": "This rule allows you to specify global variable names that you don’t want to use in your application.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noSelfCompare": { - "description": "Disallow comparisons where both sides are exactly the same.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noSetterReturn": { - "description": "Disallow returning a value from a setter", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noStringCaseMismatch": { - "description": "Disallow comparison of expressions modifying the string case with non-compliant value.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noUnreachableSuper": { - "description": "Ensures the super() constructor is called exactly once on every code path in a class constructor before this is accessed if the class has a superclass", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noUnsafeFinally": { - "description": "Disallow control flow statements in finally blocks.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noUselessSwitchCase": { - "description": "Disallow useless case in switch statements.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noVar": { - "description": "Disallow the use of var", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noVoidTypeReturn": { - "description": "Disallow returning a value from a function with the return type 'void'", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noWith": { - "description": "Disallow with statements in non-strict contexts.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "recommended": { - "description": "It enables the recommended rules for this group", - "type": [ - "boolean", - "null" - ] - }, - "useAriaPropTypes": { - "description": "Enforce that ARIA state and property values are valid.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useAriaPropsForRole": { - "description": "Enforce that elements with ARIA roles must have all required ARIA attributes for that role.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useCamelCase": { - "description": "Enforce camel case naming convention.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useConst": { - "description": "Require const declarations for variables that are never reassigned after declared.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useDefaultParameterLast": { - "description": "Enforce default function parameters and optional parameters to be last.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useDefaultSwitchClauseLast": { - "description": "Enforce default clauses in switch statements to be last", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useEnumInitializers": { - "description": "Require that each enum member value be explicitly initialized.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useExhaustiveDependencies": { - "description": "Enforce all dependencies are correctly specified.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useExponentiationOperator": { - "description": "Disallow the use of Math.pow in favor of the ** operator.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useHookAtTopLevel": { - "description": "Enforce that all React hooks are being called from the Top Level component functions.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useIframeTitle": { - "description": "Enforces the usage of the attribute title for the element iframe", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useIsNan": { - "description": "Require calls to isNaN() when checking for NaN.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useMediaCaption": { - "description": "Enforces that audio and video elements must have a track for captions.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useNumericLiterals": { - "description": "Disallow parseInt() and Number.parseInt() in favor of binary, octal, and hexadecimal literals", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useSimpleNumberKeys": { - "description": "Disallow use of number literal in format other than decimal as object member name", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useValidAriaProps": { - "description": "Ensures that ARIA properties aria-* are all valid.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useValidLang": { - "description": "Ensure that the attribute passed to the lang attribute is a correct ISO language and/or country.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - } - } - }, - "Performance": { - "description": "A list of rules that belong to this group", - "type": "object", - "properties": { - "noDelete": { - "description": "Disallow the use of the delete operator", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "recommended": { - "description": "It enables the recommended rules for this group", - "type": [ - "boolean", - "null" - ] - } - } - }, - "PlainIndentStyle": { - "type": "string", - "enum": [ - "tab", - "space" - ] - }, - "QuoteProperties": { - "type": "string", - "enum": [ - "asNeeded", - "preserve" - ] - }, - "QuoteStyle": { - "type": "string", - "enum": [ - "double", - "single" - ] - }, - "RuleConfiguration": { - "anyOf": [ - { - "$ref": "#/definitions/RulePlainConfiguration" - }, - { - "$ref": "#/definitions/RuleWithOptions" - } - ] - }, - "RulePlainConfiguration": { - "type": "string", - "enum": [ - "warn", - "error", - "off" - ] - }, - "RuleWithOptions": { - "type": "object", - "required": [ - "level", - "options" - ], - "properties": { - "level": { - "$ref": "#/definitions/RulePlainConfiguration" - }, - "options": true - }, - "additionalProperties": false - }, - "Rules": { - "type": "object", - "properties": { - "a11y": { - "anyOf": [ - { - "$ref": "#/definitions/A11y" - }, - { - "type": "null" - } - ] - }, - "complexity": { - "anyOf": [ - { - "$ref": "#/definitions/Complexity" - }, - { - "type": "null" - } - ] - }, - "correctness": { - "anyOf": [ - { - "$ref": "#/definitions/Correctness" - }, - { - "type": "null" - } - ] - }, - "nursery": { - "anyOf": [ - { - "$ref": "#/definitions/Nursery" - }, - { - "type": "null" - } - ] - }, - "performance": { - "anyOf": [ - { - "$ref": "#/definitions/Performance" - }, - { - "type": "null" - } - ] - }, - "recommended": { - "description": "It enables the lint rules recommended by Rome. `true` by default.", - "type": [ - "boolean", - "null" - ] - }, - "security": { - "anyOf": [ - { - "$ref": "#/definitions/Security" - }, - { - "type": "null" - } - ] - }, - "style": { - "anyOf": [ - { - "$ref": "#/definitions/Style" - }, - { - "type": "null" - } - ] - }, - "suspicious": { - "anyOf": [ - { - "$ref": "#/definitions/Suspicious" - }, - { - "type": "null" - } - ] - } - }, - "additionalProperties": false - }, - "Security": { - "description": "A list of rules that belong to this group", - "type": "object", - "properties": { - "noDangerouslySetInnerHtml": { - "description": "Prevent the usage of dangerous JSX props", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noDangerouslySetInnerHtmlWithChildren": { - "description": "Report when a DOM element or a component uses both children and dangerouslySetInnerHTML prop.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "recommended": { - "description": "It enables the recommended rules for this group", - "type": [ - "boolean", - "null" - ] - } - } - }, - "Semicolons": { - "type": "string", - "enum": [ - "always", - "asNeeded" - ] - }, - "Style": { - "description": "A list of rules that belong to this group", - "type": "object", - "properties": { - "noArguments": { - "description": "Disallow the use of arguments", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noImplicitBoolean": { - "description": "Disallow implicit true values on JSX boolean attributes", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noNegationElse": { - "description": "Disallow negation in the condition of an if statement if it has an else clause", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noShoutyConstants": { - "description": "Disallow the use of constants which its value is the upper-case version of its name.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noUnusedTemplateLiteral": { - "description": "Disallow template literals if interpolation and special-character handling are not needed", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "recommended": { - "description": "It enables the recommended rules for this group", - "type": [ - "boolean", - "null" - ] - }, - "useBlockStatements": { - "description": "Requires following curly brace conventions. JavaScript allows the omission of curly braces when a block contains only one statement. However, it is considered by many to be best practice to never omit curly braces around blocks, even when they are optional, because it can lead to bugs and reduces code clarity.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useFragmentSyntax": { - "description": "This rule enforces the use of <>... over ....", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useSelfClosingElements": { - "description": "Prevent extra closing tags for components without children", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useShorthandArrayType": { - "description": "When expressing array types, this rule promotes the usage of T[] shorthand instead of Array.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useSingleCaseStatement": { - "description": "Enforces case clauses have a single statement, emits a quick fix wrapping the statements in a block", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useSingleVarDeclarator": { - "description": "Disallow multiple variable declarations in the same variable statement", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useTemplate": { - "description": "Template literals are preferred over string concatenation.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useWhile": { - "description": "Enforce the use of while loops instead of for loops when the initializer and update expressions are not needed", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - } - } - }, - "Suspicious": { - "description": "A list of rules that belong to this group", - "type": "object", - "properties": { - "noArrayIndexKey": { - "description": "Discourage the usage of Array index in keys.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noAsyncPromiseExecutor": { - "description": "Disallows using an async function as a Promise executor.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noCatchAssign": { - "description": "Disallow reassigning exceptions in catch clauses", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noCommentText": { - "description": "Prevent comments from being inserted as text nodes", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noCompareNegZero": { - "description": "Disallow comparing against -0", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noDebugger": { - "description": "Disallow the use of debugger", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noDoubleEquals": { - "description": "Require the use of === and !==", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noDuplicateParameters": { - "description": "Disallow duplicate function arguments name.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noExplicitAny": { - "description": "Disallow the any type usage", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noFunctionAssign": { - "description": "Disallow reassigning function declarations.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noImportAssign": { - "description": "Disallow assigning to imported bindings", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noLabelVar": { - "description": "Disallow labels that share a name with a variable", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noShadowRestrictedNames": { - "description": "Disallow identifiers from shadowing restricted names.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noSparseArray": { - "description": "Disallow sparse arrays", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noUnsafeNegation": { - "description": "Disallow using unsafe negation.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "recommended": { - "description": "It enables the recommended rules for this group", - "type": [ - "boolean", - "null" - ] - }, - "useValidTypeof": { - "description": "This rule verifies the result of typeof $expr unary expressions is being compared to valid values, either string literals containing valid type names or other typeof expressions", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - } - } - }, - "TrailingComma": { - "type": "string", - "enum": [ - "all", - "es5", - "none" - ] - } - } -} \ No newline at end of file + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Configuration", + "description": "The configuration that is contained inside the file `rome.json`", + "type": "object", + "properties": { + "$schema": { + "description": "A field for the [JSON schema](https://json-schema.org/) specification", + "type": ["string", "null"] + }, + "files": { + "description": "The configuration of the filesystem", + "anyOf": [ + { + "$ref": "#/definitions/FilesConfiguration" + }, + { + "type": "null" + } + ] + }, + "formatter": { + "description": "The configuration of the formatter", + "anyOf": [ + { + "$ref": "#/definitions/FormatterConfiguration" + }, + { + "type": "null" + } + ] + }, + "javascript": { + "description": "Specific configuration for the JavaScript language", + "anyOf": [ + { + "$ref": "#/definitions/JavascriptConfiguration" + }, + { + "type": "null" + } + ] + }, + "linter": { + "description": "The configuration for the linter", + "anyOf": [ + { + "$ref": "#/definitions/LinterConfiguration" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false, + "definitions": { + "A11y": { + "description": "A list of rules that belong to this group", + "type": "object", + "properties": { + "noAutofocus": { + "description": "Avoid the autoFocus attribute", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noBlankTarget": { + "description": "Disallow target=\"_blank\" attribute without rel=\"noreferrer\"", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noPositiveTabindex": { + "description": "Prevent the usage of positive integers on tabIndex property", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "recommended": { + "description": "It enables the recommended rules for this group", + "type": ["boolean", "null"] + }, + "useAltText": { + "description": "It asserts that alternative text to images or areas, help to rely on to screen readers to understand the purpose and the context of the image.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useAnchorContent": { + "description": "Enforce that anchor elements have content and that the content is accessible to screen readers.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useButtonType": { + "description": "Enforces the usage of the attribute type for the element button", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useHtmlLang": { + "description": "Enforce that html element has lang attribute. This allows users to choose a language other than the default.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useKeyWithClickEvents": { + "description": "Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useKeyWithMouseEvents": { + "description": "Enforce that onMouseOver/onMouseOut are accompanied by onFocus/onBlur for keyboard-only users. It is important to take into account users with physical disabilities who cannot use a mouse, who use assistive technology or screenreader.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useValidAnchor": { + "description": "Enforce that all anchors are valid, and they are navigable elements.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + } + } + }, + "Complexity": { + "description": "A list of rules that belong to this group", + "type": "object", + "properties": { + "noExtraBooleanCast": { + "description": "Disallow unnecessary boolean casts", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noMultipleSpacesInRegularExpressionLiterals": { + "description": "Disallow unclear usage of multiple space characters in regular expression literals", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUselessFragments": { + "description": "Disallow unnecessary fragments", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "recommended": { + "description": "It enables the recommended rules for this group", + "type": ["boolean", "null"] + }, + "useFlatMap": { + "description": "Promotes the use of .flatMap() when map().flat() are used together.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useOptionalChain": { + "description": "Enforce using concise optional chain instead of chained logical expressions.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useSimplifiedLogicExpression": { + "description": "Discard redundant terms from logical expressions.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + } + } + }, + "Correctness": { + "description": "A list of rules that belong to this group", + "type": "object", + "properties": { + "noChildrenProp": { + "description": "Prevent passing of children as props.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noConstAssign": { + "description": "Prevents from having const variables being re-assigned.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noEmptyPattern": { + "description": "Disallows empty destructuring patterns.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noNewSymbol": { + "description": "Disallow new operators with the Symbol object", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noRenderReturnValue": { + "description": "Prevent the usage of the return value of React.render.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUndeclaredVariables": { + "description": "Prevents the usage of variables that haven't been declared inside the document", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUnnecessaryContinue": { + "description": "Avoid using unnecessary continue.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUnreachable": { + "description": "Disallow unreachable code", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUnusedVariables": { + "description": "Disallow unused variables.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noVoidElementsWithChildren": { + "description": "This rules prevents void elements (AKA self-closing elements) from having children.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "recommended": { + "description": "It enables the recommended rules for this group", + "type": ["boolean", "null"] + }, + "useValidForDirection": { + "description": "Enforce \"for\" loop update clause moving the counter in the right direction.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + } + } + }, + "FilesConfiguration": { + "description": "The configuration of the filesystem", + "type": "object", + "properties": { + "ignore": { + "description": "A list of Unix shell style patterns. Rome tools will ignore files/folders that will match these patterns.", + "type": ["array", "null"], + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "maxSize": { + "description": "The maximum allowed size for source code files in bytes. Files above this limit will be ignored for performance reason. Defaults to 1 MiB", + "default": null, + "type": ["integer", "null"], + "format": "uint64", + "minimum": 1.0 + } + }, + "additionalProperties": false + }, + "FormatterConfiguration": { + "type": "object", + "properties": { + "enabled": { + "default": true, + "type": "boolean" + }, + "formatWithErrors": { + "description": "Stores whether formatting should be allowed to proceed if a given file has syntax errors", + "default": false, + "type": "boolean" + }, + "ignore": { + "description": "A list of Unix shell style patterns. The formatter will ignore files/folders that will match these patterns.", + "type": ["array", "null"], + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "indentSize": { + "description": "The size of the indentation, 2 by default", + "default": 2, + "type": "integer", + "format": "uint8", + "minimum": 0.0 + }, + "indentStyle": { + "description": "The indent style.", + "default": "tab", + "allOf": [ + { + "$ref": "#/definitions/PlainIndentStyle" + } + ] + }, + "lineWidth": { + "description": "What's the max width of a line. Defaults to 80.", + "default": 80, + "allOf": [ + { + "$ref": "#/definitions/LineWidth" + } + ] + } + }, + "additionalProperties": false + }, + "JavascriptConfiguration": { + "type": "object", + "properties": { + "formatter": { + "anyOf": [ + { + "$ref": "#/definitions/JavascriptFormatter" + }, + { + "type": "null" + } + ] + }, + "globals": { + "description": "A list of global bindings that should be ignored by the analyzers\n\nIf defined here, they should not emit diagnostics.", + "type": ["array", "null"], + "items": { + "type": "string" + }, + "uniqueItems": true + } + }, + "additionalProperties": false + }, + "JavascriptFormatter": { + "type": "object", + "properties": { + "quoteProperties": { + "description": "When properties in objects are quoted. Defaults to asNeeded.", + "default": "asNeeded", + "allOf": [ + { + "$ref": "#/definitions/QuoteProperties" + } + ] + }, + "quoteStyle": { + "description": "The style for quotes. Defaults to double.", + "default": "double", + "allOf": [ + { + "$ref": "#/definitions/QuoteStyle" + } + ] + }, + "semicolons": { + "description": "Whether the formatter prints semicolons for all statements or only in for statements where it is necessary because of ASI.", + "default": "always", + "allOf": [ + { + "$ref": "#/definitions/Semicolons" + } + ] + }, + "trailingComma": { + "description": "Print trailing commas wherever possible in multi-line comma-separated syntactic structures. Defaults to \"all\".", + "default": "all", + "allOf": [ + { + "$ref": "#/definitions/TrailingComma" + } + ] + } + }, + "additionalProperties": false + }, + "LineWidth": { + "description": "Validated value for the `line_width` formatter options\n\nThe allowed range of values is 1..=320", + "type": "integer", + "format": "uint16", + "minimum": 0.0 + }, + "LinterConfiguration": { + "type": "object", + "properties": { + "enabled": { + "description": "if `false`, it disables the feature and the linter won't be executed. `true` by default", + "default": true, + "type": "boolean" + }, + "ignore": { + "description": "A list of Unix shell style patterns. The formatter will ignore files/folders that will match these patterns.", + "type": ["array", "null"], + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "rules": { + "description": "List of rules", + "default": { + "recommended": true + }, + "anyOf": [ + { + "$ref": "#/definitions/Rules" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false + }, + "Nursery": { + "description": "A list of rules that belong to this group", + "type": "object", + "properties": { + "noAccessKey": { + "description": "Enforce that the accessKey attribute is not used on any HTML element.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noAssignInExpressions": { + "description": "Disallow assignments in expressions.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noBannedTypes": { + "description": "Disallow certain types.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noClassAssign": { + "description": "Disallow reassigning class members.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noCommaOperator": { + "description": "Disallow comma operator.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noConstEnum": { + "description": "Disallow TypeScript const enum", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noConstructorReturn": { + "description": "Disallow returning a value from a constructor.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noDistractingElements": { + "description": "Enforces that no distracting elements are used.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noDuplicateCase": { + "description": "Disallow duplicate case labels. If a switch statement has duplicate test expressions in case clauses, it is likely that a programmer copied a case clause but forgot to change the test expression.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noDuplicateObjectKeys": { + "description": "Prevents object literals having more than one property declaration for the same name. If an object property with the same name is defined multiple times (except when combining a getter with a setter), only the last definition makes it into the object and previous definitions are ignored, which is likely a mistake.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noEmptyInterface": { + "description": "Disallow the declaration of empty interfaces.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noExtraNonNullAssertion": { + "description": "Prevents the wrong usage of the non-null assertion operator (!) in TypeScript files.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noExtraSemicolons": { + "description": "Typing mistakes and misunderstandings about where semicolons are required can lead to semicolons that are unnecessary. While not technically an error, extra semicolons can cause confusion when reading code.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noHeaderScope": { + "description": "Check that the scope attribute is only used on th elements.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noInvalidConstructorSuper": { + "description": "Prevents the incorrect use of super() inside classes. It also checks whether a call super() is missing from classes that extends other constructors.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noNonNullAssertion": { + "description": "Disallow non-null assertions using the ! postfix operator.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noNoninteractiveElementToInteractiveRole": { + "description": "Enforce that interactive ARIA roles are not assigned to non-interactive HTML elements.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noPrecisionLoss": { + "description": "Disallow literal numbers that lose precision", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noRedundantAlt": { + "description": "Enforce img alt prop does not contain the word \"image\", \"picture\", or \"photo\".", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noRedundantUseStrict": { + "description": "Prevents from having redundant \"use strict\".", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noRestrictedGlobals": { + "description": "This rule allows you to specify global variable names that you don’t want to use in your application.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noSelfCompare": { + "description": "Disallow comparisons where both sides are exactly the same.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noSetterReturn": { + "description": "Disallow returning a value from a setter", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noStringCaseMismatch": { + "description": "Disallow comparison of expressions modifying the string case with non-compliant value.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUnreachableSuper": { + "description": "Ensures the super() constructor is called exactly once on every code path in a class constructor before this is accessed if the class has a superclass", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUnsafeFinally": { + "description": "Disallow control flow statements in finally blocks.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUselessSwitchCase": { + "description": "Disallow useless case in switch statements.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noVar": { + "description": "Disallow the use of var", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noVoidTypeReturn": { + "description": "Disallow returning a value from a function with the return type 'void'", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noWith": { + "description": "Disallow with statements in non-strict contexts.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "recommended": { + "description": "It enables the recommended rules for this group", + "type": ["boolean", "null"] + }, + "useAriaPropTypes": { + "description": "Enforce that ARIA state and property values are valid.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useAriaPropsForRole": { + "description": "Enforce that elements with ARIA roles must have all required ARIA attributes for that role.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useCamelCase": { + "description": "Enforce camel case naming convention.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useConst": { + "description": "Require const declarations for variables that are never reassigned after declared.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useDefaultParameterLast": { + "description": "Enforce default function parameters and optional parameters to be last.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useDefaultSwitchClauseLast": { + "description": "Enforce default clauses in switch statements to be last", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useEnumInitializers": { + "description": "Require that each enum member value be explicitly initialized.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useExhaustiveDependencies": { + "description": "Enforce all dependencies are correctly specified.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useExponentiationOperator": { + "description": "Disallow the use of Math.pow in favor of the ** operator.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useHookAtTopLevel": { + "description": "Enforce that all React hooks are being called from the Top Level component functions.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useIframeTitle": { + "description": "Enforces the usage of the attribute title for the element iframe", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useIsNan": { + "description": "Require calls to isNaN() when checking for NaN.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useMediaCaption": { + "description": "Enforces that audio and video elements must have a track for captions.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useNumericLiterals": { + "description": "Disallow parseInt() and Number.parseInt() in favor of binary, octal, and hexadecimal literals", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useSimpleNumberKeys": { + "description": "Disallow number literal object member names which are not base10 or uses underscore as separator", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useValidAriaProps": { + "description": "Ensures that ARIA properties aria-* are all valid.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useValidLang": { + "description": "Ensure that the attribute passed to the lang attribute is a correct ISO language and/or country.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + } + } + }, + "Performance": { + "description": "A list of rules that belong to this group", + "type": "object", + "properties": { + "noDelete": { + "description": "Disallow the use of the delete operator", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "recommended": { + "description": "It enables the recommended rules for this group", + "type": ["boolean", "null"] + } + } + }, + "PlainIndentStyle": { + "type": "string", + "enum": ["tab", "space"] + }, + "QuoteProperties": { + "type": "string", + "enum": ["asNeeded", "preserve"] + }, + "QuoteStyle": { + "type": "string", + "enum": ["double", "single"] + }, + "RuleConfiguration": { + "anyOf": [ + { + "$ref": "#/definitions/RulePlainConfiguration" + }, + { + "$ref": "#/definitions/RuleWithOptions" + } + ] + }, + "RulePlainConfiguration": { + "type": "string", + "enum": ["warn", "error", "off"] + }, + "RuleWithOptions": { + "type": "object", + "required": ["level", "options"], + "properties": { + "level": { + "$ref": "#/definitions/RulePlainConfiguration" + }, + "options": true + }, + "additionalProperties": false + }, + "Rules": { + "type": "object", + "properties": { + "a11y": { + "anyOf": [ + { + "$ref": "#/definitions/A11y" + }, + { + "type": "null" + } + ] + }, + "complexity": { + "anyOf": [ + { + "$ref": "#/definitions/Complexity" + }, + { + "type": "null" + } + ] + }, + "correctness": { + "anyOf": [ + { + "$ref": "#/definitions/Correctness" + }, + { + "type": "null" + } + ] + }, + "nursery": { + "anyOf": [ + { + "$ref": "#/definitions/Nursery" + }, + { + "type": "null" + } + ] + }, + "performance": { + "anyOf": [ + { + "$ref": "#/definitions/Performance" + }, + { + "type": "null" + } + ] + }, + "recommended": { + "description": "It enables the lint rules recommended by Rome. `true` by default.", + "type": ["boolean", "null"] + }, + "security": { + "anyOf": [ + { + "$ref": "#/definitions/Security" + }, + { + "type": "null" + } + ] + }, + "style": { + "anyOf": [ + { + "$ref": "#/definitions/Style" + }, + { + "type": "null" + } + ] + }, + "suspicious": { + "anyOf": [ + { + "$ref": "#/definitions/Suspicious" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false + }, + "Security": { + "description": "A list of rules that belong to this group", + "type": "object", + "properties": { + "noDangerouslySetInnerHtml": { + "description": "Prevent the usage of dangerous JSX props", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noDangerouslySetInnerHtmlWithChildren": { + "description": "Report when a DOM element or a component uses both children and dangerouslySetInnerHTML prop.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "recommended": { + "description": "It enables the recommended rules for this group", + "type": ["boolean", "null"] + } + } + }, + "Semicolons": { + "type": "string", + "enum": ["always", "asNeeded"] + }, + "Style": { + "description": "A list of rules that belong to this group", + "type": "object", + "properties": { + "noArguments": { + "description": "Disallow the use of arguments", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noImplicitBoolean": { + "description": "Disallow implicit true values on JSX boolean attributes", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noNegationElse": { + "description": "Disallow negation in the condition of an if statement if it has an else clause", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noShoutyConstants": { + "description": "Disallow the use of constants which its value is the upper-case version of its name.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUnusedTemplateLiteral": { + "description": "Disallow template literals if interpolation and special-character handling are not needed", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "recommended": { + "description": "It enables the recommended rules for this group", + "type": ["boolean", "null"] + }, + "useBlockStatements": { + "description": "Requires following curly brace conventions. JavaScript allows the omission of curly braces when a block contains only one statement. However, it is considered by many to be best practice to never omit curly braces around blocks, even when they are optional, because it can lead to bugs and reduces code clarity.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useFragmentSyntax": { + "description": "This rule enforces the use of <>... over ....", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useSelfClosingElements": { + "description": "Prevent extra closing tags for components without children", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useShorthandArrayType": { + "description": "When expressing array types, this rule promotes the usage of T[] shorthand instead of Array.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useSingleCaseStatement": { + "description": "Enforces case clauses have a single statement, emits a quick fix wrapping the statements in a block", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useSingleVarDeclarator": { + "description": "Disallow multiple variable declarations in the same variable statement", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useTemplate": { + "description": "Template literals are preferred over string concatenation.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useWhile": { + "description": "Enforce the use of while loops instead of for loops when the initializer and update expressions are not needed", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + } + } + }, + "Suspicious": { + "description": "A list of rules that belong to this group", + "type": "object", + "properties": { + "noArrayIndexKey": { + "description": "Discourage the usage of Array index in keys.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noAsyncPromiseExecutor": { + "description": "Disallows using an async function as a Promise executor.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noCatchAssign": { + "description": "Disallow reassigning exceptions in catch clauses", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noCommentText": { + "description": "Prevent comments from being inserted as text nodes", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noCompareNegZero": { + "description": "Disallow comparing against -0", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noDebugger": { + "description": "Disallow the use of debugger", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noDoubleEquals": { + "description": "Require the use of === and !==", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noDuplicateParameters": { + "description": "Disallow duplicate function arguments name.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noExplicitAny": { + "description": "Disallow the any type usage", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noFunctionAssign": { + "description": "Disallow reassigning function declarations.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noImportAssign": { + "description": "Disallow assigning to imported bindings", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noLabelVar": { + "description": "Disallow labels that share a name with a variable", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noShadowRestrictedNames": { + "description": "Disallow identifiers from shadowing restricted names.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noSparseArray": { + "description": "Disallow sparse arrays", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUnsafeNegation": { + "description": "Disallow using unsafe negation.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "recommended": { + "description": "It enables the recommended rules for this group", + "type": ["boolean", "null"] + }, + "useValidTypeof": { + "description": "This rule verifies the result of typeof $expr unary expressions is being compared to valid values, either string literals containing valid type names or other typeof expressions", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + } + } + }, + "TrailingComma": { + "type": "string", + "enum": ["all", "es5", "none"] + } + } +} diff --git a/npm/backend-jsonrpc/src/workspace.ts b/npm/backend-jsonrpc/src/workspace.ts index 9093dd8ab89..99bc98c7636 100644 --- a/npm/backend-jsonrpc/src/workspace.ts +++ b/npm/backend-jsonrpc/src/workspace.ts @@ -470,7 +470,7 @@ export interface Nursery { */ useNumericLiterals?: RuleConfiguration; /** - * Disallow use of number literal in format other than decimal as object member name + * Disallow number literal object member names which are not base10 or uses underscore as separator */ useSimpleNumberKeys?: RuleConfiguration; /** diff --git a/npm/rome/configuration_schema.json b/npm/rome/configuration_schema.json index 989a9373149..ce4e00a3af2 100644 --- a/npm/rome/configuration_schema.json +++ b/npm/rome/configuration_schema.json @@ -1,1683 +1,1615 @@ { - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "Configuration", - "description": "The configuration that is contained inside the file `rome.json`", - "type": "object", - "properties": { - "$schema": { - "description": "A field for the [JSON schema](https://json-schema.org/) specification", - "type": [ - "string", - "null" - ] - }, - "files": { - "description": "The configuration of the filesystem", - "anyOf": [ - { - "$ref": "#/definitions/FilesConfiguration" - }, - { - "type": "null" - } - ] - }, - "formatter": { - "description": "The configuration of the formatter", - "anyOf": [ - { - "$ref": "#/definitions/FormatterConfiguration" - }, - { - "type": "null" - } - ] - }, - "javascript": { - "description": "Specific configuration for the JavaScript language", - "anyOf": [ - { - "$ref": "#/definitions/JavascriptConfiguration" - }, - { - "type": "null" - } - ] - }, - "linter": { - "description": "The configuration for the linter", - "anyOf": [ - { - "$ref": "#/definitions/LinterConfiguration" - }, - { - "type": "null" - } - ] - } - }, - "additionalProperties": false, - "definitions": { - "A11y": { - "description": "A list of rules that belong to this group", - "type": "object", - "properties": { - "noAutofocus": { - "description": "Avoid the autoFocus attribute", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noBlankTarget": { - "description": "Disallow target=\"_blank\" attribute without rel=\"noreferrer\"", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noPositiveTabindex": { - "description": "Prevent the usage of positive integers on tabIndex property", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "recommended": { - "description": "It enables the recommended rules for this group", - "type": [ - "boolean", - "null" - ] - }, - "useAltText": { - "description": "It asserts that alternative text to images or areas, help to rely on to screen readers to understand the purpose and the context of the image.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useAnchorContent": { - "description": "Enforce that anchor elements have content and that the content is accessible to screen readers.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useButtonType": { - "description": "Enforces the usage of the attribute type for the element button", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useHtmlLang": { - "description": "Enforce that html element has lang attribute. This allows users to choose a language other than the default.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useKeyWithClickEvents": { - "description": "Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useKeyWithMouseEvents": { - "description": "Enforce that onMouseOver/onMouseOut are accompanied by onFocus/onBlur for keyboard-only users. It is important to take into account users with physical disabilities who cannot use a mouse, who use assistive technology or screenreader.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useValidAnchor": { - "description": "Enforce that all anchors are valid, and they are navigable elements.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - } - } - }, - "Complexity": { - "description": "A list of rules that belong to this group", - "type": "object", - "properties": { - "noExtraBooleanCast": { - "description": "Disallow unnecessary boolean casts", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noMultipleSpacesInRegularExpressionLiterals": { - "description": "Disallow unclear usage of multiple space characters in regular expression literals", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noUselessFragments": { - "description": "Disallow unnecessary fragments", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "recommended": { - "description": "It enables the recommended rules for this group", - "type": [ - "boolean", - "null" - ] - }, - "useFlatMap": { - "description": "Promotes the use of .flatMap() when map().flat() are used together.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useOptionalChain": { - "description": "Enforce using concise optional chain instead of chained logical expressions.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useSimplifiedLogicExpression": { - "description": "Discard redundant terms from logical expressions.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - } - } - }, - "Correctness": { - "description": "A list of rules that belong to this group", - "type": "object", - "properties": { - "noChildrenProp": { - "description": "Prevent passing of children as props.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noConstAssign": { - "description": "Prevents from having const variables being re-assigned.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noEmptyPattern": { - "description": "Disallows empty destructuring patterns.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noNewSymbol": { - "description": "Disallow new operators with the Symbol object", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noRenderReturnValue": { - "description": "Prevent the usage of the return value of React.render.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noUndeclaredVariables": { - "description": "Prevents the usage of variables that haven't been declared inside the document", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noUnnecessaryContinue": { - "description": "Avoid using unnecessary continue.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noUnreachable": { - "description": "Disallow unreachable code", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noUnusedVariables": { - "description": "Disallow unused variables.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noVoidElementsWithChildren": { - "description": "This rules prevents void elements (AKA self-closing elements) from having children.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "recommended": { - "description": "It enables the recommended rules for this group", - "type": [ - "boolean", - "null" - ] - }, - "useValidForDirection": { - "description": "Enforce \"for\" loop update clause moving the counter in the right direction.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - } - } - }, - "FilesConfiguration": { - "description": "The configuration of the filesystem", - "type": "object", - "properties": { - "ignore": { - "description": "A list of Unix shell style patterns. Rome tools will ignore files/folders that will match these patterns.", - "type": [ - "array", - "null" - ], - "items": { - "type": "string" - }, - "uniqueItems": true - }, - "maxSize": { - "description": "The maximum allowed size for source code files in bytes. Files above this limit will be ignored for performance reason. Defaults to 1 MiB", - "default": null, - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 1.0 - } - }, - "additionalProperties": false - }, - "FormatterConfiguration": { - "type": "object", - "properties": { - "enabled": { - "default": true, - "type": "boolean" - }, - "formatWithErrors": { - "description": "Stores whether formatting should be allowed to proceed if a given file has syntax errors", - "default": false, - "type": "boolean" - }, - "ignore": { - "description": "A list of Unix shell style patterns. The formatter will ignore files/folders that will match these patterns.", - "type": [ - "array", - "null" - ], - "items": { - "type": "string" - }, - "uniqueItems": true - }, - "indentSize": { - "description": "The size of the indentation, 2 by default", - "default": 2, - "type": "integer", - "format": "uint8", - "minimum": 0.0 - }, - "indentStyle": { - "description": "The indent style.", - "default": "tab", - "allOf": [ - { - "$ref": "#/definitions/PlainIndentStyle" - } - ] - }, - "lineWidth": { - "description": "What's the max width of a line. Defaults to 80.", - "default": 80, - "allOf": [ - { - "$ref": "#/definitions/LineWidth" - } - ] - } - }, - "additionalProperties": false - }, - "JavascriptConfiguration": { - "type": "object", - "properties": { - "formatter": { - "anyOf": [ - { - "$ref": "#/definitions/JavascriptFormatter" - }, - { - "type": "null" - } - ] - }, - "globals": { - "description": "A list of global bindings that should be ignored by the analyzers\n\nIf defined here, they should not emit diagnostics.", - "type": [ - "array", - "null" - ], - "items": { - "type": "string" - }, - "uniqueItems": true - } - }, - "additionalProperties": false - }, - "JavascriptFormatter": { - "type": "object", - "properties": { - "quoteProperties": { - "description": "When properties in objects are quoted. Defaults to asNeeded.", - "default": "asNeeded", - "allOf": [ - { - "$ref": "#/definitions/QuoteProperties" - } - ] - }, - "quoteStyle": { - "description": "The style for quotes. Defaults to double.", - "default": "double", - "allOf": [ - { - "$ref": "#/definitions/QuoteStyle" - } - ] - }, - "semicolons": { - "description": "Whether the formatter prints semicolons for all statements or only in for statements where it is necessary because of ASI.", - "default": "always", - "allOf": [ - { - "$ref": "#/definitions/Semicolons" - } - ] - }, - "trailingComma": { - "description": "Print trailing commas wherever possible in multi-line comma-separated syntactic structures. Defaults to \"all\".", - "default": "all", - "allOf": [ - { - "$ref": "#/definitions/TrailingComma" - } - ] - } - }, - "additionalProperties": false - }, - "LineWidth": { - "description": "Validated value for the `line_width` formatter options\n\nThe allowed range of values is 1..=320", - "type": "integer", - "format": "uint16", - "minimum": 0.0 - }, - "LinterConfiguration": { - "type": "object", - "properties": { - "enabled": { - "description": "if `false`, it disables the feature and the linter won't be executed. `true` by default", - "default": true, - "type": "boolean" - }, - "ignore": { - "description": "A list of Unix shell style patterns. The formatter will ignore files/folders that will match these patterns.", - "type": [ - "array", - "null" - ], - "items": { - "type": "string" - }, - "uniqueItems": true - }, - "rules": { - "description": "List of rules", - "default": { - "recommended": true - }, - "anyOf": [ - { - "$ref": "#/definitions/Rules" - }, - { - "type": "null" - } - ] - } - }, - "additionalProperties": false - }, - "Nursery": { - "description": "A list of rules that belong to this group", - "type": "object", - "properties": { - "noAccessKey": { - "description": "Enforce that the accessKey attribute is not used on any HTML element.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noAssignInExpressions": { - "description": "Disallow assignments in expressions.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noBannedTypes": { - "description": "Disallow certain types.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noClassAssign": { - "description": "Disallow reassigning class members.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noCommaOperator": { - "description": "Disallow comma operator.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noConstEnum": { - "description": "Disallow TypeScript const enum", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noConstructorReturn": { - "description": "Disallow returning a value from a constructor.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noDistractingElements": { - "description": "Enforces that no distracting elements are used.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noDuplicateCase": { - "description": "Disallow duplicate case labels. If a switch statement has duplicate test expressions in case clauses, it is likely that a programmer copied a case clause but forgot to change the test expression.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noDuplicateObjectKeys": { - "description": "Prevents object literals having more than one property declaration for the same name. If an object property with the same name is defined multiple times (except when combining a getter with a setter), only the last definition makes it into the object and previous definitions are ignored, which is likely a mistake.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noEmptyInterface": { - "description": "Disallow the declaration of empty interfaces.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noExtraNonNullAssertion": { - "description": "Prevents the wrong usage of the non-null assertion operator (!) in TypeScript files.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noExtraSemicolons": { - "description": "Typing mistakes and misunderstandings about where semicolons are required can lead to semicolons that are unnecessary. While not technically an error, extra semicolons can cause confusion when reading code.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noHeaderScope": { - "description": "Check that the scope attribute is only used on th elements.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noInvalidConstructorSuper": { - "description": "Prevents the incorrect use of super() inside classes. It also checks whether a call super() is missing from classes that extends other constructors.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noNonNullAssertion": { - "description": "Disallow non-null assertions using the ! postfix operator.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noNoninteractiveElementToInteractiveRole": { - "description": "Enforce that interactive ARIA roles are not assigned to non-interactive HTML elements.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noPrecisionLoss": { - "description": "Disallow literal numbers that lose precision", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noRedundantAlt": { - "description": "Enforce img alt prop does not contain the word \"image\", \"picture\", or \"photo\".", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noRedundantUseStrict": { - "description": "Prevents from having redundant \"use strict\".", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noRestrictedGlobals": { - "description": "This rule allows you to specify global variable names that you don’t want to use in your application.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noSelfCompare": { - "description": "Disallow comparisons where both sides are exactly the same.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noSetterReturn": { - "description": "Disallow returning a value from a setter", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noStringCaseMismatch": { - "description": "Disallow comparison of expressions modifying the string case with non-compliant value.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noUnreachableSuper": { - "description": "Ensures the super() constructor is called exactly once on every code path in a class constructor before this is accessed if the class has a superclass", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noUnsafeFinally": { - "description": "Disallow control flow statements in finally blocks.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noUselessSwitchCase": { - "description": "Disallow useless case in switch statements.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noVar": { - "description": "Disallow the use of var", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noVoidTypeReturn": { - "description": "Disallow returning a value from a function with the return type 'void'", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noWith": { - "description": "Disallow with statements in non-strict contexts.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "recommended": { - "description": "It enables the recommended rules for this group", - "type": [ - "boolean", - "null" - ] - }, - "useAriaPropTypes": { - "description": "Enforce that ARIA state and property values are valid.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useAriaPropsForRole": { - "description": "Enforce that elements with ARIA roles must have all required ARIA attributes for that role.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useCamelCase": { - "description": "Enforce camel case naming convention.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useConst": { - "description": "Require const declarations for variables that are never reassigned after declared.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useDefaultParameterLast": { - "description": "Enforce default function parameters and optional parameters to be last.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useDefaultSwitchClauseLast": { - "description": "Enforce default clauses in switch statements to be last", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useEnumInitializers": { - "description": "Require that each enum member value be explicitly initialized.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useExhaustiveDependencies": { - "description": "Enforce all dependencies are correctly specified.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useExponentiationOperator": { - "description": "Disallow the use of Math.pow in favor of the ** operator.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useHookAtTopLevel": { - "description": "Enforce that all React hooks are being called from the Top Level component functions.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useIframeTitle": { - "description": "Enforces the usage of the attribute title for the element iframe", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useIsNan": { - "description": "Require calls to isNaN() when checking for NaN.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useMediaCaption": { - "description": "Enforces that audio and video elements must have a track for captions.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useNumericLiterals": { - "description": "Disallow parseInt() and Number.parseInt() in favor of binary, octal, and hexadecimal literals", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useSimpleNumberKeys": { - "description": "Disallow use of number literal in format other than decimal as object member name", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useValidAriaProps": { - "description": "Ensures that ARIA properties aria-* are all valid.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useValidLang": { - "description": "Ensure that the attribute passed to the lang attribute is a correct ISO language and/or country.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - } - } - }, - "Performance": { - "description": "A list of rules that belong to this group", - "type": "object", - "properties": { - "noDelete": { - "description": "Disallow the use of the delete operator", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "recommended": { - "description": "It enables the recommended rules for this group", - "type": [ - "boolean", - "null" - ] - } - } - }, - "PlainIndentStyle": { - "type": "string", - "enum": [ - "tab", - "space" - ] - }, - "QuoteProperties": { - "type": "string", - "enum": [ - "asNeeded", - "preserve" - ] - }, - "QuoteStyle": { - "type": "string", - "enum": [ - "double", - "single" - ] - }, - "RuleConfiguration": { - "anyOf": [ - { - "$ref": "#/definitions/RulePlainConfiguration" - }, - { - "$ref": "#/definitions/RuleWithOptions" - } - ] - }, - "RulePlainConfiguration": { - "type": "string", - "enum": [ - "warn", - "error", - "off" - ] - }, - "RuleWithOptions": { - "type": "object", - "required": [ - "level", - "options" - ], - "properties": { - "level": { - "$ref": "#/definitions/RulePlainConfiguration" - }, - "options": true - }, - "additionalProperties": false - }, - "Rules": { - "type": "object", - "properties": { - "a11y": { - "anyOf": [ - { - "$ref": "#/definitions/A11y" - }, - { - "type": "null" - } - ] - }, - "complexity": { - "anyOf": [ - { - "$ref": "#/definitions/Complexity" - }, - { - "type": "null" - } - ] - }, - "correctness": { - "anyOf": [ - { - "$ref": "#/definitions/Correctness" - }, - { - "type": "null" - } - ] - }, - "nursery": { - "anyOf": [ - { - "$ref": "#/definitions/Nursery" - }, - { - "type": "null" - } - ] - }, - "performance": { - "anyOf": [ - { - "$ref": "#/definitions/Performance" - }, - { - "type": "null" - } - ] - }, - "recommended": { - "description": "It enables the lint rules recommended by Rome. `true` by default.", - "type": [ - "boolean", - "null" - ] - }, - "security": { - "anyOf": [ - { - "$ref": "#/definitions/Security" - }, - { - "type": "null" - } - ] - }, - "style": { - "anyOf": [ - { - "$ref": "#/definitions/Style" - }, - { - "type": "null" - } - ] - }, - "suspicious": { - "anyOf": [ - { - "$ref": "#/definitions/Suspicious" - }, - { - "type": "null" - } - ] - } - }, - "additionalProperties": false - }, - "Security": { - "description": "A list of rules that belong to this group", - "type": "object", - "properties": { - "noDangerouslySetInnerHtml": { - "description": "Prevent the usage of dangerous JSX props", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noDangerouslySetInnerHtmlWithChildren": { - "description": "Report when a DOM element or a component uses both children and dangerouslySetInnerHTML prop.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "recommended": { - "description": "It enables the recommended rules for this group", - "type": [ - "boolean", - "null" - ] - } - } - }, - "Semicolons": { - "type": "string", - "enum": [ - "always", - "asNeeded" - ] - }, - "Style": { - "description": "A list of rules that belong to this group", - "type": "object", - "properties": { - "noArguments": { - "description": "Disallow the use of arguments", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noImplicitBoolean": { - "description": "Disallow implicit true values on JSX boolean attributes", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noNegationElse": { - "description": "Disallow negation in the condition of an if statement if it has an else clause", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noShoutyConstants": { - "description": "Disallow the use of constants which its value is the upper-case version of its name.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noUnusedTemplateLiteral": { - "description": "Disallow template literals if interpolation and special-character handling are not needed", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "recommended": { - "description": "It enables the recommended rules for this group", - "type": [ - "boolean", - "null" - ] - }, - "useBlockStatements": { - "description": "Requires following curly brace conventions. JavaScript allows the omission of curly braces when a block contains only one statement. However, it is considered by many to be best practice to never omit curly braces around blocks, even when they are optional, because it can lead to bugs and reduces code clarity.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useFragmentSyntax": { - "description": "This rule enforces the use of <>... over ....", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useSelfClosingElements": { - "description": "Prevent extra closing tags for components without children", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useShorthandArrayType": { - "description": "When expressing array types, this rule promotes the usage of T[] shorthand instead of Array.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useSingleCaseStatement": { - "description": "Enforces case clauses have a single statement, emits a quick fix wrapping the statements in a block", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useSingleVarDeclarator": { - "description": "Disallow multiple variable declarations in the same variable statement", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useTemplate": { - "description": "Template literals are preferred over string concatenation.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useWhile": { - "description": "Enforce the use of while loops instead of for loops when the initializer and update expressions are not needed", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - } - } - }, - "Suspicious": { - "description": "A list of rules that belong to this group", - "type": "object", - "properties": { - "noArrayIndexKey": { - "description": "Discourage the usage of Array index in keys.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noAsyncPromiseExecutor": { - "description": "Disallows using an async function as a Promise executor.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noCatchAssign": { - "description": "Disallow reassigning exceptions in catch clauses", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noCommentText": { - "description": "Prevent comments from being inserted as text nodes", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noCompareNegZero": { - "description": "Disallow comparing against -0", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noDebugger": { - "description": "Disallow the use of debugger", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noDoubleEquals": { - "description": "Require the use of === and !==", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noDuplicateParameters": { - "description": "Disallow duplicate function arguments name.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noExplicitAny": { - "description": "Disallow the any type usage", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noFunctionAssign": { - "description": "Disallow reassigning function declarations.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noImportAssign": { - "description": "Disallow assigning to imported bindings", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noLabelVar": { - "description": "Disallow labels that share a name with a variable", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noShadowRestrictedNames": { - "description": "Disallow identifiers from shadowing restricted names.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noSparseArray": { - "description": "Disallow sparse arrays", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noUnsafeNegation": { - "description": "Disallow using unsafe negation.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "recommended": { - "description": "It enables the recommended rules for this group", - "type": [ - "boolean", - "null" - ] - }, - "useValidTypeof": { - "description": "This rule verifies the result of typeof $expr unary expressions is being compared to valid values, either string literals containing valid type names or other typeof expressions", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - } - } - }, - "TrailingComma": { - "type": "string", - "enum": [ - "all", - "es5", - "none" - ] - } - } + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Configuration", + "description": "The configuration that is contained inside the file `rome.json`", + "type": "object", + "properties": { + "$schema": { + "description": "A field for the [JSON schema](https://json-schema.org/) specification", + "type": ["string", "null"] + }, + "files": { + "description": "The configuration of the filesystem", + "anyOf": [ + { + "$ref": "#/definitions/FilesConfiguration" + }, + { + "type": "null" + } + ] + }, + "formatter": { + "description": "The configuration of the formatter", + "anyOf": [ + { + "$ref": "#/definitions/FormatterConfiguration" + }, + { + "type": "null" + } + ] + }, + "javascript": { + "description": "Specific configuration for the JavaScript language", + "anyOf": [ + { + "$ref": "#/definitions/JavascriptConfiguration" + }, + { + "type": "null" + } + ] + }, + "linter": { + "description": "The configuration for the linter", + "anyOf": [ + { + "$ref": "#/definitions/LinterConfiguration" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false, + "definitions": { + "A11y": { + "description": "A list of rules that belong to this group", + "type": "object", + "properties": { + "noAutofocus": { + "description": "Avoid the autoFocus attribute", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noBlankTarget": { + "description": "Disallow target=\"_blank\" attribute without rel=\"noreferrer\"", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noPositiveTabindex": { + "description": "Prevent the usage of positive integers on tabIndex property", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "recommended": { + "description": "It enables the recommended rules for this group", + "type": ["boolean", "null"] + }, + "useAltText": { + "description": "It asserts that alternative text to images or areas, help to rely on to screen readers to understand the purpose and the context of the image.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useAnchorContent": { + "description": "Enforce that anchor elements have content and that the content is accessible to screen readers.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useButtonType": { + "description": "Enforces the usage of the attribute type for the element button", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useHtmlLang": { + "description": "Enforce that html element has lang attribute. This allows users to choose a language other than the default.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useKeyWithClickEvents": { + "description": "Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useKeyWithMouseEvents": { + "description": "Enforce that onMouseOver/onMouseOut are accompanied by onFocus/onBlur for keyboard-only users. It is important to take into account users with physical disabilities who cannot use a mouse, who use assistive technology or screenreader.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useValidAnchor": { + "description": "Enforce that all anchors are valid, and they are navigable elements.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + } + } + }, + "Complexity": { + "description": "A list of rules that belong to this group", + "type": "object", + "properties": { + "noExtraBooleanCast": { + "description": "Disallow unnecessary boolean casts", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noMultipleSpacesInRegularExpressionLiterals": { + "description": "Disallow unclear usage of multiple space characters in regular expression literals", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUselessFragments": { + "description": "Disallow unnecessary fragments", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "recommended": { + "description": "It enables the recommended rules for this group", + "type": ["boolean", "null"] + }, + "useFlatMap": { + "description": "Promotes the use of .flatMap() when map().flat() are used together.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useOptionalChain": { + "description": "Enforce using concise optional chain instead of chained logical expressions.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useSimplifiedLogicExpression": { + "description": "Discard redundant terms from logical expressions.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + } + } + }, + "Correctness": { + "description": "A list of rules that belong to this group", + "type": "object", + "properties": { + "noChildrenProp": { + "description": "Prevent passing of children as props.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noConstAssign": { + "description": "Prevents from having const variables being re-assigned.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noEmptyPattern": { + "description": "Disallows empty destructuring patterns.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noNewSymbol": { + "description": "Disallow new operators with the Symbol object", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noRenderReturnValue": { + "description": "Prevent the usage of the return value of React.render.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUndeclaredVariables": { + "description": "Prevents the usage of variables that haven't been declared inside the document", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUnnecessaryContinue": { + "description": "Avoid using unnecessary continue.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUnreachable": { + "description": "Disallow unreachable code", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUnusedVariables": { + "description": "Disallow unused variables.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noVoidElementsWithChildren": { + "description": "This rules prevents void elements (AKA self-closing elements) from having children.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "recommended": { + "description": "It enables the recommended rules for this group", + "type": ["boolean", "null"] + }, + "useValidForDirection": { + "description": "Enforce \"for\" loop update clause moving the counter in the right direction.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + } + } + }, + "FilesConfiguration": { + "description": "The configuration of the filesystem", + "type": "object", + "properties": { + "ignore": { + "description": "A list of Unix shell style patterns. Rome tools will ignore files/folders that will match these patterns.", + "type": ["array", "null"], + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "maxSize": { + "description": "The maximum allowed size for source code files in bytes. Files above this limit will be ignored for performance reason. Defaults to 1 MiB", + "default": null, + "type": ["integer", "null"], + "format": "uint64", + "minimum": 1.0 + } + }, + "additionalProperties": false + }, + "FormatterConfiguration": { + "type": "object", + "properties": { + "enabled": { + "default": true, + "type": "boolean" + }, + "formatWithErrors": { + "description": "Stores whether formatting should be allowed to proceed if a given file has syntax errors", + "default": false, + "type": "boolean" + }, + "ignore": { + "description": "A list of Unix shell style patterns. The formatter will ignore files/folders that will match these patterns.", + "type": ["array", "null"], + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "indentSize": { + "description": "The size of the indentation, 2 by default", + "default": 2, + "type": "integer", + "format": "uint8", + "minimum": 0.0 + }, + "indentStyle": { + "description": "The indent style.", + "default": "tab", + "allOf": [ + { + "$ref": "#/definitions/PlainIndentStyle" + } + ] + }, + "lineWidth": { + "description": "What's the max width of a line. Defaults to 80.", + "default": 80, + "allOf": [ + { + "$ref": "#/definitions/LineWidth" + } + ] + } + }, + "additionalProperties": false + }, + "JavascriptConfiguration": { + "type": "object", + "properties": { + "formatter": { + "anyOf": [ + { + "$ref": "#/definitions/JavascriptFormatter" + }, + { + "type": "null" + } + ] + }, + "globals": { + "description": "A list of global bindings that should be ignored by the analyzers\n\nIf defined here, they should not emit diagnostics.", + "type": ["array", "null"], + "items": { + "type": "string" + }, + "uniqueItems": true + } + }, + "additionalProperties": false + }, + "JavascriptFormatter": { + "type": "object", + "properties": { + "quoteProperties": { + "description": "When properties in objects are quoted. Defaults to asNeeded.", + "default": "asNeeded", + "allOf": [ + { + "$ref": "#/definitions/QuoteProperties" + } + ] + }, + "quoteStyle": { + "description": "The style for quotes. Defaults to double.", + "default": "double", + "allOf": [ + { + "$ref": "#/definitions/QuoteStyle" + } + ] + }, + "semicolons": { + "description": "Whether the formatter prints semicolons for all statements or only in for statements where it is necessary because of ASI.", + "default": "always", + "allOf": [ + { + "$ref": "#/definitions/Semicolons" + } + ] + }, + "trailingComma": { + "description": "Print trailing commas wherever possible in multi-line comma-separated syntactic structures. Defaults to \"all\".", + "default": "all", + "allOf": [ + { + "$ref": "#/definitions/TrailingComma" + } + ] + } + }, + "additionalProperties": false + }, + "LineWidth": { + "description": "Validated value for the `line_width` formatter options\n\nThe allowed range of values is 1..=320", + "type": "integer", + "format": "uint16", + "minimum": 0.0 + }, + "LinterConfiguration": { + "type": "object", + "properties": { + "enabled": { + "description": "if `false`, it disables the feature and the linter won't be executed. `true` by default", + "default": true, + "type": "boolean" + }, + "ignore": { + "description": "A list of Unix shell style patterns. The formatter will ignore files/folders that will match these patterns.", + "type": ["array", "null"], + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "rules": { + "description": "List of rules", + "default": { + "recommended": true + }, + "anyOf": [ + { + "$ref": "#/definitions/Rules" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false + }, + "Nursery": { + "description": "A list of rules that belong to this group", + "type": "object", + "properties": { + "noAccessKey": { + "description": "Enforce that the accessKey attribute is not used on any HTML element.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noAssignInExpressions": { + "description": "Disallow assignments in expressions.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noBannedTypes": { + "description": "Disallow certain types.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noClassAssign": { + "description": "Disallow reassigning class members.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noCommaOperator": { + "description": "Disallow comma operator.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noConstEnum": { + "description": "Disallow TypeScript const enum", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noConstructorReturn": { + "description": "Disallow returning a value from a constructor.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noDistractingElements": { + "description": "Enforces that no distracting elements are used.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noDuplicateCase": { + "description": "Disallow duplicate case labels. If a switch statement has duplicate test expressions in case clauses, it is likely that a programmer copied a case clause but forgot to change the test expression.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noDuplicateObjectKeys": { + "description": "Prevents object literals having more than one property declaration for the same name. If an object property with the same name is defined multiple times (except when combining a getter with a setter), only the last definition makes it into the object and previous definitions are ignored, which is likely a mistake.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noEmptyInterface": { + "description": "Disallow the declaration of empty interfaces.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noExtraNonNullAssertion": { + "description": "Prevents the wrong usage of the non-null assertion operator (!) in TypeScript files.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noExtraSemicolons": { + "description": "Typing mistakes and misunderstandings about where semicolons are required can lead to semicolons that are unnecessary. While not technically an error, extra semicolons can cause confusion when reading code.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noHeaderScope": { + "description": "Check that the scope attribute is only used on th elements.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noInvalidConstructorSuper": { + "description": "Prevents the incorrect use of super() inside classes. It also checks whether a call super() is missing from classes that extends other constructors.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noNonNullAssertion": { + "description": "Disallow non-null assertions using the ! postfix operator.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noNoninteractiveElementToInteractiveRole": { + "description": "Enforce that interactive ARIA roles are not assigned to non-interactive HTML elements.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noPrecisionLoss": { + "description": "Disallow literal numbers that lose precision", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noRedundantAlt": { + "description": "Enforce img alt prop does not contain the word \"image\", \"picture\", or \"photo\".", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noRedundantUseStrict": { + "description": "Prevents from having redundant \"use strict\".", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noRestrictedGlobals": { + "description": "This rule allows you to specify global variable names that you don’t want to use in your application.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noSelfCompare": { + "description": "Disallow comparisons where both sides are exactly the same.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noSetterReturn": { + "description": "Disallow returning a value from a setter", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noStringCaseMismatch": { + "description": "Disallow comparison of expressions modifying the string case with non-compliant value.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUnreachableSuper": { + "description": "Ensures the super() constructor is called exactly once on every code path in a class constructor before this is accessed if the class has a superclass", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUnsafeFinally": { + "description": "Disallow control flow statements in finally blocks.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUselessSwitchCase": { + "description": "Disallow useless case in switch statements.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noVar": { + "description": "Disallow the use of var", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noVoidTypeReturn": { + "description": "Disallow returning a value from a function with the return type 'void'", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noWith": { + "description": "Disallow with statements in non-strict contexts.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "recommended": { + "description": "It enables the recommended rules for this group", + "type": ["boolean", "null"] + }, + "useAriaPropTypes": { + "description": "Enforce that ARIA state and property values are valid.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useAriaPropsForRole": { + "description": "Enforce that elements with ARIA roles must have all required ARIA attributes for that role.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useCamelCase": { + "description": "Enforce camel case naming convention.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useConst": { + "description": "Require const declarations for variables that are never reassigned after declared.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useDefaultParameterLast": { + "description": "Enforce default function parameters and optional parameters to be last.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useDefaultSwitchClauseLast": { + "description": "Enforce default clauses in switch statements to be last", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useEnumInitializers": { + "description": "Require that each enum member value be explicitly initialized.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useExhaustiveDependencies": { + "description": "Enforce all dependencies are correctly specified.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useExponentiationOperator": { + "description": "Disallow the use of Math.pow in favor of the ** operator.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useHookAtTopLevel": { + "description": "Enforce that all React hooks are being called from the Top Level component functions.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useIframeTitle": { + "description": "Enforces the usage of the attribute title for the element iframe", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useIsNan": { + "description": "Require calls to isNaN() when checking for NaN.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useMediaCaption": { + "description": "Enforces that audio and video elements must have a track for captions.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useNumericLiterals": { + "description": "Disallow parseInt() and Number.parseInt() in favor of binary, octal, and hexadecimal literals", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useSimpleNumberKeys": { + "description": "Disallow number literal object member names which are not base10 or uses underscore as separator", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useValidAriaProps": { + "description": "Ensures that ARIA properties aria-* are all valid.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useValidLang": { + "description": "Ensure that the attribute passed to the lang attribute is a correct ISO language and/or country.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + } + } + }, + "Performance": { + "description": "A list of rules that belong to this group", + "type": "object", + "properties": { + "noDelete": { + "description": "Disallow the use of the delete operator", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "recommended": { + "description": "It enables the recommended rules for this group", + "type": ["boolean", "null"] + } + } + }, + "PlainIndentStyle": { + "type": "string", + "enum": ["tab", "space"] + }, + "QuoteProperties": { + "type": "string", + "enum": ["asNeeded", "preserve"] + }, + "QuoteStyle": { + "type": "string", + "enum": ["double", "single"] + }, + "RuleConfiguration": { + "anyOf": [ + { + "$ref": "#/definitions/RulePlainConfiguration" + }, + { + "$ref": "#/definitions/RuleWithOptions" + } + ] + }, + "RulePlainConfiguration": { + "type": "string", + "enum": ["warn", "error", "off"] + }, + "RuleWithOptions": { + "type": "object", + "required": ["level", "options"], + "properties": { + "level": { + "$ref": "#/definitions/RulePlainConfiguration" + }, + "options": true + }, + "additionalProperties": false + }, + "Rules": { + "type": "object", + "properties": { + "a11y": { + "anyOf": [ + { + "$ref": "#/definitions/A11y" + }, + { + "type": "null" + } + ] + }, + "complexity": { + "anyOf": [ + { + "$ref": "#/definitions/Complexity" + }, + { + "type": "null" + } + ] + }, + "correctness": { + "anyOf": [ + { + "$ref": "#/definitions/Correctness" + }, + { + "type": "null" + } + ] + }, + "nursery": { + "anyOf": [ + { + "$ref": "#/definitions/Nursery" + }, + { + "type": "null" + } + ] + }, + "performance": { + "anyOf": [ + { + "$ref": "#/definitions/Performance" + }, + { + "type": "null" + } + ] + }, + "recommended": { + "description": "It enables the lint rules recommended by Rome. `true` by default.", + "type": ["boolean", "null"] + }, + "security": { + "anyOf": [ + { + "$ref": "#/definitions/Security" + }, + { + "type": "null" + } + ] + }, + "style": { + "anyOf": [ + { + "$ref": "#/definitions/Style" + }, + { + "type": "null" + } + ] + }, + "suspicious": { + "anyOf": [ + { + "$ref": "#/definitions/Suspicious" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false + }, + "Security": { + "description": "A list of rules that belong to this group", + "type": "object", + "properties": { + "noDangerouslySetInnerHtml": { + "description": "Prevent the usage of dangerous JSX props", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noDangerouslySetInnerHtmlWithChildren": { + "description": "Report when a DOM element or a component uses both children and dangerouslySetInnerHTML prop.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "recommended": { + "description": "It enables the recommended rules for this group", + "type": ["boolean", "null"] + } + } + }, + "Semicolons": { + "type": "string", + "enum": ["always", "asNeeded"] + }, + "Style": { + "description": "A list of rules that belong to this group", + "type": "object", + "properties": { + "noArguments": { + "description": "Disallow the use of arguments", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noImplicitBoolean": { + "description": "Disallow implicit true values on JSX boolean attributes", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noNegationElse": { + "description": "Disallow negation in the condition of an if statement if it has an else clause", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noShoutyConstants": { + "description": "Disallow the use of constants which its value is the upper-case version of its name.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUnusedTemplateLiteral": { + "description": "Disallow template literals if interpolation and special-character handling are not needed", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "recommended": { + "description": "It enables the recommended rules for this group", + "type": ["boolean", "null"] + }, + "useBlockStatements": { + "description": "Requires following curly brace conventions. JavaScript allows the omission of curly braces when a block contains only one statement. However, it is considered by many to be best practice to never omit curly braces around blocks, even when they are optional, because it can lead to bugs and reduces code clarity.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useFragmentSyntax": { + "description": "This rule enforces the use of <>... over ....", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useSelfClosingElements": { + "description": "Prevent extra closing tags for components without children", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useShorthandArrayType": { + "description": "When expressing array types, this rule promotes the usage of T[] shorthand instead of Array.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useSingleCaseStatement": { + "description": "Enforces case clauses have a single statement, emits a quick fix wrapping the statements in a block", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useSingleVarDeclarator": { + "description": "Disallow multiple variable declarations in the same variable statement", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useTemplate": { + "description": "Template literals are preferred over string concatenation.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useWhile": { + "description": "Enforce the use of while loops instead of for loops when the initializer and update expressions are not needed", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + } + } + }, + "Suspicious": { + "description": "A list of rules that belong to this group", + "type": "object", + "properties": { + "noArrayIndexKey": { + "description": "Discourage the usage of Array index in keys.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noAsyncPromiseExecutor": { + "description": "Disallows using an async function as a Promise executor.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noCatchAssign": { + "description": "Disallow reassigning exceptions in catch clauses", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noCommentText": { + "description": "Prevent comments from being inserted as text nodes", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noCompareNegZero": { + "description": "Disallow comparing against -0", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noDebugger": { + "description": "Disallow the use of debugger", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noDoubleEquals": { + "description": "Require the use of === and !==", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noDuplicateParameters": { + "description": "Disallow duplicate function arguments name.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noExplicitAny": { + "description": "Disallow the any type usage", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noFunctionAssign": { + "description": "Disallow reassigning function declarations.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noImportAssign": { + "description": "Disallow assigning to imported bindings", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noLabelVar": { + "description": "Disallow labels that share a name with a variable", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noShadowRestrictedNames": { + "description": "Disallow identifiers from shadowing restricted names.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noSparseArray": { + "description": "Disallow sparse arrays", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUnsafeNegation": { + "description": "Disallow using unsafe negation.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "recommended": { + "description": "It enables the recommended rules for this group", + "type": ["boolean", "null"] + }, + "useValidTypeof": { + "description": "This rule verifies the result of typeof $expr unary expressions is being compared to valid values, either string literals containing valid type names or other typeof expressions", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + } + } + }, + "TrailingComma": { + "type": "string", + "enum": ["all", "es5", "none"] + } + } } diff --git a/website/src/pages/lint/rules/index.mdx b/website/src/pages/lint/rules/index.mdx index 47280e79391..b381080a2d4 100644 --- a/website/src/pages/lint/rules/index.mdx +++ b/website/src/pages/lint/rules/index.mdx @@ -763,7 +763,7 @@ Disallow parseInt() and Number.parseInt() in favor of

useSimpleNumberKeys

-Disallow use of number literal in format other than decimal as object member name +Disallow number literal object member names which are not base10 or uses underscore as separator

diff --git a/website/src/pages/lint/rules/useSimpleNumberKeys.md b/website/src/pages/lint/rules/useSimpleNumberKeys.md index 4c216e8bb34..1d7b14a7ca8 100644 --- a/website/src/pages/lint/rules/useSimpleNumberKeys.md +++ b/website/src/pages/lint/rules/useSimpleNumberKeys.md @@ -5,7 +5,7 @@ parent: lint/rules/index # useSimpleNumberKeys (since vnext) -Disallow use of number literal in format other than decimal as object member name +Disallow number literal object member names which are not base10 or uses underscore as separator ## Examples From 2f1e22fc210e9c9f70d01b97e9350afc82f2f944 Mon Sep 17 00:00:00 2001 From: Dhiraj Arun Date: Mon, 9 Jan 2023 15:05:07 +0530 Subject: [PATCH 4/8] refactor --- .../rome_js_analyze/src/analyzers/nursery.rs | 3 +- .../nursery/use_simple_number_keys.rs | 31 +- .../specs/nursery/useSimpleNumberKeys.js | 23 +- .../specs/nursery/useSimpleNumberKeys.js.snap | 253 +- .../src/configuration/linter/rules.rs | 7 +- editors/vscode/configuration_schema.json | 3318 +++++++++-------- npm/backend-jsonrpc/src/workspace.ts | 12 +- npm/rome/configuration_schema.json | 3318 +++++++++-------- 8 files changed, 3556 insertions(+), 3409 deletions(-) diff --git a/crates/rome_js_analyze/src/analyzers/nursery.rs b/crates/rome_js_analyze/src/analyzers/nursery.rs index 84b9461ff89..ca6aa844839 100644 --- a/crates/rome_js_analyze/src/analyzers/nursery.rs +++ b/crates/rome_js_analyze/src/analyzers/nursery.rs @@ -36,5 +36,4 @@ mod use_is_nan; mod use_media_caption; mod use_numeric_literals; mod use_simple_number_keys; - -declare_group! { pub (crate) Nursery { name : "nursery" , rules : [self :: no_access_key :: NoAccessKey , self :: no_assign_in_expressions :: NoAssignInExpressions , self :: no_banned_types :: NoBannedTypes , self :: no_comma_operator :: NoCommaOperator , self :: no_const_enum :: NoConstEnum , self :: no_constructor_return :: NoConstructorReturn , self :: no_distracting_elements :: NoDistractingElements , self :: no_duplicate_case :: NoDuplicateCase , self :: no_duplicate_object_keys :: NoDuplicateObjectKeys , self :: no_empty_interface :: NoEmptyInterface , self :: no_extra_non_null_assertion :: NoExtraNonNullAssertion , self :: no_extra_semicolons :: NoExtraSemicolons , self :: no_header_scope :: NoHeaderScope , self :: no_invalid_constructor_super :: NoInvalidConstructorSuper , self :: no_non_null_assertion :: NoNonNullAssertion , self :: no_precision_loss :: NoPrecisionLoss , self :: no_redundant_alt :: NoRedundantAlt , self :: no_redundant_use_strict :: NoRedundantUseStrict , self :: no_self_compare :: NoSelfCompare , self :: no_setter_return :: NoSetterReturn , self :: no_string_case_mismatch :: NoStringCaseMismatch , self :: no_unreachable_super :: NoUnreachableSuper , self :: no_unsafe_finally :: NoUnsafeFinally , self :: no_useless_switch_case :: NoUselessSwitchCase , self :: no_void_type_return :: NoVoidTypeReturn , self :: no_with :: NoWith , self :: use_default_parameter_last :: UseDefaultParameterLast , self :: use_default_switch_clause_last :: UseDefaultSwitchClauseLast , self :: use_enum_initializers :: UseEnumInitializers , self :: use_exponentiation_operator :: UseExponentiationOperator , self :: use_is_nan :: UseIsNan , self :: use_media_caption :: UseMediaCaption , self :: use_numeric_literals :: UseNumericLiterals , self :: use_simple_number_keys :: UseSimpleNumberKeys , self :: no_inner_declarations :: NoInnerDeclarations , ] } } +declare_group! { pub (crate) Nursery { name : "nursery" , rules : [self :: no_access_key :: NoAccessKey , self :: no_assign_in_expressions :: NoAssignInExpressions , self :: no_banned_types :: NoBannedTypes , self :: no_comma_operator :: NoCommaOperator , self :: no_const_enum :: NoConstEnum , self :: no_constructor_return :: NoConstructorReturn , self :: no_distracting_elements :: NoDistractingElements , self :: no_duplicate_case :: NoDuplicateCase , self :: no_duplicate_object_keys :: NoDuplicateObjectKeys , self :: no_empty_interface :: NoEmptyInterface , self :: no_extra_non_null_assertion :: NoExtraNonNullAssertion , self :: no_extra_semicolons :: NoExtraSemicolons , self :: no_header_scope :: NoHeaderScope , self :: no_inner_declarations :: NoInnerDeclarations , self :: no_invalid_constructor_super :: NoInvalidConstructorSuper , self :: no_non_null_assertion :: NoNonNullAssertion , self :: no_precision_loss :: NoPrecisionLoss , self :: no_redundant_alt :: NoRedundantAlt , self :: no_redundant_use_strict :: NoRedundantUseStrict , self :: no_self_compare :: NoSelfCompare , self :: no_setter_return :: NoSetterReturn , self :: no_string_case_mismatch :: NoStringCaseMismatch , self :: no_unreachable_super :: NoUnreachableSuper , self :: no_unsafe_finally :: NoUnsafeFinally , self :: no_useless_switch_case :: NoUselessSwitchCase , self :: no_void_type_return :: NoVoidTypeReturn , self :: no_with :: NoWith , self :: use_default_parameter_last :: UseDefaultParameterLast , self :: use_default_switch_clause_last :: UseDefaultSwitchClauseLast , self :: use_enum_initializers :: UseEnumInitializers , self :: use_exponentiation_operator :: UseExponentiationOperator , self :: use_is_nan :: UseIsNan , self :: use_media_caption :: UseMediaCaption , self :: use_numeric_literals :: UseNumericLiterals , self :: use_simple_number_keys :: UseSimpleNumberKeys ,] } } diff --git a/crates/rome_js_analyze/src/analyzers/nursery/use_simple_number_keys.rs b/crates/rome_js_analyze/src/analyzers/nursery/use_simple_number_keys.rs index 3a86260cfd8..9c5128ea82a 100644 --- a/crates/rome_js_analyze/src/analyzers/nursery/use_simple_number_keys.rs +++ b/crates/rome_js_analyze/src/analyzers/nursery/use_simple_number_keys.rs @@ -219,18 +219,16 @@ impl Rule for UseSimpleNumberKeys { number_literal: &Self::State, ) -> Option { let title = match number_literal { - NumberLiteral::Decimal { big_int: true, .. } => "Bigint is not allowed", + NumberLiteral::Decimal { big_int: true, .. } => "Bigint is not allowed here.", NumberLiteral::Decimal { underscore: true, .. - } => "Number literal with underscore is not allowed", + } => "Number literal with underscore is not allowed here.", NumberLiteral::FloatingPoint { underscore: true, .. - } => "Number literal with underscore is not allowed", - NumberLiteral::Binary { .. } => "Number literal in binary format is not allowed", - NumberLiteral::Hexadecimal { .. } => { - "Number literal in hexadecimal format is not allowed" - } - NumberLiteral::Octal { .. } => "Number literal in octal format is not allowed", + } => "Number literal with underscore is not allowed.", + NumberLiteral::Binary { .. } => "Binary number literal in is not allowed here.", + NumberLiteral::Hexadecimal { .. } => "Hexadecimal number literal is not allowed here.", + NumberLiteral::Octal { .. } => "Octal number literal is not allowed here.", _ => "", }; @@ -243,24 +241,29 @@ impl Rule for UseSimpleNumberKeys { fn action(ctx: &RuleContext, number_literal: &Self::State) -> Option { let mut mutation = ctx.root().begin(); let node = ctx.query(); + let message; if let Ok(token) = node.value() { match number_literal { NumberLiteral::Binary { .. } | NumberLiteral::Octal { .. } - | NumberLiteral::Hexadecimal { .. } => mutation.replace_token( - token, - make::js_number_literal(number_literal.to_base_ten()?), - ), + | NumberLiteral::Hexadecimal { .. } => { + let text = number_literal.to_base_ten()?; + message = markup! ("Replace "{ node.to_string() } " with "{text.to_string()}) + .to_owned(); + mutation.replace_token(token, make::js_number_literal(text)); + } NumberLiteral::FloatingPoint { .. } | NumberLiteral::Decimal { .. } => { - mutation.replace_token(token, make::js_number_literal(number_literal.value())); + let text = number_literal.value(); + message = markup! ("Replace "{ node.to_string() } " with "{text}).to_owned(); + mutation.replace_token(token, make::js_number_literal(text)); } }; return Some(JsRuleAction { category: ActionCategory::QuickFix, applicability: Applicability::Always, - message: markup! ("Remove "{ node.to_string() }).to_owned(), + message, mutation, }); } diff --git a/crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys.js b/crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys.js index a60a1289263..c48ed00b11d 100644 --- a/crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys.js +++ b/crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys.js @@ -1,18 +1,23 @@ -// invalid +// valid +({ 0: "zero" }); +({ 1: "one" }); +({ 1.2: "12" }); +({ 3.1e12: "12" }); +({ 0.1e12: "ee" }); +// invalid ({ 1n: 1 }); + ({ 0x1: 1 }); + ({ 012: 1 }); + ({ 0b1: 1 }); + ({ 0o1: 1 }); + ({ 1_0: 1 }); -({ 0.1e1_2: "ee" }); -({ 11_1.11: "ee" }); -// valid +({ 0.1e1_2: "ed" }); -({ 0: "zero" }); -({ 1: "one" }); -({ 1.2: "12" }); -({ 3.1e12: "12" }); -({ 0.1e12: "ee" }); +({ 11_1.11: "ee" }); diff --git a/crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys.js.snap b/crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys.js.snap index 3d976f83cc5..c1e064832ef 100644 --- a/crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys.js.snap +++ b/crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys.js.snap @@ -4,215 +4,218 @@ expression: useSimpleNumberKeys.js --- # Input ```js -// invalid +// valid +({ 0: "zero" }); +({ 1: "one" }); +({ 1.2: "12" }); +({ 3.1e12: "12" }); +({ 0.1e12: "ee" }); +// invalid ({ 1n: 1 }); + ({ 0x1: 1 }); + ({ 012: 1 }); + ({ 0b1: 1 }); + ({ 0o1: 1 }); + ({ 1_0: 1 }); -({ 0.1e1_2: "ee" }); -({ 11_1.11: "ee" }); -// valid +({ 0.1e1_2: "ed" }); -({ 0: "zero" }); -({ 1: "one" }); -({ 1.2: "12" }); -({ 3.1e12: "12" }); -({ 0.1e12: "ee" }); +({ 11_1.11: "ee" }); ``` # Diagnostics ``` -useSimpleNumberKeys.js:3:4 lint/nursery/useSimpleNumberKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +useSimpleNumberKeys.js:9:4 lint/nursery/useSimpleNumberKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - ! Bigint is not allowed + ! Bigint is not allowed here. - 1 │ // invalid - 2 │ - > 3 │ ({ 1n: 1 }); - │ ^^ - 4 │ ({ 0x1: 1 }); - 5 │ ({ 012: 1 }); + 8 │ // invalid + > 9 │ ({ 1n: 1 }); + │ ^^ + 10 │ + 11 │ ({ 0x1: 1 }); - i Safe fix: Remove 1n + i Safe fix: Replace 1n with 1 - 1 1 │ // invalid - 2 2 │ - 3 │ - ({·1n:·1·}); - 3 │ + ({·1:·1·}); - 4 4 │ ({ 0x1: 1 }); - 5 5 │ ({ 012: 1 }); + 7 7 │ + 8 8 │ // invalid + 9 │ - ({·1n:·1·}); + 9 │ + ({·1:·1·}); + 10 10 │ + 11 11 │ ({ 0x1: 1 }); ``` ``` -useSimpleNumberKeys.js:4:4 lint/nursery/useSimpleNumberKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +useSimpleNumberKeys.js:11:4 lint/nursery/useSimpleNumberKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - ! Number literal in hexadecimal format is not allowed + ! Hexadecimal number literal is not allowed here. - 3 │ ({ 1n: 1 }); - > 4 │ ({ 0x1: 1 }); - │ ^^^ - 5 │ ({ 012: 1 }); - 6 │ ({ 0b1: 1 }); + 9 │ ({ 1n: 1 }); + 10 │ + > 11 │ ({ 0x1: 1 }); + │ ^^^ + 12 │ + 13 │ ({ 012: 1 }); - i Safe fix: Remove 0x1 + i Safe fix: Replace 0x1 with 1 - 2 2 │ - 3 3 │ ({ 1n: 1 }); - 4 │ - ({·0x1:·1·}); - 4 │ + ({·1:·1·}); - 5 5 │ ({ 012: 1 }); - 6 6 │ ({ 0b1: 1 }); + 9 9 │ ({ 1n: 1 }); + 10 10 │ + 11 │ - ({·0x1:·1·}); + 11 │ + ({·1:·1·}); + 12 12 │ + 13 13 │ ({ 012: 1 }); ``` ``` -useSimpleNumberKeys.js:5:4 lint/nursery/useSimpleNumberKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +useSimpleNumberKeys.js:13:4 lint/nursery/useSimpleNumberKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - ! Number literal in octal format is not allowed + ! Octal number literal is not allowed here. - 3 │ ({ 1n: 1 }); - 4 │ ({ 0x1: 1 }); - > 5 │ ({ 012: 1 }); - │ ^^^ - 6 │ ({ 0b1: 1 }); - 7 │ ({ 0o1: 1 }); + 11 │ ({ 0x1: 1 }); + 12 │ + > 13 │ ({ 012: 1 }); + │ ^^^ + 14 │ + 15 │ ({ 0b1: 1 }); - i Safe fix: Remove 012 + i Safe fix: Replace 012 with 9 - 3 3 │ ({ 1n: 1 }); - 4 4 │ ({ 0x1: 1 }); - 5 │ - ({·012:·1·}); - 5 │ + ({·9:·1·}); - 6 6 │ ({ 0b1: 1 }); - 7 7 │ ({ 0o1: 1 }); + 11 11 │ ({ 0x1: 1 }); + 12 12 │ + 13 │ - ({·012:·1·}); + 13 │ + ({·9:·1·}); + 14 14 │ + 15 15 │ ({ 0b1: 1 }); ``` ``` -useSimpleNumberKeys.js:6:4 lint/nursery/useSimpleNumberKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +useSimpleNumberKeys.js:15:4 lint/nursery/useSimpleNumberKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - ! Number literal in binary format is not allowed + ! Binary number literal in is not allowed here. - 4 │ ({ 0x1: 1 }); - 5 │ ({ 012: 1 }); - > 6 │ ({ 0b1: 1 }); - │ ^^^ - 7 │ ({ 0o1: 1 }); - 8 │ ({ 1_0: 1 }); + 13 │ ({ 012: 1 }); + 14 │ + > 15 │ ({ 0b1: 1 }); + │ ^^^ + 16 │ + 17 │ ({ 0o1: 1 }); - i Safe fix: Remove 0b1 + i Safe fix: Replace 0b1 with 1 - 4 4 │ ({ 0x1: 1 }); - 5 5 │ ({ 012: 1 }); - 6 │ - ({·0b1:·1·}); - 6 │ + ({·1:·1·}); - 7 7 │ ({ 0o1: 1 }); - 8 8 │ ({ 1_0: 1 }); + 13 13 │ ({ 012: 1 }); + 14 14 │ + 15 │ - ({·0b1:·1·}); + 15 │ + ({·1:·1·}); + 16 16 │ + 17 17 │ ({ 0o1: 1 }); ``` ``` -useSimpleNumberKeys.js:7:4 lint/nursery/useSimpleNumberKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +useSimpleNumberKeys.js:17:4 lint/nursery/useSimpleNumberKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - ! Number literal in octal format is not allowed + ! Octal number literal is not allowed here. - 5 │ ({ 012: 1 }); - 6 │ ({ 0b1: 1 }); - > 7 │ ({ 0o1: 1 }); - │ ^^^ - 8 │ ({ 1_0: 1 }); - 9 │ ({ 0.1e1_2: "ee" }); + 15 │ ({ 0b1: 1 }); + 16 │ + > 17 │ ({ 0o1: 1 }); + │ ^^^ + 18 │ + 19 │ ({ 1_0: 1 }); - i Safe fix: Remove 0o1 + i Safe fix: Replace 0o1 with 1 - 5 5 │ ({ 012: 1 }); - 6 6 │ ({ 0b1: 1 }); - 7 │ - ({·0o1:·1·}); - 7 │ + ({·1:·1·}); - 8 8 │ ({ 1_0: 1 }); - 9 9 │ ({ 0.1e1_2: "ee" }); + 15 15 │ ({ 0b1: 1 }); + 16 16 │ + 17 │ - ({·0o1:·1·}); + 17 │ + ({·1:·1·}); + 18 18 │ + 19 19 │ ({ 1_0: 1 }); ``` ``` -useSimpleNumberKeys.js:8:4 lint/nursery/useSimpleNumberKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +useSimpleNumberKeys.js:19:4 lint/nursery/useSimpleNumberKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - ! Number literal with underscore is not allowed + ! Number literal with underscore is not allowed here. - 6 │ ({ 0b1: 1 }); - 7 │ ({ 0o1: 1 }); - > 8 │ ({ 1_0: 1 }); + 17 │ ({ 0o1: 1 }); + 18 │ + > 19 │ ({ 1_0: 1 }); │ ^^^ - 9 │ ({ 0.1e1_2: "ee" }); - 10 │ ({ 11_1.11: "ee" }); + 20 │ + 21 │ ({ 0.1e1_2: "ed" }); - i Safe fix: Remove 1_0 + i Safe fix: Replace 1_0 with 10 - 6 6 │ ({ 0b1: 1 }); - 7 7 │ ({ 0o1: 1 }); - 8 │ - ({·1_0:·1·}); - 8 │ + ({·10:·1·}); - 9 9 │ ({ 0.1e1_2: "ee" }); - 10 10 │ ({ 11_1.11: "ee" }); + 17 17 │ ({ 0o1: 1 }); + 18 18 │ + 19 │ - ({·1_0:·1·}); + 19 │ + ({·10:·1·}); + 20 20 │ + 21 21 │ ({ 0.1e1_2: "ed" }); ``` ``` -useSimpleNumberKeys.js:9:4 lint/nursery/useSimpleNumberKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +useSimpleNumberKeys.js:21:4 lint/nursery/useSimpleNumberKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - ! Number literal with underscore is not allowed + ! Number literal with underscore is not allowed. - 7 │ ({ 0o1: 1 }); - 8 │ ({ 1_0: 1 }); - > 9 │ ({ 0.1e1_2: "ee" }); + 19 │ ({ 1_0: 1 }); + 20 │ + > 21 │ ({ 0.1e1_2: "ed" }); │ ^^^^^^^ - 10 │ ({ 11_1.11: "ee" }); - 11 │ + 22 │ + 23 │ ({ 11_1.11: "ee" }); - i Safe fix: Remove 0.1e1_2 + i Safe fix: Replace 0.1e1_2 with .1e12 - 7 7 │ ({ 0o1: 1 }); - 8 8 │ ({ 1_0: 1 }); - 9 │ - ({·0.1e1_2:·"ee"·}); - 9 │ + ({·.1e12:·"ee"·}); - 10 10 │ ({ 11_1.11: "ee" }); - 11 11 │ + 19 19 │ ({ 1_0: 1 }); + 20 20 │ + 21 │ - ({·0.1e1_2:·"ed"·}); + 21 │ + ({·.1e12:·"ed"·}); + 22 22 │ + 23 23 │ ({ 11_1.11: "ee" }); ``` ``` -useSimpleNumberKeys.js:10:4 lint/nursery/useSimpleNumberKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +useSimpleNumberKeys.js:23:4 lint/nursery/useSimpleNumberKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - ! Number literal with underscore is not allowed + ! Number literal with underscore is not allowed. - 8 │ ({ 1_0: 1 }); - 9 │ ({ 0.1e1_2: "ee" }); - > 10 │ ({ 11_1.11: "ee" }); + 21 │ ({ 0.1e1_2: "ed" }); + 22 │ + > 23 │ ({ 11_1.11: "ee" }); │ ^^^^^^^ - 11 │ - 12 │ // valid + 24 │ - i Safe fix: Remove 11_1.11 + i Safe fix: Replace 11_1.11 with 111.11 - 8 8 │ ({ 1_0: 1 }); - 9 9 │ ({ 0.1e1_2: "ee" }); - 10 │ - ({·11_1.11:·"ee"·}); - 10 │ + ({·111.11:·"ee"·}); - 11 11 │ - 12 12 │ // valid + 21 21 │ ({ 0.1e1_2: "ed" }); + 22 22 │ + 23 │ - ({·11_1.11:·"ee"·}); + 23 │ + ({·111.11:·"ee"·}); + 24 24 │ ``` diff --git a/crates/rome_service/src/configuration/linter/rules.rs b/crates/rome_service/src/configuration/linter/rules.rs index b9b826a236b..5084e71f217 100644 --- a/crates/rome_service/src/configuration/linter/rules.rs +++ b/crates/rome_service/src/configuration/linter/rules.rs @@ -920,7 +920,7 @@ impl Nursery { "useValidAriaProps", "useValidLang", ]; - const RECOMMENDED_RULES_AS_FILTERS: [RuleFilter<'static>; 37] = [ + const RECOMMENDED_RULES_AS_FILTERS: [RuleFilter<'static>; 38] = [ RuleFilter::Rule("nursery", Self::CATEGORY_RULES[1]), RuleFilter::Rule("nursery", Self::CATEGORY_RULES[2]), RuleFilter::Rule("nursery", Self::CATEGORY_RULES[3]), @@ -956,8 +956,9 @@ impl Nursery { RuleFilter::Rule("nursery", Self::CATEGORY_RULES[41]), RuleFilter::Rule("nursery", Self::CATEGORY_RULES[42]), RuleFilter::Rule("nursery", Self::CATEGORY_RULES[43]), - RuleFilter::Rule("nursery", Self::CATEGORY_RULES[45]), + RuleFilter::Rule("nursery", Self::CATEGORY_RULES[44]), RuleFilter::Rule("nursery", Self::CATEGORY_RULES[46]), + RuleFilter::Rule("nursery", Self::CATEGORY_RULES[47]), ]; pub(crate) fn is_recommended(&self) -> bool { !matches!(self.recommended, Some(false)) } pub(crate) fn get_enabled_rules(&self) -> IndexSet { @@ -984,7 +985,7 @@ impl Nursery { pub(crate) fn is_recommended_rule(rule_name: &str) -> bool { Self::RECOMMENDED_RULES.contains(&rule_name) } - pub(crate) fn recommended_rules_as_filters() -> [RuleFilter<'static>; 37] { + pub(crate) fn recommended_rules_as_filters() -> [RuleFilter<'static>; 38] { Self::RECOMMENDED_RULES_AS_FILTERS } } diff --git a/editors/vscode/configuration_schema.json b/editors/vscode/configuration_schema.json index 23e147bad0c..03eed933cce 100644 --- a/editors/vscode/configuration_schema.json +++ b/editors/vscode/configuration_schema.json @@ -1,1626 +1,1694 @@ { - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "Configuration", - "description": "The configuration that is contained inside the file `rome.json`", - "type": "object", - "properties": { - "$schema": { - "description": "A field for the [JSON schema](https://json-schema.org/) specification", - "type": ["string", "null"] - }, - "files": { - "description": "The configuration of the filesystem", - "anyOf": [ - { - "$ref": "#/definitions/FilesConfiguration" - }, - { - "type": "null" - } - ] - }, - "formatter": { - "description": "The configuration of the formatter", - "anyOf": [ - { - "$ref": "#/definitions/FormatterConfiguration" - }, - { - "type": "null" - } - ] - }, - "javascript": { - "description": "Specific configuration for the JavaScript language", - "anyOf": [ - { - "$ref": "#/definitions/JavascriptConfiguration" - }, - { - "type": "null" - } - ] - }, - "linter": { - "description": "The configuration for the linter", - "anyOf": [ - { - "$ref": "#/definitions/LinterConfiguration" - }, - { - "type": "null" - } - ] - } - }, - "additionalProperties": false, - "definitions": { - "A11y": { - "description": "A list of rules that belong to this group", - "type": "object", - "properties": { - "noAutofocus": { - "description": "Avoid the autoFocus attribute", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noBlankTarget": { - "description": "Disallow target=\"_blank\" attribute without rel=\"noreferrer\"", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noPositiveTabindex": { - "description": "Prevent the usage of positive integers on tabIndex property", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "recommended": { - "description": "It enables the recommended rules for this group", - "type": ["boolean", "null"] - }, - "useAltText": { - "description": "It asserts that alternative text to images or areas, help to rely on to screen readers to understand the purpose and the context of the image.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useAnchorContent": { - "description": "Enforce that anchor elements have content and that the content is accessible to screen readers.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useButtonType": { - "description": "Enforces the usage of the attribute type for the element button", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useHtmlLang": { - "description": "Enforce that html element has lang attribute. This allows users to choose a language other than the default.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useKeyWithClickEvents": { - "description": "Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useKeyWithMouseEvents": { - "description": "Enforce that onMouseOver/onMouseOut are accompanied by onFocus/onBlur for keyboard-only users. It is important to take into account users with physical disabilities who cannot use a mouse, who use assistive technology or screenreader.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useValidAnchor": { - "description": "Enforce that all anchors are valid, and they are navigable elements.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - } - } - }, - "Complexity": { - "description": "A list of rules that belong to this group", - "type": "object", - "properties": { - "noExtraBooleanCast": { - "description": "Disallow unnecessary boolean casts", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noMultipleSpacesInRegularExpressionLiterals": { - "description": "Disallow unclear usage of multiple space characters in regular expression literals", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noUselessFragments": { - "description": "Disallow unnecessary fragments", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "recommended": { - "description": "It enables the recommended rules for this group", - "type": ["boolean", "null"] - }, - "useFlatMap": { - "description": "Promotes the use of .flatMap() when map().flat() are used together.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useOptionalChain": { - "description": "Enforce using concise optional chain instead of chained logical expressions.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useSimplifiedLogicExpression": { - "description": "Discard redundant terms from logical expressions.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - } - } - }, - "Correctness": { - "description": "A list of rules that belong to this group", - "type": "object", - "properties": { - "noChildrenProp": { - "description": "Prevent passing of children as props.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noConstAssign": { - "description": "Prevents from having const variables being re-assigned.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noEmptyPattern": { - "description": "Disallows empty destructuring patterns.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noNewSymbol": { - "description": "Disallow new operators with the Symbol object", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noRenderReturnValue": { - "description": "Prevent the usage of the return value of React.render.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noUndeclaredVariables": { - "description": "Prevents the usage of variables that haven't been declared inside the document", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noUnnecessaryContinue": { - "description": "Avoid using unnecessary continue.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noUnreachable": { - "description": "Disallow unreachable code", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noUnusedVariables": { - "description": "Disallow unused variables.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noVoidElementsWithChildren": { - "description": "This rules prevents void elements (AKA self-closing elements) from having children.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "recommended": { - "description": "It enables the recommended rules for this group", - "type": ["boolean", "null"] - }, - "useValidForDirection": { - "description": "Enforce \"for\" loop update clause moving the counter in the right direction.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - } - } - }, - "FilesConfiguration": { - "description": "The configuration of the filesystem", - "type": "object", - "properties": { - "ignore": { - "description": "A list of Unix shell style patterns. Rome tools will ignore files/folders that will match these patterns.", - "type": ["array", "null"], - "items": { - "type": "string" - }, - "uniqueItems": true - }, - "maxSize": { - "description": "The maximum allowed size for source code files in bytes. Files above this limit will be ignored for performance reason. Defaults to 1 MiB", - "default": null, - "type": ["integer", "null"], - "format": "uint64", - "minimum": 1.0 - } - }, - "additionalProperties": false - }, - "FormatterConfiguration": { - "type": "object", - "properties": { - "enabled": { - "default": true, - "type": "boolean" - }, - "formatWithErrors": { - "description": "Stores whether formatting should be allowed to proceed if a given file has syntax errors", - "default": false, - "type": "boolean" - }, - "ignore": { - "description": "A list of Unix shell style patterns. The formatter will ignore files/folders that will match these patterns.", - "type": ["array", "null"], - "items": { - "type": "string" - }, - "uniqueItems": true - }, - "indentSize": { - "description": "The size of the indentation, 2 by default", - "default": 2, - "type": "integer", - "format": "uint8", - "minimum": 0.0 - }, - "indentStyle": { - "description": "The indent style.", - "default": "tab", - "allOf": [ - { - "$ref": "#/definitions/PlainIndentStyle" - } - ] - }, - "lineWidth": { - "description": "What's the max width of a line. Defaults to 80.", - "default": 80, - "allOf": [ - { - "$ref": "#/definitions/LineWidth" - } - ] - } - }, - "additionalProperties": false - }, - "JavascriptConfiguration": { - "type": "object", - "properties": { - "formatter": { - "anyOf": [ - { - "$ref": "#/definitions/JavascriptFormatter" - }, - { - "type": "null" - } - ] - }, - "globals": { - "description": "A list of global bindings that should be ignored by the analyzers\n\nIf defined here, they should not emit diagnostics.", - "type": ["array", "null"], - "items": { - "type": "string" - }, - "uniqueItems": true - } - }, - "additionalProperties": false - }, - "JavascriptFormatter": { - "type": "object", - "properties": { - "quoteProperties": { - "description": "When properties in objects are quoted. Defaults to asNeeded.", - "default": "asNeeded", - "allOf": [ - { - "$ref": "#/definitions/QuoteProperties" - } - ] - }, - "quoteStyle": { - "description": "The style for quotes. Defaults to double.", - "default": "double", - "allOf": [ - { - "$ref": "#/definitions/QuoteStyle" - } - ] - }, - "semicolons": { - "description": "Whether the formatter prints semicolons for all statements or only in for statements where it is necessary because of ASI.", - "default": "always", - "allOf": [ - { - "$ref": "#/definitions/Semicolons" - } - ] - }, - "trailingComma": { - "description": "Print trailing commas wherever possible in multi-line comma-separated syntactic structures. Defaults to \"all\".", - "default": "all", - "allOf": [ - { - "$ref": "#/definitions/TrailingComma" - } - ] - } - }, - "additionalProperties": false - }, - "LineWidth": { - "description": "Validated value for the `line_width` formatter options\n\nThe allowed range of values is 1..=320", - "type": "integer", - "format": "uint16", - "minimum": 0.0 - }, - "LinterConfiguration": { - "type": "object", - "properties": { - "enabled": { - "description": "if `false`, it disables the feature and the linter won't be executed. `true` by default", - "default": true, - "type": "boolean" - }, - "ignore": { - "description": "A list of Unix shell style patterns. The formatter will ignore files/folders that will match these patterns.", - "type": ["array", "null"], - "items": { - "type": "string" - }, - "uniqueItems": true - }, - "rules": { - "description": "List of rules", - "default": { - "recommended": true - }, - "anyOf": [ - { - "$ref": "#/definitions/Rules" - }, - { - "type": "null" - } - ] - } - }, - "additionalProperties": false - }, - "Nursery": { - "description": "A list of rules that belong to this group", - "type": "object", - "properties": { - "noAccessKey": { - "description": "Enforce that the accessKey attribute is not used on any HTML element.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noAssignInExpressions": { - "description": "Disallow assignments in expressions.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noBannedTypes": { - "description": "Disallow certain types.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noClassAssign": { - "description": "Disallow reassigning class members.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noCommaOperator": { - "description": "Disallow comma operator.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noConstEnum": { - "description": "Disallow TypeScript const enum", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noConstructorReturn": { - "description": "Disallow returning a value from a constructor.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noDistractingElements": { - "description": "Enforces that no distracting elements are used.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noDuplicateCase": { - "description": "Disallow duplicate case labels. If a switch statement has duplicate test expressions in case clauses, it is likely that a programmer copied a case clause but forgot to change the test expression.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noDuplicateObjectKeys": { - "description": "Prevents object literals having more than one property declaration for the same name. If an object property with the same name is defined multiple times (except when combining a getter with a setter), only the last definition makes it into the object and previous definitions are ignored, which is likely a mistake.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noEmptyInterface": { - "description": "Disallow the declaration of empty interfaces.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noExtraNonNullAssertion": { - "description": "Prevents the wrong usage of the non-null assertion operator (!) in TypeScript files.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noExtraSemicolons": { - "description": "Typing mistakes and misunderstandings about where semicolons are required can lead to semicolons that are unnecessary. While not technically an error, extra semicolons can cause confusion when reading code.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noHeaderScope": { - "description": "Check that the scope attribute is only used on th elements.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noInnerDeclarations": { - "description": "Disallow function and var declarations in nested blocks.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noInvalidConstructorSuper": { - "description": "Prevents the incorrect use of super() inside classes. It also checks whether a call super() is missing from classes that extends other constructors.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noNonNullAssertion": { - "description": "Disallow non-null assertions using the ! postfix operator.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noNoninteractiveElementToInteractiveRole": { - "description": "Enforce that interactive ARIA roles are not assigned to non-interactive HTML elements.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noPrecisionLoss": { - "description": "Disallow literal numbers that lose precision", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noRedundantAlt": { - "description": "Enforce img alt prop does not contain the word \"image\", \"picture\", or \"photo\".", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noRedundantUseStrict": { - "description": "Prevents from having redundant \"use strict\".", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noRestrictedGlobals": { - "description": "This rule allows you to specify global variable names that you don’t want to use in your application.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noSelfCompare": { - "description": "Disallow comparisons where both sides are exactly the same.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noSetterReturn": { - "description": "Disallow returning a value from a setter", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noStringCaseMismatch": { - "description": "Disallow comparison of expressions modifying the string case with non-compliant value.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noUnreachableSuper": { - "description": "Ensures the super() constructor is called exactly once on every code path in a class constructor before this is accessed if the class has a superclass", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noUnsafeFinally": { - "description": "Disallow control flow statements in finally blocks.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noUselessSwitchCase": { - "description": "Disallow useless case in switch statements.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noVar": { - "description": "Disallow the use of var", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noVoidTypeReturn": { - "description": "Disallow returning a value from a function with the return type 'void'", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noWith": { - "description": "Disallow with statements in non-strict contexts.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "recommended": { - "description": "It enables the recommended rules for this group", - "type": ["boolean", "null"] - }, - "useAriaPropTypes": { - "description": "Enforce that ARIA state and property values are valid.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useAriaPropsForRole": { - "description": "Enforce that elements with ARIA roles must have all required ARIA attributes for that role.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useCamelCase": { - "description": "Enforce camel case naming convention.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useConst": { - "description": "Require const declarations for variables that are never reassigned after declared.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useDefaultParameterLast": { - "description": "Enforce default function parameters and optional parameters to be last.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useDefaultSwitchClauseLast": { - "description": "Enforce default clauses in switch statements to be last", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useEnumInitializers": { - "description": "Require that each enum member value be explicitly initialized.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useExhaustiveDependencies": { - "description": "Enforce all dependencies are correctly specified.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useExponentiationOperator": { - "description": "Disallow the use of Math.pow in favor of the ** operator.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useHookAtTopLevel": { - "description": "Enforce that all React hooks are being called from the Top Level component functions.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useIframeTitle": { - "description": "Enforces the usage of the attribute title for the element iframe", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useIsNan": { - "description": "Require calls to isNaN() when checking for NaN.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useMediaCaption": { - "description": "Enforces that audio and video elements must have a track for captions.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useNumericLiterals": { - "description": "Disallow parseInt() and Number.parseInt() in favor of binary, octal, and hexadecimal literals", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useSimpleNumberKeys": { - "description": "Disallow number literal object member names which are not base10 or uses underscore as separator", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useValidAriaProps": { - "description": "Ensures that ARIA properties aria-* are all valid.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useValidLang": { - "description": "Ensure that the attribute passed to the lang attribute is a correct ISO language and/or country.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - } - } - }, - "Performance": { - "description": "A list of rules that belong to this group", - "type": "object", - "properties": { - "noDelete": { - "description": "Disallow the use of the delete operator", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "recommended": { - "description": "It enables the recommended rules for this group", - "type": ["boolean", "null"] - } - } - }, - "PlainIndentStyle": { - "type": "string", - "enum": ["tab", "space"] - }, - "QuoteProperties": { - "type": "string", - "enum": ["asNeeded", "preserve"] - }, - "QuoteStyle": { - "type": "string", - "enum": ["double", "single"] - }, - "RuleConfiguration": { - "anyOf": [ - { - "$ref": "#/definitions/RulePlainConfiguration" - }, - { - "$ref": "#/definitions/RuleWithOptions" - } - ] - }, - "RulePlainConfiguration": { - "type": "string", - "enum": ["warn", "error", "off"] - }, - "RuleWithOptions": { - "type": "object", - "required": ["level", "options"], - "properties": { - "level": { - "$ref": "#/definitions/RulePlainConfiguration" - }, - "options": true - }, - "additionalProperties": false - }, - "Rules": { - "type": "object", - "properties": { - "a11y": { - "anyOf": [ - { - "$ref": "#/definitions/A11y" - }, - { - "type": "null" - } - ] - }, - "complexity": { - "anyOf": [ - { - "$ref": "#/definitions/Complexity" - }, - { - "type": "null" - } - ] - }, - "correctness": { - "anyOf": [ - { - "$ref": "#/definitions/Correctness" - }, - { - "type": "null" - } - ] - }, - "nursery": { - "anyOf": [ - { - "$ref": "#/definitions/Nursery" - }, - { - "type": "null" - } - ] - }, - "performance": { - "anyOf": [ - { - "$ref": "#/definitions/Performance" - }, - { - "type": "null" - } - ] - }, - "recommended": { - "description": "It enables the lint rules recommended by Rome. `true` by default.", - "type": ["boolean", "null"] - }, - "security": { - "anyOf": [ - { - "$ref": "#/definitions/Security" - }, - { - "type": "null" - } - ] - }, - "style": { - "anyOf": [ - { - "$ref": "#/definitions/Style" - }, - { - "type": "null" - } - ] - }, - "suspicious": { - "anyOf": [ - { - "$ref": "#/definitions/Suspicious" - }, - { - "type": "null" - } - ] - } - }, - "additionalProperties": false - }, - "Security": { - "description": "A list of rules that belong to this group", - "type": "object", - "properties": { - "noDangerouslySetInnerHtml": { - "description": "Prevent the usage of dangerous JSX props", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noDangerouslySetInnerHtmlWithChildren": { - "description": "Report when a DOM element or a component uses both children and dangerouslySetInnerHTML prop.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "recommended": { - "description": "It enables the recommended rules for this group", - "type": ["boolean", "null"] - } - } - }, - "Semicolons": { - "type": "string", - "enum": ["always", "asNeeded"] - }, - "Style": { - "description": "A list of rules that belong to this group", - "type": "object", - "properties": { - "noArguments": { - "description": "Disallow the use of arguments", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noImplicitBoolean": { - "description": "Disallow implicit true values on JSX boolean attributes", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noNegationElse": { - "description": "Disallow negation in the condition of an if statement if it has an else clause", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noShoutyConstants": { - "description": "Disallow the use of constants which its value is the upper-case version of its name.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noUnusedTemplateLiteral": { - "description": "Disallow template literals if interpolation and special-character handling are not needed", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "recommended": { - "description": "It enables the recommended rules for this group", - "type": ["boolean", "null"] - }, - "useBlockStatements": { - "description": "Requires following curly brace conventions. JavaScript allows the omission of curly braces when a block contains only one statement. However, it is considered by many to be best practice to never omit curly braces around blocks, even when they are optional, because it can lead to bugs and reduces code clarity.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useFragmentSyntax": { - "description": "This rule enforces the use of <>... over ....", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useSelfClosingElements": { - "description": "Prevent extra closing tags for components without children", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useShorthandArrayType": { - "description": "When expressing array types, this rule promotes the usage of T[] shorthand instead of Array.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useSingleCaseStatement": { - "description": "Enforces case clauses have a single statement, emits a quick fix wrapping the statements in a block", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useSingleVarDeclarator": { - "description": "Disallow multiple variable declarations in the same variable statement", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useTemplate": { - "description": "Template literals are preferred over string concatenation.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useWhile": { - "description": "Enforce the use of while loops instead of for loops when the initializer and update expressions are not needed", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - } - } - }, - "Suspicious": { - "description": "A list of rules that belong to this group", - "type": "object", - "properties": { - "noArrayIndexKey": { - "description": "Discourage the usage of Array index in keys.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noAsyncPromiseExecutor": { - "description": "Disallows using an async function as a Promise executor.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noCatchAssign": { - "description": "Disallow reassigning exceptions in catch clauses", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noCommentText": { - "description": "Prevent comments from being inserted as text nodes", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noCompareNegZero": { - "description": "Disallow comparing against -0", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noDebugger": { - "description": "Disallow the use of debugger", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noDoubleEquals": { - "description": "Require the use of === and !==", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noDuplicateParameters": { - "description": "Disallow duplicate function arguments name.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noExplicitAny": { - "description": "Disallow the any type usage", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noFunctionAssign": { - "description": "Disallow reassigning function declarations.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noImportAssign": { - "description": "Disallow assigning to imported bindings", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noLabelVar": { - "description": "Disallow labels that share a name with a variable", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noShadowRestrictedNames": { - "description": "Disallow identifiers from shadowing restricted names.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noSparseArray": { - "description": "Disallow sparse arrays", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noUnsafeNegation": { - "description": "Disallow using unsafe negation.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "recommended": { - "description": "It enables the recommended rules for this group", - "type": ["boolean", "null"] - }, - "useValidTypeof": { - "description": "This rule verifies the result of typeof $expr unary expressions is being compared to valid values, either string literals containing valid type names or other typeof expressions", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - } - } - }, - "TrailingComma": { - "type": "string", - "enum": ["all", "es5", "none"] - } - } -} + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Configuration", + "description": "The configuration that is contained inside the file `rome.json`", + "type": "object", + "properties": { + "$schema": { + "description": "A field for the [JSON schema](https://json-schema.org/) specification", + "type": [ + "string", + "null" + ] + }, + "files": { + "description": "The configuration of the filesystem", + "anyOf": [ + { + "$ref": "#/definitions/FilesConfiguration" + }, + { + "type": "null" + } + ] + }, + "formatter": { + "description": "The configuration of the formatter", + "anyOf": [ + { + "$ref": "#/definitions/FormatterConfiguration" + }, + { + "type": "null" + } + ] + }, + "javascript": { + "description": "Specific configuration for the JavaScript language", + "anyOf": [ + { + "$ref": "#/definitions/JavascriptConfiguration" + }, + { + "type": "null" + } + ] + }, + "linter": { + "description": "The configuration for the linter", + "anyOf": [ + { + "$ref": "#/definitions/LinterConfiguration" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false, + "definitions": { + "A11y": { + "description": "A list of rules that belong to this group", + "type": "object", + "properties": { + "noAutofocus": { + "description": "Avoid the autoFocus attribute", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noBlankTarget": { + "description": "Disallow target=\"_blank\" attribute without rel=\"noreferrer\"", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noPositiveTabindex": { + "description": "Prevent the usage of positive integers on tabIndex property", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "recommended": { + "description": "It enables the recommended rules for this group", + "type": [ + "boolean", + "null" + ] + }, + "useAltText": { + "description": "It asserts that alternative text to images or areas, help to rely on to screen readers to understand the purpose and the context of the image.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useAnchorContent": { + "description": "Enforce that anchor elements have content and that the content is accessible to screen readers.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useButtonType": { + "description": "Enforces the usage of the attribute type for the element button", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useHtmlLang": { + "description": "Enforce that html element has lang attribute. This allows users to choose a language other than the default.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useKeyWithClickEvents": { + "description": "Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useKeyWithMouseEvents": { + "description": "Enforce that onMouseOver/onMouseOut are accompanied by onFocus/onBlur for keyboard-only users. It is important to take into account users with physical disabilities who cannot use a mouse, who use assistive technology or screenreader.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useValidAnchor": { + "description": "Enforce that all anchors are valid, and they are navigable elements.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + } + } + }, + "Complexity": { + "description": "A list of rules that belong to this group", + "type": "object", + "properties": { + "noExtraBooleanCast": { + "description": "Disallow unnecessary boolean casts", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noMultipleSpacesInRegularExpressionLiterals": { + "description": "Disallow unclear usage of multiple space characters in regular expression literals", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUselessFragments": { + "description": "Disallow unnecessary fragments", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "recommended": { + "description": "It enables the recommended rules for this group", + "type": [ + "boolean", + "null" + ] + }, + "useFlatMap": { + "description": "Promotes the use of .flatMap() when map().flat() are used together.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useOptionalChain": { + "description": "Enforce using concise optional chain instead of chained logical expressions.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useSimplifiedLogicExpression": { + "description": "Discard redundant terms from logical expressions.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + } + } + }, + "Correctness": { + "description": "A list of rules that belong to this group", + "type": "object", + "properties": { + "noChildrenProp": { + "description": "Prevent passing of children as props.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noConstAssign": { + "description": "Prevents from having const variables being re-assigned.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noEmptyPattern": { + "description": "Disallows empty destructuring patterns.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noNewSymbol": { + "description": "Disallow new operators with the Symbol object", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noRenderReturnValue": { + "description": "Prevent the usage of the return value of React.render.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUndeclaredVariables": { + "description": "Prevents the usage of variables that haven't been declared inside the document", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUnnecessaryContinue": { + "description": "Avoid using unnecessary continue.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUnreachable": { + "description": "Disallow unreachable code", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUnusedVariables": { + "description": "Disallow unused variables.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noVoidElementsWithChildren": { + "description": "This rules prevents void elements (AKA self-closing elements) from having children.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "recommended": { + "description": "It enables the recommended rules for this group", + "type": [ + "boolean", + "null" + ] + }, + "useValidForDirection": { + "description": "Enforce \"for\" loop update clause moving the counter in the right direction.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + } + } + }, + "FilesConfiguration": { + "description": "The configuration of the filesystem", + "type": "object", + "properties": { + "ignore": { + "description": "A list of Unix shell style patterns. Rome tools will ignore files/folders that will match these patterns.", + "type": [ + "array", + "null" + ], + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "maxSize": { + "description": "The maximum allowed size for source code files in bytes. Files above this limit will be ignored for performance reason. Defaults to 1 MiB", + "default": null, + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + } + }, + "additionalProperties": false + }, + "FormatterConfiguration": { + "type": "object", + "properties": { + "enabled": { + "default": true, + "type": "boolean" + }, + "formatWithErrors": { + "description": "Stores whether formatting should be allowed to proceed if a given file has syntax errors", + "default": false, + "type": "boolean" + }, + "ignore": { + "description": "A list of Unix shell style patterns. The formatter will ignore files/folders that will match these patterns.", + "type": [ + "array", + "null" + ], + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "indentSize": { + "description": "The size of the indentation, 2 by default", + "default": 2, + "type": "integer", + "format": "uint8", + "minimum": 0.0 + }, + "indentStyle": { + "description": "The indent style.", + "default": "tab", + "allOf": [ + { + "$ref": "#/definitions/PlainIndentStyle" + } + ] + }, + "lineWidth": { + "description": "What's the max width of a line. Defaults to 80.", + "default": 80, + "allOf": [ + { + "$ref": "#/definitions/LineWidth" + } + ] + } + }, + "additionalProperties": false + }, + "JavascriptConfiguration": { + "type": "object", + "properties": { + "formatter": { + "anyOf": [ + { + "$ref": "#/definitions/JavascriptFormatter" + }, + { + "type": "null" + } + ] + }, + "globals": { + "description": "A list of global bindings that should be ignored by the analyzers\n\nIf defined here, they should not emit diagnostics.", + "type": [ + "array", + "null" + ], + "items": { + "type": "string" + }, + "uniqueItems": true + } + }, + "additionalProperties": false + }, + "JavascriptFormatter": { + "type": "object", + "properties": { + "quoteProperties": { + "description": "When properties in objects are quoted. Defaults to asNeeded.", + "default": "asNeeded", + "allOf": [ + { + "$ref": "#/definitions/QuoteProperties" + } + ] + }, + "quoteStyle": { + "description": "The style for quotes. Defaults to double.", + "default": "double", + "allOf": [ + { + "$ref": "#/definitions/QuoteStyle" + } + ] + }, + "semicolons": { + "description": "Whether the formatter prints semicolons for all statements or only in for statements where it is necessary because of ASI.", + "default": "always", + "allOf": [ + { + "$ref": "#/definitions/Semicolons" + } + ] + }, + "trailingComma": { + "description": "Print trailing commas wherever possible in multi-line comma-separated syntactic structures. Defaults to \"all\".", + "default": "all", + "allOf": [ + { + "$ref": "#/definitions/TrailingComma" + } + ] + } + }, + "additionalProperties": false + }, + "LineWidth": { + "description": "Validated value for the `line_width` formatter options\n\nThe allowed range of values is 1..=320", + "type": "integer", + "format": "uint16", + "minimum": 0.0 + }, + "LinterConfiguration": { + "type": "object", + "properties": { + "enabled": { + "description": "if `false`, it disables the feature and the linter won't be executed. `true` by default", + "default": true, + "type": "boolean" + }, + "ignore": { + "description": "A list of Unix shell style patterns. The formatter will ignore files/folders that will match these patterns.", + "type": [ + "array", + "null" + ], + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "rules": { + "description": "List of rules", + "default": { + "recommended": true + }, + "anyOf": [ + { + "$ref": "#/definitions/Rules" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false + }, + "Nursery": { + "description": "A list of rules that belong to this group", + "type": "object", + "properties": { + "noAccessKey": { + "description": "Enforce that the accessKey attribute is not used on any HTML element.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noAssignInExpressions": { + "description": "Disallow assignments in expressions.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noBannedTypes": { + "description": "Disallow certain types.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noClassAssign": { + "description": "Disallow reassigning class members.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noCommaOperator": { + "description": "Disallow comma operator.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noConstEnum": { + "description": "Disallow TypeScript const enum", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noConstructorReturn": { + "description": "Disallow returning a value from a constructor.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noDistractingElements": { + "description": "Enforces that no distracting elements are used.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noDuplicateCase": { + "description": "Disallow duplicate case labels. If a switch statement has duplicate test expressions in case clauses, it is likely that a programmer copied a case clause but forgot to change the test expression.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noDuplicateObjectKeys": { + "description": "Prevents object literals having more than one property declaration for the same name. If an object property with the same name is defined multiple times (except when combining a getter with a setter), only the last definition makes it into the object and previous definitions are ignored, which is likely a mistake.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noEmptyInterface": { + "description": "Disallow the declaration of empty interfaces.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noExtraNonNullAssertion": { + "description": "Prevents the wrong usage of the non-null assertion operator (!) in TypeScript files.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noExtraSemicolons": { + "description": "Typing mistakes and misunderstandings about where semicolons are required can lead to semicolons that are unnecessary. While not technically an error, extra semicolons can cause confusion when reading code.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noHeaderScope": { + "description": "Check that the scope attribute is only used on th elements.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noInnerDeclarations": { + "description": "Disallow function and var declarations in nested blocks.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noInvalidConstructorSuper": { + "description": "Prevents the incorrect use of super() inside classes. It also checks whether a call super() is missing from classes that extends other constructors.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noNonNullAssertion": { + "description": "Disallow non-null assertions using the ! postfix operator.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noNoninteractiveElementToInteractiveRole": { + "description": "Enforce that interactive ARIA roles are not assigned to non-interactive HTML elements.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noPrecisionLoss": { + "description": "Disallow literal numbers that lose precision", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noRedundantAlt": { + "description": "Enforce img alt prop does not contain the word \"image\", \"picture\", or \"photo\".", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noRedundantUseStrict": { + "description": "Prevents from having redundant \"use strict\".", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noRestrictedGlobals": { + "description": "This rule allows you to specify global variable names that you don’t want to use in your application.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noSelfCompare": { + "description": "Disallow comparisons where both sides are exactly the same.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noSetterReturn": { + "description": "Disallow returning a value from a setter", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noStringCaseMismatch": { + "description": "Disallow comparison of expressions modifying the string case with non-compliant value.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUnreachableSuper": { + "description": "Ensures the super() constructor is called exactly once on every code path in a class constructor before this is accessed if the class has a superclass", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUnsafeFinally": { + "description": "Disallow control flow statements in finally blocks.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUselessSwitchCase": { + "description": "Disallow useless case in switch statements.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noVar": { + "description": "Disallow the use of var", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noVoidTypeReturn": { + "description": "Disallow returning a value from a function with the return type 'void'", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noWith": { + "description": "Disallow with statements in non-strict contexts.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "recommended": { + "description": "It enables the recommended rules for this group", + "type": [ + "boolean", + "null" + ] + }, + "useAriaPropTypes": { + "description": "Enforce that ARIA state and property values are valid.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useAriaPropsForRole": { + "description": "Enforce that elements with ARIA roles must have all required ARIA attributes for that role.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useCamelCase": { + "description": "Enforce camel case naming convention.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useConst": { + "description": "Require const declarations for variables that are never reassigned after declared.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useDefaultParameterLast": { + "description": "Enforce default function parameters and optional parameters to be last.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useDefaultSwitchClauseLast": { + "description": "Enforce default clauses in switch statements to be last", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useEnumInitializers": { + "description": "Require that each enum member value be explicitly initialized.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useExhaustiveDependencies": { + "description": "Enforce all dependencies are correctly specified.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useExponentiationOperator": { + "description": "Disallow the use of Math.pow in favor of the ** operator.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useHookAtTopLevel": { + "description": "Enforce that all React hooks are being called from the Top Level component functions.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useIframeTitle": { + "description": "Enforces the usage of the attribute title for the element iframe", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useIsNan": { + "description": "Require calls to isNaN() when checking for NaN.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useMediaCaption": { + "description": "Enforces that audio and video elements must have a track for captions.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useNumericLiterals": { + "description": "Disallow parseInt() and Number.parseInt() in favor of binary, octal, and hexadecimal literals", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useSimpleNumberKeys": { + "description": "Disallow number literal object member names which are not base10 or uses underscore as separator", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useValidAriaProps": { + "description": "Ensures that ARIA properties aria-* are all valid.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useValidLang": { + "description": "Ensure that the attribute passed to the lang attribute is a correct ISO language and/or country.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + } + } + }, + "Performance": { + "description": "A list of rules that belong to this group", + "type": "object", + "properties": { + "noDelete": { + "description": "Disallow the use of the delete operator", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "recommended": { + "description": "It enables the recommended rules for this group", + "type": [ + "boolean", + "null" + ] + } + } + }, + "PlainIndentStyle": { + "type": "string", + "enum": [ + "tab", + "space" + ] + }, + "QuoteProperties": { + "type": "string", + "enum": [ + "asNeeded", + "preserve" + ] + }, + "QuoteStyle": { + "type": "string", + "enum": [ + "double", + "single" + ] + }, + "RuleConfiguration": { + "anyOf": [ + { + "$ref": "#/definitions/RulePlainConfiguration" + }, + { + "$ref": "#/definitions/RuleWithOptions" + } + ] + }, + "RulePlainConfiguration": { + "type": "string", + "enum": [ + "warn", + "error", + "off" + ] + }, + "RuleWithOptions": { + "type": "object", + "required": [ + "level", + "options" + ], + "properties": { + "level": { + "$ref": "#/definitions/RulePlainConfiguration" + }, + "options": true + }, + "additionalProperties": false + }, + "Rules": { + "type": "object", + "properties": { + "a11y": { + "anyOf": [ + { + "$ref": "#/definitions/A11y" + }, + { + "type": "null" + } + ] + }, + "complexity": { + "anyOf": [ + { + "$ref": "#/definitions/Complexity" + }, + { + "type": "null" + } + ] + }, + "correctness": { + "anyOf": [ + { + "$ref": "#/definitions/Correctness" + }, + { + "type": "null" + } + ] + }, + "nursery": { + "anyOf": [ + { + "$ref": "#/definitions/Nursery" + }, + { + "type": "null" + } + ] + }, + "performance": { + "anyOf": [ + { + "$ref": "#/definitions/Performance" + }, + { + "type": "null" + } + ] + }, + "recommended": { + "description": "It enables the lint rules recommended by Rome. `true` by default.", + "type": [ + "boolean", + "null" + ] + }, + "security": { + "anyOf": [ + { + "$ref": "#/definitions/Security" + }, + { + "type": "null" + } + ] + }, + "style": { + "anyOf": [ + { + "$ref": "#/definitions/Style" + }, + { + "type": "null" + } + ] + }, + "suspicious": { + "anyOf": [ + { + "$ref": "#/definitions/Suspicious" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false + }, + "Security": { + "description": "A list of rules that belong to this group", + "type": "object", + "properties": { + "noDangerouslySetInnerHtml": { + "description": "Prevent the usage of dangerous JSX props", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noDangerouslySetInnerHtmlWithChildren": { + "description": "Report when a DOM element or a component uses both children and dangerouslySetInnerHTML prop.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "recommended": { + "description": "It enables the recommended rules for this group", + "type": [ + "boolean", + "null" + ] + } + } + }, + "Semicolons": { + "type": "string", + "enum": [ + "always", + "asNeeded" + ] + }, + "Style": { + "description": "A list of rules that belong to this group", + "type": "object", + "properties": { + "noArguments": { + "description": "Disallow the use of arguments", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noImplicitBoolean": { + "description": "Disallow implicit true values on JSX boolean attributes", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noNegationElse": { + "description": "Disallow negation in the condition of an if statement if it has an else clause", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noShoutyConstants": { + "description": "Disallow the use of constants which its value is the upper-case version of its name.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUnusedTemplateLiteral": { + "description": "Disallow template literals if interpolation and special-character handling are not needed", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "recommended": { + "description": "It enables the recommended rules for this group", + "type": [ + "boolean", + "null" + ] + }, + "useBlockStatements": { + "description": "Requires following curly brace conventions. JavaScript allows the omission of curly braces when a block contains only one statement. However, it is considered by many to be best practice to never omit curly braces around blocks, even when they are optional, because it can lead to bugs and reduces code clarity.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useFragmentSyntax": { + "description": "This rule enforces the use of <>... over ....", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useSelfClosingElements": { + "description": "Prevent extra closing tags for components without children", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useShorthandArrayType": { + "description": "When expressing array types, this rule promotes the usage of T[] shorthand instead of Array.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useSingleCaseStatement": { + "description": "Enforces case clauses have a single statement, emits a quick fix wrapping the statements in a block", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useSingleVarDeclarator": { + "description": "Disallow multiple variable declarations in the same variable statement", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useTemplate": { + "description": "Template literals are preferred over string concatenation.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useWhile": { + "description": "Enforce the use of while loops instead of for loops when the initializer and update expressions are not needed", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + } + } + }, + "Suspicious": { + "description": "A list of rules that belong to this group", + "type": "object", + "properties": { + "noArrayIndexKey": { + "description": "Discourage the usage of Array index in keys.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noAsyncPromiseExecutor": { + "description": "Disallows using an async function as a Promise executor.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noCatchAssign": { + "description": "Disallow reassigning exceptions in catch clauses", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noCommentText": { + "description": "Prevent comments from being inserted as text nodes", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noCompareNegZero": { + "description": "Disallow comparing against -0", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noDebugger": { + "description": "Disallow the use of debugger", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noDoubleEquals": { + "description": "Require the use of === and !==", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noDuplicateParameters": { + "description": "Disallow duplicate function arguments name.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noExplicitAny": { + "description": "Disallow the any type usage.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noFunctionAssign": { + "description": "Disallow reassigning function declarations.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noImportAssign": { + "description": "Disallow assigning to imported bindings", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noLabelVar": { + "description": "Disallow labels that share a name with a variable", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noShadowRestrictedNames": { + "description": "Disallow identifiers from shadowing restricted names.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noSparseArray": { + "description": "Disallow sparse arrays", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUnsafeNegation": { + "description": "Disallow using unsafe negation.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "recommended": { + "description": "It enables the recommended rules for this group", + "type": [ + "boolean", + "null" + ] + }, + "useValidTypeof": { + "description": "This rule verifies the result of typeof $expr unary expressions is being compared to valid values, either string literals containing valid type names or other typeof expressions", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + } + } + }, + "TrailingComma": { + "type": "string", + "enum": [ + "all", + "es5", + "none" + ] + } + } +} \ No newline at end of file diff --git a/npm/backend-jsonrpc/src/workspace.ts b/npm/backend-jsonrpc/src/workspace.ts index 3cb51c610cb..8b1ccde7159 100644 --- a/npm/backend-jsonrpc/src/workspace.ts +++ b/npm/backend-jsonrpc/src/workspace.ts @@ -89,7 +89,7 @@ export interface JavascriptConfiguration { /** * A list of global bindings that should be ignored by the analyzers -If defined here, they should not emit diagnostics. +If defined here, they should not emit diagnostics. */ globals?: string[]; } @@ -111,7 +111,7 @@ export type PlainIndentStyle = "tab" | "space"; /** * Validated value for the `line_width` formatter options -The allowed range of values is 1..=320 +The allowed range of values is 1..=320 */ export type LineWidth = number; export interface JavascriptFormatter { @@ -876,7 +876,7 @@ export type DiagnosticTags = DiagnosticTag[]; /** * Serializable representation of a [Diagnostic](super::Diagnostic) advice -See the [Visitor] trait for additional documentation on all the supported advice types. +See the [Visitor] trait for additional documentation on all the supported advice types. */ export type Advice = | { Log: [LogCategory, MarkupBuf] } @@ -974,7 +974,7 @@ export interface CodeAction { /** * The category of a code action, this type maps directly to the [CodeActionKind] type in the Language Server Protocol specification -[CodeActionKind]: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#codeActionKind +[CodeActionKind]: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#codeActionKind */ export type ActionCategory = | "QuickFix" @@ -1101,7 +1101,7 @@ export interface RenameResult { } export interface Workspace { supportsFeature( - params: SupportsFeatureParams + params: SupportsFeatureParams, ): Promise; updateSettings(params: UpdateSettingsParams): Promise; openFile(params: OpenFileParams): Promise; @@ -1111,7 +1111,7 @@ export interface Workspace { getControlFlowGraph(params: GetControlFlowGraphParams): Promise; getFormatterIr(params: GetFormatterIRParams): Promise; pullDiagnostics( - params: PullDiagnosticsParams + params: PullDiagnosticsParams, ): Promise; pullActions(params: PullActionsParams): Promise; formatFile(params: FormatFileParams): Promise; diff --git a/npm/rome/configuration_schema.json b/npm/rome/configuration_schema.json index 23e147bad0c..03eed933cce 100644 --- a/npm/rome/configuration_schema.json +++ b/npm/rome/configuration_schema.json @@ -1,1626 +1,1694 @@ { - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "Configuration", - "description": "The configuration that is contained inside the file `rome.json`", - "type": "object", - "properties": { - "$schema": { - "description": "A field for the [JSON schema](https://json-schema.org/) specification", - "type": ["string", "null"] - }, - "files": { - "description": "The configuration of the filesystem", - "anyOf": [ - { - "$ref": "#/definitions/FilesConfiguration" - }, - { - "type": "null" - } - ] - }, - "formatter": { - "description": "The configuration of the formatter", - "anyOf": [ - { - "$ref": "#/definitions/FormatterConfiguration" - }, - { - "type": "null" - } - ] - }, - "javascript": { - "description": "Specific configuration for the JavaScript language", - "anyOf": [ - { - "$ref": "#/definitions/JavascriptConfiguration" - }, - { - "type": "null" - } - ] - }, - "linter": { - "description": "The configuration for the linter", - "anyOf": [ - { - "$ref": "#/definitions/LinterConfiguration" - }, - { - "type": "null" - } - ] - } - }, - "additionalProperties": false, - "definitions": { - "A11y": { - "description": "A list of rules that belong to this group", - "type": "object", - "properties": { - "noAutofocus": { - "description": "Avoid the autoFocus attribute", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noBlankTarget": { - "description": "Disallow target=\"_blank\" attribute without rel=\"noreferrer\"", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noPositiveTabindex": { - "description": "Prevent the usage of positive integers on tabIndex property", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "recommended": { - "description": "It enables the recommended rules for this group", - "type": ["boolean", "null"] - }, - "useAltText": { - "description": "It asserts that alternative text to images or areas, help to rely on to screen readers to understand the purpose and the context of the image.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useAnchorContent": { - "description": "Enforce that anchor elements have content and that the content is accessible to screen readers.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useButtonType": { - "description": "Enforces the usage of the attribute type for the element button", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useHtmlLang": { - "description": "Enforce that html element has lang attribute. This allows users to choose a language other than the default.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useKeyWithClickEvents": { - "description": "Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useKeyWithMouseEvents": { - "description": "Enforce that onMouseOver/onMouseOut are accompanied by onFocus/onBlur for keyboard-only users. It is important to take into account users with physical disabilities who cannot use a mouse, who use assistive technology or screenreader.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useValidAnchor": { - "description": "Enforce that all anchors are valid, and they are navigable elements.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - } - } - }, - "Complexity": { - "description": "A list of rules that belong to this group", - "type": "object", - "properties": { - "noExtraBooleanCast": { - "description": "Disallow unnecessary boolean casts", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noMultipleSpacesInRegularExpressionLiterals": { - "description": "Disallow unclear usage of multiple space characters in regular expression literals", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noUselessFragments": { - "description": "Disallow unnecessary fragments", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "recommended": { - "description": "It enables the recommended rules for this group", - "type": ["boolean", "null"] - }, - "useFlatMap": { - "description": "Promotes the use of .flatMap() when map().flat() are used together.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useOptionalChain": { - "description": "Enforce using concise optional chain instead of chained logical expressions.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useSimplifiedLogicExpression": { - "description": "Discard redundant terms from logical expressions.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - } - } - }, - "Correctness": { - "description": "A list of rules that belong to this group", - "type": "object", - "properties": { - "noChildrenProp": { - "description": "Prevent passing of children as props.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noConstAssign": { - "description": "Prevents from having const variables being re-assigned.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noEmptyPattern": { - "description": "Disallows empty destructuring patterns.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noNewSymbol": { - "description": "Disallow new operators with the Symbol object", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noRenderReturnValue": { - "description": "Prevent the usage of the return value of React.render.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noUndeclaredVariables": { - "description": "Prevents the usage of variables that haven't been declared inside the document", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noUnnecessaryContinue": { - "description": "Avoid using unnecessary continue.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noUnreachable": { - "description": "Disallow unreachable code", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noUnusedVariables": { - "description": "Disallow unused variables.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noVoidElementsWithChildren": { - "description": "This rules prevents void elements (AKA self-closing elements) from having children.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "recommended": { - "description": "It enables the recommended rules for this group", - "type": ["boolean", "null"] - }, - "useValidForDirection": { - "description": "Enforce \"for\" loop update clause moving the counter in the right direction.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - } - } - }, - "FilesConfiguration": { - "description": "The configuration of the filesystem", - "type": "object", - "properties": { - "ignore": { - "description": "A list of Unix shell style patterns. Rome tools will ignore files/folders that will match these patterns.", - "type": ["array", "null"], - "items": { - "type": "string" - }, - "uniqueItems": true - }, - "maxSize": { - "description": "The maximum allowed size for source code files in bytes. Files above this limit will be ignored for performance reason. Defaults to 1 MiB", - "default": null, - "type": ["integer", "null"], - "format": "uint64", - "minimum": 1.0 - } - }, - "additionalProperties": false - }, - "FormatterConfiguration": { - "type": "object", - "properties": { - "enabled": { - "default": true, - "type": "boolean" - }, - "formatWithErrors": { - "description": "Stores whether formatting should be allowed to proceed if a given file has syntax errors", - "default": false, - "type": "boolean" - }, - "ignore": { - "description": "A list of Unix shell style patterns. The formatter will ignore files/folders that will match these patterns.", - "type": ["array", "null"], - "items": { - "type": "string" - }, - "uniqueItems": true - }, - "indentSize": { - "description": "The size of the indentation, 2 by default", - "default": 2, - "type": "integer", - "format": "uint8", - "minimum": 0.0 - }, - "indentStyle": { - "description": "The indent style.", - "default": "tab", - "allOf": [ - { - "$ref": "#/definitions/PlainIndentStyle" - } - ] - }, - "lineWidth": { - "description": "What's the max width of a line. Defaults to 80.", - "default": 80, - "allOf": [ - { - "$ref": "#/definitions/LineWidth" - } - ] - } - }, - "additionalProperties": false - }, - "JavascriptConfiguration": { - "type": "object", - "properties": { - "formatter": { - "anyOf": [ - { - "$ref": "#/definitions/JavascriptFormatter" - }, - { - "type": "null" - } - ] - }, - "globals": { - "description": "A list of global bindings that should be ignored by the analyzers\n\nIf defined here, they should not emit diagnostics.", - "type": ["array", "null"], - "items": { - "type": "string" - }, - "uniqueItems": true - } - }, - "additionalProperties": false - }, - "JavascriptFormatter": { - "type": "object", - "properties": { - "quoteProperties": { - "description": "When properties in objects are quoted. Defaults to asNeeded.", - "default": "asNeeded", - "allOf": [ - { - "$ref": "#/definitions/QuoteProperties" - } - ] - }, - "quoteStyle": { - "description": "The style for quotes. Defaults to double.", - "default": "double", - "allOf": [ - { - "$ref": "#/definitions/QuoteStyle" - } - ] - }, - "semicolons": { - "description": "Whether the formatter prints semicolons for all statements or only in for statements where it is necessary because of ASI.", - "default": "always", - "allOf": [ - { - "$ref": "#/definitions/Semicolons" - } - ] - }, - "trailingComma": { - "description": "Print trailing commas wherever possible in multi-line comma-separated syntactic structures. Defaults to \"all\".", - "default": "all", - "allOf": [ - { - "$ref": "#/definitions/TrailingComma" - } - ] - } - }, - "additionalProperties": false - }, - "LineWidth": { - "description": "Validated value for the `line_width` formatter options\n\nThe allowed range of values is 1..=320", - "type": "integer", - "format": "uint16", - "minimum": 0.0 - }, - "LinterConfiguration": { - "type": "object", - "properties": { - "enabled": { - "description": "if `false`, it disables the feature and the linter won't be executed. `true` by default", - "default": true, - "type": "boolean" - }, - "ignore": { - "description": "A list of Unix shell style patterns. The formatter will ignore files/folders that will match these patterns.", - "type": ["array", "null"], - "items": { - "type": "string" - }, - "uniqueItems": true - }, - "rules": { - "description": "List of rules", - "default": { - "recommended": true - }, - "anyOf": [ - { - "$ref": "#/definitions/Rules" - }, - { - "type": "null" - } - ] - } - }, - "additionalProperties": false - }, - "Nursery": { - "description": "A list of rules that belong to this group", - "type": "object", - "properties": { - "noAccessKey": { - "description": "Enforce that the accessKey attribute is not used on any HTML element.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noAssignInExpressions": { - "description": "Disallow assignments in expressions.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noBannedTypes": { - "description": "Disallow certain types.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noClassAssign": { - "description": "Disallow reassigning class members.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noCommaOperator": { - "description": "Disallow comma operator.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noConstEnum": { - "description": "Disallow TypeScript const enum", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noConstructorReturn": { - "description": "Disallow returning a value from a constructor.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noDistractingElements": { - "description": "Enforces that no distracting elements are used.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noDuplicateCase": { - "description": "Disallow duplicate case labels. If a switch statement has duplicate test expressions in case clauses, it is likely that a programmer copied a case clause but forgot to change the test expression.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noDuplicateObjectKeys": { - "description": "Prevents object literals having more than one property declaration for the same name. If an object property with the same name is defined multiple times (except when combining a getter with a setter), only the last definition makes it into the object and previous definitions are ignored, which is likely a mistake.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noEmptyInterface": { - "description": "Disallow the declaration of empty interfaces.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noExtraNonNullAssertion": { - "description": "Prevents the wrong usage of the non-null assertion operator (!) in TypeScript files.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noExtraSemicolons": { - "description": "Typing mistakes and misunderstandings about where semicolons are required can lead to semicolons that are unnecessary. While not technically an error, extra semicolons can cause confusion when reading code.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noHeaderScope": { - "description": "Check that the scope attribute is only used on th elements.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noInnerDeclarations": { - "description": "Disallow function and var declarations in nested blocks.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noInvalidConstructorSuper": { - "description": "Prevents the incorrect use of super() inside classes. It also checks whether a call super() is missing from classes that extends other constructors.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noNonNullAssertion": { - "description": "Disallow non-null assertions using the ! postfix operator.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noNoninteractiveElementToInteractiveRole": { - "description": "Enforce that interactive ARIA roles are not assigned to non-interactive HTML elements.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noPrecisionLoss": { - "description": "Disallow literal numbers that lose precision", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noRedundantAlt": { - "description": "Enforce img alt prop does not contain the word \"image\", \"picture\", or \"photo\".", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noRedundantUseStrict": { - "description": "Prevents from having redundant \"use strict\".", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noRestrictedGlobals": { - "description": "This rule allows you to specify global variable names that you don’t want to use in your application.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noSelfCompare": { - "description": "Disallow comparisons where both sides are exactly the same.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noSetterReturn": { - "description": "Disallow returning a value from a setter", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noStringCaseMismatch": { - "description": "Disallow comparison of expressions modifying the string case with non-compliant value.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noUnreachableSuper": { - "description": "Ensures the super() constructor is called exactly once on every code path in a class constructor before this is accessed if the class has a superclass", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noUnsafeFinally": { - "description": "Disallow control flow statements in finally blocks.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noUselessSwitchCase": { - "description": "Disallow useless case in switch statements.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noVar": { - "description": "Disallow the use of var", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noVoidTypeReturn": { - "description": "Disallow returning a value from a function with the return type 'void'", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noWith": { - "description": "Disallow with statements in non-strict contexts.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "recommended": { - "description": "It enables the recommended rules for this group", - "type": ["boolean", "null"] - }, - "useAriaPropTypes": { - "description": "Enforce that ARIA state and property values are valid.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useAriaPropsForRole": { - "description": "Enforce that elements with ARIA roles must have all required ARIA attributes for that role.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useCamelCase": { - "description": "Enforce camel case naming convention.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useConst": { - "description": "Require const declarations for variables that are never reassigned after declared.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useDefaultParameterLast": { - "description": "Enforce default function parameters and optional parameters to be last.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useDefaultSwitchClauseLast": { - "description": "Enforce default clauses in switch statements to be last", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useEnumInitializers": { - "description": "Require that each enum member value be explicitly initialized.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useExhaustiveDependencies": { - "description": "Enforce all dependencies are correctly specified.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useExponentiationOperator": { - "description": "Disallow the use of Math.pow in favor of the ** operator.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useHookAtTopLevel": { - "description": "Enforce that all React hooks are being called from the Top Level component functions.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useIframeTitle": { - "description": "Enforces the usage of the attribute title for the element iframe", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useIsNan": { - "description": "Require calls to isNaN() when checking for NaN.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useMediaCaption": { - "description": "Enforces that audio and video elements must have a track for captions.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useNumericLiterals": { - "description": "Disallow parseInt() and Number.parseInt() in favor of binary, octal, and hexadecimal literals", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useSimpleNumberKeys": { - "description": "Disallow number literal object member names which are not base10 or uses underscore as separator", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useValidAriaProps": { - "description": "Ensures that ARIA properties aria-* are all valid.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useValidLang": { - "description": "Ensure that the attribute passed to the lang attribute is a correct ISO language and/or country.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - } - } - }, - "Performance": { - "description": "A list of rules that belong to this group", - "type": "object", - "properties": { - "noDelete": { - "description": "Disallow the use of the delete operator", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "recommended": { - "description": "It enables the recommended rules for this group", - "type": ["boolean", "null"] - } - } - }, - "PlainIndentStyle": { - "type": "string", - "enum": ["tab", "space"] - }, - "QuoteProperties": { - "type": "string", - "enum": ["asNeeded", "preserve"] - }, - "QuoteStyle": { - "type": "string", - "enum": ["double", "single"] - }, - "RuleConfiguration": { - "anyOf": [ - { - "$ref": "#/definitions/RulePlainConfiguration" - }, - { - "$ref": "#/definitions/RuleWithOptions" - } - ] - }, - "RulePlainConfiguration": { - "type": "string", - "enum": ["warn", "error", "off"] - }, - "RuleWithOptions": { - "type": "object", - "required": ["level", "options"], - "properties": { - "level": { - "$ref": "#/definitions/RulePlainConfiguration" - }, - "options": true - }, - "additionalProperties": false - }, - "Rules": { - "type": "object", - "properties": { - "a11y": { - "anyOf": [ - { - "$ref": "#/definitions/A11y" - }, - { - "type": "null" - } - ] - }, - "complexity": { - "anyOf": [ - { - "$ref": "#/definitions/Complexity" - }, - { - "type": "null" - } - ] - }, - "correctness": { - "anyOf": [ - { - "$ref": "#/definitions/Correctness" - }, - { - "type": "null" - } - ] - }, - "nursery": { - "anyOf": [ - { - "$ref": "#/definitions/Nursery" - }, - { - "type": "null" - } - ] - }, - "performance": { - "anyOf": [ - { - "$ref": "#/definitions/Performance" - }, - { - "type": "null" - } - ] - }, - "recommended": { - "description": "It enables the lint rules recommended by Rome. `true` by default.", - "type": ["boolean", "null"] - }, - "security": { - "anyOf": [ - { - "$ref": "#/definitions/Security" - }, - { - "type": "null" - } - ] - }, - "style": { - "anyOf": [ - { - "$ref": "#/definitions/Style" - }, - { - "type": "null" - } - ] - }, - "suspicious": { - "anyOf": [ - { - "$ref": "#/definitions/Suspicious" - }, - { - "type": "null" - } - ] - } - }, - "additionalProperties": false - }, - "Security": { - "description": "A list of rules that belong to this group", - "type": "object", - "properties": { - "noDangerouslySetInnerHtml": { - "description": "Prevent the usage of dangerous JSX props", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noDangerouslySetInnerHtmlWithChildren": { - "description": "Report when a DOM element or a component uses both children and dangerouslySetInnerHTML prop.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "recommended": { - "description": "It enables the recommended rules for this group", - "type": ["boolean", "null"] - } - } - }, - "Semicolons": { - "type": "string", - "enum": ["always", "asNeeded"] - }, - "Style": { - "description": "A list of rules that belong to this group", - "type": "object", - "properties": { - "noArguments": { - "description": "Disallow the use of arguments", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noImplicitBoolean": { - "description": "Disallow implicit true values on JSX boolean attributes", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noNegationElse": { - "description": "Disallow negation in the condition of an if statement if it has an else clause", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noShoutyConstants": { - "description": "Disallow the use of constants which its value is the upper-case version of its name.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noUnusedTemplateLiteral": { - "description": "Disallow template literals if interpolation and special-character handling are not needed", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "recommended": { - "description": "It enables the recommended rules for this group", - "type": ["boolean", "null"] - }, - "useBlockStatements": { - "description": "Requires following curly brace conventions. JavaScript allows the omission of curly braces when a block contains only one statement. However, it is considered by many to be best practice to never omit curly braces around blocks, even when they are optional, because it can lead to bugs and reduces code clarity.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useFragmentSyntax": { - "description": "This rule enforces the use of <>... over ....", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useSelfClosingElements": { - "description": "Prevent extra closing tags for components without children", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useShorthandArrayType": { - "description": "When expressing array types, this rule promotes the usage of T[] shorthand instead of Array.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useSingleCaseStatement": { - "description": "Enforces case clauses have a single statement, emits a quick fix wrapping the statements in a block", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useSingleVarDeclarator": { - "description": "Disallow multiple variable declarations in the same variable statement", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useTemplate": { - "description": "Template literals are preferred over string concatenation.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useWhile": { - "description": "Enforce the use of while loops instead of for loops when the initializer and update expressions are not needed", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - } - } - }, - "Suspicious": { - "description": "A list of rules that belong to this group", - "type": "object", - "properties": { - "noArrayIndexKey": { - "description": "Discourage the usage of Array index in keys.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noAsyncPromiseExecutor": { - "description": "Disallows using an async function as a Promise executor.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noCatchAssign": { - "description": "Disallow reassigning exceptions in catch clauses", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noCommentText": { - "description": "Prevent comments from being inserted as text nodes", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noCompareNegZero": { - "description": "Disallow comparing against -0", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noDebugger": { - "description": "Disallow the use of debugger", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noDoubleEquals": { - "description": "Require the use of === and !==", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noDuplicateParameters": { - "description": "Disallow duplicate function arguments name.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noExplicitAny": { - "description": "Disallow the any type usage", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noFunctionAssign": { - "description": "Disallow reassigning function declarations.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noImportAssign": { - "description": "Disallow assigning to imported bindings", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noLabelVar": { - "description": "Disallow labels that share a name with a variable", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noShadowRestrictedNames": { - "description": "Disallow identifiers from shadowing restricted names.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noSparseArray": { - "description": "Disallow sparse arrays", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noUnsafeNegation": { - "description": "Disallow using unsafe negation.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "recommended": { - "description": "It enables the recommended rules for this group", - "type": ["boolean", "null"] - }, - "useValidTypeof": { - "description": "This rule verifies the result of typeof $expr unary expressions is being compared to valid values, either string literals containing valid type names or other typeof expressions", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - } - } - }, - "TrailingComma": { - "type": "string", - "enum": ["all", "es5", "none"] - } - } -} + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Configuration", + "description": "The configuration that is contained inside the file `rome.json`", + "type": "object", + "properties": { + "$schema": { + "description": "A field for the [JSON schema](https://json-schema.org/) specification", + "type": [ + "string", + "null" + ] + }, + "files": { + "description": "The configuration of the filesystem", + "anyOf": [ + { + "$ref": "#/definitions/FilesConfiguration" + }, + { + "type": "null" + } + ] + }, + "formatter": { + "description": "The configuration of the formatter", + "anyOf": [ + { + "$ref": "#/definitions/FormatterConfiguration" + }, + { + "type": "null" + } + ] + }, + "javascript": { + "description": "Specific configuration for the JavaScript language", + "anyOf": [ + { + "$ref": "#/definitions/JavascriptConfiguration" + }, + { + "type": "null" + } + ] + }, + "linter": { + "description": "The configuration for the linter", + "anyOf": [ + { + "$ref": "#/definitions/LinterConfiguration" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false, + "definitions": { + "A11y": { + "description": "A list of rules that belong to this group", + "type": "object", + "properties": { + "noAutofocus": { + "description": "Avoid the autoFocus attribute", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noBlankTarget": { + "description": "Disallow target=\"_blank\" attribute without rel=\"noreferrer\"", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noPositiveTabindex": { + "description": "Prevent the usage of positive integers on tabIndex property", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "recommended": { + "description": "It enables the recommended rules for this group", + "type": [ + "boolean", + "null" + ] + }, + "useAltText": { + "description": "It asserts that alternative text to images or areas, help to rely on to screen readers to understand the purpose and the context of the image.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useAnchorContent": { + "description": "Enforce that anchor elements have content and that the content is accessible to screen readers.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useButtonType": { + "description": "Enforces the usage of the attribute type for the element button", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useHtmlLang": { + "description": "Enforce that html element has lang attribute. This allows users to choose a language other than the default.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useKeyWithClickEvents": { + "description": "Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useKeyWithMouseEvents": { + "description": "Enforce that onMouseOver/onMouseOut are accompanied by onFocus/onBlur for keyboard-only users. It is important to take into account users with physical disabilities who cannot use a mouse, who use assistive technology or screenreader.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useValidAnchor": { + "description": "Enforce that all anchors are valid, and they are navigable elements.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + } + } + }, + "Complexity": { + "description": "A list of rules that belong to this group", + "type": "object", + "properties": { + "noExtraBooleanCast": { + "description": "Disallow unnecessary boolean casts", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noMultipleSpacesInRegularExpressionLiterals": { + "description": "Disallow unclear usage of multiple space characters in regular expression literals", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUselessFragments": { + "description": "Disallow unnecessary fragments", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "recommended": { + "description": "It enables the recommended rules for this group", + "type": [ + "boolean", + "null" + ] + }, + "useFlatMap": { + "description": "Promotes the use of .flatMap() when map().flat() are used together.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useOptionalChain": { + "description": "Enforce using concise optional chain instead of chained logical expressions.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useSimplifiedLogicExpression": { + "description": "Discard redundant terms from logical expressions.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + } + } + }, + "Correctness": { + "description": "A list of rules that belong to this group", + "type": "object", + "properties": { + "noChildrenProp": { + "description": "Prevent passing of children as props.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noConstAssign": { + "description": "Prevents from having const variables being re-assigned.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noEmptyPattern": { + "description": "Disallows empty destructuring patterns.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noNewSymbol": { + "description": "Disallow new operators with the Symbol object", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noRenderReturnValue": { + "description": "Prevent the usage of the return value of React.render.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUndeclaredVariables": { + "description": "Prevents the usage of variables that haven't been declared inside the document", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUnnecessaryContinue": { + "description": "Avoid using unnecessary continue.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUnreachable": { + "description": "Disallow unreachable code", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUnusedVariables": { + "description": "Disallow unused variables.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noVoidElementsWithChildren": { + "description": "This rules prevents void elements (AKA self-closing elements) from having children.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "recommended": { + "description": "It enables the recommended rules for this group", + "type": [ + "boolean", + "null" + ] + }, + "useValidForDirection": { + "description": "Enforce \"for\" loop update clause moving the counter in the right direction.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + } + } + }, + "FilesConfiguration": { + "description": "The configuration of the filesystem", + "type": "object", + "properties": { + "ignore": { + "description": "A list of Unix shell style patterns. Rome tools will ignore files/folders that will match these patterns.", + "type": [ + "array", + "null" + ], + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "maxSize": { + "description": "The maximum allowed size for source code files in bytes. Files above this limit will be ignored for performance reason. Defaults to 1 MiB", + "default": null, + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + } + }, + "additionalProperties": false + }, + "FormatterConfiguration": { + "type": "object", + "properties": { + "enabled": { + "default": true, + "type": "boolean" + }, + "formatWithErrors": { + "description": "Stores whether formatting should be allowed to proceed if a given file has syntax errors", + "default": false, + "type": "boolean" + }, + "ignore": { + "description": "A list of Unix shell style patterns. The formatter will ignore files/folders that will match these patterns.", + "type": [ + "array", + "null" + ], + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "indentSize": { + "description": "The size of the indentation, 2 by default", + "default": 2, + "type": "integer", + "format": "uint8", + "minimum": 0.0 + }, + "indentStyle": { + "description": "The indent style.", + "default": "tab", + "allOf": [ + { + "$ref": "#/definitions/PlainIndentStyle" + } + ] + }, + "lineWidth": { + "description": "What's the max width of a line. Defaults to 80.", + "default": 80, + "allOf": [ + { + "$ref": "#/definitions/LineWidth" + } + ] + } + }, + "additionalProperties": false + }, + "JavascriptConfiguration": { + "type": "object", + "properties": { + "formatter": { + "anyOf": [ + { + "$ref": "#/definitions/JavascriptFormatter" + }, + { + "type": "null" + } + ] + }, + "globals": { + "description": "A list of global bindings that should be ignored by the analyzers\n\nIf defined here, they should not emit diagnostics.", + "type": [ + "array", + "null" + ], + "items": { + "type": "string" + }, + "uniqueItems": true + } + }, + "additionalProperties": false + }, + "JavascriptFormatter": { + "type": "object", + "properties": { + "quoteProperties": { + "description": "When properties in objects are quoted. Defaults to asNeeded.", + "default": "asNeeded", + "allOf": [ + { + "$ref": "#/definitions/QuoteProperties" + } + ] + }, + "quoteStyle": { + "description": "The style for quotes. Defaults to double.", + "default": "double", + "allOf": [ + { + "$ref": "#/definitions/QuoteStyle" + } + ] + }, + "semicolons": { + "description": "Whether the formatter prints semicolons for all statements or only in for statements where it is necessary because of ASI.", + "default": "always", + "allOf": [ + { + "$ref": "#/definitions/Semicolons" + } + ] + }, + "trailingComma": { + "description": "Print trailing commas wherever possible in multi-line comma-separated syntactic structures. Defaults to \"all\".", + "default": "all", + "allOf": [ + { + "$ref": "#/definitions/TrailingComma" + } + ] + } + }, + "additionalProperties": false + }, + "LineWidth": { + "description": "Validated value for the `line_width` formatter options\n\nThe allowed range of values is 1..=320", + "type": "integer", + "format": "uint16", + "minimum": 0.0 + }, + "LinterConfiguration": { + "type": "object", + "properties": { + "enabled": { + "description": "if `false`, it disables the feature and the linter won't be executed. `true` by default", + "default": true, + "type": "boolean" + }, + "ignore": { + "description": "A list of Unix shell style patterns. The formatter will ignore files/folders that will match these patterns.", + "type": [ + "array", + "null" + ], + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "rules": { + "description": "List of rules", + "default": { + "recommended": true + }, + "anyOf": [ + { + "$ref": "#/definitions/Rules" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false + }, + "Nursery": { + "description": "A list of rules that belong to this group", + "type": "object", + "properties": { + "noAccessKey": { + "description": "Enforce that the accessKey attribute is not used on any HTML element.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noAssignInExpressions": { + "description": "Disallow assignments in expressions.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noBannedTypes": { + "description": "Disallow certain types.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noClassAssign": { + "description": "Disallow reassigning class members.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noCommaOperator": { + "description": "Disallow comma operator.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noConstEnum": { + "description": "Disallow TypeScript const enum", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noConstructorReturn": { + "description": "Disallow returning a value from a constructor.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noDistractingElements": { + "description": "Enforces that no distracting elements are used.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noDuplicateCase": { + "description": "Disallow duplicate case labels. If a switch statement has duplicate test expressions in case clauses, it is likely that a programmer copied a case clause but forgot to change the test expression.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noDuplicateObjectKeys": { + "description": "Prevents object literals having more than one property declaration for the same name. If an object property with the same name is defined multiple times (except when combining a getter with a setter), only the last definition makes it into the object and previous definitions are ignored, which is likely a mistake.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noEmptyInterface": { + "description": "Disallow the declaration of empty interfaces.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noExtraNonNullAssertion": { + "description": "Prevents the wrong usage of the non-null assertion operator (!) in TypeScript files.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noExtraSemicolons": { + "description": "Typing mistakes and misunderstandings about where semicolons are required can lead to semicolons that are unnecessary. While not technically an error, extra semicolons can cause confusion when reading code.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noHeaderScope": { + "description": "Check that the scope attribute is only used on th elements.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noInnerDeclarations": { + "description": "Disallow function and var declarations in nested blocks.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noInvalidConstructorSuper": { + "description": "Prevents the incorrect use of super() inside classes. It also checks whether a call super() is missing from classes that extends other constructors.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noNonNullAssertion": { + "description": "Disallow non-null assertions using the ! postfix operator.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noNoninteractiveElementToInteractiveRole": { + "description": "Enforce that interactive ARIA roles are not assigned to non-interactive HTML elements.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noPrecisionLoss": { + "description": "Disallow literal numbers that lose precision", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noRedundantAlt": { + "description": "Enforce img alt prop does not contain the word \"image\", \"picture\", or \"photo\".", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noRedundantUseStrict": { + "description": "Prevents from having redundant \"use strict\".", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noRestrictedGlobals": { + "description": "This rule allows you to specify global variable names that you don’t want to use in your application.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noSelfCompare": { + "description": "Disallow comparisons where both sides are exactly the same.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noSetterReturn": { + "description": "Disallow returning a value from a setter", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noStringCaseMismatch": { + "description": "Disallow comparison of expressions modifying the string case with non-compliant value.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUnreachableSuper": { + "description": "Ensures the super() constructor is called exactly once on every code path in a class constructor before this is accessed if the class has a superclass", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUnsafeFinally": { + "description": "Disallow control flow statements in finally blocks.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUselessSwitchCase": { + "description": "Disallow useless case in switch statements.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noVar": { + "description": "Disallow the use of var", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noVoidTypeReturn": { + "description": "Disallow returning a value from a function with the return type 'void'", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noWith": { + "description": "Disallow with statements in non-strict contexts.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "recommended": { + "description": "It enables the recommended rules for this group", + "type": [ + "boolean", + "null" + ] + }, + "useAriaPropTypes": { + "description": "Enforce that ARIA state and property values are valid.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useAriaPropsForRole": { + "description": "Enforce that elements with ARIA roles must have all required ARIA attributes for that role.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useCamelCase": { + "description": "Enforce camel case naming convention.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useConst": { + "description": "Require const declarations for variables that are never reassigned after declared.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useDefaultParameterLast": { + "description": "Enforce default function parameters and optional parameters to be last.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useDefaultSwitchClauseLast": { + "description": "Enforce default clauses in switch statements to be last", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useEnumInitializers": { + "description": "Require that each enum member value be explicitly initialized.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useExhaustiveDependencies": { + "description": "Enforce all dependencies are correctly specified.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useExponentiationOperator": { + "description": "Disallow the use of Math.pow in favor of the ** operator.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useHookAtTopLevel": { + "description": "Enforce that all React hooks are being called from the Top Level component functions.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useIframeTitle": { + "description": "Enforces the usage of the attribute title for the element iframe", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useIsNan": { + "description": "Require calls to isNaN() when checking for NaN.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useMediaCaption": { + "description": "Enforces that audio and video elements must have a track for captions.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useNumericLiterals": { + "description": "Disallow parseInt() and Number.parseInt() in favor of binary, octal, and hexadecimal literals", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useSimpleNumberKeys": { + "description": "Disallow number literal object member names which are not base10 or uses underscore as separator", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useValidAriaProps": { + "description": "Ensures that ARIA properties aria-* are all valid.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useValidLang": { + "description": "Ensure that the attribute passed to the lang attribute is a correct ISO language and/or country.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + } + } + }, + "Performance": { + "description": "A list of rules that belong to this group", + "type": "object", + "properties": { + "noDelete": { + "description": "Disallow the use of the delete operator", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "recommended": { + "description": "It enables the recommended rules for this group", + "type": [ + "boolean", + "null" + ] + } + } + }, + "PlainIndentStyle": { + "type": "string", + "enum": [ + "tab", + "space" + ] + }, + "QuoteProperties": { + "type": "string", + "enum": [ + "asNeeded", + "preserve" + ] + }, + "QuoteStyle": { + "type": "string", + "enum": [ + "double", + "single" + ] + }, + "RuleConfiguration": { + "anyOf": [ + { + "$ref": "#/definitions/RulePlainConfiguration" + }, + { + "$ref": "#/definitions/RuleWithOptions" + } + ] + }, + "RulePlainConfiguration": { + "type": "string", + "enum": [ + "warn", + "error", + "off" + ] + }, + "RuleWithOptions": { + "type": "object", + "required": [ + "level", + "options" + ], + "properties": { + "level": { + "$ref": "#/definitions/RulePlainConfiguration" + }, + "options": true + }, + "additionalProperties": false + }, + "Rules": { + "type": "object", + "properties": { + "a11y": { + "anyOf": [ + { + "$ref": "#/definitions/A11y" + }, + { + "type": "null" + } + ] + }, + "complexity": { + "anyOf": [ + { + "$ref": "#/definitions/Complexity" + }, + { + "type": "null" + } + ] + }, + "correctness": { + "anyOf": [ + { + "$ref": "#/definitions/Correctness" + }, + { + "type": "null" + } + ] + }, + "nursery": { + "anyOf": [ + { + "$ref": "#/definitions/Nursery" + }, + { + "type": "null" + } + ] + }, + "performance": { + "anyOf": [ + { + "$ref": "#/definitions/Performance" + }, + { + "type": "null" + } + ] + }, + "recommended": { + "description": "It enables the lint rules recommended by Rome. `true` by default.", + "type": [ + "boolean", + "null" + ] + }, + "security": { + "anyOf": [ + { + "$ref": "#/definitions/Security" + }, + { + "type": "null" + } + ] + }, + "style": { + "anyOf": [ + { + "$ref": "#/definitions/Style" + }, + { + "type": "null" + } + ] + }, + "suspicious": { + "anyOf": [ + { + "$ref": "#/definitions/Suspicious" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false + }, + "Security": { + "description": "A list of rules that belong to this group", + "type": "object", + "properties": { + "noDangerouslySetInnerHtml": { + "description": "Prevent the usage of dangerous JSX props", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noDangerouslySetInnerHtmlWithChildren": { + "description": "Report when a DOM element or a component uses both children and dangerouslySetInnerHTML prop.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "recommended": { + "description": "It enables the recommended rules for this group", + "type": [ + "boolean", + "null" + ] + } + } + }, + "Semicolons": { + "type": "string", + "enum": [ + "always", + "asNeeded" + ] + }, + "Style": { + "description": "A list of rules that belong to this group", + "type": "object", + "properties": { + "noArguments": { + "description": "Disallow the use of arguments", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noImplicitBoolean": { + "description": "Disallow implicit true values on JSX boolean attributes", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noNegationElse": { + "description": "Disallow negation in the condition of an if statement if it has an else clause", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noShoutyConstants": { + "description": "Disallow the use of constants which its value is the upper-case version of its name.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUnusedTemplateLiteral": { + "description": "Disallow template literals if interpolation and special-character handling are not needed", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "recommended": { + "description": "It enables the recommended rules for this group", + "type": [ + "boolean", + "null" + ] + }, + "useBlockStatements": { + "description": "Requires following curly brace conventions. JavaScript allows the omission of curly braces when a block contains only one statement. However, it is considered by many to be best practice to never omit curly braces around blocks, even when they are optional, because it can lead to bugs and reduces code clarity.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useFragmentSyntax": { + "description": "This rule enforces the use of <>... over ....", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useSelfClosingElements": { + "description": "Prevent extra closing tags for components without children", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useShorthandArrayType": { + "description": "When expressing array types, this rule promotes the usage of T[] shorthand instead of Array.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useSingleCaseStatement": { + "description": "Enforces case clauses have a single statement, emits a quick fix wrapping the statements in a block", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useSingleVarDeclarator": { + "description": "Disallow multiple variable declarations in the same variable statement", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useTemplate": { + "description": "Template literals are preferred over string concatenation.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useWhile": { + "description": "Enforce the use of while loops instead of for loops when the initializer and update expressions are not needed", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + } + } + }, + "Suspicious": { + "description": "A list of rules that belong to this group", + "type": "object", + "properties": { + "noArrayIndexKey": { + "description": "Discourage the usage of Array index in keys.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noAsyncPromiseExecutor": { + "description": "Disallows using an async function as a Promise executor.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noCatchAssign": { + "description": "Disallow reassigning exceptions in catch clauses", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noCommentText": { + "description": "Prevent comments from being inserted as text nodes", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noCompareNegZero": { + "description": "Disallow comparing against -0", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noDebugger": { + "description": "Disallow the use of debugger", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noDoubleEquals": { + "description": "Require the use of === and !==", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noDuplicateParameters": { + "description": "Disallow duplicate function arguments name.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noExplicitAny": { + "description": "Disallow the any type usage.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noFunctionAssign": { + "description": "Disallow reassigning function declarations.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noImportAssign": { + "description": "Disallow assigning to imported bindings", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noLabelVar": { + "description": "Disallow labels that share a name with a variable", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noShadowRestrictedNames": { + "description": "Disallow identifiers from shadowing restricted names.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noSparseArray": { + "description": "Disallow sparse arrays", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUnsafeNegation": { + "description": "Disallow using unsafe negation.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "recommended": { + "description": "It enables the recommended rules for this group", + "type": [ + "boolean", + "null" + ] + }, + "useValidTypeof": { + "description": "This rule verifies the result of typeof $expr unary expressions is being compared to valid values, either string literals containing valid type names or other typeof expressions", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + } + } + }, + "TrailingComma": { + "type": "string", + "enum": [ + "all", + "es5", + "none" + ] + } + } +} \ No newline at end of file From 25d173e671e611d88d67d7652b302b4f00b33001 Mon Sep 17 00:00:00 2001 From: Dhiraj Arun <69076988+dhrjarun@users.noreply.github.com> Date: Tue, 10 Jan 2023 16:07:31 +0530 Subject: [PATCH 5/8] Update crates/rome_js_analyze/src/analyzers/nursery/use_simple_number_keys.rs Co-authored-by: Emanuele Stoppa --- .../src/analyzers/nursery/use_simple_number_keys.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/rome_js_analyze/src/analyzers/nursery/use_simple_number_keys.rs b/crates/rome_js_analyze/src/analyzers/nursery/use_simple_number_keys.rs index 9c5128ea82a..7b1aecfcde5 100644 --- a/crates/rome_js_analyze/src/analyzers/nursery/use_simple_number_keys.rs +++ b/crates/rome_js_analyze/src/analyzers/nursery/use_simple_number_keys.rs @@ -16,9 +16,17 @@ declare_rule! { /// /// ```js,expect_diagnostic /// ({ 0x1: 1 }); + /// ``` + /// ```js,expect_diagnostic /// ({ 11_1.11: "ee" }); + /// ``` + /// ```js,expect_diagnostic /// ({ 0o1: 1 }); + /// ``` + /// ```js,expect_diagnostic /// ({ 1n: 1 }); + /// ``` + /// ```js,expect_diagnostic /// ({ 11_1.11: "ee" }); /// ``` /// From e2cfc35e8652cb8867ecc04bd49eb3d1eb56e04d Mon Sep 17 00:00:00 2001 From: Dhiraj Arun Date: Tue, 10 Jan 2023 16:11:32 +0530 Subject: [PATCH 6/8] add useSimpleNumberKeys doc page --- .../nursery/use_simple_number_keys.rs | 10 +- .../specs/nursery/useSimpleNumberKeys.js | 7 - .../specs/nursery/useSimpleNumberKeys.js.snap | 175 +++++++++--------- website/src/pages/lint/rules/index.mdx | 9 +- .../pages/lint/rules/useSimpleNumberKeys.md | 106 ++++++++++- 5 files changed, 187 insertions(+), 120 deletions(-) diff --git a/crates/rome_js_analyze/src/analyzers/nursery/use_simple_number_keys.rs b/crates/rome_js_analyze/src/analyzers/nursery/use_simple_number_keys.rs index 7b1aecfcde5..41de5160324 100644 --- a/crates/rome_js_analyze/src/analyzers/nursery/use_simple_number_keys.rs +++ b/crates/rome_js_analyze/src/analyzers/nursery/use_simple_number_keys.rs @@ -19,13 +19,13 @@ declare_rule! { /// ``` /// ```js,expect_diagnostic /// ({ 11_1.11: "ee" }); - /// ``` + /// ``` /// ```js,expect_diagnostic /// ({ 0o1: 1 }); - /// ``` + /// ``` /// ```js,expect_diagnostic /// ({ 1n: 1 }); - /// ``` + /// ``` /// ```js,expect_diagnostic /// ({ 11_1.11: "ee" }); /// ``` @@ -34,7 +34,9 @@ declare_rule! { /// /// ```js /// ({ 0: "zero" }); - /// ({ 3.1e12: "12" }); + /// ({ 122: "integer" }); + /// ({ 1.22: "floating point" }); + /// ({ 3.1e12: "floating point with e" }); /// ``` /// pub(crate) UseSimpleNumberKeys { diff --git a/crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys.js b/crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys.js index c48ed00b11d..59a2756012d 100644 --- a/crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys.js +++ b/crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys.js @@ -7,17 +7,10 @@ // invalid ({ 1n: 1 }); - ({ 0x1: 1 }); - ({ 012: 1 }); - ({ 0b1: 1 }); - ({ 0o1: 1 }); - ({ 1_0: 1 }); - ({ 0.1e1_2: "ed" }); - ({ 11_1.11: "ee" }); diff --git a/crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys.js.snap b/crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys.js.snap index c1e064832ef..6e7e47dcc1c 100644 --- a/crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys.js.snap +++ b/crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys.js.snap @@ -13,19 +13,12 @@ expression: useSimpleNumberKeys.js // invalid ({ 1n: 1 }); - ({ 0x1: 1 }); - ({ 012: 1 }); - ({ 0b1: 1 }); - ({ 0o1: 1 }); - ({ 1_0: 1 }); - ({ 0.1e1_2: "ed" }); - ({ 11_1.11: "ee" }); ``` @@ -39,8 +32,8 @@ useSimpleNumberKeys.js:9:4 lint/nursery/useSimpleNumberKeys FIXABLE ━━━ 8 │ // invalid > 9 │ ({ 1n: 1 }); │ ^^ - 10 │ - 11 │ ({ 0x1: 1 }); + 10 │ ({ 0x1: 1 }); + 11 │ ({ 012: 1 }); i Safe fix: Replace 1n with 1 @@ -48,174 +41,174 @@ useSimpleNumberKeys.js:9:4 lint/nursery/useSimpleNumberKeys FIXABLE ━━━ 8 8 │ // invalid 9 │ - ({·1n:·1·}); 9 │ + ({·1:·1·}); - 10 10 │ - 11 11 │ ({ 0x1: 1 }); + 10 10 │ ({ 0x1: 1 }); + 11 11 │ ({ 012: 1 }); ``` ``` -useSimpleNumberKeys.js:11:4 lint/nursery/useSimpleNumberKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +useSimpleNumberKeys.js:10:4 lint/nursery/useSimpleNumberKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Hexadecimal number literal is not allowed here. + 8 │ // invalid 9 │ ({ 1n: 1 }); - 10 │ - > 11 │ ({ 0x1: 1 }); + > 10 │ ({ 0x1: 1 }); │ ^^^ - 12 │ - 13 │ ({ 012: 1 }); + 11 │ ({ 012: 1 }); + 12 │ ({ 0b1: 1 }); i Safe fix: Replace 0x1 with 1 + 8 8 │ // invalid 9 9 │ ({ 1n: 1 }); - 10 10 │ - 11 │ - ({·0x1:·1·}); - 11 │ + ({·1:·1·}); - 12 12 │ - 13 13 │ ({ 012: 1 }); + 10 │ - ({·0x1:·1·}); + 10 │ + ({·1:·1·}); + 11 11 │ ({ 012: 1 }); + 12 12 │ ({ 0b1: 1 }); ``` ``` -useSimpleNumberKeys.js:13:4 lint/nursery/useSimpleNumberKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +useSimpleNumberKeys.js:11:4 lint/nursery/useSimpleNumberKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Octal number literal is not allowed here. - 11 │ ({ 0x1: 1 }); - 12 │ - > 13 │ ({ 012: 1 }); + 9 │ ({ 1n: 1 }); + 10 │ ({ 0x1: 1 }); + > 11 │ ({ 012: 1 }); │ ^^^ - 14 │ - 15 │ ({ 0b1: 1 }); + 12 │ ({ 0b1: 1 }); + 13 │ ({ 0o1: 1 }); i Safe fix: Replace 012 with 9 - 11 11 │ ({ 0x1: 1 }); - 12 12 │ - 13 │ - ({·012:·1·}); - 13 │ + ({·9:·1·}); - 14 14 │ - 15 15 │ ({ 0b1: 1 }); + 9 9 │ ({ 1n: 1 }); + 10 10 │ ({ 0x1: 1 }); + 11 │ - ({·012:·1·}); + 11 │ + ({·9:·1·}); + 12 12 │ ({ 0b1: 1 }); + 13 13 │ ({ 0o1: 1 }); ``` ``` -useSimpleNumberKeys.js:15:4 lint/nursery/useSimpleNumberKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +useSimpleNumberKeys.js:12:4 lint/nursery/useSimpleNumberKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Binary number literal in is not allowed here. - 13 │ ({ 012: 1 }); - 14 │ - > 15 │ ({ 0b1: 1 }); + 10 │ ({ 0x1: 1 }); + 11 │ ({ 012: 1 }); + > 12 │ ({ 0b1: 1 }); │ ^^^ - 16 │ - 17 │ ({ 0o1: 1 }); + 13 │ ({ 0o1: 1 }); + 14 │ ({ 1_0: 1 }); i Safe fix: Replace 0b1 with 1 - 13 13 │ ({ 012: 1 }); - 14 14 │ - 15 │ - ({·0b1:·1·}); - 15 │ + ({·1:·1·}); - 16 16 │ - 17 17 │ ({ 0o1: 1 }); + 10 10 │ ({ 0x1: 1 }); + 11 11 │ ({ 012: 1 }); + 12 │ - ({·0b1:·1·}); + 12 │ + ({·1:·1·}); + 13 13 │ ({ 0o1: 1 }); + 14 14 │ ({ 1_0: 1 }); ``` ``` -useSimpleNumberKeys.js:17:4 lint/nursery/useSimpleNumberKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +useSimpleNumberKeys.js:13:4 lint/nursery/useSimpleNumberKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Octal number literal is not allowed here. - 15 │ ({ 0b1: 1 }); - 16 │ - > 17 │ ({ 0o1: 1 }); + 11 │ ({ 012: 1 }); + 12 │ ({ 0b1: 1 }); + > 13 │ ({ 0o1: 1 }); │ ^^^ - 18 │ - 19 │ ({ 1_0: 1 }); + 14 │ ({ 1_0: 1 }); + 15 │ ({ 0.1e1_2: "ed" }); i Safe fix: Replace 0o1 with 1 - 15 15 │ ({ 0b1: 1 }); - 16 16 │ - 17 │ - ({·0o1:·1·}); - 17 │ + ({·1:·1·}); - 18 18 │ - 19 19 │ ({ 1_0: 1 }); + 11 11 │ ({ 012: 1 }); + 12 12 │ ({ 0b1: 1 }); + 13 │ - ({·0o1:·1·}); + 13 │ + ({·1:·1·}); + 14 14 │ ({ 1_0: 1 }); + 15 15 │ ({ 0.1e1_2: "ed" }); ``` ``` -useSimpleNumberKeys.js:19:4 lint/nursery/useSimpleNumberKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +useSimpleNumberKeys.js:14:4 lint/nursery/useSimpleNumberKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Number literal with underscore is not allowed here. - 17 │ ({ 0o1: 1 }); - 18 │ - > 19 │ ({ 1_0: 1 }); + 12 │ ({ 0b1: 1 }); + 13 │ ({ 0o1: 1 }); + > 14 │ ({ 1_0: 1 }); │ ^^^ - 20 │ - 21 │ ({ 0.1e1_2: "ed" }); + 15 │ ({ 0.1e1_2: "ed" }); + 16 │ ({ 11_1.11: "ee" }); i Safe fix: Replace 1_0 with 10 - 17 17 │ ({ 0o1: 1 }); - 18 18 │ - 19 │ - ({·1_0:·1·}); - 19 │ + ({·10:·1·}); - 20 20 │ - 21 21 │ ({ 0.1e1_2: "ed" }); + 12 12 │ ({ 0b1: 1 }); + 13 13 │ ({ 0o1: 1 }); + 14 │ - ({·1_0:·1·}); + 14 │ + ({·10:·1·}); + 15 15 │ ({ 0.1e1_2: "ed" }); + 16 16 │ ({ 11_1.11: "ee" }); ``` ``` -useSimpleNumberKeys.js:21:4 lint/nursery/useSimpleNumberKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +useSimpleNumberKeys.js:15:4 lint/nursery/useSimpleNumberKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Number literal with underscore is not allowed. - 19 │ ({ 1_0: 1 }); - 20 │ - > 21 │ ({ 0.1e1_2: "ed" }); + 13 │ ({ 0o1: 1 }); + 14 │ ({ 1_0: 1 }); + > 15 │ ({ 0.1e1_2: "ed" }); │ ^^^^^^^ - 22 │ - 23 │ ({ 11_1.11: "ee" }); + 16 │ ({ 11_1.11: "ee" }); + 17 │ i Safe fix: Replace 0.1e1_2 with .1e12 - 19 19 │ ({ 1_0: 1 }); - 20 20 │ - 21 │ - ({·0.1e1_2:·"ed"·}); - 21 │ + ({·.1e12:·"ed"·}); - 22 22 │ - 23 23 │ ({ 11_1.11: "ee" }); + 13 13 │ ({ 0o1: 1 }); + 14 14 │ ({ 1_0: 1 }); + 15 │ - ({·0.1e1_2:·"ed"·}); + 15 │ + ({·.1e12:·"ed"·}); + 16 16 │ ({ 11_1.11: "ee" }); + 17 17 │ ``` ``` -useSimpleNumberKeys.js:23:4 lint/nursery/useSimpleNumberKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +useSimpleNumberKeys.js:16:4 lint/nursery/useSimpleNumberKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Number literal with underscore is not allowed. - 21 │ ({ 0.1e1_2: "ed" }); - 22 │ - > 23 │ ({ 11_1.11: "ee" }); + 14 │ ({ 1_0: 1 }); + 15 │ ({ 0.1e1_2: "ed" }); + > 16 │ ({ 11_1.11: "ee" }); │ ^^^^^^^ - 24 │ + 17 │ i Safe fix: Replace 11_1.11 with 111.11 - 21 21 │ ({ 0.1e1_2: "ed" }); - 22 22 │ - 23 │ - ({·11_1.11:·"ee"·}); - 23 │ + ({·111.11:·"ee"·}); - 24 24 │ + 14 14 │ ({ 1_0: 1 }); + 15 15 │ ({ 0.1e1_2: "ed" }); + 16 │ - ({·11_1.11:·"ee"·}); + 16 │ + ({·111.11:·"ee"·}); + 17 17 │ ``` diff --git a/website/src/pages/lint/rules/index.mdx b/website/src/pages/lint/rules/index.mdx index 4ce9a411dbb..2e70ba65a16 100644 --- a/website/src/pages/lint/rules/index.mdx +++ b/website/src/pages/lint/rules/index.mdx @@ -9,10 +9,10 @@ mainClass: rules # Rules + ## Accessibility Rules focused on preventing accessibility problems. -

@@ -93,7 +93,6 @@ Enforce that all anchors are valid, and they are navigable elements. ## Complexity Rules that focus on inspecting complex code that could be simplified. -

@@ -142,7 +141,6 @@ Discard redundant terms from logical expressions. ## Correctness Rules that detect code that is guaranteed to be incorrect or useless. -

@@ -225,7 +223,6 @@ Enforce "for" loop update clause moving the counter in the right direc ## Performance Rules catching ways your code could be written to run faster, or generally be more efficient. -

@@ -240,7 +237,6 @@ Disallow the use of the delete operator ## Security Rules that detect potential security flaws. -

@@ -262,7 +258,6 @@ Report when a DOM element or a component uses both children and

@@ -357,7 +352,6 @@ initializer and update expressions are not needed ## Suspicious Rules that detect code that is likely to be incorrect or useless. -

@@ -486,7 +480,6 @@ warning, depending on whether we intend for the rule to be recommended or not wh Nursery rules get promoted to other groups once they become stable or may be removed. Rules that belong to this group are not subject to semantic version. -

diff --git a/website/src/pages/lint/rules/useSimpleNumberKeys.md b/website/src/pages/lint/rules/useSimpleNumberKeys.md index 1d7b14a7ca8..e82b2a4ef90 100644 --- a/website/src/pages/lint/rules/useSimpleNumberKeys.md +++ b/website/src/pages/lint/rules/useSimpleNumberKeys.md @@ -12,25 +12,111 @@ Disallow number literal object member names which are not base10 or uses undersc ### Invalid ```jsx -var a = 1; -a = 2; +({ 0x1: 1 }); ``` -
nursery/useSimpleNumberKeys.js:2:1 lint/nursery/useSimpleNumberKeys ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+
nursery/useSimpleNumberKeys.js:1:4 lint/nursery/useSimpleNumberKeys  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━
 
-   Variable is read here
+   Hexadecimal number literal is not allowed here.
+  
+  > 1 │ ({ 0x1: 1 });
+      ^^^
+    2 │ 
+  
+   Safe fix: Replace 0x1 with 1
+  
+    1  - ({·0x1:·1·});
+      1+ ({·1:·1·});
+    2 2  
+  
+
+ +```jsx +({ 11_1.11: "ee" }); +``` + +
nursery/useSimpleNumberKeys.js:1:4 lint/nursery/useSimpleNumberKeys  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━
+
+   Number literal with underscore is not allowed.
+  
+  > 1 │ ({ 11_1.11: "ee" });
+      ^^^^^^^
+    2 │ 
+  
+   Safe fix: Replace 11_1.11 with 111.11
+  
+    1  - ({·11_1.11:·"ee"·});
+      1+ ({·111.11:·"ee"·});
+    2 2  
+  
+
+ +```jsx +({ 0o1: 1 }); +``` + +
nursery/useSimpleNumberKeys.js:1:4 lint/nursery/useSimpleNumberKeys  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━
 
-    1 │ var a = 1;
-  > 2 │ a = 2;
-   ^
-    3 │ 
+   Octal number literal is not allowed here.
+  
+  > 1 │ ({ 0o1: 1 });
+      ^^^
+    2 │ 
+  
+   Safe fix: Replace 0o1 with 1
+  
+    1  - ({·0o1:·1·});
+      1+ ({·1:·1·});
+    2 2  
+  
+
+ +```jsx +({ 1n: 1 }); +``` - This note will give you more information +
nursery/useSimpleNumberKeys.js:1:4 lint/nursery/useSimpleNumberKeys  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━
 
+   Bigint is not allowed here.
+  
+  > 1 │ ({ 1n: 1 });
+      ^^
+    2 │ 
+  
+   Safe fix: Replace 1n with 1
+  
+    1  - ({·1n:·1·});
+      1+ ({·1:·1·});
+    2 2  
+  
+
+ +```jsx +({ 11_1.11: "ee" }); +``` + +
nursery/useSimpleNumberKeys.js:1:4 lint/nursery/useSimpleNumberKeys  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━
+
+   Number literal with underscore is not allowed.
+  
+  > 1 │ ({ 11_1.11: "ee" });
+      ^^^^^^^
+    2 │ 
+  
+   Safe fix: Replace 11_1.11 with 111.11
+  
+    1  - ({·11_1.11:·"ee"·});
+      1+ ({·111.11:·"ee"·});
+    2 2  
+  
 
## Valid ```jsx -var a = 1; +({ 0: "zero" }); +({ 122: "integer" }); +({ 1.22: "floating point" }); +({ 3.1e12: "floating point with e" }); ``` + From 73fe0269dc837fab28255debe0043d07dc4c9919 Mon Sep 17 00:00:00 2001 From: Dhiraj Arun Date: Mon, 27 Feb 2023 19:37:30 +0530 Subject: [PATCH 7/8] fix(rome_js_analyze): resolve changes --- .../nursery/use_simple_number_keys.rs | 164 ++++++++++++------ 1 file changed, 110 insertions(+), 54 deletions(-) diff --git a/crates/rome_js_analyze/src/analyzers/nursery/use_simple_number_keys.rs b/crates/rome_js_analyze/src/analyzers/nursery/use_simple_number_keys.rs index 41de5160324..431c6fdc690 100644 --- a/crates/rome_js_analyze/src/analyzers/nursery/use_simple_number_keys.rs +++ b/crates/rome_js_analyze/src/analyzers/nursery/use_simple_number_keys.rs @@ -3,7 +3,9 @@ use rome_analyze::{context::RuleContext, declare_rule, ActionCategory, Ast, Rule use rome_console::markup; use rome_diagnostics::Applicability; use rome_js_factory::make; -use rome_js_syntax::{JsLiteralMemberName, JsSyntaxKind, JsSyntaxToken}; +use rome_js_syntax::{ + AnyJsObjectMember, JsLiteralMemberName, JsObjectExpression, JsSyntaxKind, TextRange, +}; use rome_rowan::{AstNode, BatchMutationExt}; use std::str::FromStr; @@ -49,23 +51,28 @@ declare_rule! { #[derive(Clone)] pub enum NumberLiteral { Binary { + node: JsLiteralMemberName, value: String, big_int: bool, }, Decimal { + node: JsLiteralMemberName, value: String, big_int: bool, underscore: bool, }, Octal { + node: JsLiteralMemberName, value: String, big_int: bool, }, Hexadecimal { + node: JsLiteralMemberName, value: String, big_int: bool, }, FloatingPoint { + node: JsLiteralMemberName, value: String, exponent: bool, underscore: bool, @@ -74,10 +81,18 @@ pub enum NumberLiteral { pub struct NumberLiteralError; -impl TryFrom for NumberLiteral { +impl TryFrom for NumberLiteral { type Error = NumberLiteralError; - fn try_from(token: JsSyntaxToken) -> Result { + fn try_from(any_member: AnyJsObjectMember) -> Result { + let literal_member_name_syntax = any_member + .syntax() + .children() + .find(|x| JsLiteralMemberName::can_cast(x.kind())) + .unwrap(); + let literal_member_name = JsLiteralMemberName::cast(literal_member_name_syntax).unwrap(); + + let token = literal_member_name.value().unwrap(); match token.kind() { JsSyntaxKind::JS_NUMBER_LITERAL | JsSyntaxKind::JS_BIG_INT_LITERAL => { let chars: Vec = token.to_string().chars().collect(); @@ -129,6 +144,7 @@ impl TryFrom for NumberLiteral { if contains_dot { return Ok(Self::FloatingPoint { + node: literal_member_name, value, exponent, underscore, @@ -136,6 +152,7 @@ impl TryFrom for NumberLiteral { }; if !is_first_char_zero { return Ok(Self::Decimal { + node: literal_member_name, value, big_int, underscore, @@ -143,17 +160,40 @@ impl TryFrom for NumberLiteral { }; match is_second_char_a_letter { - Some('b' | 'B') => return Ok(Self::Binary { value, big_int }), - Some('o' | 'O') => return Ok(Self::Octal { value, big_int }), - Some('x' | 'X') => return Ok(Self::Hexadecimal { value, big_int }), + Some('b' | 'B') => { + return Ok(Self::Binary { + node: literal_member_name, + value, + big_int, + }) + } + Some('o' | 'O') => { + return Ok(Self::Octal { + node: literal_member_name, + value, + big_int, + }) + } + Some('x' | 'X') => { + return Ok(Self::Hexadecimal { + node: literal_member_name, + value, + big_int, + }) + } _ => (), } if largest_digit < '8' { - return Ok(Self::Octal { value, big_int }); + return Ok(Self::Octal { + node: literal_member_name, + value, + big_int, + }); } Ok(Self::Decimal { + node: literal_member_name, value, big_int, underscore, @@ -165,6 +205,26 @@ impl TryFrom for NumberLiteral { } impl NumberLiteral { + fn node(&self) -> JsLiteralMemberName { + match self { + Self::Decimal { node, .. } => node.clone(), + Self::Binary { node, .. } => node.clone(), + Self::FloatingPoint { node, .. } => node.clone(), + Self::Octal { node, .. } => node.clone(), + Self::Hexadecimal { node, .. } => node.clone(), + } + } + + fn range(&self) -> TextRange { + match self { + Self::Decimal { node, .. } => node.range(), + Self::Binary { node, .. } => node.range(), + Self::FloatingPoint { node, .. } => node.range(), + Self::Octal { node, .. } => node.range(), + Self::Hexadecimal { node, .. } => node.range(), + } + } + fn value(&self) -> &String { match self { Self::Decimal { value, .. } => value, @@ -192,7 +252,7 @@ impl NumberLiteral { } impl Rule for UseSimpleNumberKeys { - type Query = Ast; + type Query = Ast; type State = NumberLiteral; type Signals = Vec; type Options = (); @@ -201,23 +261,24 @@ impl Rule for UseSimpleNumberKeys { let mut signals: Self::Signals = Vec::new(); let node = ctx.query(); - if let Ok(token) = node.value() { - let number_literal = NumberLiteral::try_from(token).ok(); - - if let Some(number_literal) = number_literal { - match number_literal { - NumberLiteral::Decimal { big_int: true, .. } - | NumberLiteral::Decimal { - underscore: true, .. - } => signals.push(number_literal), - NumberLiteral::FloatingPoint { - underscore: true, .. - } => signals.push(number_literal), - NumberLiteral::Binary { .. } => signals.push(number_literal), - NumberLiteral::Hexadecimal { .. } => signals.push(number_literal), - NumberLiteral::Octal { .. } => signals.push(number_literal), - _ => (), - } + for number_literal in node + .members() + .into_iter() + .flatten() + .filter_map(|member| NumberLiteral::try_from(member).ok()) + { + match number_literal { + NumberLiteral::Decimal { big_int: true, .. } + | NumberLiteral::Decimal { + underscore: true, .. + } => signals.push(number_literal), + NumberLiteral::FloatingPoint { + underscore: true, .. + } => signals.push(number_literal), + NumberLiteral::Binary { .. } => signals.push(number_literal), + NumberLiteral::Hexadecimal { .. } => signals.push(number_literal), + NumberLiteral::Octal { .. } => signals.push(number_literal), + _ => (), } } @@ -243,41 +304,36 @@ impl Rule for UseSimpleNumberKeys { }; let diagnostic = - RuleDiagnostic::new(rule_category!(), _ctx.query().range(), title.to_string()); + RuleDiagnostic::new(rule_category!(), number_literal.range(), title.to_string()); Some(diagnostic) } fn action(ctx: &RuleContext, number_literal: &Self::State) -> Option { let mut mutation = ctx.root().begin(); - let node = ctx.query(); - let message; - - if let Ok(token) = node.value() { - match number_literal { - NumberLiteral::Binary { .. } - | NumberLiteral::Octal { .. } - | NumberLiteral::Hexadecimal { .. } => { - let text = number_literal.to_base_ten()?; - message = markup! ("Replace "{ node.to_string() } " with "{text.to_string()}) - .to_owned(); - mutation.replace_token(token, make::js_number_literal(text)); - } - NumberLiteral::FloatingPoint { .. } | NumberLiteral::Decimal { .. } => { - let text = number_literal.value(); - message = markup! ("Replace "{ node.to_string() } " with "{text}).to_owned(); - mutation.replace_token(token, make::js_number_literal(text)); - } - }; - - return Some(JsRuleAction { - category: ActionCategory::QuickFix, - applicability: Applicability::Always, - message, - mutation, - }); - } + let node = number_literal.node(); + let token = node.value().ok()?; + + let message = match number_literal { + NumberLiteral::Binary { .. } + | NumberLiteral::Octal { .. } + | NumberLiteral::Hexadecimal { .. } => { + let text = number_literal.to_base_ten()?; + mutation.replace_token(token, make::js_number_literal(text)); + markup! ("Replace "{ node.to_string() } " with "{text.to_string()}).to_owned() + } + NumberLiteral::FloatingPoint { .. } | NumberLiteral::Decimal { .. } => { + let text = number_literal.value(); + mutation.replace_token(token, make::js_number_literal(text)); + markup! ("Replace "{ node.to_string() } " with "{text}).to_owned() + } + }; - None + Some(JsRuleAction { + category: ActionCategory::QuickFix, + applicability: Applicability::Always, + message, + mutation, + }) } } From 9dfba0521764a70d88a573277e44542fef46d2aa Mon Sep 17 00:00:00 2001 From: Dhiraj Arun Date: Mon, 27 Feb 2023 20:46:53 +0530 Subject: [PATCH 8/8] refactor(rome_js_analyze): use_simple_number_keys --- .../nursery/use_simple_number_keys.rs | 87 ++++++++++++------- .../specs/nursery/useSimpleNumberKeys.js.snap | 4 +- 2 files changed, 56 insertions(+), 35 deletions(-) diff --git a/crates/rome_js_analyze/src/analyzers/nursery/use_simple_number_keys.rs b/crates/rome_js_analyze/src/analyzers/nursery/use_simple_number_keys.rs index 431c6fdc690..26289ddffa2 100644 --- a/crates/rome_js_analyze/src/analyzers/nursery/use_simple_number_keys.rs +++ b/crates/rome_js_analyze/src/analyzers/nursery/use_simple_number_keys.rs @@ -251,9 +251,18 @@ impl NumberLiteral { } } +enum WrongNumberLiteralName { + Binary, + Hexadecimal, + Octal, + BigInt, + WithUnderscore, +} +pub struct RuleState(WrongNumberLiteralName, NumberLiteral); + impl Rule for UseSimpleNumberKeys { type Query = Ast; - type State = NumberLiteral; + type State = RuleState; type Signals = Vec; type Options = (); @@ -268,16 +277,28 @@ impl Rule for UseSimpleNumberKeys { .filter_map(|member| NumberLiteral::try_from(member).ok()) { match number_literal { - NumberLiteral::Decimal { big_int: true, .. } - | NumberLiteral::Decimal { - underscore: true, .. - } => signals.push(number_literal), + NumberLiteral::Decimal { big_int: true, .. } => { + signals.push(RuleState(WrongNumberLiteralName::BigInt, number_literal)) + } NumberLiteral::FloatingPoint { underscore: true, .. - } => signals.push(number_literal), - NumberLiteral::Binary { .. } => signals.push(number_literal), - NumberLiteral::Hexadecimal { .. } => signals.push(number_literal), - NumberLiteral::Octal { .. } => signals.push(number_literal), + } + | NumberLiteral::Decimal { + underscore: true, .. + } => signals.push(RuleState( + WrongNumberLiteralName::WithUnderscore, + number_literal, + )), + NumberLiteral::Binary { .. } => { + signals.push(RuleState(WrongNumberLiteralName::Binary, number_literal)) + } + NumberLiteral::Hexadecimal { .. } => signals.push(RuleState( + WrongNumberLiteralName::Hexadecimal, + number_literal, + )), + NumberLiteral::Octal { .. } => { + signals.push(RuleState(WrongNumberLiteralName::Octal, number_literal)) + } _ => (), } } @@ -287,43 +308,43 @@ impl Rule for UseSimpleNumberKeys { fn diagnostic( _ctx: &RuleContext, - number_literal: &Self::State, + RuleState(reason, literal): &Self::State, ) -> Option { - let title = match number_literal { - NumberLiteral::Decimal { big_int: true, .. } => "Bigint is not allowed here.", - NumberLiteral::Decimal { - underscore: true, .. - } => "Number literal with underscore is not allowed here.", - NumberLiteral::FloatingPoint { - underscore: true, .. - } => "Number literal with underscore is not allowed.", - NumberLiteral::Binary { .. } => "Binary number literal in is not allowed here.", - NumberLiteral::Hexadecimal { .. } => "Hexadecimal number literal is not allowed here.", - NumberLiteral::Octal { .. } => "Octal number literal is not allowed here.", - _ => "", + let title = match reason { + WrongNumberLiteralName::BigInt => "Bigint is not allowed here.", + WrongNumberLiteralName::WithUnderscore => { + "Number literal with underscore is not allowed here." + } + WrongNumberLiteralName::Binary => "Binary number literal in is not allowed here.", + WrongNumberLiteralName::Hexadecimal => { + "Hexadecimal number literal is not allowed here." + } + WrongNumberLiteralName::Octal => "Octal number literal is not allowed here.", }; - let diagnostic = - RuleDiagnostic::new(rule_category!(), number_literal.range(), title.to_string()); + let diagnostic = RuleDiagnostic::new(rule_category!(), literal.range(), title.to_string()); Some(diagnostic) } - fn action(ctx: &RuleContext, number_literal: &Self::State) -> Option { + fn action( + ctx: &RuleContext, + RuleState(reason, literal): &Self::State, + ) -> Option { let mut mutation = ctx.root().begin(); - let node = number_literal.node(); + let node = literal.node(); let token = node.value().ok()?; - let message = match number_literal { - NumberLiteral::Binary { .. } - | NumberLiteral::Octal { .. } - | NumberLiteral::Hexadecimal { .. } => { - let text = number_literal.to_base_ten()?; + let message = match reason { + WrongNumberLiteralName::Binary + | WrongNumberLiteralName::Octal + | WrongNumberLiteralName::Hexadecimal => { + let text = literal.to_base_ten()?; mutation.replace_token(token, make::js_number_literal(text)); markup! ("Replace "{ node.to_string() } " with "{text.to_string()}).to_owned() } - NumberLiteral::FloatingPoint { .. } | NumberLiteral::Decimal { .. } => { - let text = number_literal.value(); + WrongNumberLiteralName::WithUnderscore | WrongNumberLiteralName::BigInt => { + let text = literal.value(); mutation.replace_token(token, make::js_number_literal(text)); markup! ("Replace "{ node.to_string() } " with "{text}).to_owned() } diff --git a/crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys.js.snap b/crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys.js.snap index 6e7e47dcc1c..73cde74400e 100644 --- a/crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys.js.snap +++ b/crates/rome_js_analyze/tests/specs/nursery/useSimpleNumberKeys.js.snap @@ -170,7 +170,7 @@ useSimpleNumberKeys.js:14:4 lint/nursery/useSimpleNumberKeys FIXABLE ━━━ ``` useSimpleNumberKeys.js:15:4 lint/nursery/useSimpleNumberKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - ! Number literal with underscore is not allowed. + ! Number literal with underscore is not allowed here. 13 │ ({ 0o1: 1 }); 14 │ ({ 1_0: 1 }); @@ -194,7 +194,7 @@ useSimpleNumberKeys.js:15:4 lint/nursery/useSimpleNumberKeys FIXABLE ━━━ ``` useSimpleNumberKeys.js:16:4 lint/nursery/useSimpleNumberKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - ! Number literal with underscore is not allowed. + ! Number literal with underscore is not allowed here. 14 │ ({ 1_0: 1 }); 15 │ ({ 0.1e1_2: "ed" });