.eslintrc.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. module.exports = {
  2. env: {
  3. browser: true,
  4. node: true,
  5. es6: true,
  6. jest: true,
  7. },
  8. parser: '@typescript-eslint/parser',
  9. extends: [
  10. 'plugin:jest-dom/recommended',
  11. 'eslint:recommended',
  12. 'plugin:@typescript-eslint/recommended',
  13. 'plugin:react/recommended',
  14. 'plugin:react-hooks/recommended',
  15. 'plugin:react/jsx-runtime',
  16. // turns off the rules which may conflict with prettier
  17. 'prettier',
  18. ],
  19. plugins: ['@emotion', '@typescript-eslint', 'unused-imports'],
  20. settings: {
  21. react: {
  22. version: 'detect',
  23. },
  24. },
  25. rules: {
  26. // force using Logger object
  27. 'no-console': ['warn'],
  28. 'no-duplicate-imports': ['warn'],
  29. // taken care of by typescript
  30. 'react/prop-types': 'off',
  31. // disallow default React import, force destructuring instead
  32. 'no-restricted-syntax': [
  33. 'error',
  34. {
  35. selector: "ImportDeclaration[source.value='react'][specifiers.0.type='ImportDefaultSpecifier']",
  36. message: 'Default React import not allowed',
  37. },
  38. ],
  39. 'react/jsx-curly-brace-presence': ['warn', { props: 'never', children: 'never' }],
  40. 'react/self-closing-comp': [
  41. 'warn',
  42. {
  43. 'component': true,
  44. 'html': true,
  45. },
  46. ],
  47. // add exhaustive deps check to custom hooks
  48. 'react-hooks/exhaustive-deps': [
  49. 'warn',
  50. {
  51. 'additionalHooks': 'useDeepMemo',
  52. },
  53. ],
  54. 'react/no-unescaped-entities': 'off',
  55. // disable explicit return types
  56. '@typescript-eslint/explicit-module-boundary-types': 'off',
  57. // use plugin for fixing unused imports
  58. '@typescript-eslint/no-unused-vars': 'off',
  59. 'unused-imports/no-unused-imports': 'error',
  60. // allow "_" prefixed function arguments
  61. 'unused-imports/no-unused-vars': [
  62. 'warn',
  63. { 'args': 'after-used', 'argsIgnorePattern': '^_', 'ignoreRestSiblings': true, 'varsIgnorePattern': '^_+$' },
  64. ],
  65. '@typescript-eslint/no-empty-function': 'warn',
  66. '@typescript-eslint/class-name-casing': 'off',
  67. '@typescript-eslint/ban-ts-comment': [
  68. 'error',
  69. {
  70. 'ts-ignore': 'allow-with-description',
  71. },
  72. ],
  73. '@typescript-eslint/ban-types': [
  74. 'error',
  75. {
  76. types: {
  77. object: false,
  78. },
  79. },
  80. ],
  81. // make sure we use the proper Emotion imports
  82. '@emotion/pkg-renaming': 'error',
  83. '@emotion/no-vanilla': 'error',
  84. '@emotion/syntax-preference': [2, 'string'],
  85. },
  86. }