From 51eee29f81312f8ed69a7a608512278f27be1fd8 Mon Sep 17 00:00:00 2001 From: nissy-dev Date: Sat, 15 Apr 2023 15:50:53 +0900 Subject: [PATCH] add: codegen --- .../src/configuration/linter/rules.rs | 4 +-- editors/vscode/configuration_schema.json | 4 +-- npm/backend-jsonrpc/src/workspace.ts | 4 +-- npm/rome/configuration_schema.json | 4 +-- website/src/pages/lint/rules/index.mdx | 4 +-- website/src/pages/lint/rules/noAutofocus.md | 9 ++++++- website/src/pages/lint/rules/noBlankTarget.md | 27 +++---------------- .../pages/lint/rules/noDistractingElements.md | 26 ++++++++++-------- website/src/pages/lint/rules/noHeaderScope.md | 9 ++++--- 9 files changed, 43 insertions(+), 48 deletions(-) diff --git a/crates/rome_service/src/configuration/linter/rules.rs b/crates/rome_service/src/configuration/linter/rules.rs index 316e0c8d9c8..6da92cde4c7 100644 --- a/crates/rome_service/src/configuration/linter/rules.rs +++ b/crates/rome_service/src/configuration/linter/rules.rs @@ -337,7 +337,7 @@ pub struct A11y { #[doc = "Enforce that the accessKey attribute is not used on any HTML element."] #[serde(skip_serializing_if = "Option::is_none")] pub no_access_key: Option, - #[doc = "Avoid the autoFocus attribute"] + #[doc = "Enforce that autoFocus prop is not used on elements."] #[serde(skip_serializing_if = "Option::is_none")] pub no_autofocus: Option, #[doc = "Disallow target=\"_blank\" attribute without rel=\"noreferrer\""] @@ -346,7 +346,7 @@ pub struct A11y { #[doc = "Enforces that no distracting elements are used."] #[serde(skip_serializing_if = "Option::is_none")] pub no_distracting_elements: Option, - #[doc = "Check that the scope attribute is only used on th elements."] + #[doc = "The scope prop should be used only on elements."] #[serde(skip_serializing_if = "Option::is_none")] pub no_header_scope: Option, #[doc = "Prevent the usage of positive integers on tabIndex property"] diff --git a/editors/vscode/configuration_schema.json b/editors/vscode/configuration_schema.json index 66a14032616..019b17518b1 100644 --- a/editors/vscode/configuration_schema.json +++ b/editors/vscode/configuration_schema.json @@ -59,7 +59,7 @@ ] }, "noAutofocus": { - "description": "Avoid the autoFocus attribute", + "description": "Enforce that autoFocus prop is not used on elements.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" }, { "type": "null" } @@ -80,7 +80,7 @@ ] }, "noHeaderScope": { - "description": "Check that the scope attribute is only used on th elements.", + "description": "The scope prop should be used only on elements.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" }, { "type": "null" } diff --git a/npm/backend-jsonrpc/src/workspace.ts b/npm/backend-jsonrpc/src/workspace.ts index dea96a33497..da221d56d15 100644 --- a/npm/backend-jsonrpc/src/workspace.ts +++ b/npm/backend-jsonrpc/src/workspace.ts @@ -178,7 +178,7 @@ export interface A11y { */ noAccessKey?: RuleConfiguration; /** - * Avoid the autoFocus attribute + * Enforce that autoFocus prop is not used on elements. */ noAutofocus?: RuleConfiguration; /** @@ -190,7 +190,7 @@ export interface A11y { */ noDistractingElements?: RuleConfiguration; /** - * Check that the scope attribute is only used on th elements. + * The scope prop should be used only on elements. */ noHeaderScope?: RuleConfiguration; /** diff --git a/npm/rome/configuration_schema.json b/npm/rome/configuration_schema.json index 66a14032616..019b17518b1 100644 --- a/npm/rome/configuration_schema.json +++ b/npm/rome/configuration_schema.json @@ -59,7 +59,7 @@ ] }, "noAutofocus": { - "description": "Avoid the autoFocus attribute", + "description": "Enforce that autoFocus prop is not used on elements.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" }, { "type": "null" } @@ -80,7 +80,7 @@ ] }, "noHeaderScope": { - "description": "Check that the scope attribute is only used on th elements.", + "description": "The scope prop should be used only on elements.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" }, { "type": "null" } diff --git a/website/src/pages/lint/rules/index.mdx b/website/src/pages/lint/rules/index.mdx index f830ac28521..505893793a5 100644 --- a/website/src/pages/lint/rules/index.mdx +++ b/website/src/pages/lint/rules/index.mdx @@ -25,7 +25,7 @@ Enforce that the accessKey attribute is not used on any HTML elemen noAutofocus recommended -Avoid the autoFocus attribute +Enforce that autoFocus prop is not used on elements.

@@ -46,7 +46,7 @@ Enforces that no distracting elements are used. noHeaderScope recommended

-Check that the scope attribute is only used on th elements. +The scope prop should be used only on <th> elements.

diff --git a/website/src/pages/lint/rules/noAutofocus.md b/website/src/pages/lint/rules/noAutofocus.md index e7f5cfadf71..10ae908586f 100644 --- a/website/src/pages/lint/rules/noAutofocus.md +++ b/website/src/pages/lint/rules/noAutofocus.md @@ -7,7 +7,9 @@ parent: lint/rules/index > This rule is recommended by Rome. -Avoid the `autoFocus` attribute +Enforce that autoFocus prop is not used on elements. + +Autofocusing elements can cause usability issues for sighted and non-sighted users, alike. ## Examples @@ -104,6 +106,11 @@ Avoid the `autoFocus` attribute ``` +## Resources + +- [WHATWG HTML Standard, The autofocus attribute](https://html.spec.whatwg.org/multipage/interaction.html#attr-fe-autofocus) +- [The accessibility of HTML 5 autofocus](https://brucelawson.co.uk/2009/the-accessibility-of-html-5-autofocus/) + ## Related links - [Disable a rule](/linter/#disable-a-lint-rule) diff --git a/website/src/pages/lint/rules/noBlankTarget.md b/website/src/pages/lint/rules/noBlankTarget.md index d824d217ca3..97ef1980b19 100644 --- a/website/src/pages/lint/rules/noBlankTarget.md +++ b/website/src/pages/lint/rules/noBlankTarget.md @@ -80,33 +80,14 @@ and the [the noopener documentation](https://html.spec.whatwg.org/multipage/link +++++++++++ +### Valid + ```jsx -// case-insensitive -child +child ``` -
a11y/noBlankTarget.js:2:32 lint/a11y/noBlankTarget  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
-
-   Avoid using target="_blank" without rel="noreferrer".
-  
-    1 │ // case-insensitive
-  > 2 │ <a href='http://external.link' target='_BlaNk'>child</a>
-                                  ^^^^^^^^^^^^^^^
-    3 │ 
-  
-   Opening external links in new tabs without rel="noreferrer" is a security risk. See the explanation for more details.
-  
-   Safe fix: Add the rel="noreferrer" attribute.
-  
-    2 │ <a·href='http://external.link'·target='_BlaNk'·rel="noreferrer">child</a>
-                                                +++++++++++++++++          
-
- -### Valid - ```jsx -let a = child; -let a = child; +child ``` ## Related links diff --git a/website/src/pages/lint/rules/noDistractingElements.md b/website/src/pages/lint/rules/noDistractingElements.md index fd166643c47..85cc8668c84 100644 --- a/website/src/pages/lint/rules/noDistractingElements.md +++ b/website/src/pages/lint/rules/noDistractingElements.md @@ -18,51 +18,55 @@ By default, the following elements are visually distracting: `` and ` + ```
a11y/noDistractingElements.js:1:1 lint/a11y/noDistractingElements  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━
 
    Don't use the 'marquee' element.
   
-  > 1 │ <marquee/>
-   ^^^^^^^^^^
+  > 1 │ <marquee />
+   ^^^^^^^^^^^
     2 │ 
   
    Visually distracting elements can cause accessibility issues and should be avoided.
   
    Suggested fix: Remove the 'marquee' element.
   
-    1 │ <marquee/>
-  ----------
+    1 │ <marquee·/>
+  -----------
 
```jsx - + ```
a11y/noDistractingElements.js:1:1 lint/a11y/noDistractingElements  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━
 
    Don't use the 'blink' element.
   
-  > 1 │ <blink/>
-   ^^^^^^^^
+  > 1 │ <blink />
+   ^^^^^^^^^
     2 │ 
   
    Visually distracting elements can cause accessibility issues and should be avoided.
   
    Suggested fix: Remove the 'blink' element.
   
-    1 │ <blink/>
-  --------
+    1 │ <blink·/>
+  ---------
 
### Valid ```jsx -
+
``` +## Accessibility guidelines + +- [WCAG 2.2.2](https://www.w3.org/WAI/WCAG21/Understanding/pause-stop-hide) + ## Related links - [Disable a rule](/linter/#disable-a-lint-rule) diff --git a/website/src/pages/lint/rules/noHeaderScope.md b/website/src/pages/lint/rules/noHeaderScope.md index 35566006628..032c8c309ad 100644 --- a/website/src/pages/lint/rules/noHeaderScope.md +++ b/website/src/pages/lint/rules/noHeaderScope.md @@ -7,9 +7,7 @@ parent: lint/rules/index > This rule is recommended by Rome. -Check that the scope attribute is only used on `th` elements. - -ESLint Equivalent: [scope](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/scope.md) +The scope prop should be used only on `` elements. ## Examples @@ -61,6 +59,11 @@ ESLint Equivalent: [scope](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/ ``` +## Accessibility guidelines + +- [WCAG 1.3.1](https://www.w3.org/WAI/WCAG21/Understanding/info-and-relationships) +- [WCAG 4.1.1](https://www.w3.org/WAI/WCAG21/Understanding/parsing) + ## Related links - [Disable a rule](/linter/#disable-a-lint-rule)