eslint.config.js 3.6 KB

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