|
| 1 | +const getNamingConventionRule = () => [ |
| 2 | + "error", |
| 3 | + { |
| 4 | + selector: "variable", |
| 5 | + format: ["camelCase", "UPPER_CASE"], |
| 6 | + }, |
| 7 | + { |
| 8 | + selector: "variable", |
| 9 | + filter: "__typename", |
| 10 | + format: null, |
| 11 | + }, |
| 12 | + { |
| 13 | + selector: "parameter", |
| 14 | + format: ["camelCase"], |
| 15 | + }, |
| 16 | + { |
| 17 | + selector: "parameter", |
| 18 | + filter: "_", |
| 19 | + format: null, |
| 20 | + }, |
| 21 | + { |
| 22 | + selector: "enumMember", |
| 23 | + format: ["UPPER_CASE", "PascalCase"], |
| 24 | + }, |
| 25 | +]; |
| 26 | + |
| 27 | +module.exports = { |
| 28 | + ignorePatterns: ["**/node_modules/", "**/dist/", "**/*.js"], |
| 29 | + parser: "@typescript-eslint/parser", |
| 30 | + env: { |
| 31 | + node: true, |
| 32 | + }, |
| 33 | + extends: [ |
| 34 | + "airbnb-base", |
| 35 | + "plugin:@typescript-eslint/recommended", |
| 36 | + "prettier", |
| 37 | + "plugin:import/recommended", |
| 38 | + "plugin:import/typescript", |
| 39 | + "plugin:prettier/recommended", |
| 40 | + ], |
| 41 | + plugins: [ |
| 42 | + "@typescript-eslint", |
| 43 | + "import", |
| 44 | + "no-only-tests", |
| 45 | + "prettier", |
| 46 | + "unicorn", |
| 47 | + ], |
| 48 | + rules: { |
| 49 | + "@typescript-eslint/explicit-function-return-type": "off", |
| 50 | + "@typescript-eslint/explicit-member-accessibility": "off", |
| 51 | + "@typescript-eslint/explicit-module-boundary-types": "off", |
| 52 | + "@typescript-eslint/no-empty-function": "off", |
| 53 | + "@typescript-eslint/no-explicit-any": "warn", |
| 54 | + "@typescript-eslint/no-non-null-assertion": "error", |
| 55 | + "@typescript-eslint/no-use-before-define": ["error", { functions: false }], |
| 56 | + "@typescript-eslint/consistent-type-assertions": [ |
| 57 | + "error", |
| 58 | + { |
| 59 | + assertionStyle: "as", |
| 60 | + objectLiteralTypeAssertions: "allow-as-parameter", |
| 61 | + }, |
| 62 | + ], |
| 63 | + "@typescript-eslint/consistent-type-imports": "error", |
| 64 | + "@typescript-eslint/no-unused-vars": [ |
| 65 | + "error", |
| 66 | + { ignoreRestSiblings: true }, |
| 67 | + ], |
| 68 | + "@typescript-eslint/array-type": [ |
| 69 | + "error", |
| 70 | + { |
| 71 | + default: "array-simple", |
| 72 | + readonly: "array-simple", |
| 73 | + }, |
| 74 | + ], |
| 75 | + camelcase: "off", |
| 76 | + "@typescript-eslint/naming-convention": getNamingConventionRule(), |
| 77 | + curly: ["error", "all"], |
| 78 | + "import/extensions": [ |
| 79 | + "error", |
| 80 | + "ignorePackages", |
| 81 | + { js: "never", ts: "never" }, |
| 82 | + ], |
| 83 | + "import/no-extraneous-dependencies": ["error"], |
| 84 | + "import/no-named-as-default-member": "error", |
| 85 | + "import/prefer-default-export": "off", |
| 86 | + "lines-around-directive": "warn", |
| 87 | + "lines-between-class-members": [ |
| 88 | + "error", |
| 89 | + "always", |
| 90 | + { exceptAfterSingleLine: true }, |
| 91 | + ], |
| 92 | + "max-classes-per-file": "off", |
| 93 | + "new-cap": "off", |
| 94 | + "no-bitwise": "warn", |
| 95 | + "no-alert": "error", |
| 96 | + "no-console": ["error", { allow: ["warn", "info", "error"] }], |
| 97 | + "no-debugger": "error", |
| 98 | + "no-fallthrough": "warn", |
| 99 | + "no-nested-ternary": "off", |
| 100 | + // The Typescript version doesn't warn for optional chaining |
| 101 | + "no-unused-expressions": "off", |
| 102 | + "@typescript-eslint/no-unused-expressions": "error", |
| 103 | + |
| 104 | + // Deprecated in favor of ban-ts-comments: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/ban-ts-ignore.md |
| 105 | + "@typescript-eslint/ban-ts-ignore": "off", |
| 106 | + "@typescript-eslint/ban-ts-comment": "error", |
| 107 | + |
| 108 | + "no-shadow": "off", |
| 109 | + "@typescript-eslint/no-shadow": "error", |
| 110 | + |
| 111 | + "import/no-duplicates": "error", |
| 112 | + "no-plusplus": "off", |
| 113 | + "no-prototype-builtins": "warn", |
| 114 | + "no-restricted-globals": "error", |
| 115 | + "no-restricted-properties": "warn", |
| 116 | + "no-restricted-syntax": "warn", |
| 117 | + "no-return-assign": "error", |
| 118 | + "no-undef": "error", |
| 119 | + "no-underscore-dangle": "off", |
| 120 | + "no-unreachable": "warn", |
| 121 | + "no-unsafe-finally": "warn", |
| 122 | + // Turning "no-unused-vars" and "no-use-before-define" off |
| 123 | + // since the rule is already covered by |
| 124 | + // @typescript-eslint/no-unused-vars and @typescript-eslint/no-use-before-define |
| 125 | + "no-unused-vars": "off", |
| 126 | + "no-use-before-define": "off", |
| 127 | + "no-multiple-empty-lines": "error", |
| 128 | + "operator-assignment": "warn", |
| 129 | + "prefer-destructuring": "off", |
| 130 | + "prefer-rest-params": "warn", |
| 131 | + "prefer-spread": "warn", |
| 132 | + "import/no-cycle": "error", |
| 133 | + "import/order": [ |
| 134 | + "error", |
| 135 | + { |
| 136 | + alphabetize: { |
| 137 | + order: "asc", |
| 138 | + }, |
| 139 | + pathGroups: [ |
| 140 | + { |
| 141 | + pattern: "**/*.service", |
| 142 | + group: "object", |
| 143 | + position: "after", |
| 144 | + }, |
| 145 | + { |
| 146 | + pattern: "**/*.helper", |
| 147 | + group: "object", |
| 148 | + position: "after", |
| 149 | + }, |
| 150 | + { |
| 151 | + pattern: "types/**", |
| 152 | + group: "type", |
| 153 | + }, |
| 154 | + { |
| 155 | + pattern: "types", |
| 156 | + group: "type", |
| 157 | + }, |
| 158 | + ], |
| 159 | + groups: [ |
| 160 | + "builtin", |
| 161 | + "external", |
| 162 | + "internal", |
| 163 | + "unknown", |
| 164 | + "parent", |
| 165 | + "sibling", |
| 166 | + "index", |
| 167 | + "object", |
| 168 | + "type", |
| 169 | + ], |
| 170 | + "newlines-between": "always", |
| 171 | + }, |
| 172 | + ], |
| 173 | + // File and import related |
| 174 | + "unicorn/filename-case": [ |
| 175 | + "warn", |
| 176 | + { |
| 177 | + cases: { |
| 178 | + camelCase: true, |
| 179 | + pascalCase: true, |
| 180 | + }, |
| 181 | + }, |
| 182 | + ], // Manual fix |
| 183 | + "unicorn/relative-url-style": "error", |
| 184 | + |
| 185 | + // Abbreviations and naming |
| 186 | + "unicorn/prevent-abbreviations": [ |
| 187 | + "off", |
| 188 | + { |
| 189 | + checkShorthandImports: true, |
| 190 | + allowList: { |
| 191 | + req: true, |
| 192 | + res: true, |
| 193 | + ref: true, |
| 194 | + Param: true, |
| 195 | + args: true, |
| 196 | + env: true, |
| 197 | + Env: true, |
| 198 | + Ref: true, |
| 199 | + el: true, |
| 200 | + toRef: true, |
| 201 | + def: true, |
| 202 | + pkg: true, |
| 203 | + params: true, |
| 204 | + Params: true, |
| 205 | + Props: true, |
| 206 | + props: true, |
| 207 | + src: true, |
| 208 | + }, |
| 209 | + }, |
| 210 | + ], // Manual fix |
| 211 | + |
| 212 | + // Array and function related |
| 213 | + "unicorn/require-number-to-fixed-digits-argument": "error", |
| 214 | + }, |
| 215 | + settings: { |
| 216 | + "import/resolver": { |
| 217 | + node: { |
| 218 | + moduleDirectory: ["node_modules"], |
| 219 | + }, |
| 220 | + typescript: { |
| 221 | + project: "./tsconfig.json", |
| 222 | + }, |
| 223 | + }, |
| 224 | + }, |
| 225 | +}; |
0 commit comments