diff --git a/crates/rome_diagnostics_categories/src/categories.rs b/crates/rome_diagnostics_categories/src/categories.rs index 6f1da6a0abf6..41c74ac0bc90 100644 --- a/crates/rome_diagnostics_categories/src/categories.rs +++ b/crates/rome_diagnostics_categories/src/categories.rs @@ -73,6 +73,7 @@ define_dategories! { "lint/nursery/noUndeclaredVariables": "https://rome.tools/docs/lint/rules/noUndeclaredVariables", "lint/nursery/noUnreachable": "https://rome.tools/docs/lint/rules/noUnreachable", "lint/nursery/noUnusedVariables": "https://rome.tools/docs/lint/rules/noUnusedVariables", + "lint/nursery/useValidForDirection": "https://rome.tools/docs/lint/rules/useValidForDirection", ; // General categories diff --git a/crates/rome_js_analyze/src/analyzers/nursery.rs b/crates/rome_js_analyze/src/analyzers/nursery.rs index 76f4414102d2..73abce4c25b6 100644 --- a/crates/rome_js_analyze/src/analyzers/nursery.rs +++ b/crates/rome_js_analyze/src/analyzers/nursery.rs @@ -4,4 +4,5 @@ use rome_analyze::declare_group; mod no_unreachable; mod use_flat_map; mod use_optional_chain; -declare_group! { pub (crate) Nursery { name : "nursery" , rules : [self :: no_unreachable :: NoUnreachable , self :: use_flat_map :: UseFlatMap , self :: use_optional_chain :: UseOptionalChain ,] } } +mod use_valid_for_direction; +declare_group! { pub (crate) Nursery { name : "nursery" , rules : [self :: no_unreachable :: NoUnreachable , self :: use_flat_map :: UseFlatMap , self :: use_optional_chain :: UseOptionalChain , self :: use_valid_for_direction :: UseValidForDirection ,] } } diff --git a/crates/rome_service/src/configuration/linter/rules.rs b/crates/rome_service/src/configuration/linter/rules.rs index 2a87efa78c3e..c67e3753d520 100644 --- a/crates/rome_service/src/configuration/linter/rules.rs +++ b/crates/rome_service/src/configuration/linter/rules.rs @@ -640,10 +640,11 @@ struct NurserySchema { use_camel_case: Option, use_flat_map: Option, use_optional_chain: Option, + use_valid_for_direction: Option, } impl Nursery { const CATEGORY_NAME: &'static str = "nursery"; - pub(crate) const CATEGORY_RULES: [&'static str; 9] = [ + pub(crate) const CATEGORY_RULES: [&'static str; 10] = [ "noConstAssign", "noExplicitAny", "noRestrictedGlobals", @@ -653,6 +654,7 @@ impl Nursery { "useCamelCase", "useFlatMap", "useOptionalChain", + "useValidForDirection", ]; const RECOMMENDED_RULES: [&'static str; 0] = []; const RECOMMENDED_RULES_AS_FILTERS: [RuleFilter<'static>; 0] = []; diff --git a/editors/vscode/configuration_schema.json b/editors/vscode/configuration_schema.json index 077eca681dee..72ba0f868656 100644 --- a/editors/vscode/configuration_schema.json +++ b/editors/vscode/configuration_schema.json @@ -762,6 +762,16 @@ "type": "null" } ] + }, + "useValidForDirection": { + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] } } }, @@ -958,7 +968,8 @@ "type": "string", "enum": [ "all", - "es5" + "es5", + "none" ] } } diff --git a/npm/backend-jsonrpc/src/workspace.ts b/npm/backend-jsonrpc/src/workspace.ts index b5c241695627..4a1be5777837 100644 --- a/npm/backend-jsonrpc/src/workspace.ts +++ b/npm/backend-jsonrpc/src/workspace.ts @@ -120,7 +120,7 @@ export interface Rules { } export type QuoteProperties = "asNeeded" | "preserve"; export type QuoteStyle = "double" | "single"; -export type TrailingComma = "all" | "es5"; +export type TrailingComma = "all" | "es5" | "none"; /** * A list of rules that belong to this group */ @@ -208,6 +208,7 @@ export interface Nursery { useCamelCase?: RuleConfiguration; useFlatMap?: RuleConfiguration; useOptionalChain?: RuleConfiguration; + useValidForDirection?: RuleConfiguration; } /** * A list of rules that belong to this group @@ -357,6 +358,7 @@ export type Category = | "lint/nursery/noUndeclaredVariables" | "lint/nursery/noUnreachable" | "lint/nursery/noUnusedVariables" + | "lint/nursery/useValidForDirection" | "files/missingHandler" | "format" | "internalError/io" diff --git a/website/src/docs/lint/rules/index.md b/website/src/docs/lint/rules/index.md index aa53598b651e..4c4ac932915a 100644 --- a/website/src/docs/lint/rules/index.md +++ b/website/src/docs/lint/rules/index.md @@ -433,6 +433,13 @@ Promotes the use of .flatMap() when map().flat() are u Enforce using concise optional chain instead of chained logical expressions. +
+

+ useValidForDirection (since v10.0.0) + +

+Enforce "for" loop update clause moving the counter in the right direction. +

Style

diff --git a/website/src/docs/lint/rules/useBlankTarget.md b/website/src/docs/lint/rules/useBlankTarget.md index 8457c4d2b6b5..0bd03e0363e9 100644 --- a/website/src/docs/lint/rules/useBlankTarget.md +++ b/website/src/docs/lint/rules/useBlankTarget.md @@ -62,7 +62,7 @@ and the [the noopener documentation](https://html.spec.whatwg.org/multipage/link child ``` -{% raw %}
nursery/useBlankTarget.js:1:43 lint/nursery/useBlankTarget  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+{% raw %}
a11y/useBlankTarget.js:1:43 lint/a11y/useBlankTarget  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
    Avoid using target="_blank" without rel="noreferrer".
   
diff --git a/website/src/docs/lint/rules/useKeyWithClickEvents.md b/website/src/docs/lint/rules/useKeyWithClickEvents.md
index 5b8c940393e8..b51b956ca6d1 100644
--- a/website/src/docs/lint/rules/useKeyWithClickEvents.md
+++ b/website/src/docs/lint/rules/useKeyWithClickEvents.md
@@ -43,22 +43,6 @@ Enforce to have the `onClick` mouse event with the `onKeyUp`, the `onKeyDown`, o
   
 
{% endraw %} -```jsx -
{}} >
-``` - -{% raw %}
a11y/useKeyWithClickEvents.js:1:1 lint/a11y/useKeyWithClickEvents ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
-
-   Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event.
-  
-  > 1 │ <div {...spread} onClick={() => {}} ></div>
-   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-    2 │ 
-  
-   Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.
-  
-
{% endraw %} - ### Valid ```jsx