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-if.md 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # Disallow conditional logic (`no-if`)
  2. Conditional logic in tests is usually an indication that a test is attempting to
  3. cover too much, and not testing the logic it intends to. Each branch of code
  4. executing within an if statement will usually be better served by a test devoted
  5. to it.
  6. Conditionals are often used to satisfy the typescript type checker. In these
  7. cases, using the non-null assertion operator (!) would be best.
  8. ## Rule Details
  9. This rule prevents the use of if/ else statements and conditional (ternary)
  10. operations in tests.
  11. The following patterns are considered warnings:
  12. ```js
  13. it('foo', () => {
  14. if ('bar') {
  15. // an if statement here is invalid
  16. // you are probably testing too much
  17. }
  18. });
  19. it('foo', () => {
  20. const bar = foo ? 'bar' : null;
  21. });
  22. ```
  23. These patterns would not be considered warnings:
  24. ```js
  25. it('foo', () => {
  26. // only test the 'foo' case
  27. });
  28. it('bar', () => {
  29. // test the 'bar' case separately
  30. });
  31. it('foo', () => {
  32. function foo(bar) {
  33. // nested functions are valid
  34. return foo ? bar : null;
  35. }
  36. });
  37. ```
  38. ## When Not To Use It
  39. If you do not wish to prevent the use of if statements in tests, you can safely
  40. disable this rule.