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 6.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. # eslint-plugin-prettier [![Build Status](https://github.com/prettier/eslint-plugin-prettier/workflows/CI/badge.svg?branch=master)](https://github.com/prettier/eslint-plugin-prettier/actions?query=workflow%3ACI+branch%3Amaster)
  2. Runs [Prettier](https://github.com/prettier/prettier) as an [ESLint](http://eslint.org) rule and reports differences as individual ESLint issues.
  3. If your desired formatting does not match Prettier’s output, you should use a different tool such as [prettier-eslint](https://github.com/prettier/prettier-eslint) instead.
  4. Please read [Integrating with linters](https://prettier.io/docs/en/integrating-with-linters.html) before installing.
  5. ## Sample
  6. ```js
  7. error: Insert `,` (prettier/prettier) at pkg/commons-atom/ActiveEditorRegistry.js:22:25:
  8. 20 | import {
  9. 21 | observeActiveEditorsDebounced,
  10. > 22 | editorChangesDebounced
  11. | ^
  12. 23 | } from './debounced';;
  13. 24 |
  14. 25 | import {observableFromSubscribeFunction} from '../commons-node/event';
  15. error: Delete `;` (prettier/prettier) at pkg/commons-atom/ActiveEditorRegistry.js:23:21:
  16. 21 | observeActiveEditorsDebounced,
  17. 22 | editorChangesDebounced
  18. > 23 | } from './debounced';;
  19. | ^
  20. 24 |
  21. 25 | import {observableFromSubscribeFunction} from '../commons-node/event';
  22. 26 | import {cacheWhileSubscribed} from '../commons-node/observable';
  23. 2 errors found.
  24. ```
  25. > `./node_modules/.bin/eslint --format codeframe pkg/commons-atom/ActiveEditorRegistry.js` (code from [nuclide](https://github.com/facebook/nuclide)).
  26. ## Installation
  27. ```sh
  28. npm install --save-dev eslint-plugin-prettier
  29. npm install --save-dev --save-exact prettier
  30. ```
  31. **_`eslint-plugin-prettier` does not install Prettier or ESLint for you._** _You must install these yourself._
  32. Then, in your `.eslintrc.json`:
  33. ```json
  34. {
  35. "plugins": ["prettier"],
  36. "rules": {
  37. "prettier/prettier": "error"
  38. }
  39. }
  40. ```
  41. ## Recommended Configuration
  42. This plugin works best if you disable all other ESLint rules relating to code formatting, and only enable rules that detect potential bugs. (If another active ESLint rule disagrees with `prettier` about how code should be formatted, it will be impossible to avoid lint errors.) You can use [eslint-config-prettier](https://github.com/prettier/eslint-config-prettier) to disable all formatting-related ESLint rules.
  43. This plugin ships with a `plugin:prettier/recommended` config that sets up both the plugin and `eslint-config-prettier` in one go.
  44. 1. In addition to the above installation instructions, install `eslint-config-prettier`:
  45. ```sh
  46. npm install --save-dev eslint-config-prettier
  47. ```
  48. 2. Then you need to add `plugin:prettier/recommended` as the _last_ extension in your `.eslintrc.json`:
  49. ```json
  50. {
  51. "extends": ["plugin:prettier/recommended"]
  52. }
  53. ```
  54. You can then set Prettier's own options inside a `.prettierrc` file.
  55. Exactly what does `plugin:prettier/recommended` do? Well, this is what it expands to:
  56. ```json
  57. {
  58. "extends": ["prettier"],
  59. "plugins": ["prettier"],
  60. "rules": {
  61. "prettier/prettier": "error",
  62. "arrow-body-style": "off",
  63. "prefer-arrow-callback": "off"
  64. }
  65. }
  66. ```
  67. - `"extends": ["prettier"]` enables the config from `eslint-config-prettier`, which turns off some ESLint rules that conflict with Prettier.
  68. - `"plugins": ["prettier"]` registers this plugin.
  69. - `"prettier/prettier": "error"` turns on the rule provided by this plugin, which runs Prettier from within ESLint.
  70. - `"arrow-body-style": "off"` and `"prefer-arrow-callback": "off"` turns off two ESLint core rules that unfortunately are problematic with this plugin – see the next section.
  71. ## `arrow-body-style` and `prefer-arrow-callback` issue
  72. If you use [arrow-body-style](https://eslint.org/docs/rules/arrow-body-style) or [prefer-arrow-callback](https://eslint.org/docs/rules/prefer-arrow-callback) together with the `prettier/prettier` rule from this plugin, you can in some cases end up with invalid code due to a bug in ESLint’s autofix – see [issue #65](https://github.com/prettier/eslint-plugin-prettier/issues/65).
  73. For this reason, it’s recommended to turn off these rules. The `plugin:prettier/recommended` config does that for you.
  74. You _can_ still use these rules together with this plugin if you want, because the bug does not occur _all the time._ But if you do, you need to keep in mind that you might end up with invalid code, where you manually have to insert a missing closing parenthesis to get going again.
  75. If you’re fixing large of amounts of previously unformatted code, consider temporarily disabling the `prettier/prettier` rule and running `eslint --fix` and `prettier --write` separately.
  76. ## Options
  77. > Note: While it is possible to pass options to Prettier via your ESLint configuration file, it is not recommended because editor extensions such as `prettier-atom` and `prettier-vscode` **will** read [`.prettierrc`](https://prettier.io/docs/en/configuration.html), but **won't** read settings from ESLint, which can lead to an inconsistent experience.
  78. - The first option:
  79. - An object representing [options](https://prettier.io/docs/en/options.html) that will be passed into prettier. Example:
  80. ```json
  81. "prettier/prettier": ["error", {"singleQuote": true, "parser": "flow"}]
  82. ```
  83. NB: This option will merge and override any config set with `.prettierrc` files
  84. - The second option:
  85. - An object with the following options
  86. - `usePrettierrc`: Enables loading of the Prettier configuration file, (default: `true`). May be useful if you are using multiple tools that conflict with each other, or do not wish to mix your ESLint settings with your Prettier configuration.
  87. ```json
  88. "prettier/prettier": ["error", {}, {
  89. "usePrettierrc": false
  90. }]
  91. ```
  92. - `fileInfoOptions`: Options that are passed to [prettier.getFileInfo](https://prettier.io/docs/en/api.html#prettiergetfileinfofilepath--options) to decide whether a file needs to be formatted. Can be used for example to opt-out from ignoring files located in `node_modules` directories.
  93. ```json
  94. "prettier/prettier": ["error", {}, {
  95. "fileInfoOptions": {
  96. "withNodeModules": true
  97. }
  98. }]
  99. ```
  100. - The rule is autofixable -- if you run `eslint` with the `--fix` flag, your code will be formatted according to `prettier` style.
  101. ---
  102. ## Contributing
  103. See [CONTRIBUTING.md](https://github.com/prettier/eslint-plugin-prettier/blob/master/CONTRIBUTING.md)