智慧水务管理系统 - 精河县供水工程综合管理平台

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. import globals from "globals";
  2. import html from "eslint-plugin-html";
  3. import configCesium from "@cesium/eslint-config";
  4. import reactHooks from "eslint-plugin-react-hooks";
  5. import { reactRefresh } from "eslint-plugin-react-refresh";
  6. import tseslint from "typescript-eslint";
  7. import seatbelt from "eslint-seatbelt";
  8. import { fileURLToPath } from "node:url";
  9. import { dirname, join } from "node:path";
  10. const __dirname = dirname(fileURLToPath(import.meta.url));
  11. export default [
  12. tseslint.configs.base,
  13. {
  14. ignores: [
  15. "**/Build/",
  16. "Documentation/**/*",
  17. "Source/*",
  18. "**/ThirdParty/",
  19. "Tools/**/*",
  20. "index.html",
  21. "index.release.html",
  22. "Apps/HelloWorld.html",
  23. "Apps/Sandcastle2/",
  24. "packages/sandcastle/public/",
  25. "packages/sandcastle/templates/Sandcastle.d.ts",
  26. "packages/sandcastle/templates/Sandcastle.js",
  27. "packages/sandcastle/gallery/pagefind/",
  28. "packages/engine/Source/Scene/GltfPipeline/**/*",
  29. "packages/engine/Source/Shaders/**/*",
  30. "Specs/jasmine/*",
  31. "**/*/SpecList.js",
  32. ],
  33. },
  34. {
  35. ...configCesium.configs.recommended,
  36. linterOptions: {
  37. reportUnusedDisableDirectives: "error",
  38. },
  39. languageOptions: {
  40. sourceType: "module",
  41. },
  42. },
  43. {
  44. files: ["**/*.cjs"],
  45. ...configCesium.configs.node,
  46. },
  47. {
  48. files: [
  49. ".github/**/*.js",
  50. "scripts/**/*.js",
  51. "packages/sandcastle/scripts/**/*.js",
  52. "gulpfile.js",
  53. "gulpfile.apps.js",
  54. "gulpfile.makezip.js",
  55. "server.js",
  56. ],
  57. ...configCesium.configs.node,
  58. languageOptions: {
  59. ...configCesium.configs.node.languageOptions,
  60. sourceType: "module",
  61. },
  62. },
  63. {
  64. files: ["packages/**/*.js", "Apps/**/*.js", "Specs/**/*.js", "**/*.html"],
  65. ignores: ["packages/sandcastle/scripts/**/*.js"],
  66. ...configCesium.configs.browser,
  67. plugins: { html, "eslint-seatbelt": seatbelt },
  68. processor: seatbelt.processors.seatbelt,
  69. settings: {
  70. seatbelt: {
  71. seatbeltFile: join(__dirname, "eslint.seatbelt.tsv"),
  72. },
  73. },
  74. rules: {
  75. ...configCesium.configs.browser.rules,
  76. "eslint-seatbelt/configure": "error",
  77. "no-unused-vars": [
  78. "error",
  79. { vars: "all", args: "none", caughtErrors: "none" },
  80. ],
  81. // There were too many errors to address when this was first turned on.
  82. // Using eslint-seatbelt to gradually address them
  83. "no-useless-assignment": "error",
  84. "no-restricted-syntax": [
  85. "warn",
  86. {
  87. // The pattern of Array.push.apply() can lead to stack
  88. // overflow errors when the source array is large.
  89. // See https://github.com/CesiumGS/cesium/issues/12053
  90. selector:
  91. "CallExpression[callee.object.property.name=push][callee.property.name=apply]",
  92. message:
  93. "Avoid Array.push.apply(). Use addAllToArray() for arrays of unknown size, or the spread syntax for arrays that are known to be small",
  94. },
  95. ],
  96. // When ES6 class implementations refer to scratch variable instances of
  97. // the same class, ESLint raises a use-before-define error. At runtime
  98. // this is just fine, so configure ESLint to allow it in upper scopes.
  99. "no-use-before-define": [
  100. "error",
  101. { variables: false, functions: false, classes: false },
  102. ],
  103. // Prefer @ts-expect-error (with description) over @ts-ignore. Allow both
  104. // @ts-check and @ts-nocheck during transition to type checking.
  105. "@typescript-eslint/ban-ts-comment": [
  106. "error",
  107. {
  108. minimumDescriptionLength: 3,
  109. "ts-ignore": true,
  110. "ts-expect-error": "allow-with-description",
  111. "ts-check": false,
  112. "ts-nocheck": false,
  113. },
  114. ],
  115. // Disallow e.g. `new Cartesian3.fromDegrees(...)`; invalid with ES6 classes.
  116. "new-cap": ["error", { capIsNew: true }],
  117. },
  118. },
  119. ...[...tseslint.configs.recommended].map((config) => ({
  120. // This is needed to restrict to a specific path unless using the tseslint.config function
  121. // https://typescript-eslint.io/packages/typescript-eslint#config
  122. ...config,
  123. files: ["packages/sandcastle/**/*.{ts,tsx}"],
  124. })),
  125. {
  126. // This config came from the vite project generation
  127. files: ["packages/sandcastle/**/*.{ts,tsx}"],
  128. languageOptions: {
  129. ecmaVersion: 2020,
  130. globals: globals.browser,
  131. },
  132. plugins: {
  133. "react-hooks": reactHooks,
  134. "react-refresh": reactRefresh.plugin,
  135. },
  136. rules: {
  137. ...reactHooks.configs.recommended.rules,
  138. "react-refresh/only-export-components": [
  139. "warn",
  140. { allowConstantExport: true },
  141. ],
  142. },
  143. },
  144. {
  145. files: ["packages/sandcastle/gallery/**/*.js"],
  146. languageOptions: {
  147. ecmaVersion: 2022,
  148. sourceType: "module",
  149. },
  150. rules: {
  151. "no-alert": "off",
  152. },
  153. },
  154. {
  155. files: ["packages/sandcastle/gallery/hello-world/main.js"],
  156. rules: {
  157. // ignore this rule here to avoid the excessive eslint-disable comment in our bare minimum example
  158. "no-unused-vars": "off",
  159. },
  160. },
  161. {
  162. files: ["Specs/**/*", "packages/**/Specs/**/*"],
  163. languageOptions: {
  164. globals: {
  165. ...globals.jasmine,
  166. },
  167. },
  168. rules: {
  169. "no-self-assign": "off",
  170. },
  171. },
  172. {
  173. files: ["Specs/e2e/**/*"],
  174. languageOptions: {
  175. globals: {
  176. ...globals.node,
  177. Cesium: true,
  178. },
  179. },
  180. rules: {
  181. "no-unused-vars": "off",
  182. },
  183. },
  184. {
  185. files: [".github/**/*"],
  186. rules: {
  187. "n/no-missing-import": "off",
  188. },
  189. },
  190. ];