.eslintrc 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. {
  2. "parserOptions": {
  3. "ecmaVersion": 2022,
  4. "sourceType": "module",
  5. },
  6. "plugins": [
  7. "import",
  8. "json",
  9. "mozilla",
  10. "no-unsanitized",
  11. "sort-exports",
  12. "unicorn",
  13. ],
  14. "extends": [
  15. "plugin:json/recommended",
  16. "plugin:prettier/recommended"
  17. ],
  18. "env": {
  19. "browser": true,
  20. "es2022": true,
  21. "worker": true,
  22. "amd": true,
  23. },
  24. "globals": {
  25. "PDFJSDev": false,
  26. "exports": false,
  27. "SystemJS": false,
  28. },
  29. "rules": {
  30. // Plugins
  31. "import/extensions": ["error", "always", { "ignorePackages": true, }],
  32. "import/no-unresolved": ["error", {
  33. "ignore": ["pdfjs", "pdfjs-lib", "pdfjs-web", "pdfjs-fitCurve"]
  34. }],
  35. "mozilla/avoid-removeChild": "error",
  36. "mozilla/use-includes-instead-of-indexOf": "error",
  37. "no-unsanitized/method": "error",
  38. "no-unsanitized/property": "error",
  39. "sort-exports/sort-exports": ["error", {
  40. "ignoreCase": true,
  41. }],
  42. "unicorn/no-abusive-eslint-disable": "error",
  43. "unicorn/no-array-push-push": "error",
  44. "unicorn/no-instanceof-array": "error",
  45. "unicorn/no-new-buffer": "error",
  46. "unicorn/no-useless-spread": "error",
  47. "unicorn/prefer-array-find": "error",
  48. "unicorn/prefer-array-flat": "error",
  49. "unicorn/prefer-array-flat-map": "error",
  50. "unicorn/prefer-array-index-of": "error",
  51. "unicorn/prefer-at": "error",
  52. "unicorn/prefer-date-now": "error",
  53. "unicorn/prefer-dom-node-append": "error",
  54. "unicorn/prefer-dom-node-remove": "error",
  55. "unicorn/prefer-logical-operator-over-ternary": "error",
  56. "unicorn/prefer-modern-dom-apis": "error",
  57. "unicorn/prefer-regexp-test": "error",
  58. "unicorn/prefer-string-starts-ends-with": "error",
  59. "unicorn/no-typeof-undefined": ["error", { "checkGlobalVariables": false, }],
  60. // Possible errors
  61. "for-direction": "error",
  62. "getter-return": "error",
  63. "no-async-promise-executor": "error",
  64. "no-cond-assign": ["error", "except-parens"],
  65. "no-constant-condition": ["error", { "checkLoops": false, }],
  66. "no-debugger": "error",
  67. "no-dupe-args": "error",
  68. "no-dupe-else-if": "error",
  69. "no-dupe-keys": "error",
  70. "no-duplicate-case": "error",
  71. "no-empty": ["error", { "allowEmptyCatch": true, }],
  72. "no-empty-character-class": "error",
  73. "no-ex-assign": "error",
  74. "no-extra-boolean-cast": "error",
  75. "no-func-assign": "error",
  76. "no-inner-declarations": ["error", "functions"],
  77. "no-invalid-regexp": "error",
  78. "no-irregular-whitespace": "error",
  79. "no-loss-of-precision": "error",
  80. "no-obj-calls": "error",
  81. "no-promise-executor-return": "error",
  82. "no-regex-spaces": "error",
  83. "no-setter-return": "error",
  84. "no-sparse-arrays": "error",
  85. "no-template-curly-in-string": "error",
  86. "no-unexpected-multiline": "error",
  87. "no-unreachable": "error",
  88. "no-unsafe-finally": "error",
  89. "no-unsafe-negation": "error",
  90. "no-unsafe-optional-chaining": ["error", { "disallowArithmeticOperators": true }],
  91. "no-unused-private-class-members": "error",
  92. "use-isnan": ["error", { "enforceForIndexOf": true, }],
  93. "valid-typeof": ["error", { "requireStringLiterals": true, }],
  94. // Best Practices
  95. "accessor-pairs": ["error", {
  96. "setWithoutGet": true,
  97. "enforceForClassMembers": true,
  98. }],
  99. "consistent-return": "error",
  100. "curly": ["error", "all"],
  101. "default-case-last": "error",
  102. "dot-notation": "error",
  103. "eqeqeq": ["error", "always"],
  104. "grouped-accessor-pairs": ["error", "getBeforeSet"],
  105. "no-alert": "error",
  106. "no-caller": "error",
  107. "no-else-return": "error",
  108. "no-empty-pattern": "error",
  109. "no-eval": "error",
  110. "no-extend-native": "error",
  111. "no-extra-bind": "error",
  112. "no-extra-label": "error",
  113. "no-fallthrough": "error",
  114. "no-floating-decimal": "error",
  115. "no-global-assign": "error",
  116. "no-implied-eval": "error",
  117. "no-iterator": "error",
  118. "no-lone-blocks": "error",
  119. "no-multi-str": "error",
  120. "no-new-func": "error",
  121. "no-new-wrappers": "error",
  122. "no-new": "error",
  123. "no-octal-escape": "error",
  124. "no-octal": "error",
  125. "no-redeclare": "error",
  126. "no-return-await": "error",
  127. "no-self-assign": "error",
  128. "no-self-compare": "error",
  129. "no-throw-literal": "error",
  130. "no-unused-expressions": "error",
  131. "no-unused-labels": "error",
  132. "no-useless-call": "error",
  133. "no-useless-catch": "error",
  134. "no-useless-concat": "error",
  135. "no-useless-escape": "error",
  136. "no-useless-return": "error",
  137. "prefer-promise-reject-errors": "error",
  138. "prefer-spread": "error",
  139. "wrap-iife": ["error", "any"],
  140. "yoda": ["error", "never", {
  141. "exceptRange": true,
  142. }],
  143. // Strict Mode
  144. "strict": ["off", "global"],
  145. // Variables
  146. "no-delete-var": "error",
  147. "no-label-var": "error",
  148. "no-shadow": "error",
  149. "no-shadow-restricted-names": "error",
  150. "no-undef-init": "error",
  151. "no-undef": ["error", { "typeof": true, }],
  152. "no-unused-vars": ["error", {
  153. "vars": "all",
  154. "args": "none",
  155. }],
  156. "no-use-before-define": ["error", {
  157. "functions": false,
  158. "classes": false,
  159. "variables": false,
  160. }],
  161. // Stylistic Issues
  162. "lines-between-class-members": ["error", "always"],
  163. "max-len": ["error", {
  164. "code": 1000,
  165. "comments": 80,
  166. "ignoreUrls": true
  167. }],
  168. "new-cap": ["error", { "newIsCap": true, "capIsNew": false, }],
  169. "no-array-constructor": "error",
  170. "no-multiple-empty-lines": ["error", { "max": 1, "maxEOF": 0, "maxBOF": 1, }],
  171. "no-nested-ternary": "error",
  172. "no-new-object": "error",
  173. "no-restricted-syntax": ["error",
  174. {
  175. "selector": "BinaryExpression[operator='instanceof'][right.name='Object']",
  176. "message": "Use `typeof` rather than `instanceof Object`.",
  177. },
  178. {
  179. "selector": "CallExpression[callee.name='assert'][arguments.length!=2]",
  180. "message": "`assert()` must always be invoked with two arguments.",
  181. },
  182. {
  183. "selector": "CallExpression[callee.name='isCmd'][arguments.length<2]",
  184. "message": "Use `instanceof Cmd` rather than `isCmd()` with one argument.",
  185. },
  186. {
  187. "selector": "CallExpression[callee.name='isDict'][arguments.length<2]",
  188. "message": "Use `instanceof Dict` rather than `isDict()` with one argument.",
  189. },
  190. {
  191. "selector": "CallExpression[callee.name='isName'][arguments.length<2]",
  192. "message": "Use `instanceof Name` rather than `isName()` with one argument.",
  193. },
  194. {
  195. "selector": "NewExpression[callee.name='Cmd']",
  196. "message": "Use `Cmd.get()` rather than `new Cmd()`.",
  197. },
  198. {
  199. "selector": "NewExpression[callee.name='Name']",
  200. "message": "Use `Name.get()` rather than `new Name()`.",
  201. },
  202. {
  203. "selector": "NewExpression[callee.name='Ref']",
  204. "message": "Use `Ref.get()` rather than `new Ref()`.",
  205. },
  206. ],
  207. "no-unneeded-ternary": "error",
  208. "operator-assignment": "error",
  209. "prefer-exponentiation-operator": "error",
  210. "spaced-comment": ["error", "always", {
  211. "block": {
  212. "balanced": true,
  213. }
  214. }],
  215. // ECMAScript 6
  216. "constructor-super": "error",
  217. "no-class-assign": "error",
  218. "no-confusing-arrow": "error",
  219. "no-const-assign": "error",
  220. "no-dupe-class-members": "error",
  221. "no-duplicate-imports": "error",
  222. "no-this-before-super": "error",
  223. "no-useless-computed-key": "error",
  224. "no-useless-constructor": "error",
  225. "no-useless-rename": "error",
  226. "no-var": "error",
  227. "object-shorthand": ["error", "always", {
  228. "avoidQuotes": true,
  229. }],
  230. "prefer-const": "error",
  231. "sort-imports": ["error", {
  232. "ignoreCase": true,
  233. }],
  234. "template-curly-spacing": ["error", "never"],
  235. },
  236. }