.eslintrc.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. module.exports = {
  2. root: true,
  3. env: {
  4. browser: true,
  5. node: true,
  6. es6: true,
  7. jest: true,
  8. },
  9. globals: {
  10. ATTACHMENT_HOST: false,
  11. },
  12. parser: 'babel-eslint',
  13. plugins: [
  14. 'react',
  15. 'jsx-a11y',
  16. 'import',
  17. 'promise',
  18. ],
  19. parserOptions: {
  20. sourceType: 'module',
  21. ecmaFeatures: {
  22. experimentalObjectRestSpread: true,
  23. jsx: true,
  24. },
  25. ecmaVersion: 2018,
  26. },
  27. settings: {
  28. react: {
  29. version: 'detect',
  30. },
  31. 'import/extensions': [
  32. '.js',
  33. ],
  34. 'import/ignore': [
  35. 'node_modules',
  36. '\\.(css|scss|json)$',
  37. ],
  38. },
  39. rules: {
  40. 'brace-style': 'warn',
  41. 'comma-dangle': ['error', 'always-multiline'],
  42. 'comma-spacing': [
  43. 'warn',
  44. {
  45. before: false,
  46. after: true,
  47. },
  48. ],
  49. 'comma-style': ['warn', 'last'],
  50. 'consistent-return': 'error',
  51. 'dot-notation': 'error',
  52. eqeqeq: 'error',
  53. indent: ['warn', 2],
  54. 'jsx-quotes': ['error', 'prefer-single'],
  55. 'no-catch-shadow': 'error',
  56. 'no-cond-assign': 'error',
  57. 'no-console': [
  58. 'warn',
  59. {
  60. allow: [
  61. 'error',
  62. 'warn',
  63. ],
  64. },
  65. ],
  66. 'no-fallthrough': 'error',
  67. 'no-irregular-whitespace': 'error',
  68. 'no-mixed-spaces-and-tabs': 'warn',
  69. 'no-nested-ternary': 'warn',
  70. 'no-trailing-spaces': 'warn',
  71. 'no-undef': 'error',
  72. 'no-unreachable': 'error',
  73. 'no-unused-expressions': 'error',
  74. 'no-unused-vars': [
  75. 'error',
  76. {
  77. vars: 'all',
  78. args: 'after-used',
  79. ignoreRestSiblings: true,
  80. },
  81. ],
  82. 'object-curly-spacing': ['error', 'always'],
  83. 'padded-blocks': [
  84. 'error',
  85. {
  86. classes: 'always',
  87. },
  88. ],
  89. quotes: ['error', 'single'],
  90. semi: 'error',
  91. strict: 'off',
  92. 'valid-typeof': 'error',
  93. 'react/jsx-boolean-value': 'error',
  94. 'react/jsx-closing-bracket-location': ['error', 'line-aligned'],
  95. 'react/jsx-curly-spacing': 'error',
  96. 'react/jsx-equals-spacing': 'error',
  97. 'react/jsx-first-prop-new-line': ['error', 'multiline-multiprop'],
  98. 'react/jsx-indent': ['error', 2],
  99. 'react/jsx-no-bind': 'error',
  100. 'react/jsx-no-duplicate-props': 'error',
  101. 'react/jsx-no-undef': 'error',
  102. 'react/jsx-tag-spacing': 'error',
  103. 'react/jsx-uses-react': 'error',
  104. 'react/jsx-uses-vars': 'error',
  105. 'react/jsx-wrap-multilines': 'error',
  106. 'react/no-multi-comp': 'off',
  107. 'react/no-string-refs': 'error',
  108. 'react/prop-types': 'error',
  109. 'react/self-closing-comp': 'error',
  110. 'jsx-a11y/accessible-emoji': 'warn',
  111. 'jsx-a11y/alt-text': 'warn',
  112. 'jsx-a11y/anchor-has-content': 'warn',
  113. 'jsx-a11y/anchor-is-valid': [
  114. 'warn',
  115. {
  116. components: [
  117. 'Link',
  118. 'NavLink',
  119. ],
  120. specialLink: [
  121. 'to',
  122. ],
  123. aspect: [
  124. 'noHref',
  125. 'invalidHref',
  126. 'preferButton',
  127. ],
  128. },
  129. ],
  130. 'jsx-a11y/aria-activedescendant-has-tabindex': 'warn',
  131. 'jsx-a11y/aria-props': 'warn',
  132. 'jsx-a11y/aria-proptypes': 'warn',
  133. 'jsx-a11y/aria-role': 'warn',
  134. 'jsx-a11y/aria-unsupported-elements': 'warn',
  135. 'jsx-a11y/heading-has-content': 'warn',
  136. 'jsx-a11y/html-has-lang': 'warn',
  137. 'jsx-a11y/iframe-has-title': 'warn',
  138. 'jsx-a11y/img-redundant-alt': 'warn',
  139. 'jsx-a11y/interactive-supports-focus': 'warn',
  140. 'jsx-a11y/label-has-for': 'off',
  141. 'jsx-a11y/mouse-events-have-key-events': 'warn',
  142. 'jsx-a11y/no-access-key': 'warn',
  143. 'jsx-a11y/no-distracting-elements': 'warn',
  144. 'jsx-a11y/no-noninteractive-element-interactions': [
  145. 'warn',
  146. {
  147. handlers: [
  148. 'onClick',
  149. ],
  150. },
  151. ],
  152. 'jsx-a11y/no-onchange': 'warn',
  153. 'jsx-a11y/no-redundant-roles': 'warn',
  154. 'jsx-a11y/no-static-element-interactions': [
  155. 'warn',
  156. {
  157. handlers: [
  158. 'onClick',
  159. ],
  160. },
  161. ],
  162. 'jsx-a11y/role-has-required-aria-props': 'warn',
  163. 'jsx-a11y/role-supports-aria-props': 'off',
  164. 'jsx-a11y/scope': 'warn',
  165. 'jsx-a11y/tabindex-no-positive': 'warn',
  166. 'import/extensions': [
  167. 'error',
  168. 'always',
  169. {
  170. js: 'never',
  171. },
  172. ],
  173. 'import/newline-after-import': 'error',
  174. 'import/no-extraneous-dependencies': [
  175. 'error',
  176. {
  177. devDependencies: [
  178. 'config/webpack/**',
  179. 'app/javascript/mastodon/test_setup.js',
  180. 'app/javascript/**/__tests__/**',
  181. ],
  182. },
  183. ],
  184. 'import/no-unresolved': 'error',
  185. 'import/no-webpack-loader-syntax': 'error',
  186. 'promise/catch-or-return': 'error',
  187. },
  188. };