eslint.config.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. import js from '@eslint/js';
  2. import globals from 'globals';
  3. import mdcs from 'eslint-config-mdcs';
  4. import compat from 'eslint-plugin-compat';
  5. import html from 'eslint-plugin-html';
  6. import jsdoc from 'eslint-plugin-jsdoc';
  7. export default [
  8. // files to ignore
  9. {
  10. name: 'files to ignore',
  11. ignores: [
  12. '**/node_modules/**',
  13. '**/build/**',
  14. 'examples/jsm/libs/**',
  15. 'editor/js/libs/acorn/**',
  16. 'editor/js/libs/codemirror/**',
  17. 'editor/js/libs/tern-threejs/**',
  18. 'editor/js/libs/ternjs/**',
  19. 'editor/js/libs/esprima.js',
  20. 'editor/js/libs/jsonlint.js',
  21. 'editor/js/libs/signals.min.js',
  22. '**/ifc/**',
  23. '**/prettify.js',
  24. '**/prettify/**',
  25. '**/3rdparty/**',
  26. '**/shapefile.js',
  27. '**/vendor/**',
  28. '**/fuse/**',
  29. '**/template/static/**',
  30. ]
  31. },
  32. // recommended
  33. js.configs.recommended,
  34. // jsdoc.configs['flat/recommended'],
  35. // base rules
  36. {
  37. name: 'base rules',
  38. files: [ '**/*.js', '**/*.html' ],
  39. plugins: {
  40. html,
  41. compat,
  42. jsdoc
  43. },
  44. languageOptions: {
  45. ecmaVersion: 2022,
  46. sourceType: 'module',
  47. globals: {
  48. ...globals.browser,
  49. ...globals.node,
  50. ...globals.es2017,
  51. __THREE_DEVTOOLS__: 'readonly',
  52. potpack: 'readonly',
  53. fflate: 'readonly',
  54. Stats: 'readonly',
  55. XRWebGLBinding: 'readonly',
  56. XRWebGLLayer: 'readonly',
  57. GPUShaderStage: 'readonly',
  58. GPUBufferUsage: 'readonly',
  59. GPUTextureUsage: 'readonly',
  60. GPUTexture: 'readonly',
  61. GPUMapMode: 'readonly',
  62. QUnit: 'readonly',
  63. Ammo: 'readonly',
  64. XRRigidTransform: 'readonly',
  65. XRMediaBinding: 'readonly',
  66. CodeMirror: 'readonly',
  67. esprima: 'readonly',
  68. jsonlint: 'readonly',
  69. VideoFrame: 'readonly',
  70. VideoDecoder: 'readonly',
  71. Float16Array: 'readonly',
  72. BigInt: 'readonly',
  73. BigUint64Array: 'readonly'
  74. },
  75. },
  76. settings: {
  77. polyfills: [
  78. 'WebGL2RenderingContext'
  79. ],
  80. jsdoc: {
  81. preferredTypes: {
  82. Any: 'any',
  83. Boolean: 'boolean',
  84. Number: 'number',
  85. object: 'Object',
  86. String: 'string'
  87. },
  88. tagNamePreference: {
  89. returns: 'return',
  90. extends: 'augments'
  91. },
  92. },
  93. },
  94. rules: {
  95. ...mdcs.rules,
  96. ...compat.configs.recommended.rules,
  97. 'no-throw-literal': 'error',
  98. 'quotes': [ 'error', 'single' ],
  99. 'prefer-const': [ 'error', {
  100. destructuring: 'any',
  101. ignoreReadBeforeAssign: false
  102. } ],
  103. 'no-irregular-whitespace': 'error',
  104. 'no-duplicate-imports': 'error',
  105. 'prefer-spread': 'error',
  106. // 'eqeqeq': 'error',
  107. 'no-useless-escape': 'off',
  108. 'no-case-declarations': 'off',
  109. 'no-cond-assign': 'off',
  110. 'getter-return': 'off',
  111. 'no-async-promise-executor': 'off',
  112. 'no-empty': 'off',
  113. 'no-fallthrough': 'off',
  114. 'no-prototype-builtins': 'off',
  115. 'no-loss-of-precision': 'off',
  116. 'no-unused-vars': [ 'error', {
  117. caughtErrors: 'none',
  118. } ],
  119. 'jsdoc/check-types': 'error',
  120. 'jsdoc/require-returns': 'off',
  121. 'jsdoc/require-returns-type': 'error',
  122. 'jsdoc/require-param-description': 'off',
  123. 'jsdoc/require-returns-description': 'off',
  124. 'jsdoc/require-param-type': 'error'
  125. }
  126. },
  127. // editor rules
  128. {
  129. name: 'editor rules',
  130. files: [ 'editor/**/*.js' ],
  131. languageOptions: {
  132. ecmaVersion: 2022,
  133. sourceType: 'module'
  134. }
  135. }
  136. ];
粤ICP备19079148号