.eslintrc.js 4.9 KB

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