interfaceIdMatch.js 928 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports["default"] = void 0;
  6. var schema = [{
  7. type: 'string'
  8. }];
  9. var create = function create(context) {
  10. var pattern = new RegExp(context.options[0] || '^([A-Z][a-z0-9]*)+Type$', 'u');
  11. var checkInterface = function checkInterface(interfaceDeclarationNode) {
  12. var interfaceIdentifierName = interfaceDeclarationNode.id.name;
  13. if (!pattern.test(interfaceIdentifierName)) {
  14. context.report({
  15. data: {
  16. name: interfaceIdentifierName,
  17. pattern: pattern.toString()
  18. },
  19. message: 'Interface identifier \'{{name}}\' does not match pattern \'{{pattern}}\'.',
  20. node: interfaceDeclarationNode
  21. });
  22. }
  23. };
  24. return {
  25. InterfaceDeclaration: checkInterface
  26. };
  27. };
  28. var _default = {
  29. create: create,
  30. schema: schema
  31. };
  32. exports["default"] = _default;
  33. module.exports = exports.default;