.eslintrc.json 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. {
  2. "extends": [
  3. "next",
  4. "airbnb",
  5. "airbnb/hooks",
  6. "plugin:import/recommended",
  7. "plugin:import/typescript",
  8. "prettier",
  9. "plugin:i18next/recommended",
  10. "plugin:storybook/recommended"
  11. ],
  12. "plugins": ["prettier", "react", "react-func", "sonarjs", "unicorn", "jsdoc"],
  13. "rules": {
  14. "i18next/no-literal-string": [
  15. "error",
  16. {
  17. "ignoreCallee": ["t"],
  18. "markupOnly": true,
  19. "onlyAttribute": [""],
  20. "validateTemplate": true,
  21. "ignore": ["—", "⇧", "⌥", "⌃", "©"]
  22. }
  23. ],
  24. "no-use-before-define": "off", // since we are using airbnb, it turns this on, we need to disabled it @see https://stackoverflow.com/a/64024916/1931451
  25. "@typescript-eslint/no-use-before-define": "off",
  26. "no-shadow": "off", // we need to disable this @see https://stackoverflow.com/a/63961972/1931451
  27. "@typescript-eslint/no-shadow": 2,
  28. "react/jsx-filename-extension": 0,
  29. "react/jsx-props-no-spreading": 0,
  30. "react/function-component-definition": 0,
  31. "react/jsx-no-useless-fragment": 0,
  32. "react/no-unstable-nested-components": 0,
  33. "react/boolean-prop-naming": ["error", { "rule": "^(is|has|should)[A-Z]([A-Za-z0-9]?)+" }],
  34. "react/destructuring-assignment": 2,
  35. "react/no-children-prop": 2,
  36. "react/no-deprecated": 2,
  37. "react/no-multi-comp": 2,
  38. "react/jsx-fragments": 2,
  39. "react/jsx-handler-names": 2,
  40. "react/jsx-sort-default-props": 2,
  41. "react/jsx-key": 1,
  42. "react-func/max-lines-per-function": [
  43. "error",
  44. {
  45. "max": 30,
  46. "skipBlankLines": true,
  47. "skipComments": true
  48. }
  49. ],
  50. "import/order": [
  51. "error",
  52. {
  53. "newlines-between": "always",
  54. "alphabetize": { "order": "asc", "caseInsensitive": true },
  55. "pathGroups": [
  56. {
  57. "pattern": "react",
  58. "group": "builtin",
  59. "position": "before"
  60. }
  61. ],
  62. "pathGroupsExcludedImportTypes": ["react"]
  63. }
  64. ],
  65. "max-lines": [2, { "max": 150, "skipBlankLines": true, "skipComments": true }],
  66. "prefer-destructuring": [
  67. "error",
  68. {
  69. "VariableDeclarator": {
  70. "array": false,
  71. "object": true
  72. },
  73. "AssignmentExpression": {
  74. "array": false,
  75. "object": true
  76. }
  77. },
  78. {
  79. "enforceForRenamedProperties": false
  80. }
  81. ],
  82. "import/extensions": [
  83. 2,
  84. "ignorePackages",
  85. {
  86. "ts": "never",
  87. "tsx": "never"
  88. }
  89. ],
  90. "sonarjs/no-inverted-boolean-check": "error",
  91. "sonarjs/no-nested-switch": "error",
  92. "sonarjs/no-redundant-boolean": "error",
  93. "unicorn/no-abusive-eslint-disable": "error",
  94. "unicorn/no-array-reduce": "error",
  95. "unicorn/filename-case": [
  96. "error",
  97. {
  98. "cases": {
  99. "kebabCase": true,
  100. "camelCase": true,
  101. "pascalCase": true
  102. }
  103. }
  104. ],
  105. "jsdoc/check-alignment": 2,
  106. "jsdoc/check-param-names": 2,
  107. "jsdoc/check-tag-names": 2,
  108. "jsdoc/check-types": 2,
  109. "jsdoc/no-bad-blocks": 2,
  110. "jsdoc/no-multi-asterisks": 2,
  111. "jsdoc/require-asterisk-prefix": 2,
  112. "jsdoc/require-param-type": 2,
  113. "jsdoc/require-param-name": 2,
  114. "jsdoc/require-returns": 2,
  115. "jsdoc/require-returns-type": 2,
  116. "arrow-body-style": 0,
  117. "prettier/prettier": [
  118. 2,
  119. {
  120. "arrowParens": "always",
  121. "bracketSpacing": true,
  122. "jsxBracketSameLine": false,
  123. "printWidth": 100,
  124. "proseWrap": "always",
  125. "requirePragma": false,
  126. "semi": true,
  127. "singleQuote": true,
  128. "tabWidth": 2,
  129. "trailingComma": "all",
  130. "useTabs": false
  131. }
  132. ]
  133. },
  134. "overrides": [
  135. {
  136. "extends": ["plugin:@typescript-eslint/recommended", "prettier"],
  137. "files": ["*.ts", "*.tsx", "*.scss"],
  138. "rules": {
  139. "@typescript-eslint/no-explicit-any": "off",
  140. "@typescript-eslint/no-unused-vars": 2,
  141. "@typescript-eslint/explicit-module-boundary-types": "off",
  142. "react/require-default-props": "off",
  143. "jsx-a11y/media-has-caption": "off",
  144. "no-param-reassign": [
  145. "error",
  146. {
  147. "props": true,
  148. "ignorePropertyModificationsFor": ["draft"]
  149. }
  150. ],
  151. "react/forbid-prop-types": 0,
  152. "react/jsx-no-undef": 0,
  153. "react/no-unused-prop-types": 2,
  154. "react/prop-types": 0,
  155. "react/react-in-jsx-scope": 0,
  156. "curly": "error",
  157. "import/no-extraneous-dependencies": [
  158. "error",
  159. {
  160. "devDependencies": ["**/*.test.ts", "**/*.test.tsx", "tests/**/*"]
  161. }
  162. ],
  163. "@typescript-eslint/ban-ts-comment": 0,
  164. "jsx-a11y/anchor-is-valid": [
  165. "error",
  166. {
  167. "components": ["Link"],
  168. "specialLink": ["hrefLeft", "hrefRight"],
  169. "aspects": ["invalidHref", "preferButton"]
  170. }
  171. ],
  172. "@typescript-eslint/naming-convention": [
  173. 2,
  174. {
  175. "selector": "variableLike",
  176. "format": ["camelCase", "UPPER_CASE", "PascalCase"]
  177. },
  178. {
  179. "selector": "memberLike",
  180. "filter": {
  181. "regex": "^__|^\\d+",
  182. "match": false
  183. },
  184. "format": ["camelCase", "UPPER_CASE", "PascalCase"]
  185. },
  186. {
  187. "selector": "typeLike",
  188. "format": ["PascalCase"]
  189. }
  190. ]
  191. }
  192. },
  193. {
  194. "files": ["**/*.ts", "*.stories.tsx", "*.js"],
  195. "rules": {
  196. "i18next/no-literal-string": 0
  197. }
  198. }
  199. ],
  200. "settings": {
  201. "import/resolver": {
  202. "typescript": {}, // this loads tsconfig.json to eslint
  203. "node": {
  204. "paths": ["."],
  205. "extensions": [".js", ".jsx", ".ts", ".tsx", ".d.ts", ".svg"]
  206. }
  207. }
  208. }
  209. }