You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

144 lines
4.9 KiB

4 years ago
  1. 'use strict';
  2. module.exports = {
  3. env: {
  4. es2017: true,
  5. },
  6. extends: [
  7. 'eslint:recommended',
  8. 'plugin:eslint-comments/recommended',
  9. 'plugin:promise/recommended',
  10. 'plugin:you-dont-need-lodash-underscore/compatible',
  11. ],
  12. plugins: [
  13. 'eslint-comments',
  14. 'prefer-arrow',
  15. 'promise',
  16. 'you-dont-need-lodash-underscore',
  17. ],
  18. rules: {
  19. 'array-bracket-newline': ['error', 'consistent'],
  20. 'array-bracket-spacing': 'error',
  21. 'array-element-newline': ['error', 'consistent'],
  22. 'arrow-body-style': 'error',
  23. 'arrow-parens': 'error',
  24. 'arrow-spacing': 'error',
  25. 'block-spacing': 'error',
  26. 'brace-style': ['error', '1tbs', {allowSingleLine: true}],
  27. 'camelcase': ['warn', {allow: ['^ace_', '^eejsBlock_', '^handleClientMessage_']}],
  28. 'comma-dangle': ['error', {
  29. arrays: 'always-multiline',
  30. objects: 'always-multiline',
  31. imports: 'always-multiline',
  32. exports: 'always-multiline',
  33. // Trailing commas for function declarations and function calls is only supported in
  34. // ECMAScript 2017 and newer.
  35. functions: 'never',
  36. }],
  37. 'comma-spacing': 'error',
  38. 'comma-style': 'error',
  39. 'computed-property-spacing': 'error',
  40. 'curly': ['error', 'multi-line', 'consistent'],
  41. 'dot-location': ['error', 'property'],
  42. 'dot-notation': 'error',
  43. 'eol-last': 'error',
  44. 'eqeqeq': ['error', 'always', {null: 'never'}],
  45. 'func-call-spacing': 'error',
  46. 'guard-for-in': 'error',
  47. 'implicit-arrow-linebreak': 'error',
  48. 'indent': ['error', 2, {
  49. CallExpression: {
  50. arguments: 2,
  51. },
  52. FunctionDeclaration: {
  53. parameters: 2,
  54. },
  55. FunctionExpression: {
  56. parameters: 2,
  57. },
  58. MemberExpression: 2,
  59. SwitchCase: 1,
  60. flatTernaryExpressions: true,
  61. offsetTernaryExpressions: true,
  62. }],
  63. 'key-spacing': 'error',
  64. 'keyword-spacing': 'error',
  65. 'linebreak-style': 'error',
  66. 'max-len': ['error', {code: 100, tabWidth: 2, ignoreUrls: true}],
  67. 'new-cap': ['error', {
  68. capIsNewExceptions: [
  69. // ERR is an async-stacktrace convention. Remove this exception after modernizing code to
  70. // use async and await.
  71. 'ERR',
  72. ],
  73. }],
  74. 'new-parens': 'error',
  75. 'no-array-constructor': 'error',
  76. 'no-caller': 'error',
  77. 'no-duplicate-imports': 'error',
  78. 'no-eval': 'error',
  79. 'no-extend-native': 'error',
  80. 'no-implicit-globals': 'error',
  81. 'no-implied-eval': 'error',
  82. 'no-lonely-if': 'error',
  83. 'no-multi-spaces': 'error',
  84. 'no-multi-str': 'error',
  85. 'no-multiple-empty-lines': ['error', {max: 2, maxBOF: 0, maxEOF: 0}],
  86. 'no-new-object': 'error',
  87. 'no-new-wrappers': 'error',
  88. 'no-nonoctal-decimal-escape': 'error',
  89. 'no-prototype-builtins': 'error',
  90. 'no-script-url': 'error',
  91. 'no-tabs': 'error',
  92. 'no-throw-literal': 'error',
  93. 'no-trailing-spaces': 'error',
  94. 'no-unsafe-optional-chaining': 'error',
  95. 'no-unused-vars': ['error', {args: 'none'}],
  96. // There is a lot of existing code that intentionally declares functions below their use.
  97. // Hopefully that code will be updated, but until then this is set to warn to keep CI tests from
  98. // failing.
  99. 'no-use-before-define': 'warn',
  100. 'no-var': 'error',
  101. 'no-whitespace-before-property': 'error',
  102. 'nonblock-statement-body-position': 'error',
  103. 'object-curly-newline': 'error',
  104. 'object-curly-spacing': 'error',
  105. 'object-shorthand': 'error',
  106. 'one-var': ['error', {initialized: 'never'}],
  107. 'one-var-declaration-per-line': ['error', 'initializations'],
  108. 'operator-assignment': 'error',
  109. 'operator-linebreak': 'error',
  110. 'padded-blocks': ['error', 'never'],
  111. 'prefer-arrow-callback': 'error',
  112. 'prefer-arrow/prefer-arrow-functions': 'error',
  113. 'prefer-const': 'error',
  114. 'prefer-promise-reject-errors': 'error',
  115. 'prefer-rest-params': 'error',
  116. 'prefer-spread': 'error',
  117. 'prefer-template': 'error',
  118. // This rule is largely unnecessary thanks to the `await` keyword (`.then()` should be rare).
  119. // Also, being forced to add a return statement for a valueless Promise is annoying.
  120. 'promise/always-return': 'off',
  121. // This rule is largely unnecessary because most browsers now log unhandled Promise rejections.
  122. 'promise/catch-or-return': 'off',
  123. 'quote-props': ['error', 'consistent-as-needed'],
  124. 'quotes': ['error', 'single', {avoidEscape: true}],
  125. 'rest-spread-spacing': 'error',
  126. 'semi': 'error',
  127. 'semi-spacing': 'error',
  128. 'semi-style': 'error',
  129. 'space-before-blocks': 'error',
  130. 'space-before-function-paren': [
  131. 'error',
  132. {anonymous: 'always', asyncArrow: 'always', named: 'never'},
  133. ],
  134. 'space-in-parens': 'error',
  135. 'space-infix-ops': 'error',
  136. 'space-unary-ops': ['error', {words: true, nonwords: false}],
  137. 'spaced-comment': 'error',
  138. 'strict': ['error', 'global'],
  139. 'switch-colon-spacing': 'error',
  140. 'template-curly-spacing': 'error',
  141. 'template-tag-spacing': 'error',
  142. },
  143. };