.eslintrc.cjs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. module.exports = {
  2. 'extends': 'airbnb-base',
  3. 'parserOptions': {
  4. 'ecmaVersion': 11,
  5. 'sourceType': 'module'
  6. },
  7. 'env': {
  8. 'browser': true,
  9. 'es6': true,
  10. 'node': true
  11. },
  12. 'plugins': [
  13. 'chai-friendly',
  14. 'import',
  15. 'unicorn'
  16. ],
  17. 'globals': { // TODO are all these necessary?
  18. 'globalThis': true,
  19. 'console': true,
  20. 'Promise': true,
  21. 'importScripts': true,
  22. 'process': true,
  23. 'Event': true,
  24. 'describe': true,
  25. 'it': true,
  26. 'mocha': true,
  27. 'before': true,
  28. 'beforeEach': true,
  29. 'after': true,
  30. 'afterEach': true,
  31. 'escape': true,
  32. 'unescape': true,
  33. 'resolves': true,
  34. 'rejects': true,
  35. 'TransformStream': true,
  36. 'BigInt': true
  37. },
  38. 'rules': {
  39. 'arrow-body-style': 'off',
  40. 'arrow-parens': ['error','as-needed'],
  41. 'class-methods-use-this': 'off',
  42. 'comma-dangle': ['error', 'never'],
  43. 'comma-spacing': 'off',
  44. 'consistent-return': 'off',
  45. 'default-case': 'off',
  46. 'default-param-last': 'off',
  47. 'eol-last': ['error', 'always'],
  48. 'function-call-argument-newline': 'off',
  49. 'func-names': ['error', 'never'],
  50. 'function-paren-newline': 'off',
  51. 'global-require': 'off',
  52. 'key-spacing': 'off',
  53. 'keyword-spacing': 'error',
  54. 'max-classes-per-file': 'off',
  55. 'max-len': 'off',
  56. 'newline-per-chained-call': 'off',
  57. 'no-bitwise': 'off',
  58. 'no-continue': 'off',
  59. 'no-else-return': 'off',
  60. 'no-empty': ['error', { 'allowEmptyCatch': true }],
  61. 'no-multiple-empty-lines': ['error', { 'max': 2, 'maxEOF': 1, 'maxBOF':0 }],
  62. 'no-nested-ternary': 'off',
  63. 'no-param-reassign': 'off', // TODO get rid of this
  64. 'no-plusplus': 'off',
  65. 'no-restricted-syntax': ['error', 'ForInStatement', 'LabeledStatement', 'WithStatement'],
  66. 'object-curly-newline': 'off',
  67. 'no-shadow': 'off', // TODO get rid of this
  68. 'object-property-newline': [
  69. 'error',
  70. {
  71. 'allowMultiplePropertiesPerLine': true
  72. }
  73. ],
  74. 'object-shorthand': 'off',
  75. 'operator-assignment': 'off',
  76. 'operator-linebreak': [
  77. 'error',
  78. 'after'
  79. ],
  80. 'padded-blocks': 'off',
  81. 'prefer-arrow-callback': 'off',
  82. 'prefer-destructuring': 'off',
  83. 'prefer-rest-params': 'off', // TODO get rid of this
  84. 'prefer-spread': 'off', // TODO get rid of this
  85. 'prefer-template': 'off',
  86. 'quote-props': 'off',
  87. 'quotes': ['error', 'single', { 'avoidEscape': true }],
  88. 'space-before-function-paren': ['error', { 'anonymous': 'ignore', 'named': 'never', 'asyncArrow': 'always' }],
  89. 'spaced-comment': 'off',
  90. 'indent': ['error', 2, { 'SwitchCase': 1 }],
  91. 'no-unused-vars': 'error',
  92. // eslint-plugin-import rules:
  93. 'import/named': 'error',
  94. 'import/extensions': 'off', // temporary: we use them in tests (ESM compliant), but not in the lib (to limit diff)
  95. 'import/first': 'off',
  96. 'import/no-extraneous-dependencies': ['error', { 'devDependencies': true, 'optionalDependencies': false, 'peerDependencies': false }],
  97. 'import/no-unassigned-import': 'error',
  98. 'import/no-unresolved': ['error', {
  99. // esm exports not supported: https://github.com/import-js/eslint-plugin-import/issues/1810
  100. ignore: ['openpgp', '@openpgp/noble-hashes', '@openpgp/web-stream-tools', '@openpgp/asmcrypto.js']
  101. }],
  102. 'import/prefer-default-export': 'off',
  103. // Custom silencers:
  104. 'camelcase': 'off', // used in tests, need to fix separately
  105. 'no-multi-assign': 'off',
  106. 'no-underscore-dangle': 'off',
  107. 'no-await-in-loop': 'off',
  108. // Custom errors:
  109. 'no-use-before-define': [2, { 'functions': false, 'classes': true, 'variables': false }],
  110. 'no-constant-condition': [2, { 'checkLoops': false }],
  111. 'new-cap': [2, { 'properties': false, 'capIsNewExceptionPattern': 'EAX|OCB|GCM|CMAC|CBC|OMAC|CTR', 'newIsCapExceptionPattern': 'type|hash*' }],
  112. 'max-lines': [2, { 'max': 620, 'skipBlankLines': true, 'skipComments': true }],
  113. 'no-unused-expressions': 0,
  114. 'chai-friendly/no-unused-expressions': [2, { 'allowShortCircuit': true }],
  115. 'unicorn/switch-case-braces': ['error', 'avoid'],
  116. // Custom warnings:
  117. 'no-console': 1
  118. }
  119. };