Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
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.

no-export.js 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _experimentalUtils = require("@typescript-eslint/experimental-utils");
  7. var _utils = require("./utils");
  8. var _default = (0, _utils.createRule)({
  9. name: __filename,
  10. meta: {
  11. docs: {
  12. category: 'Best Practices',
  13. description: 'Disallow using `exports` in files containing tests',
  14. recommended: 'error'
  15. },
  16. messages: {
  17. unexpectedExport: `Do not export from a test file.`
  18. },
  19. type: 'suggestion',
  20. schema: []
  21. },
  22. defaultOptions: [],
  23. create(context) {
  24. const exportNodes = [];
  25. let hasTestCase = false;
  26. return {
  27. 'Program:exit'() {
  28. if (hasTestCase && exportNodes.length > 0) {
  29. for (const node of exportNodes) {
  30. context.report({
  31. node,
  32. messageId: 'unexpectedExport'
  33. });
  34. }
  35. }
  36. },
  37. CallExpression(node) {
  38. if ((0, _utils.isTestCaseCall)(node)) {
  39. hasTestCase = true;
  40. }
  41. },
  42. 'ExportNamedDeclaration, ExportDefaultDeclaration'(node) {
  43. exportNodes.push(node);
  44. },
  45. 'AssignmentExpression > MemberExpression'(node) {
  46. let {
  47. object,
  48. property
  49. } = node;
  50. if (object.type === _experimentalUtils.AST_NODE_TYPES.MemberExpression) {
  51. ({
  52. object,
  53. property
  54. } = object);
  55. }
  56. if ('name' in object && object.name === 'module' && property.type === _experimentalUtils.AST_NODE_TYPES.Identifier && /^exports?$/u.test(property.name)) {
  57. exportNodes.push(node);
  58. }
  59. }
  60. };
  61. }
  62. });
  63. exports.default = _default;