web 3d图形渲染器
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.4 KiB

  1. "use strict";
  2. var _jsxAstUtils = require("jsx-ast-utils");
  3. var _schemas = require("../util/schemas");
  4. /**
  5. * @fileoverview Enforce distracting elements are not used.
  6. * @author Ethan Cohen
  7. */
  8. // ----------------------------------------------------------------------------
  9. // Rule Definition
  10. // ----------------------------------------------------------------------------
  11. var errorMessage = function errorMessage(element) {
  12. return "Do not use <".concat(element, "> elements as they can create visual accessibility issues and are deprecated.");
  13. };
  14. var DEFAULT_ELEMENTS = ['marquee', 'blink'];
  15. var schema = (0, _schemas.generateObjSchema)({
  16. elements: (0, _schemas.enumArraySchema)(DEFAULT_ELEMENTS)
  17. });
  18. module.exports = {
  19. meta: {
  20. docs: {
  21. url: 'https://github.com/evcohen/eslint-plugin-jsx-a11y/tree/master/docs/rules/no-distracting-elements.md'
  22. },
  23. schema: [schema]
  24. },
  25. create: function create(context) {
  26. return {
  27. JSXOpeningElement: function JSXOpeningElement(node) {
  28. var options = context.options[0] || {};
  29. var elementOptions = options.elements || DEFAULT_ELEMENTS;
  30. var type = (0, _jsxAstUtils.elementType)(node);
  31. var distractingElement = elementOptions.find(function (element) {
  32. return type === element;
  33. });
  34. if (distractingElement) {
  35. context.report({
  36. node,
  37. message: errorMessage(distractingElement)
  38. });
  39. }
  40. }
  41. };
  42. }
  43. };