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.

prefer-todo.js 2.0KB

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. function isEmptyFunction(node) {
  9. if (!(0, _utils.isFunction)(node)) {
  10. return false;
  11. }
  12. return node.body.type === _experimentalUtils.AST_NODE_TYPES.BlockStatement && !node.body.body.length;
  13. }
  14. function createTodoFixer(node, fixer) {
  15. const testName = (0, _utils.getNodeName)(node).split('.').shift();
  16. return fixer.replaceText(node.callee, `${testName}.todo`);
  17. }
  18. const isTargetedTestCase = node => (0, _utils.isTestCaseCall)(node) && [_utils.TestCaseName.it, _utils.TestCaseName.test, 'it.skip', 'test.skip'].includes((0, _utils.getNodeName)(node));
  19. var _default = (0, _utils.createRule)({
  20. name: __filename,
  21. meta: {
  22. docs: {
  23. category: 'Best Practices',
  24. description: 'Suggest using `test.todo`',
  25. recommended: false
  26. },
  27. messages: {
  28. emptyTest: 'Prefer todo test case over empty test case',
  29. unimplementedTest: 'Prefer todo test case over unimplemented test case'
  30. },
  31. fixable: 'code',
  32. schema: [],
  33. type: 'layout'
  34. },
  35. defaultOptions: [],
  36. create(context) {
  37. return {
  38. CallExpression(node) {
  39. const [title, callback] = node.arguments;
  40. if (!title || !isTargetedTestCase(node) || !(0, _utils.isStringNode)(title)) {
  41. return;
  42. }
  43. if (callback && isEmptyFunction(callback)) {
  44. context.report({
  45. messageId: 'emptyTest',
  46. node,
  47. fix: fixer => [fixer.removeRange([title.range[1], callback.range[1]]), createTodoFixer(node, fixer)]
  48. });
  49. }
  50. if ((0, _utils.hasOnlyOneArgument)(node)) {
  51. context.report({
  52. messageId: 'unimplementedTest',
  53. node,
  54. fix: fixer => [createTodoFixer(node, fixer)]
  55. });
  56. }
  57. }
  58. };
  59. }
  60. });
  61. exports.default = _default;