.eslintrc.json 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. {
  2. "$schema": "https://json.schemastore.org/eslintrc.json",
  3. "plugins": ["@typescript-eslint", "import"],
  4. "parserOptions": {
  5. "project": "tsconfig.json"
  6. },
  7. "extends": [
  8. "plugin:@typescript-eslint/recommended",
  9. "plugin:@typescript-eslint/recommended-requiring-type-checking",
  10. "plugin:import/recommended",
  11. "plugin:import/typescript",
  12. "prettier",
  13. "next/core-web-vitals"
  14. ],
  15. "rules": {
  16. // sort imports
  17. "import/order": "error",
  18. // no let exports
  19. "import/no-mutable-exports": "error",
  20. "import/no-cycle": "error",
  21. "import/no-default-export": "error",
  22. "import/no-unresolved": "off",
  23. // allow {} even though it's unsafe but comes handy
  24. "@typescript-eslint/ban-types": [
  25. "error",
  26. {
  27. "types": {
  28. "{}": false
  29. }
  30. }
  31. ],
  32. "@typescript-eslint/consistent-type-imports": [
  33. "error",
  34. {
  35. "prefer": "type-imports",
  36. "fixStyle": "inline-type-imports",
  37. "disallowTypeAnnotations": false
  38. }
  39. ],
  40. "import/no-duplicates": ["error", { "prefer-inline": true }],
  41. // false negatives
  42. "import/namespace": ["off"],
  43. // we allow empty interfaces
  44. "no-empty-pattern": "off",
  45. "@typescript-eslint/no-empty-interface": "off",
  46. // we allow empty functions
  47. "@typescript-eslint/no-empty-function": "off",
  48. // we sometimes use async functions that don't await anything
  49. "@typescript-eslint/require-await": "off",
  50. // make sure to `await` inside try…catch
  51. "@typescript-eslint/return-await": ["error", "in-try-catch"],
  52. // allow unused vars prefixed with `_`
  53. "@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_", "varsIgnorePattern": "^_" }],
  54. // numbers and booleans are fine in template strings
  55. "@typescript-eslint/restrict-template-expressions": [
  56. "error",
  57. { "allowNumber": true, "allowBoolean": true }
  58. ],
  59. // @todo
  60. "@typescript-eslint/no-explicit-any": "off",
  61. "@typescript-eslint/no-misused-promises": [
  62. "error",
  63. {
  64. "checksVoidReturn": false
  65. }
  66. ]
  67. },
  68. "overrides": [
  69. {
  70. "files": ["src/app/**/{page,layout,error,loading,not-found}.tsx", "*.ts"],
  71. "rules": {
  72. "import/no-default-export": "off"
  73. }
  74. },
  75. {
  76. "files": ["src/checkout/**/*.{ts,tsx}"],
  77. "rules": {
  78. "no-restricted-imports": [
  79. "error",
  80. {
  81. "patterns": [
  82. {
  83. "group": ["next/*", "@next/*", "next"],
  84. "message": "Usage of Next.js-specific imports inside src/checkout is forbidden. Checkout is a standalone component and should not depend on Next.js."
  85. }
  86. ]
  87. }
  88. ]
  89. }
  90. },
  91. {
  92. "files": ["__tests__/**/*.{ts,tsx}"],
  93. "extends": ["plugin:playwright/recommended"]
  94. }
  95. ],
  96. "ignorePatterns": ["*.js", "*.jsx", "*.cjs", "src/checkout/src/graphql"]
  97. }