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-focused-tests.js 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. const findOnlyNode = node => {
  9. const callee = node.callee.type === _experimentalUtils.AST_NODE_TYPES.TaggedTemplateExpression ? node.callee.tag : node.callee.type === _experimentalUtils.AST_NODE_TYPES.CallExpression ? node.callee.callee : node.callee;
  10. if (callee.type === _experimentalUtils.AST_NODE_TYPES.MemberExpression) {
  11. if (callee.object.type === _experimentalUtils.AST_NODE_TYPES.MemberExpression) {
  12. if ((0, _utils.isSupportedAccessor)(callee.object.property, 'only')) {
  13. return callee.object.property;
  14. }
  15. }
  16. if ((0, _utils.isSupportedAccessor)(callee.property, 'only')) {
  17. return callee.property;
  18. }
  19. }
  20. return null;
  21. };
  22. var _default = (0, _utils.createRule)({
  23. name: __filename,
  24. meta: {
  25. docs: {
  26. category: 'Best Practices',
  27. description: 'Disallow focused tests',
  28. recommended: 'error',
  29. suggestion: true
  30. },
  31. messages: {
  32. focusedTest: 'Unexpected focused test.',
  33. suggestRemoveFocus: 'Remove focus from test.'
  34. },
  35. schema: [],
  36. type: 'suggestion',
  37. hasSuggestions: true
  38. },
  39. defaultOptions: [],
  40. create: context => ({
  41. CallExpression(node) {
  42. if (!(0, _utils.isDescribeCall)(node) && !(0, _utils.isTestCaseCall)(node)) {
  43. return;
  44. }
  45. if ((0, _utils.getNodeName)(node).startsWith('f')) {
  46. context.report({
  47. messageId: 'focusedTest',
  48. node,
  49. suggest: [{
  50. messageId: 'suggestRemoveFocus',
  51. fix: fixer => fixer.removeRange([node.range[0], node.range[0] + 1])
  52. }]
  53. });
  54. return;
  55. }
  56. const onlyNode = findOnlyNode(node);
  57. if (!onlyNode) {
  58. return;
  59. }
  60. context.report({
  61. messageId: 'focusedTest',
  62. node: onlyNode,
  63. suggest: [{
  64. messageId: 'suggestRemoveFocus',
  65. fix: fixer => fixer.removeRange([onlyNode.range[0] - 1, onlyNode.range[1] + Number(onlyNode.type !== _experimentalUtils.AST_NODE_TYPES.Identifier)])
  66. }]
  67. });
  68. }
  69. })
  70. });
  71. exports.default = _default;