From c96d1f6367e10f460937de11f51bde0f7b9399a7 Mon Sep 17 00:00:00 2001 From: ematipico Date: Tue, 13 Dec 2022 09:37:06 +0000 Subject: [PATCH] chore: clippy and regressions --- crates/rome_aria/src/roles.rs | 6 ++---- editors/vscode/configuration_schema.json | 1 + npm/backend-jsonrpc/src/workspace.ts | 5 +++++ npm/rome/configuration_schema.json | 1 + website/src/playground/Playground.tsx | 4 ---- website/src/playground/components/Tabs.tsx | 1 + 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/crates/rome_aria/src/roles.rs b/crates/rome_aria/src/roles.rs index 7c5b7756045f..6f627968f3a5 100644 --- a/crates/rome_aria/src/roles.rs +++ b/crates/rome_aria/src/roles.rs @@ -698,10 +698,8 @@ impl<'a> AriaRoles { _ => return false, }; if let Some(mut concepts) = role.concepts_by_element_name(element_name) { - if concepts.any(|(name, _)| *name == element_name) { - if !role.is_interactive() { - return true; - } + if concepts.any(|(name, _)| *name == element_name) && !role.is_interactive() { + return true; } } } diff --git a/editors/vscode/configuration_schema.json b/editors/vscode/configuration_schema.json index 4997b2fa192f..cc80dc3d8aa7 100644 --- a/editors/vscode/configuration_schema.json +++ b/editors/vscode/configuration_schema.json @@ -732,6 +732,7 @@ ] }, "noNoninteractiveElementToInteractiveRole": { + "description": "Enforce that interactive ARIA roles are not assigned to non-interactive HTML elements.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" diff --git a/npm/backend-jsonrpc/src/workspace.ts b/npm/backend-jsonrpc/src/workspace.ts index ffb6f417638e..59d3eeb316a0 100644 --- a/npm/backend-jsonrpc/src/workspace.ts +++ b/npm/backend-jsonrpc/src/workspace.ts @@ -341,6 +341,10 @@ export interface Nursery { * Disallow non-null assertions using the ! postfix operator. */ noNonNullAssertion?: RuleConfiguration; + /** + * Enforce that interactive ARIA roles are not assigned to non-interactive HTML elements. + */ + noNoninteractiveElementToInteractiveRole?: RuleConfiguration; /** * Disallow literal numbers that lose precision */ @@ -747,6 +751,7 @@ export type Category = | "lint/nursery/useExhaustiveDependencies" | "lint/nursery/useExponentiationOperator" | "lint/nursery/useNumericLiterals" + | "lint/nursery/noNoninteractiveElementToInteractiveRole" | "lint/nursery/useValidForDirection" | "lint/nursery/useHookAtTopLevel" | "lint/performance/noDelete" diff --git a/npm/rome/configuration_schema.json b/npm/rome/configuration_schema.json index 4997b2fa192f..cc80dc3d8aa7 100644 --- a/npm/rome/configuration_schema.json +++ b/npm/rome/configuration_schema.json @@ -732,6 +732,7 @@ ] }, "noNoninteractiveElementToInteractiveRole": { + "description": "Enforce that interactive ARIA roles are not assigned to non-interactive HTML elements.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" diff --git a/website/src/playground/Playground.tsx b/website/src/playground/Playground.tsx index 45c5fd9c8769..85c12f3a9d34 100644 --- a/website/src/playground/Playground.tsx +++ b/website/src/playground/Playground.tsx @@ -47,7 +47,6 @@ export default function PlaygroundLoader({ const romeOutput = file.rome; const prettierOutput = file.prettier; - // rome-ignore lint/nursery/useExhaustiveDependencies: dynamic dependencies const codeMirrorExtensions = useMemo(() => { if (isJSONFilename(playgroundState.currentFile)) { return [json()]; @@ -65,14 +64,12 @@ export default function PlaygroundLoader({ const astPanelCodeMirrorRef = useRef(null); - // rome-ignore lint/nursery/useExhaustiveDependencies: dynamic dependencies useEffect(() => { if (clipboardStatus !== "normal") { setClipboardStatus("normal"); } }, [romeOutput.formatter.ir]); - // rome-ignore lint/nursery/useExhaustiveDependencies: dynamic dependencies const onUpdate = useCallback((viewUpdate: ViewUpdate) => { const cursorPosition = viewUpdate.state.selection.ranges[0]?.from ?? 0; setPlaygroundState((state) => @@ -127,7 +124,6 @@ export default function PlaygroundLoader({ }); }, [romeOutput.syntax.ast]); - // rome-ignore lint/nursery/useExhaustiveDependencies: dynamic dependencies const onChange = useCallback((value: string) => { setPlaygroundState((state) => ({ ...state, diff --git a/website/src/playground/components/Tabs.tsx b/website/src/playground/components/Tabs.tsx index 15185afa7a94..fcab60c483d9 100644 --- a/website/src/playground/components/Tabs.tsx +++ b/website/src/playground/components/Tabs.tsx @@ -45,6 +45,7 @@ export default function Tabs({ "react-tabs__tab", isSelected && "react-tabs__tab--selected", )} + // rome-ignore lint/nursery/noNoninteractiveElementToInteractiveRole: false positive? role="tab" aria-selected={isSelected} aria-disabled={isSelected}