|
| 1 | +module.exports = { |
| 2 | + env: { |
| 3 | + browser: true, |
| 4 | + es2021: true, |
| 5 | + }, |
| 6 | + extends: [ |
| 7 | + "eslint:recommended", |
| 8 | + "plugin:react/recommended", |
| 9 | + "plugin:@typescript-eslint/recommended", |
| 10 | + "plugin:import/errors", |
| 11 | + "plugin:import/warnings", |
| 12 | + "plugin:import/typescript", |
| 13 | + "plugin:prettier/recommended", |
| 14 | + ], |
| 15 | + parser: "@typescript-eslint/parser", |
| 16 | + parserOptions: { |
| 17 | + ecmaFeatures: { |
| 18 | + jsx: true, |
| 19 | + }, |
| 20 | + ecmaVersion: 12, |
| 21 | + sourceType: "module", |
| 22 | + }, |
| 23 | + plugins: ["react", "react-hooks", "@typescript-eslint", "prettier", "import"], |
| 24 | + ignorePatterns: [".eslintrc.js", "react-app-.env.d.ts"], |
| 25 | + rules: { |
| 26 | + "no-param-reassign": ["error"], |
| 27 | + "prettier/prettier": "error", |
| 28 | + "linebreak-style": ["error", "unix"], |
| 29 | + "arrow-body-style": [ |
| 30 | + "error", |
| 31 | + "as-needed", |
| 32 | + { |
| 33 | + requireReturnForObjectLiteral: false, |
| 34 | + }, |
| 35 | + ], |
| 36 | + curly: ["error", "all"], |
| 37 | + "no-implicit-coercion": ["error"], |
| 38 | + "spaced-comment": ["error", "always"], |
| 39 | + eqeqeq: ["error", "always"], |
| 40 | + "prefer-template": "error", |
| 41 | + "no-useless-concat": "error", |
| 42 | + "prefer-destructuring": [ |
| 43 | + "error", |
| 44 | + { |
| 45 | + VariableDeclarator: { |
| 46 | + array: false, |
| 47 | + object: true, |
| 48 | + }, |
| 49 | + AssignmentExpression: { |
| 50 | + array: false, |
| 51 | + object: true, |
| 52 | + }, |
| 53 | + }, |
| 54 | + { |
| 55 | + enforceForRenamedProperties: false, |
| 56 | + }, |
| 57 | + ], |
| 58 | + "no-restricted-imports": [ |
| 59 | + "error", |
| 60 | + { |
| 61 | + patterns: ["../*"], |
| 62 | + }, |
| 63 | + ], |
| 64 | + "react-hooks/rules-of-hooks": "error", |
| 65 | + "react-hooks/exhaustive-deps": "warn", |
| 66 | + "react/self-closing-comp": "error", |
| 67 | + "import/extensions": [ |
| 68 | + "error", |
| 69 | + "ignorePackages", |
| 70 | + { |
| 71 | + ts: "never", |
| 72 | + tsx: "never", |
| 73 | + }, |
| 74 | + ], |
| 75 | + "import/no-extraneous-dependencies": ["error", { devDependencies: true }], |
| 76 | + "import/order": [ |
| 77 | + "error", |
| 78 | + { |
| 79 | + "newlines-between": "always", |
| 80 | + groups: ["builtin", "external", "parent", "sibling", "index"], |
| 81 | + pathGroups: [ |
| 82 | + { |
| 83 | + pattern: "src/**", |
| 84 | + group: "parent", |
| 85 | + position: "after", |
| 86 | + }, |
| 87 | + ], |
| 88 | + }, |
| 89 | + ], |
| 90 | + "import/newline-after-import": "error", |
| 91 | + "@typescript-eslint/no-explicit-any": "error", |
| 92 | + "@typescript-eslint/explicit-function-return-type": "off", |
| 93 | + "@typescript-eslint/explicit-module-boundary-types": "off", |
| 94 | + "@typescript-eslint/ban-types": ["error"], |
| 95 | + "@typescript-eslint/no-shadow": ["error"], |
| 96 | + "@typescript-eslint/naming-convention": [ |
| 97 | + "error", |
| 98 | + { |
| 99 | + selector: "default", |
| 100 | + format: ["camelCase"], |
| 101 | + }, |
| 102 | + { |
| 103 | + selector: ["enumMember", "variable"], |
| 104 | + format: ["camelCase", "PascalCase", "UPPER_CASE"], |
| 105 | + }, |
| 106 | + { |
| 107 | + selector: "parameter", |
| 108 | + format: ["camelCase"], |
| 109 | + leadingUnderscore: "allow", |
| 110 | + modifiers: ["unused"], |
| 111 | + }, |
| 112 | + { |
| 113 | + selector: "objectLiteralProperty", |
| 114 | + filter: { |
| 115 | + // Regular expression for BEM classnames |
| 116 | + // Source: https://medium.com/takeaway-tech/the-search-for-a-regex-to-match-hyphenated-bem-css-class-names-5f8b66cc2bd9 |
| 117 | + regex: |
| 118 | + "^[a-z]([a-z0-9-]+)?(__([a-z0-9]+-?)+)?(--([a-z0-9]+-?)+){0,2}$", |
| 119 | + match: true, |
| 120 | + }, |
| 121 | + format: null, |
| 122 | + }, |
| 123 | + { |
| 124 | + selector: "typeLike", |
| 125 | + format: ["PascalCase"], |
| 126 | + }, |
| 127 | + { |
| 128 | + selector: "typeProperty", |
| 129 | + format: ["snake_case", "camelCase"], |
| 130 | + }, |
| 131 | + ], |
| 132 | + }, |
| 133 | + overrides: [ |
| 134 | + { |
| 135 | + files: ["*.ts", "*.tsx"], |
| 136 | + rules: { |
| 137 | + "react/prop-types": "off", |
| 138 | + }, |
| 139 | + }, |
| 140 | + ], |
| 141 | + settings: { |
| 142 | + 'import/resolver': { |
| 143 | + node: { |
| 144 | + extensions: ['.js', '.jsx', '.ts', '.tsx'], |
| 145 | + moduleDirectory: ['node_modules', '.'], |
| 146 | + }, |
| 147 | + }, |
| 148 | + react: { |
| 149 | + version: "detect", |
| 150 | + }, |
| 151 | + } |
| 152 | +}; |
0 commit comments