validators.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. "use strict";
  2. // These validator functions answer the question “Is the config valid?” – return
  3. // `false` if the options DO conflict with Prettier, and `true` if they don’t.
  4. module.exports = {
  5. curly(options) {
  6. if (options.length === 0) {
  7. return true;
  8. }
  9. const firstOption = options[0];
  10. return firstOption !== "multi-line" && firstOption !== "multi-or-nest";
  11. },
  12. "lines-around-comment"(options) {
  13. if (options.length === 0) {
  14. return false;
  15. }
  16. const firstOption = options[0];
  17. return Boolean(
  18. firstOption &&
  19. firstOption.allowBlockStart &&
  20. firstOption.allowBlockEnd &&
  21. firstOption.allowObjectStart &&
  22. firstOption.allowObjectEnd &&
  23. firstOption.allowArrayStart &&
  24. firstOption.allowArrayEnd
  25. );
  26. },
  27. "no-confusing-arrow"(options) {
  28. if (options.length === 0) {
  29. return false;
  30. }
  31. const firstOption = options[0];
  32. return firstOption ? firstOption.allowParens === false : false;
  33. },
  34. "vue/html-self-closing"(options) {
  35. if (options.length === 0) {
  36. return false;
  37. }
  38. const firstOption = options[0];
  39. return Boolean(
  40. firstOption && firstOption.html && firstOption.html.void === "any"
  41. // Enable when Prettier supports SVG: https://github.com/prettier/prettier/issues/5322
  42. // && firstOption.svg === "any"
  43. );
  44. },
  45. };