eslint.config.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. import js from "@eslint/js";
  2. import globals from "globals";
  3. export default [
  4. js.configs.recommended,
  5. {
  6. // Global ignores
  7. ignores: [
  8. "**/*.min.js",
  9. "**/src/lib/**",
  10. "**/dist/",
  11. "src/backend/src/public/assets/**",
  12. ],
  13. },
  14. {
  15. // Top-level and tools use Node
  16. files: [
  17. "tools/**/*.js",
  18. ],
  19. languageOptions: {
  20. globals: {
  21. ...globals.node,
  22. }
  23. }
  24. },
  25. {
  26. // Back end
  27. files: [
  28. "src/backend/**/*.js",
  29. "mods/**/*.js",
  30. "dev-server.js",
  31. "utils.js",
  32. ],
  33. languageOptions: {
  34. globals: {
  35. ...globals.node,
  36. "kv": true,
  37. "def": true,
  38. "use": true,
  39. "ll":true,
  40. }
  41. }
  42. },
  43. {
  44. // Front end
  45. files: [
  46. "src/**/*.js",
  47. ],
  48. ignores: [
  49. "src/backend/**/*.js",
  50. ],
  51. languageOptions: {
  52. globals: {
  53. ...globals.browser,
  54. ...globals.commonjs,
  55. "puter": true,
  56. "i18n": true,
  57. "html_encode": true,
  58. "html_decode": true,
  59. "isMobile": true,
  60. // Class Registry
  61. "logger": true,
  62. "def": true,
  63. "use": true,
  64. // Libraries
  65. "saveAs": true, // FileSaver
  66. "iro": true, // iro.js color picker
  67. "$": true, // jQuery
  68. "jQuery": true, // jQuery
  69. "JSZip": true, // JSZip
  70. "_": true, // lodash
  71. "QRCode": true, // qrcode
  72. "io": true, // socket.io
  73. "timeago": true, // timeago
  74. "SelectionArea": true, // viselect
  75. // Puter GUI Globals
  76. "set_menu_item_prop": true,
  77. "determine_active_container_parent": true,
  78. "privacy_aware_path": true,
  79. "api_origin": true,
  80. "auth_token": true,
  81. "logout": true,
  82. "is_email": true,
  83. "select_ctxmenu_item": true,
  84. }
  85. }
  86. },
  87. {
  88. // Mods
  89. // NOTE: Mods have backend and frontend parts, so this just includes the globals for both.
  90. files: [
  91. "mods/**/*.js",
  92. ],
  93. languageOptions: {
  94. globals: {
  95. ...globals.node,
  96. "use": true,
  97. "window": true,
  98. "puter": true,
  99. }
  100. }
  101. },
  102. {
  103. // Tests
  104. files: [
  105. "**/test/**/*.js",
  106. ],
  107. languageOptions: {
  108. globals: {
  109. ...globals.mocha,
  110. }
  111. }
  112. },
  113. {
  114. // Phoenix
  115. files: [
  116. "src/phoenix/**/*.js",
  117. ],
  118. languageOptions: {
  119. globals: {
  120. ...globals.node,
  121. }
  122. }
  123. },
  124. {
  125. // Global rule settings
  126. rules: {
  127. "no-prototype-builtins": "off", // Complains about any use of hasOwnProperty()
  128. "no-unused-vars": "off", // Temporary, we just have a lot of these
  129. "no-debugger": "warn",
  130. "no-async-promise-executor": "off", // We do this quite often and it's fine
  131. }
  132. },
  133. ];