eslint.config.js 2.8 KB

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