Skip to content

Commit

Permalink
fix(axe-core): disabled experimental rules
Browse files Browse the repository at this point in the history
  • Loading branch information
LuLaValva authored Oct 21, 2024
2 parents dbb272a + 3f54186 commit 5f51853
Show file tree
Hide file tree
Showing 6 changed files with 230 additions and 203 deletions.
5 changes: 5 additions & 0 deletions .changeset/breezy-flies-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@marko/language-server": patch
---

fix(axe-core): disabled experimental rules

This file was deleted.

This file was deleted.

385 changes: 205 additions & 180 deletions packages/language-server/src/service/html/axe-rules/axe-rules.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ axe.getRules().forEach((rule) => {
}
});

const contents = Object.entries(categories)
.map(
([cat, rules]) => `export const ${kebabToCamelCase(cat.slice(4))} = {
const contents =
Object.entries(categories)
.map(
([cat, rules]) => `export const ${kebabToCamelCase(cat.slice(4))} = {
${rules
.map(
(rule) => ` /**
Expand All @@ -28,8 +29,8 @@ ${rules
)
.join("\n")}
} as const;`,
)
.join("\n\n");
)
.join("\n\n") + "\n";

fs.writeFileSync(
path.join(__dirname, "axe-rules.ts"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ type Blacklist =
| typeof r.semantics.pageHasHeadingOne
| typeof r.structure.dlitem
| typeof r.structure.listitem
| typeof r.tables.tdHasHeader
| typeof r.tables.tdHeadersAttr
// Seemingly broken in axe-core or JSDom
| typeof r.aria.ariaRoledescription
Expand All @@ -46,25 +45,34 @@ type Blacklist =
| typeof r.parsing.duplicateId
| typeof r.parsing.duplicateIdActive
| typeof r.parsing.duplicateIdAria
| typeof r.semantics.pAsHeading
| typeof r.sensoryAndVisualCues.targetSize
| typeof r.structure.avoidInlineSpacing
| typeof r.structure.cssOrientationLock
| typeof r.structure.hiddenContent
// handled by TypeScript
| typeof r.aria.ariaValidAttrValue
| typeof r.aria.ariaAllowedAttr;
| typeof r.aria.ariaAllowedAttr
// blacklisted as the rules are in axe-core experimental phase
| typeof r.structure.cssOrientationLock
| typeof r.keyboard.focusOrderSemantics
| typeof r.structure.hiddenContent
| typeof r.semantics.labelContentNameMismatch
| typeof r.semantics.pAsHeading
| typeof r.tables.tableFakeCaption
| typeof r.tables.tdHasHeader;

type Whitelist = Exclude<RuleId, Blacklist>;

export const ruleExceptions: { [id in Whitelist]: Exceptions } = {
[r.aria.ariaAllowedRole]: { dynamicAttrs: ["role"] },
[r.aria.ariaBrailleEquivalent]: { attrSpread: true },
[r.aria.ariaCommandName]: { unknownBody: true, attrSpread: true },
[r.aria.ariaConditionalAttr]: { unknownBody: true, attrSpread: true },
[r.aria.ariaDeprecatedRole]: { dynamicAttrs: ["role"] },
[r.aria.ariaDialogName]: { unknownBody: true, attrSpread: true },
[r.aria.ariaHiddenBody]: {},
[r.aria.ariaInputFieldName]: { unknownBody: true, attrSpread: true },
[r.aria.ariaMeterName]: { unknownBody: true, attrSpread: true },
[r.aria.ariaProgressbarName]: { unknownBody: true, attrSpread: true },
[r.aria.ariaProhibitedAttr]: {},
[r.aria.ariaRequiredAttr]: { attrSpread: true },
[r.aria.ariaRequiredChildren]: { unknownBody: true },
[r.aria.ariaRoles]: { dynamicAttrs: ["role"] },
Expand All @@ -76,7 +84,6 @@ export const ruleExceptions: { [id in Whitelist]: Exceptions } = {
[r.forms.autocompleteValid]: {},
[r.forms.formFieldMultipleLabels]: {},
[r.keyboard.accesskeys]: {},
[r.keyboard.focusOrderSemantics]: {},
[r.keyboard.frameFocusableContent]: { unknownBody: true },
[r.keyboard.skipLink]: { unknownBody: true },
[r.keyboard.tabindex]: {},
Expand All @@ -93,9 +100,9 @@ export const ruleExceptions: { [id in Whitelist]: Exceptions } = {
attrSpread: true,
},
[r.nameRoleValue.linkName]: { unknownBody: true, attrSpread: true },
[r.nameRoleValue.summaryName]: { unknownBody: true, attrSpread: true },
[r.parsing.marquee]: {},
[r.semantics.identicalLinksSamePurpose]: {},
[r.semantics.labelContentNameMismatch]: { unknownBody: true },
[r.semantics.landmarkNoDuplicateBanner]: {},
[r.semantics.landmarkNoDuplicateContentinfo]: {},
[r.semantics.landmarkNoDuplicateMain]: {},
Expand All @@ -106,7 +113,6 @@ export const ruleExceptions: { [id in Whitelist]: Exceptions } = {
[r.structure.list]: { unknownBody: true },
[r.tables.scopeAttrValid]: {},
[r.tables.tableDuplicateName]: { unknownBody: true },
[r.tables.tableFakeCaption]: { unknownBody: true },
[r.tables.thHasDataCells]: { unknownBody: true },
[r.textAlternatives.areaAlt]: { attrSpread: true },
[r.textAlternatives.documentTitle]: { unknownBody: true },
Expand Down

0 comments on commit 5f51853

Please sign in to comment.