Skip to content

Commit

Permalink
revert schema
Browse files Browse the repository at this point in the history
  • Loading branch information
bmish committed Oct 28, 2022
1 parent 8913fe2 commit f27d22b
Show file tree
Hide file tree
Showing 20 changed files with 112 additions and 60 deletions.
80 changes: 40 additions & 40 deletions README.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -31,7 +31,7 @@
"test:ci": "npm run jest -- --ci --runInBand",
"jest": "jest --coverage __tests__/**/*",
"pregenerate-list-of-rules": "npm run build",
"generate-list-of-rules": "eslint-doc-generator --rule-doc-title-format prefix-name --config-emoji recommended,☑️",
"generate-list-of-rules": "eslint-doc-generator --rule-doc-title-format prefix-name --rule-doc-section-options false --config-emoji recommended,☑️",
"generate-list-of-rules:check": "npm run generate-list-of-rules -- --check"
},
"devDependencies": {
Expand All @@ -47,7 +47,7 @@
"babel-preset-airbnb": "^5.0.0",
"eslint": "^3 || ^4 || ^5 || ^6 || ^7 || ^8",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-doc-generator": "^0.15.0",
"eslint-doc-generator": "^0.16.0",
"eslint-plugin-eslint-plugin": "^4.3.0",
"eslint-plugin-flowtype": "^5.8.0 || ^8.0.3",
"eslint-plugin-import": "^2.26.0",
Expand Down
5 changes: 4 additions & 1 deletion src/rules/accessible-emoji.js
Expand Up @@ -9,18 +9,21 @@

import emojiRegex from 'emoji-regex';
import { getProp, getLiteralPropValue } from 'jsx-ast-utils';
import { generateObjSchema } from '../util/schemas';
import getElementType from '../util/getElementType';
import isHiddenFromScreenReader from '../util/isHiddenFromScreenReader';

const errorMessage = 'Emojis should be wrapped in <span>, have role="img", and have an accessible description with aria-label or aria-labelledby.';

const schema = generateObjSchema();

export default {
meta: {
docs: {
url: 'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/accessible-emoji.md',
},
deprecated: true,
schema: [],
schema: [schema],
},

create: (context) => {
Expand Down
5 changes: 4 additions & 1 deletion src/rules/aria-activedescendant-has-tabindex.js
Expand Up @@ -5,6 +5,7 @@

import { dom } from 'aria-query';
import { getProp } from 'jsx-ast-utils';
import { generateObjSchema } from '../util/schemas';
import getElementType from '../util/getElementType';
import getTabIndex from '../util/getTabIndex';
import isInteractiveElement from '../util/isInteractiveElement';
Expand All @@ -15,6 +16,8 @@ import isInteractiveElement from '../util/isInteractiveElement';

const errorMessage = 'An element that manages focus with `aria-activedescendant` must have a tabindex';

const schema = generateObjSchema();

const domElements = [...dom.keys()];

export default {
Expand All @@ -23,7 +26,7 @@ export default {
url: 'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/aria-activedescendant-has-tabindex.md',
description: 'Enforce elements with aria-activedescendant are tabbable.',
},
schema: [],
schema: [schema],
},

create: (context) => {
Expand Down
5 changes: 4 additions & 1 deletion src/rules/aria-props.js
Expand Up @@ -9,6 +9,7 @@

import { aria } from 'aria-query';
import { propName } from 'jsx-ast-utils';
import { generateObjSchema } from '../util/schemas';
import getSuggestion from '../util/getSuggestion';

const ariaAttributes = [...aria.keys()];
Expand All @@ -24,13 +25,15 @@ const errorMessage = (name) => {
return message;
};

const schema = generateObjSchema();

export default {
meta: {
docs: {
url: 'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/aria-props.md',
description: 'Enforce all `aria-*` props are valid.',
},
schema: [],
schema: [schema],
},

create: (context) => ({
Expand Down
5 changes: 4 additions & 1 deletion src/rules/aria-proptypes.js
Expand Up @@ -9,6 +9,7 @@

import { aria } from 'aria-query';
import { getLiteralPropValue, getPropValue, propName } from 'jsx-ast-utils';
import { generateObjSchema } from '../util/schemas';

const errorMessage = (name, type, permittedValues) => {
switch (type) {
Expand Down Expand Up @@ -59,14 +60,16 @@ const validityCheck = (value, expectedType, permittedValues) => {
}
};

const schema = generateObjSchema();

export default {
validityCheck,
meta: {
docs: {
url: 'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/aria-proptypes.md',
description: 'Enforce ARIA state and property values are valid.',
},
schema: [],
schema: [schema],
},

create: (context) => ({
Expand Down
5 changes: 4 additions & 1 deletion src/rules/aria-unsupported-elements.js
Expand Up @@ -13,20 +13,23 @@ import {
dom,
} from 'aria-query';
import { propName } from 'jsx-ast-utils';
import { generateObjSchema } from '../util/schemas';
import getElementType from '../util/getElementType';

const errorMessage = (invalidProp) => (
`This element does not support ARIA roles, states and properties. \
Try removing the prop '${invalidProp}'.`
);

const schema = generateObjSchema();

export default {
meta: {
docs: {
url: 'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/aria-unsupported-elements.md',
description: 'Enforce that elements that do not support ARIA roles, states, and properties do not have those attributes.',
},
schema: [],
schema: [schema],
},

create: (context) => {
Expand Down
4 changes: 3 additions & 1 deletion src/rules/click-events-have-key-events.js
Expand Up @@ -10,13 +10,15 @@
import { dom } from 'aria-query';
import { getProp, hasAnyProp } from 'jsx-ast-utils';
import includes from 'array-includes';
import { generateObjSchema } from '../util/schemas';
import getElementType from '../util/getElementType';
import isHiddenFromScreenReader from '../util/isHiddenFromScreenReader';
import isInteractiveElement from '../util/isInteractiveElement';
import isPresentationRole from '../util/isPresentationRole';

const errorMessage = 'Visible, non-interactive elements with click handlers must have at least one keyboard listener.';

const schema = generateObjSchema();
const domElements = [...dom.keys()];

export default {
Expand All @@ -25,7 +27,7 @@ export default {
url: 'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/click-events-have-key-events.md',
description: 'Enforce a clickable non-interactive element has at least one keyboard event listener.',
},
schema: [],
schema: [schema],
},

create: (context) => {
Expand Down
5 changes: 4 additions & 1 deletion src/rules/html-has-lang.js
Expand Up @@ -8,17 +8,20 @@
// ----------------------------------------------------------------------------

import { getProp, getPropValue } from 'jsx-ast-utils';
import { generateObjSchema } from '../util/schemas';
import getElementType from '../util/getElementType';

const errorMessage = '<html> elements must have the lang prop.';

const schema = generateObjSchema();

export default {
meta: {
docs: {
url: 'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/html-has-lang.md',
description: 'Enforce `<html>` element has `lang` prop.',
},
schema: [],
schema: [schema],
},

create: (context) => {
Expand Down
5 changes: 4 additions & 1 deletion src/rules/iframe-has-title.js
Expand Up @@ -9,16 +9,19 @@

import { getProp, getPropValue } from 'jsx-ast-utils';
import getElementType from '../util/getElementType';
import { generateObjSchema } from '../util/schemas';

const errorMessage = '<iframe> elements must have a unique title property.';

const schema = generateObjSchema();

export default {
meta: {
docs: {
url: 'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/iframe-has-title.md',
description: 'Enforce iframe elements have a title attribute.',
},
schema: [],
schema: [schema],
},

create: (context) => {
Expand Down
5 changes: 4 additions & 1 deletion src/rules/lang.js
Expand Up @@ -9,17 +9,20 @@

import { propName, getLiteralPropValue } from 'jsx-ast-utils';
import tags from 'language-tags';
import { generateObjSchema } from '../util/schemas';
import getElementType from '../util/getElementType';

const errorMessage = 'lang attribute must have a valid value.';

const schema = generateObjSchema();

export default {
meta: {
docs: {
url: 'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/lang.md',
description: 'Enforce lang attribute has a valid value.',
},
schema: [],
schema: [schema],
},

create: (context) => {
Expand Down
5 changes: 4 additions & 1 deletion src/rules/mouse-events-have-key-events.js
Expand Up @@ -10,17 +10,20 @@

import { dom } from 'aria-query';
import { getProp, getPropValue } from 'jsx-ast-utils';
import { generateObjSchema } from '../util/schemas';

const mouseOverErrorMessage = 'onMouseOver must be accompanied by onFocus for accessibility.';
const mouseOutErrorMessage = 'onMouseOut must be accompanied by onBlur for accessibility.';

const schema = generateObjSchema();

export default {
meta: {
docs: {
url: 'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/mouse-events-have-key-events.md',
description: 'Enforce that `onMouseOver`/`onMouseOut` are accompanied by `onFocus`/`onBlur` for keyboard-only users.',
},
schema: [],
schema: [schema],
},

create: (context) => ({
Expand Down
5 changes: 4 additions & 1 deletion src/rules/no-access-key.js
Expand Up @@ -8,16 +8,19 @@
// ----------------------------------------------------------------------------

import { getProp, getPropValue } from 'jsx-ast-utils';
import { generateObjSchema } from '../util/schemas';

const errorMessage = 'No access key attribute allowed. Inconsistencies between keyboard shortcuts and keyboard commands used by screenreaders and keyboard-only users create a11y complications.';

const schema = generateObjSchema();

export default {
meta: {
docs: {
url: 'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/no-access-key.md',
description: 'Enforce that the `accessKey` prop is not used on any element to avoid complications with keyboard commands used by a screenreader.',
},
schema: [],
schema: [schema],
},

create: (context) => ({
Expand Down
4 changes: 3 additions & 1 deletion src/rules/no-aria-hidden-on-focusable.js
Expand Up @@ -10,16 +10,18 @@
import { getProp, getPropValue } from 'jsx-ast-utils';
import getElementType from '../util/getElementType';
import isFocusable from '../util/isFocusable';
import { generateObjSchema } from '../util/schemas';

const errorMessage = 'aria-hidden="true" must not be set on focusable elements.';
const schema = generateObjSchema();

export default {
meta: {
docs: {
url: 'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/no-aria-hidden-on-focusable.md',
description: errorMessage,
},
schema: [],
schema: [schema],
},

create(context) {
Expand Down
5 changes: 4 additions & 1 deletion src/rules/no-onchange.js
Expand Up @@ -8,6 +8,7 @@
// ----------------------------------------------------------------------------

import { getProp } from 'jsx-ast-utils';
import { generateObjSchema } from '../util/schemas';
import getElementType from '../util/getElementType';

const errorMessage = 'onBlur must be used instead of onchange, unless absolutely necessary and it causes no negative consequences for keyboard only or screen reader users.';
Expand All @@ -17,14 +18,16 @@ const applicableTypes = [
'option',
];

const schema = generateObjSchema();

export default {
meta: {
docs: {
url: 'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/no-onchange.md',
description: 'Enforce usage of `onBlur` over `onChange` on select menus for accessibility.',
},
deprecated: true,
schema: [],
schema: [schema],
},

create: (context) => {
Expand Down
5 changes: 4 additions & 1 deletion src/rules/prefer-tag-over-role.js
Expand Up @@ -2,9 +2,12 @@ import { roleElements } from 'aria-query';
import { getProp, getPropValue } from 'jsx-ast-utils';

import getElementType from '../util/getElementType';
import { generateObjSchema } from '../util/schemas';

const errorMessage = 'Use {{tag}} instead of the "{{role}}" role to ensure accessibility across all devices.';

const schema = generateObjSchema();

const formatTag = (tag) => {
if (!tag.attributes) {
return `<${tag.name}>`;
Expand Down Expand Up @@ -34,7 +37,7 @@ export default {
docs: {
url: 'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/prefer-tag-over-role.md',
},
schema: [],
schema: [schema],
},

create: (context) => {
Expand Down
5 changes: 4 additions & 1 deletion src/rules/role-has-required-aria-props.js
Expand Up @@ -14,20 +14,23 @@ import {
getLiteralPropValue,
propName,
} from 'jsx-ast-utils';
import { generateObjSchema } from '../util/schemas';
import getElementType from '../util/getElementType';
import isSemanticRoleElement from '../util/isSemanticRoleElement';

const errorMessage = (role, requiredProps) => (
`Elements with the ARIA role "${role}" must have the following attributes defined: ${String(requiredProps).toLowerCase()}`
);

const schema = generateObjSchema();

export default {
meta: {
docs: {
url: 'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/role-has-required-aria-props.md',
description: 'Enforce that elements with ARIA roles must have all required attributes for that role.',
},
schema: [],
schema: [schema],
},

create: (context) => {
Expand Down
5 changes: 4 additions & 1 deletion src/rules/role-supports-aria-props.js
Expand Up @@ -18,6 +18,7 @@ import {
getPropValue,
propName,
} from 'jsx-ast-utils';
import { generateObjSchema } from '../util/schemas';
import getElementType from '../util/getElementType';
import getImplicitRole from '../util/getImplicitRole';

Expand All @@ -30,13 +31,15 @@ This role is implicit on the element ${tag}.`;
return `The attribute ${attr} is not supported by the role ${role}.`;
};

const schema = generateObjSchema();

export default {
meta: {
docs: {
url: 'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/role-supports-aria-props.md',
description: 'Enforce that elements with explicit or implicit roles defined contain only `aria-*` properties supported by that `role`.',
},
schema: [],
schema: [schema],
},

create(context) {
Expand Down

0 comments on commit f27d22b

Please sign in to comment.