How to use the eslint-plugin-jsx-a11y/lib/util/schemas.js.enumArraySchema function in eslint-plugin-jsx-a11y

To help you get started, we’ve selected a few eslint-plugin-jsx-a11y examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github maranran / eslint-plugin-vue-a11y / lib / rules / label-has-for.js View on Github external
const VueUtils = require('eslint-plugin-vue/lib/utils')
const utils = require('../utils')
const JsxRule = require('eslint-plugin-jsx-a11y/lib/rules/label-has-for.js')

const errorMessage = 'Form label must have associated control';

const enumValues = ['nesting', 'id'];
const schema = {
  type: 'object',
  properties: {
    components: arraySchema,
    required: {
      oneOf: [
        { type: 'string', enum: enumValues },
        generateObjSchema({ some: enumArraySchema(enumValues) }, ['some']),
        generateObjSchema({ every: enumArraySchema(enumValues) }, ['every']),
      ],
    },
    allowChildren: { type: 'boolean' },
  },
};
const validateNesting = node => node.children.some(child => child.type === 'VElement');

const validateId = (node) => {
  const htmlForAttr = utils.getAttribute(node, 'for');
  return htmlForAttr && utils.hasAttributeValue(htmlForAttr);
};

const validate = (node, required, allowChildren) => {
  if (allowChildren === true) {
    return utils.hasAccessibleChild(node);
  }
github maranran / eslint-plugin-vue-a11y / lib / rules / no-distracting-elements.js View on Github external
const VueUtils = require('eslint-plugin-vue/lib/utils');
const utils = require('../utils');
const altRule = require('eslint-plugin-jsx-a11y/lib/rules/no-distracting-elements.js');
const { generateObjSchema, enumArraySchema } = require('eslint-plugin-jsx-a11y/lib/util/schemas.js');

const errorMessage = element =>
  `Do not use <${element}> elements as they can create visual accessibility issues and are deprecated.`;

const DEFAULT_ELEMENTS = [
  'marquee',
  'blink',
];

const schema = generateObjSchema({
  elements: enumArraySchema(DEFAULT_ELEMENTS),
});

module.exports = {
  meta: {
    docs: {
      url: 'https://github.com/maranran/eslint-plugin-vue-a11y/blob/master/docs/rules/no-distracting-elements.md'
    },
    schema: [schema],
  },

  create (context) {
    return VueUtils.defineTemplateBodyVisitor(context, {
      "VElement" (node) {
        const options = context.options[0] || {};
        const elementOptions = options.elements || DEFAULT_ELEMENTS;
        const type = utils.getElementType(node);
github maranran / eslint-plugin-vue-a11y / lib / rules / label-has-for.js View on Github external
const { generateObjSchema, arraySchema, enumArraySchema } = require('eslint-plugin-jsx-a11y/lib/util/schemas.js');
const VueUtils = require('eslint-plugin-vue/lib/utils')
const utils = require('../utils')
const JsxRule = require('eslint-plugin-jsx-a11y/lib/rules/label-has-for.js')

const errorMessage = 'Form label must have associated control';

const enumValues = ['nesting', 'id'];
const schema = {
  type: 'object',
  properties: {
    components: arraySchema,
    required: {
      oneOf: [
        { type: 'string', enum: enumValues },
        generateObjSchema({ some: enumArraySchema(enumValues) }, ['some']),
        generateObjSchema({ every: enumArraySchema(enumValues) }, ['every']),
      ],
    },
    allowChildren: { type: 'boolean' },
  },
};
const validateNesting = node => node.children.some(child => child.type === 'VElement');

const validateId = (node) => {
  const htmlForAttr = utils.getAttribute(node, 'for');
  return htmlForAttr && utils.hasAttributeValue(htmlForAttr);
};

const validate = (node, required, allowChildren) => {
  if (allowChildren === true) {
    return utils.hasAccessibleChild(node);