diff --git a/crates/rome_js_unicode_table/src/tables.rs b/crates/rome_js_unicode_table/src/tables.rs index 7f67057597cf..eb783866c931 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/editors/vscode/configuration_schema.json b/editors/vscode/configuration_schema.json index 196d84f10c95..d58eb08ee2e6 100644 --- a/editors/vscode/configuration_schema.json +++ b/editors/vscode/configuration_schema.json @@ -1068,6 +1068,17 @@ } ] }, + "useHookAtTopLevel": { + "description": "Enforce that all React hooks are being called from the Top Level component functions.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, "useNumericLiterals": { "description": "Disallow parseInt() and Number.parseInt() in favor of binary, octal, and hexadecimal literals", "anyOf": [ diff --git a/justfile b/justfile index 7578ed7cbc11..e679e787192b 100644 --- a/justfile +++ b/justfile @@ -21,10 +21,10 @@ test-lintrule name: cargo test -p rome_js_analyze -- {{snakecase(name)}} check-ready: - git diff --exit-code + git diff --exit-code --quiet just codegen just documentation cargo lint cargo fmt cargo test - git diff --exit-code + git diff --exit-code --quiet diff --git a/npm/backend-jsonrpc/src/workspace.ts b/npm/backend-jsonrpc/src/workspace.ts index 556ec1fd1950..b1adf190f293 100644 --- a/npm/backend-jsonrpc/src/workspace.ts +++ b/npm/backend-jsonrpc/src/workspace.ts @@ -463,6 +463,10 @@ export interface Nursery { * Promotes the use of .flatMap() when map().flat() are used together. */ useFlatMap?: RuleConfiguration; + /** + * Enforce that all React hooks are being called from the Top Level component functions. + */ + useHookAtTopLevel?: RuleConfiguration; /** * Disallow parseInt() and Number.parseInt() in favor of binary, octal, and hexadecimal literals */ @@ -705,6 +709,7 @@ export type Category = | "lint/nursery/useAriaPropsForRole" | "lint/nursery/useAriaPropTypes" | "lint/nursery/noRedundantUseStrict" + | "lint/nursery/useHookAtTopLevel" | "files/missingHandler" | "format" | "internalError/io" diff --git a/npm/rome/configuration_schema.json b/npm/rome/configuration_schema.json index 196d84f10c95..d58eb08ee2e6 100644 --- a/npm/rome/configuration_schema.json +++ b/npm/rome/configuration_schema.json @@ -1068,6 +1068,17 @@ } ] }, + "useHookAtTopLevel": { + "description": "Enforce that all React hooks are being called from the Top Level component functions.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, "useNumericLiterals": { "description": "Disallow parseInt() and Number.parseInt() in favor of binary, octal, and hexadecimal literals", "anyOf": [ diff --git a/xtask/codegen/src/generate_new_lintrule.rs b/xtask/codegen/src/generate_new_lintrule.rs index e6606e5b9794..ee0316e64a24 100644 --- a/xtask/codegen/src/generate_new_lintrule.rs +++ b/xtask/codegen/src/generate_new_lintrule.rs @@ -3,7 +3,7 @@ use std::{path::PathBuf, str::FromStr}; use case::CaseExt; pub fn generate_new_lintrule(path: &str, rule_name: &str) { - let rule_folder = PathBuf::from_str(&path).unwrap(); + let rule_folder = PathBuf::from_str(path).unwrap(); match rule_folder.file_stem() .and_then(|x| x.to_str()) { Some("nursery") => {},