From a411bdef6751a07d23fc02a22acb3b8e4a341fdb Mon Sep 17 00:00:00 2001 From: Ajay Agarwal Date: Mon, 23 Sep 2024 10:57:27 +0530 Subject: [PATCH 1/2] updated release pipeline to build before publishing, removed dist folder from git tracking --- .github/workflows/release-package.yml | 2 + .gitignore | 3 +- .husky/pre-commit | 1 + .../buttonBasedComponents.d.ts | 1 - .../buttonBasedComponents.js | 7 - .../imageBasedComponents.d.ts | 2 - .../imageBasedComponents.js | 9 -- .../inputBasedComponents.d.ts | 1 - .../inputBasedComponents.js | 7 - .../linkBasedComponents.d.ts | 1 - .../linkBasedComponents.js | 7 - dist/lib/index.d.ts | 1 - dist/lib/index.js | 112 --------------- .../accordion-header-needs-labelling.d.ts | 5 - .../rules/accordion-header-needs-labelling.js | 66 --------- ...accordion-item-needs-header-and-panel.d.ts | 5 - .../accordion-item-needs-header-and-panel.js | 47 ------ dist/lib/rules/avatar-needs-name.d.ts | 5 - dist/lib/rules/avatar-needs-name.js | 54 ------- ...ria-describedby-for-primary-labelling.d.ts | 5 - ...-aria-describedby-for-primary-labelling.js | 63 -------- .../rules/badge-needs-accessible-name.d.ts | 5 - dist/lib/rules/badge-needs-accessible-name.js | 101 ------------- .../lib/rules/breadcrumb-needs-labelling.d.ts | 5 - dist/lib/rules/breadcrumb-needs-labelling.js | 51 ------- .../compound-button-needs-labelling.d.ts | 5 - .../compound-button-needs-labelling.js | 60 -------- .../buttons/image-button-missing-aria.d.ts | 5 - .../buttons/image-button-missing-aria.js | 70 --------- dist/lib/rules/buttons/no-empty-buttons.d.ts | 5 - dist/lib/rules/buttons/no-empty-buttons.js | 64 --------- dist/lib/rules/checkbox-needs-labelling.d.ts | 5 - dist/lib/rules/checkbox-needs-labelling.js | 57 -------- dist/lib/rules/combobox-needs-labelling.d.ts | 5 - dist/lib/rules/combobox-needs-labelling.js | 55 ------- ...gbody-needs-title-content-and-actions.d.ts | 5 - ...logbody-needs-title-content-and-actions.js | 50 ------- dist/lib/rules/dialogsurface-needs-aria.d.ts | 5 - dist/lib/rules/dialogsurface-needs-aria.js | 71 --------- dist/lib/rules/dropdown-needs-labelling.d.ts | 5 - dist/lib/rules/dropdown-needs-labelling.js | 56 -------- dist/lib/rules/field-needs-labelling.d.ts | 15 -- dist/lib/rules/field-needs-labelling.js | 46 ------ dist/lib/rules/image-link-missing-aria.d.ts | 2 - dist/lib/rules/image-link-missing-aria.js | 69 --------- ...ut-components-require-accessible-name.d.ts | 5 - ...nput-components-require-accessible-name.js | 53 ------- dist/lib/rules/link-missing-labelling.d.ts | 5 - dist/lib/rules/link-missing-labelling.js | 79 ---------- dist/lib/rules/menu-item-needs-labelling.d.ts | 5 - dist/lib/rules/menu-item-needs-labelling.js | 56 -------- dist/lib/rules/no-empty-components.d.ts | 5 - dist/lib/rules/no-empty-components.js | 48 ------- .../prefer-aria-over-title-attribute.d.ts | 5 - .../rules/prefer-aria-over-title-attribute.js | 81 ----------- .../rules/progressbar-needs-labelling.d.ts | 5 - dist/lib/rules/progressbar-needs-labelling.js | 65 --------- .../lib/rules/radio-button-missing-label.d.ts | 5 - dist/lib/rules/radio-button-missing-label.js | 58 -------- dist/lib/rules/radiogroup-missing-label.d.ts | 5 - dist/lib/rules/radiogroup-missing-label.js | 58 -------- .../rules/spin-button-needs-labelling.d.ts | 5 - dist/lib/rules/spin-button-needs-labelling.js | 54 ------- .../spin-button-unrecommended-labelling.d.ts | 5 - .../spin-button-unrecommended-labelling.js | 49 ------- dist/lib/rules/spinner-needs-labelling.d.ts | 5 - dist/lib/rules/spinner-needs-labelling.js | 51 ------- dist/lib/rules/switch-needs-labelling.d.ts | 5 - dist/lib/rules/switch-needs-labelling.js | 56 -------- dist/lib/rules/toolbar-missing-aria.d.ts | 5 - dist/lib/rules/toolbar-missing-aria.js | 49 ------- dist/lib/rules/tooltip-not-recommended.d.ts | 5 - dist/lib/rules/tooltip-not-recommended.js | 48 ------- dist/lib/util/flattenChildren.d.ts | 1 - dist/lib/util/flattenChildren.js | 19 --- dist/lib/util/hasFieldParent.d.ts | 1 - dist/lib/util/hasFieldParent.js | 23 --- dist/lib/util/hasLabelledChildImage.d.ts | 6 - dist/lib/util/hasLabelledChildImage.js | 35 ----- dist/lib/util/hasNonEmptyProp.d.ts | 7 - dist/lib/util/hasNonEmptyProp.js | 27 ---- dist/lib/util/hasTextContentChild.d.ts | 6 - dist/lib/util/hasTextContentChild.js | 21 --- dist/lib/util/hasTooltipParent.d.ts | 1 - dist/lib/util/hasTooltipParent.js | 23 --- dist/lib/util/labelUtils.d.ts | 71 --------- dist/lib/util/labelUtils.js | 136 ------------------ package.json | 4 +- 88 files changed, 8 insertions(+), 2469 deletions(-) delete mode 100644 dist/lib/applicableComponents/buttonBasedComponents.d.ts delete mode 100644 dist/lib/applicableComponents/buttonBasedComponents.js delete mode 100644 dist/lib/applicableComponents/imageBasedComponents.d.ts delete mode 100644 dist/lib/applicableComponents/imageBasedComponents.js delete mode 100644 dist/lib/applicableComponents/inputBasedComponents.d.ts delete mode 100644 dist/lib/applicableComponents/inputBasedComponents.js delete mode 100644 dist/lib/applicableComponents/linkBasedComponents.d.ts delete mode 100644 dist/lib/applicableComponents/linkBasedComponents.js delete mode 100644 dist/lib/index.d.ts delete mode 100644 dist/lib/index.js delete mode 100644 dist/lib/rules/accordion-header-needs-labelling.d.ts delete mode 100644 dist/lib/rules/accordion-header-needs-labelling.js delete mode 100644 dist/lib/rules/accordion-item-needs-header-and-panel.d.ts delete mode 100644 dist/lib/rules/accordion-item-needs-header-and-panel.js delete mode 100644 dist/lib/rules/avatar-needs-name.d.ts delete mode 100644 dist/lib/rules/avatar-needs-name.js delete mode 100644 dist/lib/rules/avoid-using-aria-describedby-for-primary-labelling.d.ts delete mode 100644 dist/lib/rules/avoid-using-aria-describedby-for-primary-labelling.js delete mode 100644 dist/lib/rules/badge-needs-accessible-name.d.ts delete mode 100644 dist/lib/rules/badge-needs-accessible-name.js delete mode 100644 dist/lib/rules/breadcrumb-needs-labelling.d.ts delete mode 100644 dist/lib/rules/breadcrumb-needs-labelling.js delete mode 100644 dist/lib/rules/buttons/compound-button-needs-labelling.d.ts delete mode 100644 dist/lib/rules/buttons/compound-button-needs-labelling.js delete mode 100644 dist/lib/rules/buttons/image-button-missing-aria.d.ts delete mode 100644 dist/lib/rules/buttons/image-button-missing-aria.js delete mode 100644 dist/lib/rules/buttons/no-empty-buttons.d.ts delete mode 100644 dist/lib/rules/buttons/no-empty-buttons.js delete mode 100644 dist/lib/rules/checkbox-needs-labelling.d.ts delete mode 100644 dist/lib/rules/checkbox-needs-labelling.js delete mode 100644 dist/lib/rules/combobox-needs-labelling.d.ts delete mode 100644 dist/lib/rules/combobox-needs-labelling.js delete mode 100644 dist/lib/rules/dialogbody-needs-title-content-and-actions.d.ts delete mode 100644 dist/lib/rules/dialogbody-needs-title-content-and-actions.js delete mode 100644 dist/lib/rules/dialogsurface-needs-aria.d.ts delete mode 100644 dist/lib/rules/dialogsurface-needs-aria.js delete mode 100644 dist/lib/rules/dropdown-needs-labelling.d.ts delete mode 100644 dist/lib/rules/dropdown-needs-labelling.js delete mode 100644 dist/lib/rules/field-needs-labelling.d.ts delete mode 100644 dist/lib/rules/field-needs-labelling.js delete mode 100644 dist/lib/rules/image-link-missing-aria.d.ts delete mode 100644 dist/lib/rules/image-link-missing-aria.js delete mode 100644 dist/lib/rules/input-components-require-accessible-name.d.ts delete mode 100644 dist/lib/rules/input-components-require-accessible-name.js delete mode 100644 dist/lib/rules/link-missing-labelling.d.ts delete mode 100644 dist/lib/rules/link-missing-labelling.js delete mode 100644 dist/lib/rules/menu-item-needs-labelling.d.ts delete mode 100644 dist/lib/rules/menu-item-needs-labelling.js delete mode 100644 dist/lib/rules/no-empty-components.d.ts delete mode 100644 dist/lib/rules/no-empty-components.js delete mode 100644 dist/lib/rules/prefer-aria-over-title-attribute.d.ts delete mode 100644 dist/lib/rules/prefer-aria-over-title-attribute.js delete mode 100644 dist/lib/rules/progressbar-needs-labelling.d.ts delete mode 100644 dist/lib/rules/progressbar-needs-labelling.js delete mode 100644 dist/lib/rules/radio-button-missing-label.d.ts delete mode 100644 dist/lib/rules/radio-button-missing-label.js delete mode 100644 dist/lib/rules/radiogroup-missing-label.d.ts delete mode 100644 dist/lib/rules/radiogroup-missing-label.js delete mode 100644 dist/lib/rules/spin-button-needs-labelling.d.ts delete mode 100644 dist/lib/rules/spin-button-needs-labelling.js delete mode 100644 dist/lib/rules/spin-button-unrecommended-labelling.d.ts delete mode 100644 dist/lib/rules/spin-button-unrecommended-labelling.js delete mode 100644 dist/lib/rules/spinner-needs-labelling.d.ts delete mode 100644 dist/lib/rules/spinner-needs-labelling.js delete mode 100644 dist/lib/rules/switch-needs-labelling.d.ts delete mode 100644 dist/lib/rules/switch-needs-labelling.js delete mode 100644 dist/lib/rules/toolbar-missing-aria.d.ts delete mode 100644 dist/lib/rules/toolbar-missing-aria.js delete mode 100644 dist/lib/rules/tooltip-not-recommended.d.ts delete mode 100644 dist/lib/rules/tooltip-not-recommended.js delete mode 100644 dist/lib/util/flattenChildren.d.ts delete mode 100644 dist/lib/util/flattenChildren.js delete mode 100644 dist/lib/util/hasFieldParent.d.ts delete mode 100644 dist/lib/util/hasFieldParent.js delete mode 100644 dist/lib/util/hasLabelledChildImage.d.ts delete mode 100644 dist/lib/util/hasLabelledChildImage.js delete mode 100644 dist/lib/util/hasNonEmptyProp.d.ts delete mode 100644 dist/lib/util/hasNonEmptyProp.js delete mode 100644 dist/lib/util/hasTextContentChild.d.ts delete mode 100644 dist/lib/util/hasTextContentChild.js delete mode 100644 dist/lib/util/hasTooltipParent.d.ts delete mode 100644 dist/lib/util/hasTooltipParent.js delete mode 100644 dist/lib/util/labelUtils.d.ts delete mode 100644 dist/lib/util/labelUtils.js diff --git a/.github/workflows/release-package.yml b/.github/workflows/release-package.yml index 50f4834..8d4a085 100644 --- a/.github/workflows/release-package.yml +++ b/.github/workflows/release-package.yml @@ -13,6 +13,7 @@ jobs: with: node-version: 16 - run: npm ci + - run: npm build - run: npm test publish-gpr: @@ -28,6 +29,7 @@ jobs: node-version: 16 registry-url: https://npm.pkg.github.com/ - run: npm ci + - run: npm build - run: npm publish env: NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/.gitignore b/.gitignore index b512c09..d26c746 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -node_modules \ No newline at end of file +node_modules +dist/ \ No newline at end of file diff --git a/.husky/pre-commit b/.husky/pre-commit index 72c4429..8afe83b 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1 +1,2 @@ +npm run build npm test diff --git a/dist/lib/applicableComponents/buttonBasedComponents.d.ts b/dist/lib/applicableComponents/buttonBasedComponents.d.ts deleted file mode 100644 index 822650c..0000000 --- a/dist/lib/applicableComponents/buttonBasedComponents.d.ts +++ /dev/null @@ -1 +0,0 @@ -export const applicableComponents: string[]; diff --git a/dist/lib/applicableComponents/buttonBasedComponents.js b/dist/lib/applicableComponents/buttonBasedComponents.js deleted file mode 100644 index 80184ee..0000000 --- a/dist/lib/applicableComponents/buttonBasedComponents.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict"; -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -const applicableComponents = ["Button", "ToggleButton", "CompoundButton"]; -module.exports = { - applicableComponents -}; diff --git a/dist/lib/applicableComponents/imageBasedComponents.d.ts b/dist/lib/applicableComponents/imageBasedComponents.d.ts deleted file mode 100644 index 56ab423..0000000 --- a/dist/lib/applicableComponents/imageBasedComponents.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export const fluentImageComponents: string[]; -export const imageDomNodes: string[]; diff --git a/dist/lib/applicableComponents/imageBasedComponents.js b/dist/lib/applicableComponents/imageBasedComponents.js deleted file mode 100644 index c312150..0000000 --- a/dist/lib/applicableComponents/imageBasedComponents.js +++ /dev/null @@ -1,9 +0,0 @@ -"use strict"; -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -const fluentImageComponents = ["Image"]; -const imageDomNodes = ["img"]; -module.exports = { - fluentImageComponents, - imageDomNodes -}; diff --git a/dist/lib/applicableComponents/inputBasedComponents.d.ts b/dist/lib/applicableComponents/inputBasedComponents.d.ts deleted file mode 100644 index 822650c..0000000 --- a/dist/lib/applicableComponents/inputBasedComponents.d.ts +++ /dev/null @@ -1 +0,0 @@ -export const applicableComponents: string[]; diff --git a/dist/lib/applicableComponents/inputBasedComponents.js b/dist/lib/applicableComponents/inputBasedComponents.js deleted file mode 100644 index 3009f44..0000000 --- a/dist/lib/applicableComponents/inputBasedComponents.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict"; -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -const applicableComponents = ["Input", "Slider", "DatePicker", "Textarea", "TextField", "TimePicker", "SearchBox", "Select"]; -module.exports = { - applicableComponents -}; diff --git a/dist/lib/applicableComponents/linkBasedComponents.d.ts b/dist/lib/applicableComponents/linkBasedComponents.d.ts deleted file mode 100644 index 58227e0..0000000 --- a/dist/lib/applicableComponents/linkBasedComponents.d.ts +++ /dev/null @@ -1 +0,0 @@ -export const linkBasedComponents: string[]; diff --git a/dist/lib/applicableComponents/linkBasedComponents.js b/dist/lib/applicableComponents/linkBasedComponents.js deleted file mode 100644 index fe87bdc..0000000 --- a/dist/lib/applicableComponents/linkBasedComponents.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict"; -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -const linkBasedComponents = ["Link", "a"]; // , "BreadcrumbButton" -module.exports = { - linkBasedComponents -}; diff --git a/dist/lib/index.d.ts b/dist/lib/index.d.ts deleted file mode 100644 index cb0ff5c..0000000 --- a/dist/lib/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/dist/lib/index.js b/dist/lib/index.js deleted file mode 100644 index e1784d5..0000000 --- a/dist/lib/index.js +++ /dev/null @@ -1,112 +0,0 @@ -"use strict"; -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -console.log("Loading my-eslint-plugin"); -const prefer_aria_over_title_attribute_1 = __importDefault(require("./rules/prefer-aria-over-title-attribute")); -const checkbox_needs_labelling_1 = __importDefault(require("./rules/checkbox-needs-labelling")); -const image_button_missing_aria_1 = __importDefault(require("./rules/buttons/image-button-missing-aria")); -const link_missing_labelling_1 = __importDefault(require("./rules/link-missing-labelling")); -const input_components_require_accessible_name_1 = __importDefault(require("./rules/input-components-require-accessible-name")); -const menu_item_needs_labelling_1 = __importDefault(require("./rules/menu-item-needs-labelling")); -const switch_needs_labelling_1 = __importDefault(require("./rules/switch-needs-labelling")); -const toolbar_missing_aria_1 = __importDefault(require("./rules/toolbar-missing-aria")); -const combobox_needs_labelling_1 = __importDefault(require("./rules/combobox-needs-labelling")); -const no_empty_components_1 = __importDefault(require("./rules/no-empty-components")); -const accordion_header_needs_labelling_1 = __importDefault(require("./rules/accordion-header-needs-labelling")); -const accordion_item_needs_header_and_panel_1 = __importDefault(require("./rules/accordion-item-needs-header-and-panel")); -const compound_button_needs_labelling_1 = __importDefault(require("./rules/buttons/compound-button-needs-labelling")); -const no_empty_buttons_1 = __importDefault(require("./rules/buttons/no-empty-buttons")); -const spin_button_needs_labelling_1 = __importDefault(require("./rules/spin-button-needs-labelling")); -const spin_button_unrecommended_labelling_1 = __importDefault(require("./rules/spin-button-unrecommended-labelling")); -const breadcrumb_needs_labelling_1 = __importDefault(require("./rules/breadcrumb-needs-labelling")); -const dropdown_needs_labelling_1 = __importDefault(require("./rules/dropdown-needs-labelling")); -const tooltip_not_recommended_1 = __importDefault(require("./rules/tooltip-not-recommended")); -const avatar_needs_name_1 = __importDefault(require("./rules/avatar-needs-name")); -const radio_button_missing_label_1 = __importDefault(require("./rules/radio-button-missing-label")); -const radiogroup_missing_label_1 = __importDefault(require("./rules/radiogroup-missing-label")); -const dialogbody_needs_title_content_and_actions_1 = __importDefault(require("./rules/dialogbody-needs-title-content-and-actions")); -const dialogsurface_needs_aria_1 = __importDefault(require("./rules/dialogsurface-needs-aria")); -const spinner_needs_labelling_1 = __importDefault(require("./rules/spinner-needs-labelling")); -const badge_needs_accessible_name_1 = __importDefault(require("./rules/badge-needs-accessible-name")); -const progressbar_needs_labelling_1 = __importDefault(require("./rules/progressbar-needs-labelling")); -const field_needs_labelling_1 = __importDefault(require("./rules/field-needs-labelling")); -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ -//------------------------------------------------------------------------------ -// Plugin Definition -//------------------------------------------------------------------------------ -// import all rules in lib/rules -module.exports = { - rules: { - "checkbox-needs-labelling": checkbox_needs_labelling_1.default, - "image-button-missing-aria": image_button_missing_aria_1.default, - "link-missing-labelling": link_missing_labelling_1.default, - "input-components-require-accessible-name": input_components_require_accessible_name_1.default, - "menu-item-needs-labelling": menu_item_needs_labelling_1.default, - "switch-needs-labelling": switch_needs_labelling_1.default, - "toolbar-missing-aria": toolbar_missing_aria_1.default, - "combobox-needs-labelling": combobox_needs_labelling_1.default, - "no-empty-components": no_empty_components_1.default, - "accordion-header-needs-labelling": accordion_header_needs_labelling_1.default, - "accordion-item-needs-header-and-panel": accordion_item_needs_header_and_panel_1.default, - "compound-button-needs-labelling": compound_button_needs_labelling_1.default, - "no-empty-buttons": no_empty_buttons_1.default, - "spin-button-needs-labelling": spin_button_needs_labelling_1.default, - "spin-button-unrecommended-labelling": spin_button_unrecommended_labelling_1.default, - "breadcrumb-needs-labelling": breadcrumb_needs_labelling_1.default, - "dropdown-needs-labelling": dropdown_needs_labelling_1.default, - "tooltip-not-recommended": tooltip_not_recommended_1.default, - "avatar-needs-name": avatar_needs_name_1.default, - "radio-button-missing-label": radio_button_missing_label_1.default, - "radiogroup-missing-label": radiogroup_missing_label_1.default, - "prefer-aria-over-title-attribute": prefer_aria_over_title_attribute_1.default, - "dialogbody-needs-title-content-and-actions": dialogbody_needs_title_content_and_actions_1.default, - "dialogsurface-needs-aria": dialogsurface_needs_aria_1.default, - "spinner-needs-labelling": spinner_needs_labelling_1.default, - "badge-needs-accessible-name": badge_needs_accessible_name_1.default, - "progressbar-needs-labelling": progressbar_needs_labelling_1.default, - "field-needs-labelling": field_needs_labelling_1.default - }, - configs: { - recommended: { - rules: { - "@microsoft/fluentui-jsx-a11y/checkbox-needs-labelling": "error", - "@microsoft/fluentui-jsx-a11y/link-missing-labelling": "error", - "@microsoft/fluentui-jsx-a11y/input-components-require-accessible-name": "error", - "@microsoft/fluentui-jsx-a11y/menu-item-needs-labelling": "error", - "@microsoft/fluentui-jsx-a11y/switch-needs-labelling": "error", - "@microsoft/fluentui-jsx-a11y/image-button-missing-aria": "error", - "@microsoft/fluentui-jsx-a11y/toolbar-missing-aria": "error", - "@microsoft/fluentui-jsx-a11y/combobox-needs-labelling": "error", - "@microsoft/fluentui-jsx-a11y/no-empty-components": "error", - "@microsoft/fluentui-jsx-a11y/accordion-header-needs-labelling": "error", - "@microsoft/fluentui-jsx-a11y/accordion-item-needs-header-and-panel": "error", - "@microsoft/fluentui-jsx-a11y/compound-button-needs-labelling": "error", - "@microsoft/fluentui-jsx-a11y/no-empty-buttons": "error", - "@microsoft/fluentui-jsx-a11y/spin-button-needs-labelling": "error", - "@microsoft/fluentui-jsx-a11y/spin-button-unrecommended-labelling": "error", - "@microsoft/fluentui-jsx-a11y/breadcrumb-needs-labelling": "error", - "@microsoft/fluentui-jsx-a11y/dropdown-needs-labelling": "error", - "@microsoft/fluentui-jsx-a11y/tooltip-not-recommended": "error", - "@microsoft/fluentui-jsx-a11y/avatar-needs-name": "error", - "@microsoft/fluentui-jsx-a11y/radio-button-missing-label": "error", - "@microsoft/fluentui-jsx-a11y/radiogroup-missing-label": "error", - "@microsoft/fluentui-jsx-a11y/prefer-aria-over-title-attribute": "warn", - "@microsoft/fluentui-jsx-a11y/dialogbody-needs-title-content-and-actions": "error", - "@microsoft/fluentui-jsx-a11y/dialogsurface-needs-aria": "error", - "@microsoft/fluentui-jsx-a11y/spinner-needs-labelling": "error", - "@microsoft/fluentui-jsx-a11y/progressbar-needs-labelling": "error", - "@microsoft/fluentui-jsx-a11y/field-needs-labelling": "error" - } - } - } -}; -// import processors -module.exports.processors = { -// add your processors here -}; diff --git a/dist/lib/rules/accordion-header-needs-labelling.d.ts b/dist/lib/rules/accordion-header-needs-labelling.d.ts deleted file mode 100644 index f2a0058..0000000 --- a/dist/lib/rules/accordion-header-needs-labelling.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { TSESTree } from "@typescript-eslint/utils"; -declare const rule: import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<"missingAriaLabel", [], { - JSXElement(node: TSESTree.JSXElement): void; -}>; -export default rule; diff --git a/dist/lib/rules/accordion-header-needs-labelling.js b/dist/lib/rules/accordion-header-needs-labelling.js deleted file mode 100644 index ccb655e..0000000 --- a/dist/lib/rules/accordion-header-needs-labelling.js +++ /dev/null @@ -1,66 +0,0 @@ -"use strict"; -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -Object.defineProperty(exports, "__esModule", { value: true }); -const utils_1 = require("@typescript-eslint/utils"); -const jsx_ast_utils_1 = require("jsx-ast-utils"); -const hasNonEmptyProp_1 = require("../util/hasNonEmptyProp"); -const hasTooltipParent_1 = require("../util/hasTooltipParent"); -const hasTextContentChild_1 = require("../util/hasTextContentChild"); -const labelUtils_1 = require("../util/labelUtils"); -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ -const rule = utils_1.ESLintUtils.RuleCreator.withoutDocs({ - defaultOptions: [], - meta: { - messages: { - missingAriaLabel: "Accessibility: the accordion header must have an accessible name" - }, - type: "problem", // `problem`, `suggestion`, or `layout` - docs: { - description: "The accordion header is a button and it needs an accessibile name e.g. text content, aria-label, aria-labelledby.", - recommended: false - }, - schema: [] // Add a schema if the rule has options - }, - // create (function) returns an object with methods that ESLint calls to “visit” nodes while traversing the abstract syntax tree - create(context) { - return { - // visitor functions for different types of nodes - JSXElement(node) { - const openingElement = node.openingElement; - // if it is not a AccordionHeader, return - if ((0, jsx_ast_utils_1.elementType)(openingElement) !== "AccordionHeader") { - return; - } - // if it has text content, return - if ((0, hasTextContentChild_1.hasTextContentChild)(node)) { - return; - } - // if it is not an icon button, return - if (!(0, jsx_ast_utils_1.hasProp)(openingElement.attributes, "icon") && - !(0, jsx_ast_utils_1.hasProp)(openingElement.attributes, "expandIcon")) { - return; - } - // if it has a tooltip parent, return - if ((0, hasTooltipParent_1.hasToolTipParent)(context)) { - return; - } - // the button has an associated label - if ((0, labelUtils_1.hasAssociatedLabelViaAriaLabelledBy)(openingElement, context)) { - return; - } - const hasAccessibleLabelling = (0, hasNonEmptyProp_1.hasNonEmptyProp)(openingElement.attributes, "title") || (0, hasNonEmptyProp_1.hasNonEmptyProp)(openingElement.attributes, "aria-label"); - // if it has no accessible name, report error - if (!hasAccessibleLabelling) { - context.report({ - node, - messageId: `missingAriaLabel` - }); - } - } - }; - } -}); -exports.default = rule; diff --git a/dist/lib/rules/accordion-item-needs-header-and-panel.d.ts b/dist/lib/rules/accordion-item-needs-header-and-panel.d.ts deleted file mode 100644 index 34313bb..0000000 --- a/dist/lib/rules/accordion-item-needs-header-and-panel.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { TSESTree } from "@typescript-eslint/utils"; -declare const rule: import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<"accordionItemOneHeaderOnePanel", [], { - JSXOpeningElement(node: TSESTree.JSXOpeningElement): void; -}>; -export default rule; diff --git a/dist/lib/rules/accordion-item-needs-header-and-panel.js b/dist/lib/rules/accordion-item-needs-header-and-panel.js deleted file mode 100644 index d25ab92..0000000 --- a/dist/lib/rules/accordion-item-needs-header-and-panel.js +++ /dev/null @@ -1,47 +0,0 @@ -"use strict"; -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -Object.defineProperty(exports, "__esModule", { value: true }); -const utils_1 = require("@typescript-eslint/utils"); -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ -const rule = utils_1.ESLintUtils.RuleCreator.withoutDocs({ - defaultOptions: [], - meta: { - messages: { - accordionItemOneHeaderOnePanel: "ensure AccordionItem has exactly one header and one panel" - }, - type: "problem", // `problem`, `suggestion`, or `layout` - docs: { - description: "An AccordionItem needs exactly one header and one panel", - recommended: "strict", - url: "https://www.w3.org/WAI/ARIA/apg/patterns/accordion/" // URL to the documentation page for this rule - }, - schema: [] // Add a schema if the rule has options - }, - create(context) { - return { - JSXOpeningElement(node) { - if (node.name.type === utils_1.AST_NODE_TYPES.JSXIdentifier && node.name.name !== "AccordionItem") { - return; - } - if (!(node.parent && node.parent.type === utils_1.AST_NODE_TYPES.JSXElement)) { - return; - } - const children = node.parent.children.filter(child => child.type === "JSXElement"); - const hasOneHeader = children.filter(child => child.openingElement.name.type === utils_1.AST_NODE_TYPES.JSXIdentifier && - child.openingElement.name.name === "AccordionHeader").length === 1; - const hasOnePanel = children.filter(child => child.openingElement.name.type === utils_1.AST_NODE_TYPES.JSXIdentifier && - child.openingElement.name.name === "AccordionPanel").length === 1; - if (!hasOneHeader || !hasOnePanel || children.length !== 2) { - context.report({ - node, - messageId: "accordionItemOneHeaderOnePanel" - }); - } - } - }; - } -}); -exports.default = rule; diff --git a/dist/lib/rules/avatar-needs-name.d.ts b/dist/lib/rules/avatar-needs-name.d.ts deleted file mode 100644 index 3ac584a..0000000 --- a/dist/lib/rules/avatar-needs-name.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { TSESTree } from "@typescript-eslint/utils"; -declare const rule: import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<"missingAriaLabel", [], { - JSXOpeningElement(node: TSESTree.JSXOpeningElement): void; -}>; -export default rule; diff --git a/dist/lib/rules/avatar-needs-name.js b/dist/lib/rules/avatar-needs-name.js deleted file mode 100644 index 79adb20..0000000 --- a/dist/lib/rules/avatar-needs-name.js +++ /dev/null @@ -1,54 +0,0 @@ -"use strict"; -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -Object.defineProperty(exports, "__esModule", { value: true }); -const utils_1 = require("@typescript-eslint/utils"); -const jsx_ast_utils_1 = require("jsx-ast-utils"); -const hasNonEmptyProp_1 = require("../util/hasNonEmptyProp"); -const labelUtils_1 = require("../util/labelUtils"); -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ -const rule = utils_1.ESLintUtils.RuleCreator.withoutDocs({ - defaultOptions: [], - meta: { - // possible error messages for the rule - messages: { - missingAriaLabel: "Accessibility: Avatar must have an accessible name" - }, - // "problem" means the rule is identifying code that either will cause an error or may cause a confusing behavior: https://eslint.org/docs/latest/developer-guide/working-with-rules - type: "problem", - // docs for the rule - docs: { - // DONE - description: "Accessibility: Avatar must have an accessible labelling: name, aria-label, aria-labelledby", - recommended: "strict", - url: "https://www.w3.org/TR/html-aria/" // URL to the documentation page for this rule - }, - schema: [] - }, - // create (function) returns an object with methods that ESLint calls to “visit” nodes while traversing the abstract syntax tree - create(context) { - return { - // visitor functions for different types of nodes - JSXOpeningElement(node) { - // if it is not an Avatar, return - if ((0, jsx_ast_utils_1.elementType)(node) !== "Avatar") { - return; - } - // if the Avatar has a name, aria-label or aria-labelledby, return - if ((0, hasNonEmptyProp_1.hasNonEmptyProp)(node.attributes, "name") || - (0, hasNonEmptyProp_1.hasNonEmptyProp)(node.attributes, "aria-label") || - (0, labelUtils_1.hasAssociatedLabelViaAriaLabelledBy)(node, context)) { - return; - } - // no aria - context.report({ - node, - messageId: `missingAriaLabel` - }); - } - }; - } -}); -exports.default = rule; diff --git a/dist/lib/rules/avoid-using-aria-describedby-for-primary-labelling.d.ts b/dist/lib/rules/avoid-using-aria-describedby-for-primary-labelling.d.ts deleted file mode 100644 index ae2e6fb..0000000 --- a/dist/lib/rules/avoid-using-aria-describedby-for-primary-labelling.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { TSESTree } from "@typescript-eslint/utils"; -declare const rule: import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<"noAriaDescribedbyAsLabel", [], { - JSXElement(node: TSESTree.JSXElement): void; -}>; -export default rule; diff --git a/dist/lib/rules/avoid-using-aria-describedby-for-primary-labelling.js b/dist/lib/rules/avoid-using-aria-describedby-for-primary-labelling.js deleted file mode 100644 index be3887a..0000000 --- a/dist/lib/rules/avoid-using-aria-describedby-for-primary-labelling.js +++ /dev/null @@ -1,63 +0,0 @@ -"use strict"; -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -Object.defineProperty(exports, "__esModule", { value: true }); -const utils_1 = require("@typescript-eslint/utils"); -const jsx_ast_utils_1 = require("jsx-ast-utils"); -const inputBasedComponents_1 = require("../applicableComponents/inputBasedComponents"); -const buttonBasedComponents_1 = require("../applicableComponents/buttonBasedComponents"); -const labelUtils_1 = require("../util/labelUtils"); -const hasFieldParent_1 = require("../util/hasFieldParent"); -const hasNonEmptyProp_1 = require("../util/hasNonEmptyProp"); -const hasTooltipParent_1 = require("../util/hasTooltipParent"); -const hasTextContentChild_1 = require("../util/hasTextContentChild"); -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ -const rule = utils_1.ESLintUtils.RuleCreator.withoutDocs({ - defaultOptions: [], - meta: { - messages: { - noAriaDescribedbyAsLabel: "Accessibility: aria-describedby provides additional context and is not meant for primary labeling." - }, - type: "suggestion", // `problem`, `suggestion`, or `layout` - docs: { - description: "aria-describedby provides additional context and is not meant for primary labeling.", - recommended: "strict" - }, - schema: [] // Add a schema if the rule has options - }, - create(context) { - return { - JSXElement(node) { - const openingElement = node.openingElement; - if (buttonBasedComponents_1.applicableComponents.includes((0, jsx_ast_utils_1.elementType)(openingElement)) && // It's a button-based component - !(0, hasTooltipParent_1.hasToolTipParent)(context) && // It doesn't have a tooltip parent - !(0, hasTextContentChild_1.hasTextContentChild)(node) && // It doesn't have text content - !(0, hasNonEmptyProp_1.hasNonEmptyProp)(openingElement.attributes, "title") && // Doesn't have a title - !(0, hasNonEmptyProp_1.hasNonEmptyProp)(openingElement.attributes, "aria-label") && // Doesn't have an aria-label - !(0, labelUtils_1.hasAssociatedLabelViaAriaLabelledBy)(openingElement, context) && // Doesn't have aria-labelledby - (0, labelUtils_1.hasAssociatedLabelViaAriaDescribedby)(openingElement, context) // But it does have aria-describedby - ) { - context.report({ - node, - messageId: "noAriaDescribedbyAsLabel" - }); - } - if (inputBasedComponents_1.applicableComponents.includes((0, jsx_ast_utils_1.elementType)(openingElement)) && // It's an input component - !(0, hasFieldParent_1.hasFieldParent)(context) && // It doesn't have a field parent - !(0, labelUtils_1.isInsideLabelTag)(context) && // It's not inside a label tag - !(0, labelUtils_1.hasAssociatedLabelViaHtmlFor)(openingElement, context) && // Doesn't have a label via htmlFor - !(0, labelUtils_1.hasAssociatedLabelViaAriaLabelledBy)(openingElement, context) && // Doesn't have aria-labelledby - (0, labelUtils_1.hasAssociatedLabelViaAriaDescribedby)(openingElement, context) // But it does have aria-describedby - ) { - context.report({ - node, - messageId: "noAriaDescribedbyAsLabel" - }); - } - } - }; - } -}); -exports.default = rule; diff --git a/dist/lib/rules/badge-needs-accessible-name.d.ts b/dist/lib/rules/badge-needs-accessible-name.d.ts deleted file mode 100644 index 50c63b5..0000000 --- a/dist/lib/rules/badge-needs-accessible-name.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { TSESTree } from "@typescript-eslint/utils"; -declare const rule: import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<"badgeNeedsAccessibleName" | "colourOnlyBadgesNeedAttributes" | "badgeIconNeedsLabelling", [], { - JSXElement(node: TSESTree.JSXElement): void; -}>; -export default rule; diff --git a/dist/lib/rules/badge-needs-accessible-name.js b/dist/lib/rules/badge-needs-accessible-name.js deleted file mode 100644 index 4ab3b3e..0000000 --- a/dist/lib/rules/badge-needs-accessible-name.js +++ /dev/null @@ -1,101 +0,0 @@ -"use strict"; -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -Object.defineProperty(exports, "__esModule", { value: true }); -const utils_1 = require("@typescript-eslint/utils"); -const jsx_ast_utils_1 = require("jsx-ast-utils"); -const jsx_ast_utils_2 = require("jsx-ast-utils"); -const hasTextContentChild_1 = require("../util/hasTextContentChild"); -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ -const rule = utils_1.ESLintUtils.RuleCreator.withoutDocs({ - defaultOptions: [], - meta: { - // possible error messages for the rule - messages: { - badgeNeedsAccessibleName: "Badge: needs accessible name. Add text content or a labelled image.", - colourOnlyBadgesNeedAttributes: 'Color-only must have role="img" and an aria-label attribute.', - badgeIconNeedsLabelling: "The icon inside must have an aria-label attribute." - }, - type: "problem", // `problem`, `suggestion`, or `layout` - docs: { - description: "", - recommended: false, - url: "https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/img_role" // URL to the documentation page for this rule - }, - fixable: "code", // Or `code` or `whitespace` - schema: [] // Add a schema if the rule has options - }, - create(context) { - return { - // visitor functions for different types of nodes - JSXElement(node) { - const openingElement = node.openingElement; - // If it's not a Badge component, return early - if ((0, jsx_ast_utils_1.elementType)(openingElement) !== "Badge") { - return; - } - const hasTextContent = (0, hasTextContentChild_1.hasTextContentChild)(node); - // Check if Badge has text content and return early if it does - if (hasTextContent) { - return; - } - // Check if Badge has an icon - const hasIconProp = (0, jsx_ast_utils_1.hasProp)(openingElement.attributes, "icon"); - if (hasIconProp) { - const iconProp = (0, jsx_ast_utils_2.getProp)(openingElement.attributes, "icon"); - if (iconProp && iconProp.value && iconProp.value.type === utils_1.AST_NODE_TYPES.JSXExpressionContainer) { - const iconElement = iconProp.value.expression; - // Check if the icon has an aria-label - const ariaLabelAttr = (0, jsx_ast_utils_1.hasProp)(iconElement.openingElement.attributes, "aria-label"); - // Report an error if aria-label is missing - if (!ariaLabelAttr) { - context.report({ - node, - messageId: "badgeIconNeedsLabelling", - fix(fixer) { - const ariaLabelFix = fixer.insertTextAfter(iconElement.openingElement.name, ' aria-label=""'); - return ariaLabelFix; - } - }); - } - } - } - // Simplified logic to check for a color-only Badge (no icon, no text) - const roleProp = (0, jsx_ast_utils_2.getProp)(openingElement.attributes, "role"); - const hasColorProp = (0, jsx_ast_utils_1.hasProp)(openingElement.attributes, "color"); - const hasRole = !!roleProp && (0, jsx_ast_utils_2.getPropValue)(roleProp) === "img"; - const hasAriaLabel = (0, jsx_ast_utils_1.hasProp)(openingElement.attributes, "aria-label"); - // If it's color-only, ensure it has role="img" and aria-label - if (!hasIconProp && !(hasRole && hasAriaLabel)) { - if (hasColorProp) { - context.report({ - node, - messageId: "colourOnlyBadgesNeedAttributes", - fix(fixer) { - const fixes = []; - // Fix role by adding role="img" - if (!hasRole) { - fixes.push(fixer.insertTextAfter(openingElement.name, ' role="img"')); - } - // Fix aria-label by adding aria-label="" - if (!hasAriaLabel) { - fixes.push(fixer.insertTextAfter(openingElement.name, ' aria-label=""')); - } - return fixes; - } - }); - } - else { - context.report({ - node, - messageId: "badgeNeedsAccessibleName" - }); - } - } - } - }; - } -}); -exports.default = rule; diff --git a/dist/lib/rules/breadcrumb-needs-labelling.d.ts b/dist/lib/rules/breadcrumb-needs-labelling.d.ts deleted file mode 100644 index 9376036..0000000 --- a/dist/lib/rules/breadcrumb-needs-labelling.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { TSESTree } from "@typescript-eslint/utils"; -declare const rule: import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<"noUnlabelledBreadcrumb", [], { - JSXOpeningElement(node: TSESTree.JSXOpeningElement): void; -}>; -export default rule; diff --git a/dist/lib/rules/breadcrumb-needs-labelling.js b/dist/lib/rules/breadcrumb-needs-labelling.js deleted file mode 100644 index ae5333d..0000000 --- a/dist/lib/rules/breadcrumb-needs-labelling.js +++ /dev/null @@ -1,51 +0,0 @@ -"use strict"; -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -Object.defineProperty(exports, "__esModule", { value: true }); -const utils_1 = require("@typescript-eslint/utils"); -const jsx_ast_utils_1 = require("jsx-ast-utils"); -const hasNonEmptyProp_1 = require("../util/hasNonEmptyProp"); -const labelUtils_1 = require("../util/labelUtils"); -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ -const rule = utils_1.ESLintUtils.RuleCreator.withoutDocs({ - defaultOptions: [], - meta: { - // possible error messages for the rule - messages: { - noUnlabelledBreadcrumb: "Accessibility: Breadcrumb must have an accessible label" - }, - // "problem" means the rule is identifying code that either will cause an error or may cause a confusing behavior: https://eslint.org/docs/latest/developer-guide/working-with-rules - type: "problem", - docs: { - description: "All interactive elements must have an accessible name", - recommended: false, - url: "https://www.w3.org/TR/html-aria/" // URL to the documentation page for this rule - }, - schema: [] // Add a schema if the rule has options - }, - create(context) { - return { - // visitor functions for different types of nodes - JSXOpeningElement(node) { - // if it is not a Breadcrumb, return - if ((0, jsx_ast_utils_1.elementType)(node) !== "Breadcrumb") { - return; - } - // if the Breadcrumb has a label, if the Breadcrumb has an associated label, return - if ((0, hasNonEmptyProp_1.hasNonEmptyProp)(node.attributes, "aria-label") || //aria-label - (0, labelUtils_1.hasAssociatedLabelViaAriaLabelledBy)(node, context) // aria-labelledby - ) { - return; - } - // if it has no visual labelling, report error - context.report({ - node, - messageId: `noUnlabelledBreadcrumb` - }); - } - }; - } -}); -exports.default = rule; diff --git a/dist/lib/rules/buttons/compound-button-needs-labelling.d.ts b/dist/lib/rules/buttons/compound-button-needs-labelling.d.ts deleted file mode 100644 index f2a0058..0000000 --- a/dist/lib/rules/buttons/compound-button-needs-labelling.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { TSESTree } from "@typescript-eslint/utils"; -declare const rule: import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<"missingAriaLabel", [], { - JSXElement(node: TSESTree.JSXElement): void; -}>; -export default rule; diff --git a/dist/lib/rules/buttons/compound-button-needs-labelling.js b/dist/lib/rules/buttons/compound-button-needs-labelling.js deleted file mode 100644 index 7d83385..0000000 --- a/dist/lib/rules/buttons/compound-button-needs-labelling.js +++ /dev/null @@ -1,60 +0,0 @@ -"use strict"; -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -Object.defineProperty(exports, "__esModule", { value: true }); -const utils_1 = require("@typescript-eslint/utils"); -const jsx_ast_utils_1 = require("jsx-ast-utils"); -const hasNonEmptyProp_1 = require("../../util/hasNonEmptyProp"); -const hasTooltipParent_1 = require("../../util/hasTooltipParent"); -const hasTextContentChild_1 = require("../../util/hasTextContentChild"); -const labelUtils_1 = require("../../util/labelUtils"); -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ -const rule = utils_1.ESLintUtils.RuleCreator.withoutDocs({ - defaultOptions: [], - meta: { - // possible error messages for the rule - messages: { - missingAriaLabel: "Accessibility: Compound buttons must have an accessible name" - }, - // "problem" means the rule is identifying code that either will cause an error or may cause a confusing behavior: https://eslint.org/docs/latest/developer-guide/working-with-rules - type: "problem", - // docs for the rule - docs: { - description: "Accessibility: Compound buttons must have accessible labelling: title, aria-label, aria-labelledby, aria-describedby", - recommended: "strict", - url: "https://www.w3.org/TR/html-aria/" // URL to the documentation page for this rule - }, - schema: [] - }, - // create (function) returns an object with methods that ESLint calls to “visit” nodes while traversing the abstract syntax tree - create(context) { - return { - // visitor functions for different types of nodes - JSXElement(node) { - const openingElement = node.openingElement; - // if it is not a Compound button, return - if ((0, jsx_ast_utils_1.elementType)(openingElement) !== "CompoundButton") { - return; - } - // if it has a tooltip parent Or has text content Or has an associated label or has secondaryContent, return - if ((0, hasTooltipParent_1.hasToolTipParent)(context) || - (0, hasTextContentChild_1.hasTextContentChild)(node) || - (0, labelUtils_1.hasAssociatedLabelViaAriaLabelledBy)(openingElement, context) || - (0, hasNonEmptyProp_1.hasNonEmptyProp)(openingElement.attributes, "secondaryContent")) { - return; - } - const hasAccessibleLabelling = (0, hasNonEmptyProp_1.hasNonEmptyProp)(openingElement.attributes, "title") || (0, hasNonEmptyProp_1.hasNonEmptyProp)(openingElement.attributes, "aria-label"); - // if it has no accessible name, report error - if (!hasAccessibleLabelling) { - context.report({ - node, - messageId: `missingAriaLabel` - }); - } - } - }; - } -}); -exports.default = rule; diff --git a/dist/lib/rules/buttons/image-button-missing-aria.d.ts b/dist/lib/rules/buttons/image-button-missing-aria.d.ts deleted file mode 100644 index f2a0058..0000000 --- a/dist/lib/rules/buttons/image-button-missing-aria.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { TSESTree } from "@typescript-eslint/utils"; -declare const rule: import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<"missingAriaLabel", [], { - JSXElement(node: TSESTree.JSXElement): void; -}>; -export default rule; diff --git a/dist/lib/rules/buttons/image-button-missing-aria.js b/dist/lib/rules/buttons/image-button-missing-aria.js deleted file mode 100644 index aa8ac6f..0000000 --- a/dist/lib/rules/buttons/image-button-missing-aria.js +++ /dev/null @@ -1,70 +0,0 @@ -"use strict"; -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -Object.defineProperty(exports, "__esModule", { value: true }); -const utils_1 = require("@typescript-eslint/utils"); -const jsx_ast_utils_1 = require("jsx-ast-utils"); -const hasNonEmptyProp_1 = require("../../util/hasNonEmptyProp"); -const hasTooltipParent_1 = require("../../util/hasTooltipParent"); -const hasTextContentChild_1 = require("../../util/hasTextContentChild"); -const labelUtils_1 = require("../../util/labelUtils"); -const buttonBasedComponents_1 = require("../../applicableComponents/buttonBasedComponents"); -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ -const rule = utils_1.ESLintUtils.RuleCreator.withoutDocs({ - defaultOptions: [], - meta: { - // possible error messages for the rule - messages: { - missingAriaLabel: "Accessibility: Image buttons must have an accessible name" - }, - // "problem" means the rule is identifying code that either will cause an error or may cause a confusing behavior: https://eslint.org/docs/latest/developer-guide/working-with-rules - type: "problem", - // docs for the rule - docs: { - description: "Accessibility: Image buttons must have accessible labelling: title, aria-label, aria-labelledby, aria-describedby", - recommended: "strict", - url: "https://www.w3.org/TR/html-aria/" // URL to the documentation page for this rule - }, - schema: [] - }, - // create (function) returns an object with methods that ESLint calls to “visit” nodes while traversing the abstract syntax tree - create(context) { - return { - // visitor functions for different types of nodes - JSXElement(node) { - const openingElement = node.openingElement; - // if it is not a button, return - if (!buttonBasedComponents_1.applicableComponents.includes((0, jsx_ast_utils_1.elementType)(openingElement))) { - return; - } - // if it is not an icon button, return - if (!(0, jsx_ast_utils_1.hasProp)(openingElement.attributes, "icon")) { - return; - } - // if it has a tooltip parent, return - if ((0, hasTooltipParent_1.hasToolTipParent)(context)) { - return; - } - // if it has text content, return - if ((0, hasTextContentChild_1.hasTextContentChild)(node)) { - return; - } - // the button has an associated label - if ((0, labelUtils_1.hasAssociatedLabelViaAriaLabelledBy)(openingElement, context)) { - return; - } - const hasAccessibleLabelling = (0, hasNonEmptyProp_1.hasNonEmptyProp)(openingElement.attributes, "title") || (0, hasNonEmptyProp_1.hasNonEmptyProp)(openingElement.attributes, "aria-label"); - // if it has no accessible name, report error - if (!hasAccessibleLabelling) { - context.report({ - node, - messageId: `missingAriaLabel` - }); - } - } - }; - } -}); -exports.default = rule; diff --git a/dist/lib/rules/buttons/no-empty-buttons.d.ts b/dist/lib/rules/buttons/no-empty-buttons.d.ts deleted file mode 100644 index 4765267..0000000 --- a/dist/lib/rules/buttons/no-empty-buttons.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { TSESTree } from "@typescript-eslint/utils"; -declare const rule: import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<"noEmptyButtons", [], { - JSXElement(node: TSESTree.JSXElement): void; -}>; -export default rule; diff --git a/dist/lib/rules/buttons/no-empty-buttons.js b/dist/lib/rules/buttons/no-empty-buttons.js deleted file mode 100644 index 265fd97..0000000 --- a/dist/lib/rules/buttons/no-empty-buttons.js +++ /dev/null @@ -1,64 +0,0 @@ -"use strict"; -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -Object.defineProperty(exports, "__esModule", { value: true }); -const utils_1 = require("@typescript-eslint/utils"); -const jsx_ast_utils_1 = require("jsx-ast-utils"); -const hasTextContentChild_1 = require("../../util/hasTextContentChild"); -const hasNonEmptyProp_1 = require("../../util/hasNonEmptyProp"); -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ -const allowedComponents = ["Button", "ToggleButton", "SplitButton", "MenuButton", "CompoundButton"]; -const rule = utils_1.ESLintUtils.RuleCreator.withoutDocs({ - defaultOptions: [], - meta: { - // possible error messages for the lint rule - messages: { - noEmptyButtons: `Accessibility: no empty ${allowedComponents.join(", ")}` - }, - // "problem" means the rule is identifying code that either will cause an error or may cause a confusing behavior: https://eslint.org/docs/latest/developer-guide/working-with-rules - type: "problem", - // docs for the rule - docs: { - description: `Accessibility: ${allowedComponents.join(", ")} must either text content or icon or child component`, - recommended: "strict", - url: "https://www.w3.org/TR/html-aria/" // URL to the documentation page for this rule - }, - schema: [] // no options - }, - // create (function) returns an object with methods that ESLint calls to “visit” nodes while traversing the abstract syntax tree - create(context) { - return { - // visitor functions for different types of nodes - JSXElement(node) { - const openingElement = node.openingElement; - // if it is not a button, return - if (!allowedComponents.includes((0, jsx_ast_utils_1.elementType)(openingElement))) { - return; - } - // if it has text content, return - if ((0, hasTextContentChild_1.hasTextContentChild)(node)) - return; - // if there is icon prop, return - if ((0, jsx_ast_utils_1.hasProp)(openingElement.attributes, "icon")) { - return; - } - // if split button has secondary content, return - if ((0, jsx_ast_utils_1.elementType)(openingElement) === "CompoundButton" && - (0, hasNonEmptyProp_1.hasNonEmptyProp)(openingElement.attributes, "secondaryContent")) { - return; - } - const hasChildren = node.children.length > 0; - // if there are children, return - if (hasChildren) - return; - return context.report({ - node, - messageId: `noEmptyButtons` - }); - } - }; - } -}); -exports.default = rule; diff --git a/dist/lib/rules/checkbox-needs-labelling.d.ts b/dist/lib/rules/checkbox-needs-labelling.d.ts deleted file mode 100644 index 55b9e4a..0000000 --- a/dist/lib/rules/checkbox-needs-labelling.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { TSESTree } from "@typescript-eslint/utils"; -declare const rule: import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<"noUnlabelledCheckbox", [], { - JSXOpeningElement(node: TSESTree.JSXOpeningElement): void; -}>; -export default rule; diff --git a/dist/lib/rules/checkbox-needs-labelling.js b/dist/lib/rules/checkbox-needs-labelling.js deleted file mode 100644 index 11344b2..0000000 --- a/dist/lib/rules/checkbox-needs-labelling.js +++ /dev/null @@ -1,57 +0,0 @@ -"use strict"; -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -Object.defineProperty(exports, "__esModule", { value: true }); -const utils_1 = require("@typescript-eslint/utils"); -const hasNonEmptyProp_1 = require("../util/hasNonEmptyProp"); -const jsx_ast_utils_1 = require("jsx-ast-utils"); -const labelUtils_1 = require("../util/labelUtils"); -const hasFieldParent_1 = require("../util/hasFieldParent"); -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ -const rule = utils_1.ESLintUtils.RuleCreator.withoutDocs({ - defaultOptions: [], - meta: { - // possible error messages for the rule - messages: { - noUnlabelledCheckbox: "Accessibility: Checkbox without label must have an accessible and visual label: aria-labelledby" - }, - // "problem" means the rule is identifying code that either will cause an error or may cause a confusing behavior: https://eslint.org/docs/latest/developer-guide/working-with-rules - type: "problem", - // docs for the rule - docs: { - // DONE - description: "Accessibility: Checkbox without label must have an accessible and visual label: aria-labelledby", - recommended: "strict", - url: "https://www.w3.org/TR/html-aria/" // URL to the documentation page for this rule - }, - schema: [] - }, - // create (function) returns an object with methods that ESLint calls to “visit” nodes while traversing the abstract syntax tree - create(context) { - return { - // visitor functions for different types of nodes - JSXOpeningElement(node) { - // if it is not a Checkbox, return - if ((0, jsx_ast_utils_1.elementType)(node) !== "Checkbox") { - return; - } - // if the Checkbox has a label, if the Switch has an associated label, return - if ((0, hasNonEmptyProp_1.hasNonEmptyProp)(node.attributes, "label") || - (0, hasFieldParent_1.hasFieldParent)(context) || - (0, labelUtils_1.isInsideLabelTag)(context) || - (0, labelUtils_1.hasAssociatedLabelViaHtmlFor)(node, context) || - (0, labelUtils_1.hasAssociatedLabelViaAriaLabelledBy)(node, context)) { - return; - } - // if it has no visual labelling, report error - context.report({ - node, - messageId: `noUnlabelledCheckbox` - }); - } - }; - } -}); -exports.default = rule; diff --git a/dist/lib/rules/combobox-needs-labelling.d.ts b/dist/lib/rules/combobox-needs-labelling.d.ts deleted file mode 100644 index d855084..0000000 --- a/dist/lib/rules/combobox-needs-labelling.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { TSESTree } from "@typescript-eslint/utils"; -declare const rule: import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<"noUnlabelledCombobox", [], { - JSXOpeningElement(node: TSESTree.JSXOpeningElement): void; -}>; -export default rule; diff --git a/dist/lib/rules/combobox-needs-labelling.js b/dist/lib/rules/combobox-needs-labelling.js deleted file mode 100644 index 1124820..0000000 --- a/dist/lib/rules/combobox-needs-labelling.js +++ /dev/null @@ -1,55 +0,0 @@ -"use strict"; -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -Object.defineProperty(exports, "__esModule", { value: true }); -const utils_1 = require("@typescript-eslint/utils"); -const jsx_ast_utils_1 = require("jsx-ast-utils"); -const hasNonEmptyProp_1 = require("../util/hasNonEmptyProp"); -const labelUtils_1 = require("../util/labelUtils"); -const hasFieldParent_1 = require("../util/hasFieldParent"); -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ -const rule = utils_1.ESLintUtils.RuleCreator.withoutDocs({ - defaultOptions: [], - meta: { - // possible error messages for the rule - messages: { - noUnlabelledCombobox: "Accessibility: Combobox must have an accessible label" - }, - // "problem" means the rule is identifying code that either will cause an error or may cause a confusing behavior: https://eslint.org/docs/latest/developer-guide/working-with-rules - type: "problem", - docs: { - description: "All interactive elements must have an accessible name", - recommended: false, - url: "https://www.w3.org/TR/html-aria/" // URL to the documentation page for this rule - }, - schema: [] // Add a schema if the rule has options - }, - create(context) { - return { - // visitor functions for different types of nodes - JSXOpeningElement(node) { - // if it is not a Combobox, return - if ((0, jsx_ast_utils_1.elementType)(node) !== "Combobox") { - return; - } - // if the Combobox has a label, if the Combobox has an associated label, return - if ((0, hasFieldParent_1.hasFieldParent)(context) || - (0, hasNonEmptyProp_1.hasNonEmptyProp)(node.attributes, "aria-label") || //aria-label, not recommended but will work for screen reader users - (0, labelUtils_1.isInsideLabelTag)(context) || // wrapped in label - (0, labelUtils_1.hasAssociatedLabelViaHtmlFor)(node, context) || // label with htmlFor - (0, labelUtils_1.hasAssociatedLabelViaAriaLabelledBy)(node, context) // aria-labelledby - ) { - return; - } - // if it has no visual labelling, report error - context.report({ - node, - messageId: `noUnlabelledCombobox` - }); - } - }; - } -}); -exports.default = rule; diff --git a/dist/lib/rules/dialogbody-needs-title-content-and-actions.d.ts b/dist/lib/rules/dialogbody-needs-title-content-and-actions.d.ts deleted file mode 100644 index 717e62d..0000000 --- a/dist/lib/rules/dialogbody-needs-title-content-and-actions.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { TSESTree } from "@typescript-eslint/utils"; -declare const rule: import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<"dialogBodyOneTitleOneContentOneFooter", [], { - JSXOpeningElement(node: TSESTree.JSXOpeningElement): void; -}>; -export default rule; diff --git a/dist/lib/rules/dialogbody-needs-title-content-and-actions.js b/dist/lib/rules/dialogbody-needs-title-content-and-actions.js deleted file mode 100644 index 003bf2c..0000000 --- a/dist/lib/rules/dialogbody-needs-title-content-and-actions.js +++ /dev/null @@ -1,50 +0,0 @@ -"use strict"; -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -Object.defineProperty(exports, "__esModule", { value: true }); -const utils_1 = require("@typescript-eslint/utils"); -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ -const rule = utils_1.ESLintUtils.RuleCreator.withoutDocs({ - defaultOptions: [], - meta: { - messages: { - dialogBodyOneTitleOneContentOneFooter: "ensure DialogBody has exactly one header,one content and one footer" - }, - type: "problem", // `problem`, `suggestion`, or `layout` - docs: { - description: "A DialogBody should have a header(DialogTitle), content(DialogContent), and footer(DialogActions)", - recommended: "strict", - url: "https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/" // URL to the documentation page for this rule - }, - schema: [] // Add a schema if the rule has options - }, - create(context) { - return { - JSXOpeningElement(node) { - if (node.name.type === utils_1.AST_NODE_TYPES.JSXIdentifier && node.name.name !== "DialogBody") { - return; - } - const children = node.parent && - node.parent.type === utils_1.AST_NODE_TYPES.JSXElement && - node.parent.children.filter(child => child.type === "JSXElement"); - if (children) { - const hasOneTitle = children.filter(child => child.openingElement.name.type === utils_1.AST_NODE_TYPES.JSXIdentifier && - child.openingElement.name.name === "DialogTitle").length === 1; - const hasOneContnet = children.filter(child => child.openingElement.name.type === utils_1.AST_NODE_TYPES.JSXIdentifier && - child.openingElement.name.name === "DialogContent").length === 1; - const hasOneAction = children.filter(child => child.openingElement.name.type === utils_1.AST_NODE_TYPES.JSXIdentifier && - child.openingElement.name.name === "DialogActions").length === 1; - if (!hasOneTitle || !hasOneContnet || !hasOneAction || children.length !== 3) { - context.report({ - node, - messageId: "dialogBodyOneTitleOneContentOneFooter" - }); - } - } - } - }; - } -}); -exports.default = rule; diff --git a/dist/lib/rules/dialogsurface-needs-aria.d.ts b/dist/lib/rules/dialogsurface-needs-aria.d.ts deleted file mode 100644 index 651b4c5..0000000 --- a/dist/lib/rules/dialogsurface-needs-aria.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { TSESTree } from "@typescript-eslint/utils"; -declare const rule: import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<"missingAriaOnDialogSurface", [], { - JSXOpeningElement(node: TSESTree.JSXOpeningElement): void; -}>; -export default rule; diff --git a/dist/lib/rules/dialogsurface-needs-aria.js b/dist/lib/rules/dialogsurface-needs-aria.js deleted file mode 100644 index 156b980..0000000 --- a/dist/lib/rules/dialogsurface-needs-aria.js +++ /dev/null @@ -1,71 +0,0 @@ -"use strict"; -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -Object.defineProperty(exports, "__esModule", { value: true }); -const utils_1 = require("@typescript-eslint/utils"); -const jsx_ast_utils_1 = require("jsx-ast-utils"); -const labelUtils_1 = require("../util/labelUtils"); -const hasNonEmptyProp_1 = require("../util/hasNonEmptyProp"); -const hasTextContentChild_1 = require("../util/hasTextContentChild"); -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ -const rule = utils_1.ESLintUtils.RuleCreator.withoutDocs({ - defaultOptions: [], - meta: { - // possible error messages for the rule - messages: { - missingAriaOnDialogSurface: "DialogueSurface need accessible labelling: aria-describedby on DialogueSurface and aria-label or aria-labelledby(if DialogueTitle is missing)" - }, - // "problem" means the rule is identifying code that either will cause an error or may cause a confusing behavior: https://eslint.org/docs/latest/developer-guide/working-with-rules - type: "problem", - // docs for the rule - docs: { - description: "DialogueSurface need accessible labelling: aria-describedby on DialogueSurface and aria-label or aria-labelledby(if DialogueTitle is missing)", - recommended: "strict", - url: "https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/" // URL to the documentation page for this rule - }, - schema: [] - }, - create(context) { - return { - // visitor functions for different types of nodes - JSXOpeningElement(node) { - // if it is not a DialogSurface, return - if ((0, jsx_ast_utils_1.elementType)(node) !== "DialogSurface") { - return; - } - // determine if DialogSurface as aria-describedby - const hasAriaDescribedBy = (0, labelUtils_1.hasAssociatedAriaText)(node, context, "aria-describedby"); - // find DialogBody Component - const dialogueSurfaceChildren = node.parent && - node.parent.type === utils_1.AST_NODE_TYPES.JSXElement && - node.parent.children.filter(child => child.type === "JSXElement"); - if (dialogueSurfaceChildren) { - const DialogBodyNode = dialogueSurfaceChildren.find(child => child.openingElement.name.type === utils_1.AST_NODE_TYPES.JSXIdentifier && - child.openingElement.name.name === "DialogBody"); - // find DialogTitle inside DialogBody Component - const dialogueBodyChildren = DialogBodyNode && DialogBodyNode.children.filter(child => child.type === "JSXElement"); - const DialogTitleNode = dialogueBodyChildren && - dialogueBodyChildren.find(child => child.openingElement.name.type === utils_1.AST_NODE_TYPES.JSXIdentifier && - child.openingElement.name.name === "DialogTitle"); - // determine if DialogueText has any text content - const hasDialogTitleText = DialogTitleNode && (0, hasTextContentChild_1.hasTextContentChild)(DialogTitleNode); - // determine if DialogueText or aria-label is present - const hasTitleOrAriaLabelledBy = hasDialogTitleText || - (0, hasNonEmptyProp_1.hasNonEmptyProp)(node.attributes, "aria-label") || - (0, labelUtils_1.hasAssociatedAriaText)(node, context, "aria-labelledby"); - // if the DialogSurface has aria labelling and description, return - if (hasAriaDescribedBy && hasTitleOrAriaLabelledBy) { - return; - } - context.report({ - node, - messageId: `missingAriaOnDialogSurface` - }); - } - } - }; - } -}); -exports.default = rule; diff --git a/dist/lib/rules/dropdown-needs-labelling.d.ts b/dist/lib/rules/dropdown-needs-labelling.d.ts deleted file mode 100644 index dbdb20e..0000000 --- a/dist/lib/rules/dropdown-needs-labelling.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { TSESTree } from "@typescript-eslint/utils"; -declare const rule: import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<"missingLabelOrAriaLabeledByInDropdown", [], { - JSXOpeningElement(node: TSESTree.JSXOpeningElement): void; -}>; -export default rule; diff --git a/dist/lib/rules/dropdown-needs-labelling.js b/dist/lib/rules/dropdown-needs-labelling.js deleted file mode 100644 index ccdf2e6..0000000 --- a/dist/lib/rules/dropdown-needs-labelling.js +++ /dev/null @@ -1,56 +0,0 @@ -"use strict"; -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -Object.defineProperty(exports, "__esModule", { value: true }); -const utils_1 = require("@typescript-eslint/utils"); -const jsx_ast_utils_1 = require("jsx-ast-utils"); -const labelUtils_1 = require("../util/labelUtils"); -const hasNonEmptyProp_1 = require("../util/hasNonEmptyProp"); -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ -const rule = utils_1.ESLintUtils.RuleCreator.withoutDocs({ - defaultOptions: [], - meta: { - // possible error messages for the rule - messages: { - missingLabelOrAriaLabeledByInDropdown: "Accessibility: Dropdown mising label or missing aria-labelledby" - }, - // "problem" means the rule is identifying code that either will cause an error or may cause a confusing behavior: https://eslint.org/docs/latest/developer-guide/working-with-rules - type: "problem", - // docs for the rule - docs: { - description: "Accessibility: Dropdown menu must have an id and it needs to be linked via htmlFor of a Label", - recommended: "strict" - }, - schema: [] - }, - // create (function) returns an object with methods that ESLint calls to “visit” nodes while traversing the abstract syntax tree - create(context) { - return { - // visitor functions for different types of nodes - JSXOpeningElement(node) { - // if it is not a Dropdown, return - if ((0, jsx_ast_utils_1.elementType)(node) !== "Dropdown") { - return; - } - // if the dropdown has a aria-LabeledBy with same value present in id of Label, return (Most recommended) - // if the dropdown has an id and a label with htmlFor with sanme value as id, return - // if the dropdown has an associated label, return - // if the dropdown is inside Label tag, return - if ((0, labelUtils_1.hasAssociatedLabelViaHtmlFor)(node, context) || - (0, labelUtils_1.hasAssociatedLabelViaAriaLabelledBy)(node, context) || - (0, hasNonEmptyProp_1.hasNonEmptyProp)(node.attributes, "aria-label") || - (0, labelUtils_1.isInsideLabelTag)(context)) { - return; - } - // if it has no visual labelling, report error - context.report({ - node, - messageId: `missingLabelOrAriaLabeledByInDropdown` - }); - } - }; - } -}); -exports.default = rule; diff --git a/dist/lib/rules/field-needs-labelling.d.ts b/dist/lib/rules/field-needs-labelling.d.ts deleted file mode 100644 index 01fa01d..0000000 --- a/dist/lib/rules/field-needs-labelling.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -export namespace meta { - namespace messages { - let noUnlabelledField: string; - } - let type: string; - namespace docs { - let description: string; - let recommended: boolean; - let url: string; - } - let schema: never[]; -} -export function create(context: any): { - JSXOpeningElement(node: any): void; -}; diff --git a/dist/lib/rules/field-needs-labelling.js b/dist/lib/rules/field-needs-labelling.js deleted file mode 100644 index eb3af8e..0000000 --- a/dist/lib/rules/field-needs-labelling.js +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -"use strict"; -const { hasNonEmptyProp } = require("../util/hasNonEmptyProp"); -const elementType = require("jsx-ast-utils").elementType; -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ -module.exports = { - meta: { - // possible error messages for the rule - messages: { - noUnlabelledField: "Accessibility: Field must have either label, validationMessage and hint attributes" - }, - // "problem" means the rule is identifying code that either will cause an error or may cause a confusing behavior: https://eslint.org/docs/latest/developer-guide/working-with-rules - type: "problem", - // docs for the rule - docs: { - description: "Accessibility: Field must have either label, validationMessage and hint attributes", - recommended: true, - url: "https://www.w3.org/TR/html-aria/" // URL to the documentation page for this rule - }, - schema: [] - }, - // create (function) returns an object with methods that ESLint calls to “visit” nodes while traversing the abstract syntax tree - create(context) { - return { - // visitor functions for different types of nodes - JSXOpeningElement(node) { - // if it is not a Spinner, return - if (elementType(node) !== "Field") { - return; - } - if (hasNonEmptyProp(node.attributes, "label", true) && - (hasNonEmptyProp(node.attributes, "validationMessage", true) || hasNonEmptyProp(node.attributes, "hint", true))) { - return; - } - // if it has no visual labelling, report error - context.report({ - node, - messageId: `noUnlabelledField` - }); - } - }; - } -}; diff --git a/dist/lib/rules/image-link-missing-aria.d.ts b/dist/lib/rules/image-link-missing-aria.d.ts deleted file mode 100644 index de4c0ec..0000000 --- a/dist/lib/rules/image-link-missing-aria.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -declare const _exports: import("eslint").Rule.RuleModule; -export = _exports; diff --git a/dist/lib/rules/image-link-missing-aria.js b/dist/lib/rules/image-link-missing-aria.js deleted file mode 100644 index 1d34ebb..0000000 --- a/dist/lib/rules/image-link-missing-aria.js +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -"use strict"; -const { hasProp, elementType } = require("jsx-ast-utils"); -const { flattenChildren } = require("../util/flattenChildren"); -const { hasNonEmptyProp } = require("../util/hasNonEmptyProp"); -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ -/** @type {import('eslint').Rule.RuleModule} */ -module.exports = { - meta: { - type: "problem", - docs: { - description: "Accessibility: Image links must have an accessible name", - recommended: true, - url: "https://www.w3.org/WAI/standards-guidelines/act/rules/c487ae/" // URL to the documentation page for this rule - }, - messages: { - missingAriaLabel: "Accessibility Rule: Image links must have an accessible name. Link can have a title attribute or text content, or Image can have an aria-label, aria-labelledby, or title attribute." - }, - fixable: "code", - schema: [] // Add a schema if the rule has options - }, - // create (function) returns an object with methods that ESLint calls to “visit” nodes while traversing the abstract syntax tree - create(context) { - //---------------------------------------------------------------------- - // Public - //---------------------------------------------------------------------- - return { - // visitor functions for different types of nodes - JSXOpeningElement(node) { - if (elementType(node) === "Link") { - const flatChildren = flattenChildren(node.parent); - // Check if there is text content - const hasTextContent = flatChildren.some(child => (child.type === "JSXText" ? child.value.trim().length > 0 : false)); - if (hasTextContent) - return; - // Check if there is an accessible link - const hasAccessibleLink = hasNonEmptyProp(node.attributes, "title") || - hasNonEmptyProp(node.attributes, "aria-label") || - hasNonEmptyProp(node.attributes, "aria-labelledby"); - if (hasAccessibleLink) - return; - // Check if there is an accessible image - const hasAccessibleImage = flatChildren.some(child => { - if (child.type === "JSXElement" && child.openingElement.name.name === "Image") { - return hasProp(child.openingElement.attributes, "aria-hidden") - ? false - : hasNonEmptyProp(child.openingElement.attributes, "title") || - hasNonEmptyProp(child.openingElement.attributes, "aria-label") || - hasNonEmptyProp(child.openingElement.attributes, "aria-labelledby"); - } - return false; - }); - if (hasAccessibleImage) - return; - // Report if there is no text content, accessible link or image - if (!hasTextContent && !hasAccessibleLink && !hasAccessibleImage) { - context.report({ - node, - messageId: `missingAriaLabel` - }); - } - } - } - }; - } -}; diff --git a/dist/lib/rules/input-components-require-accessible-name.d.ts b/dist/lib/rules/input-components-require-accessible-name.d.ts deleted file mode 100644 index 00b3681..0000000 --- a/dist/lib/rules/input-components-require-accessible-name.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { TSESTree } from "@typescript-eslint/utils"; -declare const rule: import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<"missingLabelOnInput", [], { - JSXOpeningElement(node: TSESTree.JSXOpeningElement): void; -}>; -export default rule; diff --git a/dist/lib/rules/input-components-require-accessible-name.js b/dist/lib/rules/input-components-require-accessible-name.js deleted file mode 100644 index 6aa199b..0000000 --- a/dist/lib/rules/input-components-require-accessible-name.js +++ /dev/null @@ -1,53 +0,0 @@ -"use strict"; -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -Object.defineProperty(exports, "__esModule", { value: true }); -const utils_1 = require("@typescript-eslint/utils"); -const jsx_ast_utils_1 = require("jsx-ast-utils"); -const labelUtils_1 = require("../util/labelUtils"); -const hasFieldParent_1 = require("../util/hasFieldParent"); -const inputBasedComponents_1 = require("../applicableComponents/inputBasedComponents"); -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ -const rule = utils_1.ESLintUtils.RuleCreator.withoutDocs({ - defaultOptions: [], - meta: { - // possible error messages for the rule - messages: { - missingLabelOnInput: `Accessibility - input fields must have a aria label associated with it: ${inputBasedComponents_1.applicableComponents.join(", ")}` - }, - // "problem" means the rule is identifying code that either will cause an error or may cause a confusing behavior: https://eslint.org/docs/latest/developer-guide/working-with-rules - type: "problem", - // docs for the rule - docs: { - description: "Accessibility: Input fields must have accessible labelling: aria-label, aria-labelledby or an associated label", - recommended: "strict", - url: "https://www.w3.org/WAI/tutorials/forms/labels/" // URL to the documentation page for this rule - }, - schema: [] - }, - create(context) { - return { - // visitor functions for different types of nodes - JSXOpeningElement(node) { - // if it is not a listed component, return - if (!inputBasedComponents_1.applicableComponents.includes((0, jsx_ast_utils_1.elementType)(node))) { - return; - } - // wrapped in Label tag, labelled with htmlFor, labelled with aria-labelledby - if ((0, hasFieldParent_1.hasFieldParent)(context) || - (0, labelUtils_1.isInsideLabelTag)(context) || - (0, labelUtils_1.hasAssociatedLabelViaHtmlFor)(node, context) || - (0, labelUtils_1.hasAssociatedLabelViaAriaLabelledBy)(node, context)) { - return; - } - context.report({ - node, - messageId: `missingLabelOnInput` - }); - } - }; - } -}); -exports.default = rule; diff --git a/dist/lib/rules/link-missing-labelling.d.ts b/dist/lib/rules/link-missing-labelling.d.ts deleted file mode 100644 index 8c36a14..0000000 --- a/dist/lib/rules/link-missing-labelling.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { TSESTree } from "@typescript-eslint/utils"; -declare const rule: import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<"missingAriaLabel" | "missingHref", [], { - JSXElement(node: TSESTree.JSXElement): void; -}>; -export default rule; diff --git a/dist/lib/rules/link-missing-labelling.js b/dist/lib/rules/link-missing-labelling.js deleted file mode 100644 index e4ebc47..0000000 --- a/dist/lib/rules/link-missing-labelling.js +++ /dev/null @@ -1,79 +0,0 @@ -"use strict"; -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -Object.defineProperty(exports, "__esModule", { value: true }); -const utils_1 = require("@typescript-eslint/utils"); -const jsx_ast_utils_1 = require("jsx-ast-utils"); -const hasNonEmptyProp_1 = require("../util/hasNonEmptyProp"); -const hasTextContentChild_1 = require("../util/hasTextContentChild"); -const hasLabelledChildImage_1 = require("../util/hasLabelledChildImage"); -const linkBasedComponents_1 = require("../applicableComponents/linkBasedComponents"); -const labelUtils_1 = require("../util/labelUtils"); -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ -const rule = utils_1.ESLintUtils.RuleCreator.withoutDocs({ - defaultOptions: [], - meta: { - type: "problem", - docs: { - description: "Accessibility: Image links must have an accessible name. Add either text content, labelling to the image or labelling to the link itself.", - recommended: "strict", - url: "https://www.w3.org/WAI/standards-guidelines/act/rules/c487ae/" // URL to the documentation page for this rule - }, - messages: { - missingAriaLabel: "Accessibility Rule: Image links must have an accessible name. Link can have a title attribute or text content, or Image can have an aria-label, aria-labelledby, or title attribute.", - missingHref: "Links must have an href" - }, - fixable: "code", - schema: [] // Add a schema if the rule has options - }, - // create (function) returns an object with methods that ESLint calls to “visit” nodes while traversing the abstract syntax tree - create(context) { - //---------------------------------------------------------------------- - // Public - //---------------------------------------------------------------------- - return { - // visitor functions for different types of nodes - JSXElement(node) { - const openingElement = node.openingElement; - // if it's not a link based component, return - if (!linkBasedComponents_1.linkBasedComponents.includes((0, jsx_ast_utils_1.elementType)(openingElement))) { - return; - } - const hasHref = (0, hasNonEmptyProp_1.hasNonEmptyProp)(openingElement.attributes, "href"); - // check if the link has an href - if (!hasHref) { - context.report({ - node, - messageId: `missingHref` - }); - } - // if it has text content, return - if ((0, hasTextContentChild_1.hasTextContentChild)(node)) { - return; - } - // if there is a containing image and it is labelled correctly, return - const hasAccessibleImage = (0, hasLabelledChildImage_1.hasLabelledChildImage)(node); - if (hasAccessibleImage) { - return; - } - // Check if there is an accessible link - const linkHasAccessibleLabel = (0, hasNonEmptyProp_1.hasNonEmptyProp)(openingElement.attributes, "title") || - (0, hasNonEmptyProp_1.hasNonEmptyProp)(openingElement.attributes, "aria-label") || - (0, labelUtils_1.hasAssociatedLabelViaAriaLabelledBy)(openingElement, context); - if (linkHasAccessibleLabel) { - return; - } - // Report if there is no text content, accessible link or image - if (!linkHasAccessibleLabel || !hasAccessibleImage) { - context.report({ - node, - messageId: `missingAriaLabel` - }); - } - } - }; - } -}); -exports.default = rule; diff --git a/dist/lib/rules/menu-item-needs-labelling.d.ts b/dist/lib/rules/menu-item-needs-labelling.d.ts deleted file mode 100644 index b830d80..0000000 --- a/dist/lib/rules/menu-item-needs-labelling.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { TSESTree } from "@typescript-eslint/utils"; -declare const rule: import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<"noUnlabelledMenuItem", [], { - JSXElement(node: TSESTree.JSXElement): void; -}>; -export default rule; diff --git a/dist/lib/rules/menu-item-needs-labelling.js b/dist/lib/rules/menu-item-needs-labelling.js deleted file mode 100644 index 6b19020..0000000 --- a/dist/lib/rules/menu-item-needs-labelling.js +++ /dev/null @@ -1,56 +0,0 @@ -"use strict"; -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -Object.defineProperty(exports, "__esModule", { value: true }); -const utils_1 = require("@typescript-eslint/utils"); -const jsx_ast_utils_1 = require("jsx-ast-utils"); -const hasNonEmptyProp_1 = require("../util/hasNonEmptyProp"); -const labelUtils_1 = require("../util/labelUtils"); -const hasTextContentChild_1 = require("../util/hasTextContentChild"); -const hasTooltipParent_1 = require("../util/hasTooltipParent"); -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ -const rule = utils_1.ESLintUtils.RuleCreator.withoutDocs({ - defaultOptions: [], - meta: { - // possible error messages for the rule - messages: { - noUnlabelledMenuItem: "Accessibility: MenuItem must have an accessible label" - }, - // "problem" means the rule is identifying code that either will cause an error or may cause a confusing behavior: https://eslint.org/docs/latest/developer-guide/working-with-rules - type: "problem", - docs: { - description: "Accessibility: MenuItem without label must have an accessible and visual label: aria-labelledby", - recommended: "strict", - url: "https://www.w3.org/TR/html-aria/" // URL to the documentation page for this rule - }, - schema: [] // Add a schema if the rule has options - }, - create(context) { - return { - // visitor functions for different types of nodes - JSXElement(node) { - const openingElement = node.openingElement; - // if it is not a MenuItem, return - if ((0, jsx_ast_utils_1.elementType)(openingElement) !== "MenuItem") { - return; - } - // if the MenuItem has a text, label or an associated label, return - if ((0, hasNonEmptyProp_1.hasNonEmptyProp)(openingElement.attributes, "aria-label") || //aria-label, not recommended but will work for screen reader users - (0, labelUtils_1.hasAssociatedLabelViaAriaLabelledBy)(openingElement, context) || // aria-labelledby - (0, hasTextContentChild_1.hasTextContentChild)(node) || // has text content - (0, hasTooltipParent_1.hasToolTipParent)(context) // has tooltip parent, not recommended but will work for screen reader users - ) { - return; - } - // if it has no visual labelling, report error - context.report({ - node, - messageId: `noUnlabelledMenuItem` - }); - } - }; - } -}); -exports.default = rule; diff --git a/dist/lib/rules/no-empty-components.d.ts b/dist/lib/rules/no-empty-components.d.ts deleted file mode 100644 index 5ebe065..0000000 --- a/dist/lib/rules/no-empty-components.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { TSESTree } from "@typescript-eslint/utils"; -declare const rule: import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<"noEmptyComponents", [], { - JSXElement(node: TSESTree.JSXElement): void; -}>; -export default rule; diff --git a/dist/lib/rules/no-empty-components.js b/dist/lib/rules/no-empty-components.js deleted file mode 100644 index 0528eaa..0000000 --- a/dist/lib/rules/no-empty-components.js +++ /dev/null @@ -1,48 +0,0 @@ -"use strict"; -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -Object.defineProperty(exports, "__esModule", { value: true }); -const utils_1 = require("@typescript-eslint/utils"); -const jsx_ast_utils_1 = require("jsx-ast-utils"); -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ -// Define an array of allowed component names -const allowedComponents = ["Text", "Label", "Combobox", "Breadcrumb", "Dropdown", "Accordion", "AccordionItem", "AccordionPanel"]; -const rule = utils_1.ESLintUtils.RuleCreator.withoutDocs({ - defaultOptions: [], - meta: { - // possible error messages for the lint rule - messages: { - noEmptyComponents: `Accessibility: no empty ${allowedComponents.join(", ")} components` - }, - type: "problem", // `problem`, `suggestion`, or `layout` - docs: { - description: "FluentUI components should not be empty", - recommended: "strict" - }, - schema: [] // Add a schema if the rule has options - }, - // create (function) returns an object with methods that ESLint calls to “visit” nodes while traversing the abstract syntax tree - create(context) { - return { - // visitor functions for different types of nodes - JSXElement(node) { - const openingElement = node.openingElement; - // if it is not a listed component, return - if (!allowedComponents.includes((0, jsx_ast_utils_1.elementType)(openingElement))) { - return; - } - const hasChildren = node.children.length > 0; - // if there are no children, report error - if (!hasChildren) { - context.report({ - node, - messageId: `noEmptyComponents` - }); - } - } - }; - } -}); -exports.default = rule; diff --git a/dist/lib/rules/prefer-aria-over-title-attribute.d.ts b/dist/lib/rules/prefer-aria-over-title-attribute.d.ts deleted file mode 100644 index 12896b8..0000000 --- a/dist/lib/rules/prefer-aria-over-title-attribute.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { TSESTree } from "@typescript-eslint/types"; -declare const rule: import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<"preferAria", [], { - JSXElement(node: TSESTree.JSXElement): void; -}>; -export default rule; diff --git a/dist/lib/rules/prefer-aria-over-title-attribute.js b/dist/lib/rules/prefer-aria-over-title-attribute.js deleted file mode 100644 index d857f91..0000000 --- a/dist/lib/rules/prefer-aria-over-title-attribute.js +++ /dev/null @@ -1,81 +0,0 @@ -"use strict"; -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -Object.defineProperty(exports, "__esModule", { value: true }); -const utils_1 = require("@typescript-eslint/utils"); -const types_1 = require("@typescript-eslint/types"); -const jsx_ast_utils_1 = require("jsx-ast-utils"); -const labelUtils_1 = require("../util/labelUtils"); -const hasNonEmptyProp_1 = require("../util/hasNonEmptyProp"); -const hasTooltipParent_1 = require("../util/hasTooltipParent"); -const hasTextContentChild_1 = require("../util/hasTextContentChild"); -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ -const applicableComponents = ["Button"]; -const rule = utils_1.ESLintUtils.RuleCreator.withoutDocs({ - defaultOptions: [], - meta: { - // possible error messages for the rule - messages: { - preferAria: `Prefer aria over the title attribute for accessible labelling: ${applicableComponents.join(", ")}` - }, - type: "suggestion", // `problem`, `suggestion`, or `layout` - docs: { - description: "The title attribute is not consistently read by screen readers, and its behavior can vary depending on the screen reader and the user's settings.", - recommended: "warn" - }, - fixable: "code", // Or `code` or `whitespace` - schema: [] // Add a schema if the rule has options - }, - create(context) { - return { - // visitor functions for different types of nodes - JSXElement(node) { - const openingElement = node.openingElement; - // if it is not a listed component, return - if (!applicableComponents.includes((0, jsx_ast_utils_1.elementType)(openingElement))) { - return; - } - // if it is not an icon button, return - if (!(0, jsx_ast_utils_1.hasProp)(openingElement.attributes, "icon")) { - return; - } - // if it has a tooltip parent, return - if ((0, hasTooltipParent_1.hasToolTipParent)(context)) { - return; - } - // if it has text content, return - if ((0, hasTextContentChild_1.hasTextContentChild)(node)) { - return; - } - // the button has an associated label - if ((0, labelUtils_1.hasAssociatedLabelViaAriaLabelledBy)(openingElement, context)) { - return; - } - const hasAria = (0, hasNonEmptyProp_1.hasNonEmptyProp)(openingElement.attributes, "aria-label"); - const hasTitle = (0, hasNonEmptyProp_1.hasNonEmptyProp)(openingElement.attributes, "title"); - // if it has no accessible name, report error - if (hasTitle && !hasAria) { - context.report({ - node, - messageId: `preferAria`, - fix(fixer) { - const attributes = openingElement.attributes; - const titleAttribute = attributes.find(attr => attr.type === types_1.AST_NODE_TYPES.JSXAttribute && attr.name && attr.name.name === "title"); - // Generate the aria-label attribute - const ariaLabel = ` aria-label="${titleAttribute && titleAttribute.type === types_1.AST_NODE_TYPES.JSXAttribute && titleAttribute.value - ? titleAttribute.value.value - : ""}"`; - // Find the location to insert the new attribute - const lastAttribute = attributes[attributes.length - 1]; - const insertPosition = lastAttribute.range[1]; - return fixer.insertTextAfterRange([insertPosition, insertPosition], ariaLabel); - } - }); - } - } - }; - } -}); -exports.default = rule; diff --git a/dist/lib/rules/progressbar-needs-labelling.d.ts b/dist/lib/rules/progressbar-needs-labelling.d.ts deleted file mode 100644 index 85b4d29..0000000 --- a/dist/lib/rules/progressbar-needs-labelling.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { TSESTree } from "@typescript-eslint/utils"; -declare const rule: import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<"noUnlabelledProgressbar", [], { - JSXOpeningElement(node: TSESTree.JSXOpeningElement): void; -}>; -export default rule; diff --git a/dist/lib/rules/progressbar-needs-labelling.js b/dist/lib/rules/progressbar-needs-labelling.js deleted file mode 100644 index 1b79719..0000000 --- a/dist/lib/rules/progressbar-needs-labelling.js +++ /dev/null @@ -1,65 +0,0 @@ -"use strict"; -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -Object.defineProperty(exports, "__esModule", { value: true }); -const utils_1 = require("@typescript-eslint/utils"); -const jsx_ast_utils_1 = require("jsx-ast-utils"); -const hasFieldParent_1 = require("../util/hasFieldParent"); -const hasNonEmptyProp_1 = require("../util/hasNonEmptyProp"); -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ -const rule = utils_1.ESLintUtils.RuleCreator.withoutDocs({ - defaultOptions: [], - meta: { - // possible error messages for the rule - messages: { - noUnlabelledProgressbar: "Accessibility: Progressbar must have aria-valuemin, aria-valuemax, aria-valuenow, aria-describedby and either aria-label or aria-labelledby attributes" - }, - // "problem" means the rule is identifying code that either will cause an error or may cause a confusing behavior: https://eslint.org/docs/latest/developer-guide/working-with-rules - type: "problem", - // docs for the rule - docs: { - description: "Accessibility: Progressbar must have aria-valuemin, aria-valuemax, aria-valuenow, aria-describedby and either aria-label or aria-labelledby attributes", - recommended: "strict", - url: "https://www.w3.org/TR/html-aria/" // URL to the documentation page for this rule - }, - schema: [] - }, - // create (function) returns an object with methods that ESLint calls to “visit” nodes while traversing the abstract syntax tree - create(context) { - return { - // visitor functions for different types of nodes - JSXOpeningElement(node) { - // if it is not a ProgressBar, return - if ((0, jsx_ast_utils_1.elementType)(node) !== "ProgressBar") { - return; - } - // check if the ProgressBar has a Field parent - const hasFieldParentCheck = (0, hasFieldParent_1.hasFieldParent)(context); - // If no Field parent, ensure one of the aria-label or aria-labelledby is provided as well as aria-describedby - const hasLabelling = ((0, hasNonEmptyProp_1.hasNonEmptyProp)(node.attributes, "aria-label") || (0, hasNonEmptyProp_1.hasNonEmptyProp)(node.attributes, "aria-labelledby")) && - (0, hasNonEmptyProp_1.hasNonEmptyProp)(node.attributes, "aria-describedby"); - const mandatoryAttributes = []; - // Check if max is provided, if not, require aria-valuemax - const hasMaxProp = (0, hasNonEmptyProp_1.hasNonEmptyProp)(node.attributes, "max"); - if (!hasMaxProp) { - mandatoryAttributes.push("aria-valuemax"); - mandatoryAttributes.push("aria-valuemin"); - mandatoryAttributes.push("aria-valuenow"); - } - // If all mandatory attributes (including optional aria-valuemax) are present, return - if (mandatoryAttributes.every(attribute => (0, hasNonEmptyProp_1.hasNonEmptyProp)(node.attributes, attribute)) && - (hasFieldParentCheck || hasLabelling)) { - return; - } - // if it has no visual labelling, report error - context.report({ - node, - messageId: `noUnlabelledProgressbar` - }); - } - }; - } -}); -exports.default = rule; diff --git a/dist/lib/rules/radio-button-missing-label.d.ts b/dist/lib/rules/radio-button-missing-label.d.ts deleted file mode 100644 index 23ca7db..0000000 --- a/dist/lib/rules/radio-button-missing-label.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { TSESTree } from "@typescript-eslint/utils"; -declare const rule: import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<"noUnlabeledRadioButton", [], { - JSXOpeningElement(node: TSESTree.JSXOpeningElement): void; -}>; -export default rule; diff --git a/dist/lib/rules/radio-button-missing-label.js b/dist/lib/rules/radio-button-missing-label.js deleted file mode 100644 index e6812ac..0000000 --- a/dist/lib/rules/radio-button-missing-label.js +++ /dev/null @@ -1,58 +0,0 @@ -"use strict"; -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -Object.defineProperty(exports, "__esModule", { value: true }); -const utils_1 = require("@typescript-eslint/utils"); -const jsx_ast_utils_1 = require("jsx-ast-utils"); -const hasNonEmptyProp_1 = require("../util/hasNonEmptyProp"); -const labelUtils_1 = require("../util/labelUtils"); -const hasFieldParent_1 = require("../util/hasFieldParent"); -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ -const rule = utils_1.ESLintUtils.RuleCreator.withoutDocs({ - defaultOptions: [], - meta: { - // possible error messages for the rule - messages: { - noUnlabeledRadioButton: "Accessibility: Radio button without label must have an accessible and visual label: aria-labelledby" - }, - // "problem" means the rule is identifying code that either will cause an error or may cause a confusing behavior: https://eslint.org/docs/latest/developer-guide/working-with-rules - type: "problem", - // docs for the rule - docs: { - // DONE - description: "Accessibility: Radio button without label must have an accessible and visual label: aria-labelledby", - recommended: "strict", - url: "https://www.w3.org/TR/html-aria/" // URL to the documentation page for this rule - }, - schema: [] - }, - // create (function) returns an object with methods that ESLint calls to “visit” nodes while traversing the abstract syntax tree - create(context) { - return { - // visitor functions for different types of nodes - JSXOpeningElement(node) { - // if it is not a Checkbox, return - if ((0, jsx_ast_utils_1.elementType)(node) !== "Radio") { - return; - } - // if the Checkbox has a label, if the Switch has an associated label, return - if ((0, hasFieldParent_1.hasFieldParent)(context) || - (0, hasNonEmptyProp_1.hasNonEmptyProp)(node.attributes, "label") || - (0, hasNonEmptyProp_1.hasNonEmptyProp)(node.attributes, "aria-label") || - (0, labelUtils_1.isInsideLabelTag)(context) || - (0, labelUtils_1.hasAssociatedLabelViaHtmlFor)(node, context) || - (0, labelUtils_1.hasAssociatedLabelViaAriaLabelledBy)(node, context)) { - return; - } - // if it has no visual labelling, report error - context.report({ - node, - messageId: `noUnlabeledRadioButton` - }); - } - }; - } -}); -exports.default = rule; diff --git a/dist/lib/rules/radiogroup-missing-label.d.ts b/dist/lib/rules/radiogroup-missing-label.d.ts deleted file mode 100644 index ba22572..0000000 --- a/dist/lib/rules/radiogroup-missing-label.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { TSESTree } from "@typescript-eslint/utils"; -declare const rule: import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<"noUnlabeledRadioGroup", [], { - JSXOpeningElement(node: TSESTree.JSXOpeningElement): void; -}>; -export default rule; diff --git a/dist/lib/rules/radiogroup-missing-label.js b/dist/lib/rules/radiogroup-missing-label.js deleted file mode 100644 index 817099d..0000000 --- a/dist/lib/rules/radiogroup-missing-label.js +++ /dev/null @@ -1,58 +0,0 @@ -"use strict"; -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -Object.defineProperty(exports, "__esModule", { value: true }); -const utils_1 = require("@typescript-eslint/utils"); -const jsx_ast_utils_1 = require("jsx-ast-utils"); -const hasNonEmptyProp_1 = require("../util/hasNonEmptyProp"); -const labelUtils_1 = require("../util/labelUtils"); -const hasFieldParent_1 = require("../util/hasFieldParent"); -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ -const rule = utils_1.ESLintUtils.RuleCreator.withoutDocs({ - defaultOptions: [], - meta: { - // possible error messages for the rule - messages: { - noUnlabeledRadioGroup: "Accessibility: RadioGroup without label must have an accessible and visual label: aria-labelledby" - }, - // "problem" means the rule is identifying code that either will cause an error or may cause a confusing behavior: https://eslint.org/docs/latest/developer-guide/working-with-rules - type: "problem", - // docs for the rule - docs: { - // DONE - description: "Accessibility: RadioGroup without label must have an accessible and visual label: aria-labelledby", - recommended: "strict", - url: "https://www.w3.org/TR/html-aria/" // URL to the documentation page for this rule - }, - schema: [] - }, - // create (function) returns an object with methods that ESLint calls to “visit” nodes while traversing the abstract syntax tree - create(context) { - return { - // visitor functions for different types of nodes - JSXOpeningElement(node) { - // if it is not a Checkbox, return - if ((0, jsx_ast_utils_1.elementType)(node) !== "RadioGroup") { - return; - } - // if the Checkbox has a label, if the Switch has an associated label, return - if ((0, hasFieldParent_1.hasFieldParent)(context) || - (0, hasNonEmptyProp_1.hasNonEmptyProp)(node.attributes, "label") || - (0, hasNonEmptyProp_1.hasNonEmptyProp)(node.attributes, "aria-label") || - (0, labelUtils_1.isInsideLabelTag)(context) || - (0, labelUtils_1.hasAssociatedLabelViaHtmlFor)(node, context) || - (0, labelUtils_1.hasAssociatedLabelViaAriaLabelledBy)(node, context)) { - return; - } - // if it has no visual labelling, report error - context.report({ - node, - messageId: `noUnlabeledRadioGroup` - }); - } - }; - } -}); -exports.default = rule; diff --git a/dist/lib/rules/spin-button-needs-labelling.d.ts b/dist/lib/rules/spin-button-needs-labelling.d.ts deleted file mode 100644 index df462b9..0000000 --- a/dist/lib/rules/spin-button-needs-labelling.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { TSESTree } from "@typescript-eslint/utils"; -declare const rule: import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<"noUnlabelledSpinButton", [], { - JSXOpeningElement(node: TSESTree.JSXOpeningElement): void; -}>; -export default rule; diff --git a/dist/lib/rules/spin-button-needs-labelling.js b/dist/lib/rules/spin-button-needs-labelling.js deleted file mode 100644 index eec2150..0000000 --- a/dist/lib/rules/spin-button-needs-labelling.js +++ /dev/null @@ -1,54 +0,0 @@ -"use strict"; -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -Object.defineProperty(exports, "__esModule", { value: true }); -const utils_1 = require("@typescript-eslint/utils"); -const jsx_ast_utils_1 = require("jsx-ast-utils"); -const labelUtils_1 = require("../util/labelUtils"); -const hasFieldParent_1 = require("../util/hasFieldParent"); -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ -const rule = utils_1.ESLintUtils.RuleCreator.withoutDocs({ - defaultOptions: [], - meta: { - // possible error messages for the rule - messages: { - noUnlabelledSpinButton: "Accessibility: SpinButtons must have an accessible label" - }, - // "problem" means the rule is identifying code that either will cause an error or may cause a confusing behavior: https://eslint.org/docs/latest/developer-guide/working-with-rules - type: "problem", - // docs for the rule - docs: { - description: "Accessibility: SpinButtons must have an accessible label", - recommended: "strict", - url: "https://www.w3.org/TR/html-aria/" // URL to the documentation page for this rule - }, - schema: [] - }, - // create (function) returns an object with methods that ESLint calls to “visit” nodes while traversing the abstract syntax tree - create(context) { - return { - // visitor functions for different types of nodes - JSXOpeningElement(node) { - // if it is not a SpinButton, return - if ((0, jsx_ast_utils_1.elementType)(node) !== "SpinButton") { - return; - } - // if the SpinButton has an associated label, return - if ((0, hasFieldParent_1.hasFieldParent)(context) || - (0, labelUtils_1.isInsideLabelTag)(context) || - (0, labelUtils_1.hasAssociatedLabelViaHtmlFor)(node, context) || - (0, labelUtils_1.hasAssociatedLabelViaAriaLabelledBy)(node, context)) { - return; - } - // if it has no visual labelling, report error - context.report({ - node, - messageId: `noUnlabelledSpinButton` - }); - } - }; - } -}); -exports.default = rule; diff --git a/dist/lib/rules/spin-button-unrecommended-labelling.d.ts b/dist/lib/rules/spin-button-unrecommended-labelling.d.ts deleted file mode 100644 index 5de3d41..0000000 --- a/dist/lib/rules/spin-button-unrecommended-labelling.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { TSESTree } from "@typescript-eslint/utils"; -declare const rule: import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<"unRecommendedlabellingSpinButton", [], { - JSXOpeningElement(node: TSESTree.JSXOpeningElement): void; -}>; -export default rule; diff --git a/dist/lib/rules/spin-button-unrecommended-labelling.js b/dist/lib/rules/spin-button-unrecommended-labelling.js deleted file mode 100644 index 01cd595..0000000 --- a/dist/lib/rules/spin-button-unrecommended-labelling.js +++ /dev/null @@ -1,49 +0,0 @@ -"use strict"; -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -Object.defineProperty(exports, "__esModule", { value: true }); -const utils_1 = require("@typescript-eslint/utils"); -const jsx_ast_utils_1 = require("jsx-ast-utils"); -const hasNonEmptyProp_1 = require("../util/hasNonEmptyProp"); -const hasTooltipParent_1 = require("../util/hasTooltipParent"); -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ -const rule = utils_1.ESLintUtils.RuleCreator.withoutDocs({ - defaultOptions: [], - meta: { - // possible suggestion messages for the rule - messages: { - unRecommendedlabellingSpinButton: "Accessibility: Unrecommended accessibility labelling - SpinButton" - }, - // "problem" means the rule is identifying something that could be done in a better way but no errors will occur if the code isn’t changed: https://eslint.org/docs/latest/developer-guide/working-with-rules - type: "suggestion", - // docs for the rule - docs: { - description: "Accessibility: Unrecommended accessibility labelling - SpinButton", - recommended: "strict", - url: "https://www.w3.org/TR/html-aria/" // URL to the documentation page for this rule - }, - schema: [] - }, - // create (function) returns an object with methods that ESLint calls to “visit” nodes while traversing the abstract syntax tree - create(context) { - return { - // visitor functions for different types of nodes - JSXOpeningElement(node) { - // if it is not a SpinButton, return - if ((0, jsx_ast_utils_1.elementType)(node) !== "SpinButton") { - return; - } - // if the SpinButton has an aria-label or is wrapped in a Tooltip, show warning - if ((0, hasNonEmptyProp_1.hasNonEmptyProp)(node.attributes, "aria-label") || (0, hasTooltipParent_1.hasToolTipParent)(context)) { - context.report({ - node, - messageId: `unRecommendedlabellingSpinButton` - }); - } - } - }; - } -}); -exports.default = rule; diff --git a/dist/lib/rules/spinner-needs-labelling.d.ts b/dist/lib/rules/spinner-needs-labelling.d.ts deleted file mode 100644 index bc40b13..0000000 --- a/dist/lib/rules/spinner-needs-labelling.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { TSESTree } from "@typescript-eslint/utils"; -declare const rule: import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<"noUnlabelledSpinner", [], { - JSXOpeningElement(node: TSESTree.JSXOpeningElement): void; -}>; -export default rule; diff --git a/dist/lib/rules/spinner-needs-labelling.js b/dist/lib/rules/spinner-needs-labelling.js deleted file mode 100644 index bc0b298..0000000 --- a/dist/lib/rules/spinner-needs-labelling.js +++ /dev/null @@ -1,51 +0,0 @@ -"use strict"; -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -Object.defineProperty(exports, "__esModule", { value: true }); -const utils_1 = require("@typescript-eslint/utils"); -const jsx_ast_utils_1 = require("jsx-ast-utils"); -const hasNonEmptyProp_1 = require("../util/hasNonEmptyProp"); -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ -const rule = utils_1.ESLintUtils.RuleCreator.withoutDocs({ - defaultOptions: [], - meta: { - // possible error messages for the rule - messages: { - noUnlabelledSpinner: "Accessibility: Spinner must have either aria-label or label, aria-live and aria-busy attributes" - }, - // "problem" means the rule is identifying code that either will cause an error or may cause a confusing behavior: https://eslint.org/docs/latest/developer-guide/working-with-rules - type: "problem", - // docs for the rule - docs: { - description: "Accessibility: Spinner must have either aria-label or label, aria-live and aria-busy attributes", - recommended: "strict", - url: "https://www.w3.org/TR/html-aria/" // URL to the documentation page for this rule - }, - schema: [] - }, - // create (function) returns an object with methods that ESLint calls to “visit” nodes while traversing the abstract syntax tree - create(context) { - return { - // visitor functions for different types of nodes - JSXOpeningElement(node) { - // if it is not a Spinner, return - if ((0, jsx_ast_utils_1.elementType)(node) !== "Spinner") { - return; - } - if ((0, hasNonEmptyProp_1.hasNonEmptyProp)(node.attributes, "aria-busy") && - (0, hasNonEmptyProp_1.hasNonEmptyProp)(node.attributes, "aria-live") && - ((0, hasNonEmptyProp_1.hasNonEmptyProp)(node.attributes, "label") || (0, hasNonEmptyProp_1.hasNonEmptyProp)(node.attributes, "aria-label"))) { - return; - } - // if it has no visual labelling, report error - context.report({ - node, - messageId: `noUnlabelledSpinner` - }); - } - }; - } -}); -exports.default = rule; diff --git a/dist/lib/rules/switch-needs-labelling.d.ts b/dist/lib/rules/switch-needs-labelling.d.ts deleted file mode 100644 index 9a4895d..0000000 --- a/dist/lib/rules/switch-needs-labelling.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { TSESTree } from "@typescript-eslint/utils"; -declare const rule: import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<"noUnlabelledSwitch", [], { - JSXOpeningElement(node: TSESTree.JSXOpeningElement): void; -}>; -export default rule; diff --git a/dist/lib/rules/switch-needs-labelling.js b/dist/lib/rules/switch-needs-labelling.js deleted file mode 100644 index 3f357b6..0000000 --- a/dist/lib/rules/switch-needs-labelling.js +++ /dev/null @@ -1,56 +0,0 @@ -"use strict"; -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -Object.defineProperty(exports, "__esModule", { value: true }); -const utils_1 = require("@typescript-eslint/utils"); -const jsx_ast_utils_1 = require("jsx-ast-utils"); -const hasNonEmptyProp_1 = require("../util/hasNonEmptyProp"); -const labelUtils_1 = require("../util/labelUtils"); -const hasFieldParent_1 = require("../util/hasFieldParent"); -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ -const rule = utils_1.ESLintUtils.RuleCreator.withoutDocs({ - defaultOptions: [], - meta: { - // possible error messages for the rule - messages: { - noUnlabelledSwitch: "Accessibility: Switch must have an accessible label" - }, - // "problem" means the rule is identifying code that either will cause an error or may cause a confusing behavior: https://eslint.org/docs/latest/developer-guide/working-with-rules - type: "problem", - // docs for the rule - docs: { - description: "Accessibility: Switch must have an accessible label", - recommended: "strict", - url: "https://www.w3.org/TR/html-aria/" // URL to the documentation page for this rule - }, - schema: [] - }, - // create (function) returns an object with methods that ESLint calls to “visit” nodes while traversing the abstract syntax tree - create(context) { - return { - // visitor functions for different types of nodes - JSXOpeningElement(node) { - // if it is not a Switch, return - if ((0, jsx_ast_utils_1.elementType)(node) !== "Switch") { - return; - } - // if the Switch has a label, if the Switch has an associated label, return - if ((0, hasNonEmptyProp_1.hasNonEmptyProp)(node.attributes, "label") || - (0, hasFieldParent_1.hasFieldParent)(context) || - (0, labelUtils_1.isInsideLabelTag)(context) || - (0, labelUtils_1.hasAssociatedLabelViaHtmlFor)(node, context) || - (0, labelUtils_1.hasAssociatedLabelViaAriaLabelledBy)(node, context)) { - return; - } - // if it has no visual labelling, report error - context.report({ - node, - messageId: `noUnlabelledSwitch` - }); - } - }; - } -}); -exports.default = rule; diff --git a/dist/lib/rules/toolbar-missing-aria.d.ts b/dist/lib/rules/toolbar-missing-aria.d.ts deleted file mode 100644 index 1af37a3..0000000 --- a/dist/lib/rules/toolbar-missing-aria.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { TSESTree } from "@typescript-eslint/utils"; -declare const rule: import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<"missingLabelOnToolbar", [], { - JSXOpeningElement(node: TSESTree.JSXOpeningElement): void; -}>; -export default rule; diff --git a/dist/lib/rules/toolbar-missing-aria.js b/dist/lib/rules/toolbar-missing-aria.js deleted file mode 100644 index 239fffd..0000000 --- a/dist/lib/rules/toolbar-missing-aria.js +++ /dev/null @@ -1,49 +0,0 @@ -"use strict"; -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -Object.defineProperty(exports, "__esModule", { value: true }); -const utils_1 = require("@typescript-eslint/utils"); -const jsx_ast_utils_1 = require("jsx-ast-utils"); -const labelUtils_1 = require("../util/labelUtils"); -const hasNonEmptyProp_1 = require("../util/hasNonEmptyProp"); -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ -const rule = utils_1.ESLintUtils.RuleCreator.withoutDocs({ - defaultOptions: [], - meta: { - // possible error messages for the rule - messages: { - missingLabelOnToolbar: "Toolbars need accessible labelling: aria-label or aria-labelledby" - }, - // "problem" means the rule is identifying code that either will cause an error or may cause a confusing behavior: https://eslint.org/docs/latest/developer-guide/working-with-rules - type: "problem", - // docs for the rule - docs: { - description: "Accessibility: Toolbars need accessible labelling: aria-label or aria-labelledby", - recommended: "strict", - url: "https://www.w3.org/WAI/tutorials/forms/labels/" // URL to the documentation page for this rule - }, - schema: [] - }, - create(context) { - return { - // visitor functions for different types of nodes - JSXOpeningElement(node) { - // if it is not a Toolbar, return - if ((0, jsx_ast_utils_1.elementType)(node) !== "Toolbar") { - return; - } - // if the Toolbar has aria labelling, return - if ((0, hasNonEmptyProp_1.hasNonEmptyProp)(node.attributes, "aria-label") || (0, labelUtils_1.hasAssociatedLabelViaAriaLabelledBy)(node, context)) { - return; - } - context.report({ - node, - messageId: `missingLabelOnToolbar` - }); - } - }; - } -}); -exports.default = rule; diff --git a/dist/lib/rules/tooltip-not-recommended.d.ts b/dist/lib/rules/tooltip-not-recommended.d.ts deleted file mode 100644 index c0f910b..0000000 --- a/dist/lib/rules/tooltip-not-recommended.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { TSESTree } from '@typescript-eslint/utils'; -declare const rule: import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<"tooltipNotRecommended", [], { - JSXElement(node: TSESTree.JSXElement): void; -}>; -export default rule; diff --git a/dist/lib/rules/tooltip-not-recommended.js b/dist/lib/rules/tooltip-not-recommended.js deleted file mode 100644 index b8b545a..0000000 --- a/dist/lib/rules/tooltip-not-recommended.js +++ /dev/null @@ -1,48 +0,0 @@ -"use strict"; -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -Object.defineProperty(exports, "__esModule", { value: true }); -const utils_1 = require("@typescript-eslint/utils"); -const jsx_ast_utils_1 = require("jsx-ast-utils"); -const hasTooltipParent_1 = require("../util/hasTooltipParent"); -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ -// Define an array of allowed component names -const allowedComponents = ["MenuItem", "SpinButton"]; -const rule = utils_1.ESLintUtils.RuleCreator.withoutDocs({ - defaultOptions: [], - meta: { - // possible error messages for the lint rule - messages: { - tooltipNotRecommended: `Accessibility: Tooltop not recommended for these components ${allowedComponents.join(", ")}` - }, - type: "suggestion", // `problem`, `suggestion`, or `layout` - docs: { - description: `Accessibility: Prefer text content or aria over a tooltip for these components ${allowedComponents.join(", ")}`, - recommended: 'strict', - }, - schema: [] // Add a schema if the rule has options - }, - // create (function) returns an object with methods that ESLint calls to “visit” nodes while traversing the abstract syntax tree - create(context) { - return { - // visitor functions for different types of nodes - JSXElement(node) { - const openingElement = node.openingElement; - // if it is not a listed component, return - if (!allowedComponents.includes((0, jsx_ast_utils_1.elementType)(openingElement))) { - return; - } - // if there are is tooltip, report - if ((0, hasTooltipParent_1.hasToolTipParent)(context)) { - context.report({ - node, - messageId: `tooltipNotRecommended` - }); - } - } - }; - } -}); -exports.default = rule; diff --git a/dist/lib/util/flattenChildren.d.ts b/dist/lib/util/flattenChildren.d.ts deleted file mode 100644 index fec9578..0000000 --- a/dist/lib/util/flattenChildren.d.ts +++ /dev/null @@ -1 +0,0 @@ -export function flattenChildren(node: any): any[]; diff --git a/dist/lib/util/flattenChildren.js b/dist/lib/util/flattenChildren.js deleted file mode 100644 index f9b7b8a..0000000 --- a/dist/lib/util/flattenChildren.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict"; -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// TODO: add comments -function flattenChildren(node) { - const flatChildren = []; - if (node.children && node.children.length > 0) { - node.children.forEach(child => { - if (child.type === 'JSXElement' && child.children && child.children.length > 0) { - flatChildren.push(child, ...flattenChildren(child)); - } - else { - flatChildren.push(child); - } - }); - } - return flatChildren; -} -module.exports.flattenChildren = flattenChildren; diff --git a/dist/lib/util/hasFieldParent.d.ts b/dist/lib/util/hasFieldParent.d.ts deleted file mode 100644 index f2ad2e4..0000000 --- a/dist/lib/util/hasFieldParent.d.ts +++ /dev/null @@ -1 +0,0 @@ -export function hasFieldParent(context: any): boolean; diff --git a/dist/lib/util/hasFieldParent.js b/dist/lib/util/hasFieldParent.js deleted file mode 100644 index a142ecb..0000000 --- a/dist/lib/util/hasFieldParent.js +++ /dev/null @@ -1,23 +0,0 @@ -"use strict"; -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -var elementType = require("jsx-ast-utils").elementType; -function hasFieldParent(context) { - const ancestors = context.getAncestors(); - if (ancestors == null || ancestors.length === 0) { - return false; - } - var field = false; - ancestors.forEach(item => { - if (item.type === "JSXElement" && - item.openingElement != null && - item.openingElement.type === "JSXOpeningElement" && - elementType(item.openingElement) === "Field") { - field = true; - } - }); - return field; -} -module.exports = { - hasFieldParent -}; diff --git a/dist/lib/util/hasLabelledChildImage.d.ts b/dist/lib/util/hasLabelledChildImage.d.ts deleted file mode 100644 index b26b4b0..0000000 --- a/dist/lib/util/hasLabelledChildImage.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -/** - * hasLabelledChildImage - determines if a component has text content as a child e.g. abc - * @param {*} node JSXElement - * @returns boolean - */ -export function hasLabelledChildImage(node: any): boolean; diff --git a/dist/lib/util/hasLabelledChildImage.js b/dist/lib/util/hasLabelledChildImage.js deleted file mode 100644 index 2970c63..0000000 --- a/dist/lib/util/hasLabelledChildImage.js +++ /dev/null @@ -1,35 +0,0 @@ -"use strict"; -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -const { flattenChildren } = require("./flattenChildren"); -const { hasProp, getPropValue } = require("jsx-ast-utils"); -const { hasNonEmptyProp } = require("./hasNonEmptyProp"); -const { fluentImageComponents, imageDomNodes } = require("../applicableComponents/imageBasedComponents"); -const mergedImageComponents = [...fluentImageComponents, ...imageDomNodes]; -/** - * hasLabelledChildImage - determines if a component has text content as a child e.g. abc - * @param {*} node JSXElement - * @returns boolean - */ -function hasLabelledChildImage(node) { - // no children - if (node.children == null || node.children == undefined || node.children.length === 0) { - return false; - } - // Check if there is an accessible image - const hasAccessibleImage = flattenChildren(node).some(child => { - if (child.type === "JSXElement" && mergedImageComponents.includes(child.openingElement.name.name)) { - return hasProp(child.openingElement.attributes, "aria-hidden") || getPropValue(child.openingElement.attributes, "alt") - ? false - : hasNonEmptyProp(child.openingElement.attributes, "title") || - hasNonEmptyProp(child.openingElement.attributes, "alt") || - hasNonEmptyProp(child.openingElement.attributes, "aria-label") || - hasNonEmptyProp(child.openingElement.attributes, "aria-labelledby"); - } - return false; - }); - return hasAccessibleImage; -} -module.exports = { - hasLabelledChildImage -}; diff --git a/dist/lib/util/hasNonEmptyProp.d.ts b/dist/lib/util/hasNonEmptyProp.d.ts deleted file mode 100644 index dc1ddb1..0000000 --- a/dist/lib/util/hasNonEmptyProp.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -/** - * Determines if the prop exists and has a non-empty value. - * @param {*} attributes - * @param {*} name - * @returns boolean - */ -export function hasNonEmptyProp(attributes: any, name: any): boolean; diff --git a/dist/lib/util/hasNonEmptyProp.js b/dist/lib/util/hasNonEmptyProp.js deleted file mode 100644 index 1c4e749..0000000 --- a/dist/lib/util/hasNonEmptyProp.js +++ /dev/null @@ -1,27 +0,0 @@ -"use strict"; -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -var hasProp = require("jsx-ast-utils").hasProp; -var getPropValue = require("jsx-ast-utils").getPropValue; -var getProp = require("jsx-ast-utils").getProp; -/** - * Determines if the prop exists and has a non-empty value. - * @param {*} attributes - * @param {*} name - * @returns boolean - */ -function hasNonEmptyProp(attributes, name) { - if (!hasProp(attributes, name)) { - return false; - } - const propValue = getPropValue(getProp(attributes, name)); - /** - * getPropValue internally normalizes "true", "false" to boolean values. - * So it is sufficent to check if the prop exists and return. - */ - if (typeof propValue === "boolean" || typeof propValue === "number") { - return true; - } - return propValue.trim().length > 0; -} -module.exports.hasNonEmptyProp = hasNonEmptyProp; diff --git a/dist/lib/util/hasTextContentChild.d.ts b/dist/lib/util/hasTextContentChild.d.ts deleted file mode 100644 index 7be2576..0000000 --- a/dist/lib/util/hasTextContentChild.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -/** - * hasTextContentChild - determines if a component has text content as a child e.g. - * @param {*} node JSXElement - * @returns boolean - */ -export function hasTextContentChild(node: any): boolean; diff --git a/dist/lib/util/hasTextContentChild.js b/dist/lib/util/hasTextContentChild.js deleted file mode 100644 index 465fe0b..0000000 --- a/dist/lib/util/hasTextContentChild.js +++ /dev/null @@ -1,21 +0,0 @@ -"use strict"; -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -/** - * hasTextContentChild - determines if a component has text content as a child e.g. - * @param {*} node JSXElement - * @returns boolean - */ -function hasTextContentChild(node) { - // no children - if (node.children == null || node.children == undefined || node.children.length === 0) { - return false; - } - const result = node.children.filter(element => { - return element.type === "JSXText" && element.value.trim().length > 0; - }); - return result.length !== 0; -} -module.exports = { - hasTextContentChild -}; diff --git a/dist/lib/util/hasTooltipParent.d.ts b/dist/lib/util/hasTooltipParent.d.ts deleted file mode 100644 index 150c885..0000000 --- a/dist/lib/util/hasTooltipParent.d.ts +++ /dev/null @@ -1 +0,0 @@ -export function hasToolTipParent(context: any): boolean; diff --git a/dist/lib/util/hasTooltipParent.js b/dist/lib/util/hasTooltipParent.js deleted file mode 100644 index 7b21878..0000000 --- a/dist/lib/util/hasTooltipParent.js +++ /dev/null @@ -1,23 +0,0 @@ -"use strict"; -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -var elementType = require("jsx-ast-utils").elementType; -function hasToolTipParent(context) { - const ancestors = context.getAncestors(); - if (ancestors == null || ancestors.length === 0) { - return false; - } - var toolTip = false; - ancestors.forEach(item => { - if (item.type === "JSXElement" && - item.openingElement != null && - item.openingElement.type === "JSXOpeningElement" && - elementType(item.openingElement) === "Tooltip") { - toolTip = true; - } - }); - return toolTip; -} -module.exports = { - hasToolTipParent -}; diff --git a/dist/lib/util/labelUtils.d.ts b/dist/lib/util/labelUtils.d.ts deleted file mode 100644 index 19e994a..0000000 --- a/dist/lib/util/labelUtils.d.ts +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Checks if the element is nested within a Label tag. - * e.g. - * - * @param {*} context - * @returns - */ -export function isInsideLabelTag(context: any): any; -/** - * Checks if there is a Label component inside the source code with a htmlFor attribute matching that of the id parameter. - * e.g. - * id=parameter, - * @param {*} idValue - * @param {*} context - * @returns boolean for match found or not. - */ -export function hasLabelWithHtmlForId(idValue: any, context: any): boolean; -/** - * Checks if there is a Label component inside the source code with an id matching that of the id parameter. - * e.g. - * id=parameter, - * @param {*} idValue value of the props id e.g. - * - * - * @param {*} openingElement - * @param {*} context - * @param {*} ariaAttribute - * @returns boolean for match found or not. - */ -export function hasAssociatedAriaText(openingElement: any, context: any, ariaAttribute: any): boolean; diff --git a/dist/lib/util/labelUtils.js b/dist/lib/util/labelUtils.js deleted file mode 100644 index 736f988..0000000 --- a/dist/lib/util/labelUtils.js +++ /dev/null @@ -1,136 +0,0 @@ -"use strict"; -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -var elementType = require("jsx-ast-utils").elementType; -var getPropValue = require("jsx-ast-utils").getPropValue; -var getProp = require("jsx-ast-utils").getProp; -const { hasNonEmptyProp } = require("./hasNonEmptyProp"); -/** - * Checks if the element is nested within a Label tag. - * e.g. - * - * @param {*} context - * @returns - */ -function isInsideLabelTag(context) { - return context - .getAncestors() - .some(node => node.type === "JSXElement" && (elementType(node.openingElement) === "Label" || elementType(node.openingElement) === "label")); -} -/** - * Checks if there is a Label component inside the source code with a htmlFor attribute matching that of the id parameter. - * e.g. - * id=parameter, - * @param {*} idValue - * @param {*} context - * @returns boolean for match found or not. - */ -function hasLabelWithHtmlForId(idValue, context) { - if (idValue === "") { - return false; - } - const sourceCode = context.getSourceCode(); - const regex = /]*htmlFor[^>]*=[^>]*[{"|{'|"|']([^>'"}]*)['|"|'}|"}][^>]*>/gim; - const matches = regex.exec(sourceCode.text); - return !!matches && matches.some(match => match === idValue); -} -/** - * Checks if there is a Label component inside the source code with an id matching that of the id parameter. - * e.g. - * id=parameter, - * @param {*} idValue value of the props id e.g. - * - * - * @param {*} openingElement - * @param {*} context - * @param {*} ariaAttribute - * @returns boolean for match found or not. - */ -function hasAssociatedAriaText(openingElement, context, ariaAttribute) { - const hasAssociatedAriaText = hasNonEmptyProp(openingElement.attributes, ariaAttribute); - const idValue = getPropValue(getProp(openingElement.attributes, ariaAttribute)); - let hasHtmlId = false; - if (idValue) { - const sourceCode = context.getSourceCode(); - const regex = /<(\w+)[^>]*id\s*=\s*["']([^"']*)["'][^>]*>/gi; - let match; - const ids = []; - while ((match = regex.exec(sourceCode.text)) !== null) { - ids.push(match[2]); - } - hasHtmlId = ids.some(id => id === idValue); - } - return hasAssociatedAriaText && hasHtmlId; -} -module.exports = { - isInsideLabelTag, - hasLabelWithHtmlForId, - hasLabelWithHtmlId, - hasAssociatedLabelViaAriaLabelledBy, - hasAssociatedLabelViaHtmlFor, - hasAssociatedLabelViaAriaDescribedby, - hasAssociatedAriaText -}; diff --git a/package.json b/package.json index 85f2f91..37d82e0 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,9 @@ "url": "https://github.com/microsoft/eslint-plugin-fluentui-jsx-a11y" }, "files": [ - "dist" + "dist", + "README.md", + "LICENSE" ], "type": "commonjs", "exports": { From 1552f2dadd3c6d2cd8273fe4babf288a80dd9b3f Mon Sep 17 00:00:00 2001 From: Ajay Agarwal Date: Mon, 23 Sep 2024 11:00:09 +0530 Subject: [PATCH 2/2] fixed incorrect command --- .github/workflows/release-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-package.yml b/.github/workflows/release-package.yml index 8d4a085..aba2abd 100644 --- a/.github/workflows/release-package.yml +++ b/.github/workflows/release-package.yml @@ -13,7 +13,7 @@ jobs: with: node-version: 16 - run: npm ci - - run: npm build + - run: npm run build - run: npm test publish-gpr: @@ -29,7 +29,7 @@ jobs: node-version: 16 registry-url: https://npm.pkg.github.com/ - run: npm ci - - run: npm build + - run: npm run build - run: npm publish env: NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}