eslint.config.js 2.7 KB

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