Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

3 лет назад
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. 'use strict';
  2. var _ariaQuery = require('aria-query');
  3. var _jsxAstUtils = require('jsx-ast-utils');
  4. var _schemas = require('../util/schemas');
  5. var errorMessage = 'The scope prop can only be used on <th> elements.'; /**
  6. * @fileoverview Enforce scope prop is only used on <th> elements.
  7. * @author Ethan Cohen
  8. */
  9. // ----------------------------------------------------------------------------
  10. // Rule Definition
  11. // ----------------------------------------------------------------------------
  12. var schema = (0, _schemas.generateObjSchema)();
  13. module.exports = {
  14. meta: {
  15. docs: {
  16. url: 'https://github.com/evcohen/eslint-plugin-jsx-a11y/tree/master/docs/rules/scope.md'
  17. },
  18. schema: [schema]
  19. },
  20. create: function create(context) {
  21. return {
  22. JSXAttribute: function JSXAttribute(node) {
  23. var name = (0, _jsxAstUtils.propName)(node);
  24. if (name && name.toUpperCase() !== 'SCOPE') {
  25. return;
  26. }
  27. var parent = node.parent;
  28. var tagName = (0, _jsxAstUtils.elementType)(parent);
  29. // Do not test higher level JSX components, as we do not know what
  30. // low-level DOM element this maps to.
  31. if (!_ariaQuery.dom.has(tagName)) {
  32. return;
  33. }
  34. if (tagName && tagName.toUpperCase() === 'TH') {
  35. return;
  36. }
  37. context.report({
  38. node: node,
  39. message: errorMessage
  40. });
  41. }
  42. };
  43. }
  44. };