eslint.config.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. "packages/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. "packages/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. "index.js",
  47. "initgui.js",
  48. "src/**/*.js",
  49. "packages/**/*.js",
  50. ],
  51. ignores: [
  52. "packages/backend/**/*.js",
  53. ],
  54. languageOptions: {
  55. globals: {
  56. ...globals.browser,
  57. ...globals.commonjs,
  58. "puter": true,
  59. "i18n": true,
  60. "html_encode": true,
  61. "html_decode": true,
  62. "isMobile": true,
  63. // Class Registry
  64. "logger": true,
  65. "def": true,
  66. "use": true,
  67. // Libraries
  68. "saveAs": true, // FileSaver
  69. "iro": true, // iro.js color picker
  70. "$": true, // jQuery
  71. "jQuery": true, // jQuery
  72. "JSZip": true, // JSZip
  73. "_": true, // lodash
  74. "QRCode": true, // qrcode
  75. "io": true, // socket.io
  76. "timeago": true, // timeago
  77. "SelectionArea": true, // viselect
  78. // Puter GUI Globals
  79. "set_menu_item_prop": true,
  80. "determine_active_container_parent": true,
  81. "privacy_aware_path": true,
  82. "api_origin": true,
  83. "auth_token": true,
  84. "logout": true,
  85. "is_email": true,
  86. "select_ctxmenu_item": true,
  87. }
  88. }
  89. },
  90. {
  91. // Mods
  92. // NOTE: Mods have backend and frontend parts, so this just includes the globals for both.
  93. files: [
  94. "mods/**/*.js",
  95. ],
  96. languageOptions: {
  97. globals: {
  98. ...globals.node,
  99. "use": true,
  100. "window": true,
  101. "puter": true,
  102. }
  103. }
  104. },
  105. {
  106. // Tests
  107. files: [
  108. "**/test/**/*.js",
  109. ],
  110. languageOptions: {
  111. globals: {
  112. ...globals.mocha,
  113. }
  114. }
  115. },
  116. {
  117. // Phoenix
  118. files: [
  119. "packages/phoenix/**/*.js",
  120. ],
  121. languageOptions: {
  122. globals: {
  123. ...globals.node,
  124. }
  125. }
  126. },
  127. {
  128. // Global rule settings
  129. rules: {
  130. "no-prototype-builtins": "off", // Complains about any use of hasOwnProperty()
  131. "no-unused-vars": "off", // Temporary, we just have a lot of these
  132. "no-debugger": "warn",
  133. "no-async-promise-executor": "off", // We do this quite often and it's fine
  134. }
  135. },
  136. ];