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.

209 lines
4.8 KiB

  1. module.exports = {
  2. root: true,
  3. extends: [
  4. 'eslint:recommended',
  5. 'plugin:react/recommended',
  6. 'plugin:jsx-a11y/recommended',
  7. 'plugin:import/recommended',
  8. ],
  9. env: {
  10. browser: true,
  11. node: true,
  12. es6: true,
  13. jest: true,
  14. },
  15. globals: {
  16. ATTACHMENT_HOST: false,
  17. },
  18. parser: '@babel/eslint-parser',
  19. plugins: [
  20. 'react',
  21. 'jsx-a11y',
  22. 'import',
  23. 'promise',
  24. ],
  25. parserOptions: {
  26. sourceType: 'module',
  27. ecmaFeatures: {
  28. experimentalObjectRestSpread: true,
  29. jsx: true,
  30. },
  31. ecmaVersion: 2021,
  32. },
  33. settings: {
  34. react: {
  35. version: 'detect',
  36. },
  37. 'import/extensions': [
  38. '.js',
  39. ],
  40. 'import/ignore': [
  41. 'node_modules',
  42. '\\.(css|scss|json)$',
  43. ],
  44. 'import/resolver': {
  45. node: {
  46. paths: ['app/javascript'],
  47. },
  48. },
  49. },
  50. rules: {
  51. 'brace-style': 'warn',
  52. 'comma-dangle': ['error', 'always-multiline'],
  53. 'comma-spacing': [
  54. 'warn',
  55. {
  56. before: false,
  57. after: true,
  58. },
  59. ],
  60. 'comma-style': ['warn', 'last'],
  61. 'consistent-return': 'error',
  62. 'dot-notation': 'error',
  63. eqeqeq: 'error',
  64. indent: ['warn', 2],
  65. 'jsx-quotes': ['error', 'prefer-single'],
  66. 'no-case-declarations': 'off',
  67. 'no-catch-shadow': 'error',
  68. 'no-console': [
  69. 'warn',
  70. {
  71. allow: [
  72. 'error',
  73. 'warn',
  74. ],
  75. },
  76. ],
  77. 'no-empty': 'off',
  78. 'no-restricted-properties': [
  79. 'error',
  80. { property: 'substring', message: 'Use .slice instead of .substring.' },
  81. { property: 'substr', message: 'Use .slice instead of .substr.' },
  82. ],
  83. 'no-self-assign': 'off',
  84. 'no-trailing-spaces': 'warn',
  85. 'no-unused-expressions': 'error',
  86. 'no-unused-vars': [
  87. 'error',
  88. {
  89. vars: 'all',
  90. args: 'after-used',
  91. ignoreRestSiblings: true,
  92. },
  93. ],
  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/display-name': 'off',
  108. 'react/jsx-equals-spacing': 'error',
  109. 'react/jsx-first-prop-new-line': ['error', 'multiline-multiprop'],
  110. 'react/jsx-indent': ['error', 2],
  111. 'react/jsx-no-bind': 'error',
  112. 'react/jsx-no-target-blank': 'off',
  113. 'react/jsx-tag-spacing': 'error',
  114. 'react/jsx-wrap-multilines': 'error',
  115. 'react/no-deprecated': 'off',
  116. 'react/no-unknown-property': 'off',
  117. 'react/self-closing-comp': 'error',
  118. // recommended values found in https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/src/index.js
  119. 'jsx-a11y/accessible-emoji': 'warn',
  120. 'jsx-a11y/click-events-have-key-events': 'off',
  121. 'jsx-a11y/label-has-associated-control': 'off',
  122. 'jsx-a11y/media-has-caption': 'off',
  123. 'jsx-a11y/no-autofocus': 'off',
  124. // recommended rule is:
  125. // 'jsx-a11y/no-interactive-element-to-noninteractive-role': [
  126. // 'error',
  127. // {
  128. // tr: ['none', 'presentation'],
  129. // canvas: ['img'],
  130. // },
  131. // ],
  132. 'jsx-a11y/no-interactive-element-to-noninteractive-role': 'off',
  133. // recommended rule is:
  134. // 'jsx-a11y/no-noninteractive-element-interactions': [
  135. // 'error',
  136. // {
  137. // body: ['onError', 'onLoad'],
  138. // iframe: ['onError', 'onLoad'],
  139. // img: ['onError', 'onLoad'],
  140. // },
  141. // ],
  142. 'jsx-a11y/no-noninteractive-element-interactions': [
  143. 'warn',
  144. {
  145. handlers: [
  146. 'onClick',
  147. ],
  148. },
  149. ],
  150. // recommended rule is:
  151. // 'jsx-a11y/no-noninteractive-tabindex': [
  152. // 'error',
  153. // {
  154. // tags: [],
  155. // roles: ['tabpanel'],
  156. // allowExpressionValues: true,
  157. // },
  158. // ],
  159. 'jsx-a11y/no-noninteractive-tabindex': 'off',
  160. 'jsx-a11y/no-onchange': 'warn',
  161. // recommended is full 'error'
  162. 'jsx-a11y/no-static-element-interactions': [
  163. 'warn',
  164. {
  165. handlers: [
  166. 'onClick',
  167. ],
  168. },
  169. ],
  170. // See https://github.com/import-js/eslint-plugin-import/blob/main/config/recommended.js
  171. 'import/extensions': [
  172. 'error',
  173. 'always',
  174. {
  175. js: 'never',
  176. },
  177. ],
  178. 'import/newline-after-import': 'error',
  179. 'import/no-extraneous-dependencies': [
  180. 'error',
  181. {
  182. devDependencies: [
  183. 'config/webpack/**',
  184. 'app/javascript/mastodon/test_setup.js',
  185. 'app/javascript/**/__tests__/**',
  186. ],
  187. },
  188. ],
  189. 'import/no-webpack-loader-syntax': 'error',
  190. 'promise/catch-or-return': [
  191. 'error',
  192. {
  193. allowFinally: true,
  194. },
  195. ],
  196. },
  197. };