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.

formatters.md 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. # Writing formatters
  2. A formatter is a function with the following signature:
  3. ```js
  4. /**
  5. * @type {import('stylelint').Formatter}
  6. */
  7. function formatter(results, returnValue) {
  8. return "a string of formatted results";
  9. }
  10. ```
  11. Where the first argument (`results`) is an array of stylelint result objects (type `Array<StylelintResult>`) in the form:
  12. ```js
  13. // A stylelint result object
  14. {
  15. "source": "path/to/file.css", // The filepath or PostCSS identifier like <input css 1>
  16. "errored": true, // This is `true` if at least one rule with an "error"-level severity triggered a warning
  17. "warnings": [
  18. // Array of rule violation warning objects, each like the following ...
  19. {
  20. "line": 3,
  21. "column": 12,
  22. "rule": "block-no-empty",
  23. "severity": "error",
  24. "text": "You should not have an empty block (block-no-empty)"
  25. }
  26. ],
  27. "deprecations": [
  28. // Array of deprecation warning objects, each like the following ...
  29. {
  30. "text": "Feature X has been deprecated and will be removed in the next major version.",
  31. "reference": "https://stylelint.io/docs/feature-x.md"
  32. }
  33. ],
  34. "invalidOptionWarnings": [
  35. // Array of invalid option warning objects, each like the following ...
  36. {
  37. "text": "Invalid option X for rule Y"
  38. }
  39. ],
  40. "ignored": false // This is `true` if the file's path matches a provided ignore pattern
  41. }
  42. ```
  43. And the second argument (`returnValue`) is an object (type `StylelintStandaloneReturnValue`) with one or more of the following keys:
  44. ```js
  45. {
  46. "errored": false, // `true` if there were any warnings with "error" severity
  47. "maxWarningsExceeded": {
  48. // Present if stylelint was configured with a `maxWarnings` count
  49. "maxWarnings": 10,
  50. "foundWarnings": 15
  51. }
  52. }
  53. ```
  54. ## Passing arguments
  55. You can use environmental variables in your formatter. For example, pass `SKIP_WARNINGS`:
  56. ```console
  57. SKIP_WARNINGS=true stylelint "*.css" --custom-formatter ./my-formatter.js
  58. ```
  59. Alternatively, you can create a separate formatting program and pipe the output from the built-in JSON formatter into it:
  60. ```console
  61. stylelint -f json "*.css" | my-program-that-reads-JSON --option
  62. ```
  63. ## `stylelint.formatters`
  64. stylelint's internal formatters are exposed publicly in `stylelint.formatters`.