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.

README.md 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <div align="center">
  2. <a href="https://eslint.org/">
  3. <img width="150" height="150" src="https://eslint.org/assets/img/logo.svg">
  4. </a>
  5. <a href="https://facebook.github.io/jest/">
  6. <img width="150" height="150" vspace="" hspace="25" src="https://jestjs.io/img/jest.png">
  7. </a>
  8. <h1>eslint-plugin-jest</h1>
  9. <p>ESLint plugin for Jest</p>
  10. </div>
  11. [![Actions Status](https://github.com/jest-community/eslint-plugin-jest/actions/workflows/nodejs.yml/badge.svg?branch=main)](https://github.com/jest-community/eslint-plugin-jest/actions)
  12. ## Installation
  13. ```bash
  14. yarn add --dev eslint eslint-plugin-jest
  15. ```
  16. **Note:** If you installed ESLint globally then you must also install
  17. `eslint-plugin-jest` globally.
  18. ## Usage
  19. Add `jest` to the plugins section of your `.eslintrc` configuration file. You
  20. can omit the `eslint-plugin-` prefix:
  21. ```json
  22. {
  23. "plugins": ["jest"]
  24. }
  25. ```
  26. Then configure the rules you want to use under the rules section.
  27. ```json
  28. {
  29. "rules": {
  30. "jest/no-disabled-tests": "warn",
  31. "jest/no-focused-tests": "error",
  32. "jest/no-identical-title": "error",
  33. "jest/prefer-to-have-length": "warn",
  34. "jest/valid-expect": "error"
  35. }
  36. }
  37. ```
  38. You can also tell ESLint about the environment variables provided by Jest by
  39. doing:
  40. ```json
  41. {
  42. "env": {
  43. "jest/globals": true
  44. }
  45. }
  46. ```
  47. This is included in all configs shared by this plugin, so can be omitted if
  48. extending them.
  49. The behaviour of some rules (specifically `no-deprecated-functions`) change
  50. depending on the version of `jest` being used.
  51. This setting is detected automatically based off the version of the `jest`
  52. package installed in `node_modules`, but it can also be provided explicitly if
  53. desired:
  54. ```json
  55. {
  56. "settings": {
  57. "jest": {
  58. "version": 26
  59. }
  60. }
  61. }
  62. ```
  63. ## Shareable configurations
  64. ### Recommended
  65. This plugin exports a recommended configuration that enforces good testing
  66. practices.
  67. To enable this configuration use the `extends` property in your `.eslintrc`
  68. config file:
  69. ```json
  70. {
  71. "extends": ["plugin:jest/recommended"]
  72. }
  73. ```
  74. ### Style
  75. This plugin also exports a configuration named `style`, which adds some
  76. stylistic rules, such as `prefer-to-be-null`, which enforces usage of `toBeNull`
  77. over `toBe(null)`.
  78. To enable this configuration use the `extends` property in your `.eslintrc`
  79. config file:
  80. ```json
  81. {
  82. "extends": ["plugin:jest/style"]
  83. }
  84. ```
  85. See
  86. [ESLint documentation](http://eslint.org/docs/user-guide/configuring#extending-configuration-files)
  87. for more information about extending configuration files.
  88. ### All
  89. If you want to enable all rules instead of only some you can do so by adding the
  90. `all` configuration to your `.eslintrc` config file:
  91. ```json
  92. {
  93. "extends": ["plugin:jest/all"]
  94. }
  95. ```
  96. While the `recommended` and `style` configurations only change in major versions
  97. the `all` configuration may change in any release and is thus unsuited for
  98. installations requiring long-term consistency.
  99. ## Rules
  100. <!-- begin base rules list -->
  101. | Rule | Description | Configurations | Fixable |
  102. | ---------------------------------------------------------------------------- | --------------------------------------------------------------- | ---------------- | ------------ |
  103. | [consistent-test-it](docs/rules/consistent-test-it.md) | Have control over `test` and `it` usages | | ![fixable][] |
  104. | [expect-expect](docs/rules/expect-expect.md) | Enforce assertion to be made in a test body | ![recommended][] | |
  105. | [lowercase-name](docs/rules/lowercase-name.md) | Enforce lowercase test names | | ![fixable][] |
  106. | [max-nested-describe](docs/rules/max-nested-describe.md) | Enforces a maximum depth to nested describe calls | | |
  107. | [no-alias-methods](docs/rules/no-alias-methods.md) | Disallow alias methods | ![style][] | ![fixable][] |
  108. | [no-commented-out-tests](docs/rules/no-commented-out-tests.md) | Disallow commented out tests | ![recommended][] | |
  109. | [no-conditional-expect](docs/rules/no-conditional-expect.md) | Prevent calling `expect` conditionally | ![recommended][] | |
  110. | [no-deprecated-functions](docs/rules/no-deprecated-functions.md) | Disallow use of deprecated functions | ![recommended][] | ![fixable][] |
  111. | [no-disabled-tests](docs/rules/no-disabled-tests.md) | Disallow disabled tests | ![recommended][] | |
  112. | [no-done-callback](docs/rules/no-done-callback.md) | Avoid using a callback in asynchronous tests and hooks | ![recommended][] | ![suggest][] |
  113. | [no-duplicate-hooks](docs/rules/no-duplicate-hooks.md) | Disallow duplicate setup and teardown hooks | | |
  114. | [no-export](docs/rules/no-export.md) | Disallow using `exports` in files containing tests | ![recommended][] | |
  115. | [no-focused-tests](docs/rules/no-focused-tests.md) | Disallow focused tests | ![recommended][] | ![suggest][] |
  116. | [no-hooks](docs/rules/no-hooks.md) | Disallow setup and teardown hooks | | |
  117. | [no-identical-title](docs/rules/no-identical-title.md) | Disallow identical titles | ![recommended][] | |
  118. | [no-if](docs/rules/no-if.md) | Disallow conditional logic | | |
  119. | [no-interpolation-in-snapshots](docs/rules/no-interpolation-in-snapshots.md) | Disallow string interpolation inside snapshots | ![recommended][] | |
  120. | [no-jasmine-globals](docs/rules/no-jasmine-globals.md) | Disallow Jasmine globals | ![recommended][] | ![fixable][] |
  121. | [no-jest-import](docs/rules/no-jest-import.md) | Disallow importing Jest | ![recommended][] | |
  122. | [no-large-snapshots](docs/rules/no-large-snapshots.md) | disallow large snapshots | | |
  123. | [no-mocks-import](docs/rules/no-mocks-import.md) | Disallow manually importing from `__mocks__` | ![recommended][] | |
  124. | [no-restricted-matchers](docs/rules/no-restricted-matchers.md) | Disallow specific matchers & modifiers | | |
  125. | [no-standalone-expect](docs/rules/no-standalone-expect.md) | Disallow using `expect` outside of `it` or `test` blocks | ![recommended][] | |
  126. | [no-test-prefixes](docs/rules/no-test-prefixes.md) | Use `.only` and `.skip` over `f` and `x` | ![recommended][] | ![fixable][] |
  127. | [no-test-return-statement](docs/rules/no-test-return-statement.md) | Disallow explicitly returning from tests | | |
  128. | [prefer-called-with](docs/rules/prefer-called-with.md) | Suggest using `toBeCalledWith()` or `toHaveBeenCalledWith()` | | |
  129. | [prefer-expect-assertions](docs/rules/prefer-expect-assertions.md) | Suggest using `expect.assertions()` OR `expect.hasAssertions()` | | ![suggest][] |
  130. | [prefer-hooks-on-top](docs/rules/prefer-hooks-on-top.md) | Suggest having hooks before any test cases | | |
  131. | [prefer-spy-on](docs/rules/prefer-spy-on.md) | Suggest using `jest.spyOn()` | | ![fixable][] |
  132. | [prefer-strict-equal](docs/rules/prefer-strict-equal.md) | Suggest using `toStrictEqual()` | | ![suggest][] |
  133. | [prefer-to-be-null](docs/rules/prefer-to-be-null.md) | Suggest using `toBeNull()` | ![style][] | ![fixable][] |
  134. | [prefer-to-be-undefined](docs/rules/prefer-to-be-undefined.md) | Suggest using `toBeUndefined()` | ![style][] | ![fixable][] |
  135. | [prefer-to-contain](docs/rules/prefer-to-contain.md) | Suggest using `toContain()` | ![style][] | ![fixable][] |
  136. | [prefer-to-have-length](docs/rules/prefer-to-have-length.md) | Suggest using `toHaveLength()` | ![style][] | ![fixable][] |
  137. | [prefer-todo](docs/rules/prefer-todo.md) | Suggest using `test.todo` | | ![fixable][] |
  138. | [require-to-throw-message](docs/rules/require-to-throw-message.md) | Require a message for `toThrow()` | | |
  139. | [require-top-level-describe](docs/rules/require-top-level-describe.md) | Require test cases and hooks to be inside a `describe` block | | |
  140. | [valid-describe](docs/rules/valid-describe.md) | Enforce valid `describe()` callback | ![recommended][] | |
  141. | [valid-expect](docs/rules/valid-expect.md) | Enforce valid `expect()` usage | ![recommended][] | |
  142. | [valid-expect-in-promise](docs/rules/valid-expect-in-promise.md) | Enforce having return statement when testing with promises | ![recommended][] | |
  143. | [valid-title](docs/rules/valid-title.md) | Enforce valid titles | ![recommended][] | ![fixable][] |
  144. <!-- end base rules list -->
  145. ## TypeScript Rules
  146. In addition to the above rules, this plugin also includes a few advanced rules
  147. that are powered by type-checking information provided by TypeScript.
  148. In order to use these rules, you must be using `@typescript-eslint/parser` &
  149. adjust your eslint config as outlined
  150. [here](https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/TYPED_LINTING.md)
  151. Note that unlike the type-checking rules in `@typescript-eslint/eslint-plugin`,
  152. the rules here will fallback to doing nothing if type information is not
  153. available, meaning its safe to include them in shared configs that could be used
  154. on JavaScript and TypeScript projects.
  155. Also note that `unbound-method` depends on `@typescript-eslint/eslint-plugin`,
  156. as it extends the original `unbound-method` rule from that plugin.
  157. <!-- begin type rules list -->
  158. | Rule | Description | Configurations | Fixable |
  159. | ---------------------------------------------- | ------------------------------------------------------------- | -------------- | ------- |
  160. | [unbound-method](docs/rules/unbound-method.md) | Enforces unbound methods are called with their expected scope | | |
  161. <!-- end type rules list -->
  162. ## Credit
  163. - [eslint-plugin-mocha](https://github.com/lo1tuma/eslint-plugin-mocha)
  164. - [eslint-plugin-jasmine](https://github.com/tlvince/eslint-plugin-jasmine)
  165. ## Related Projects
  166. ### eslint-plugin-jest-formatting
  167. This project aims to provide formatting rules (auto-fixable where possible) to
  168. ensure consistency and readability in jest test suites.
  169. https://github.com/dangreenisrael/eslint-plugin-jest-formatting
  170. ### eslint-plugin-istanbul
  171. A set of rules to enforce good practices for Istanbul, one of the code coverage
  172. tools used by Jest.
  173. https://github.com/istanbuljs/eslint-plugin-istanbul
  174. [recommended]: https://img.shields.io/badge/-recommended-lightgrey.svg
  175. [suggest]: https://img.shields.io/badge/-suggest-yellow.svg
  176. [fixable]: https://img.shields.io/badge/-fixable-green.svg
  177. [style]: https://img.shields.io/badge/-style-blue.svg