|
| 1 | +function* range(min, max) { |
| 2 | + for (let num = min; num < max; num++) { |
| 3 | + yield num |
| 4 | + } |
| 5 | +} |
| 6 | + |
| 7 | +module.exports = { |
| 8 | + env: { |
| 9 | + es2021: true, |
| 10 | + node: true, |
| 11 | + }, |
| 12 | + extends: ["eslint:recommended", "plugin:@typescript-eslint/eslint-recommended"], |
| 13 | + parser: "@typescript-eslint/parser", |
| 14 | + globals: { |
| 15 | + Atomics: "readonly", |
| 16 | + SharedArrayBuffer: "readonly", |
| 17 | + }, |
| 18 | + parserOptions: { |
| 19 | + ecmaVersion: 2021, |
| 20 | + sourceType: "module", |
| 21 | + project: ["./tsconfig.json"], |
| 22 | + }, |
| 23 | + plugins: ["@typescript-eslint", "prefer-arrow"], |
| 24 | + rules: { |
| 25 | + // General ESLint rules |
| 26 | + "arrow-body-style": ["warn", "as-needed"], |
| 27 | + "default-case-last": "warn", |
| 28 | + "dot-location": ["warn", "property"], |
| 29 | + eqeqeq: "error", |
| 30 | + "id-length": ["error", {exceptions: ["_", "$"]}], |
| 31 | + "max-len": "off", |
| 32 | + "max-lines": ["warn", 500], |
| 33 | + "max-statements": ["warn", {max: 25}], |
| 34 | + "no-else-return": "warn", |
| 35 | + "no-empty": ["warn", {allowEmptyCatch: true}], |
| 36 | + "no-extra-semi": "off", |
| 37 | + "no-negated-condition": "warn", |
| 38 | + "no-nested-ternary": "warn", |
| 39 | + "no-unused-vars": "off", |
| 40 | + "no-var": "warn", |
| 41 | + "object-shorthand": "warn", |
| 42 | + "one-var": ["warn", "never"], |
| 43 | + "padding-line-between-statements": [ |
| 44 | + "warn", |
| 45 | + {blankLine: "always", prev: "*", next: "return"}, |
| 46 | + {blankLine: "always", prev: ["const", "let", "var"], next: "*"}, |
| 47 | + {blankLine: "any", prev: ["const", "let", "var"], next: ["const", "let", "var"]}, |
| 48 | + {blankLine: "always", prev: "function", next: "*"}, |
| 49 | + ], |
| 50 | + "prefer-const": "warn", |
| 51 | + "prefer-destructuring": [ |
| 52 | + "error", |
| 53 | + { |
| 54 | + array: false, |
| 55 | + object: true, |
| 56 | + }, |
| 57 | + ], |
| 58 | + "prefer-exponentiation-operator": "warn", |
| 59 | + "prefer-object-spread": "warn", |
| 60 | + "prefer-template": "warn", |
| 61 | + "require-await": "warn", |
| 62 | + "require-unicode-regexp": "warn", |
| 63 | + "sort-imports": ["warn"], |
| 64 | + |
| 65 | + // Typescript Rules |
| 66 | + "@typescript-eslint/array-type": "warn", |
| 67 | + "@typescript-eslint/consistent-indexed-object-style": ["warn", "index-signature"], |
| 68 | + "@typescript-eslint/consistent-type-assertions": ["warn", {assertionStyle: "as"}], |
| 69 | + "@typescript-eslint/member-ordering": "warn", |
| 70 | + "@typescript-eslint/naming-convention": [ |
| 71 | + "error", |
| 72 | + { |
| 73 | + selector: "default", |
| 74 | + format: ["camelCase"], |
| 75 | + }, |
| 76 | + { |
| 77 | + selector: "variableLike", |
| 78 | + format: ["camelCase"], |
| 79 | + leadingUnderscore: "allow", |
| 80 | + }, |
| 81 | + { |
| 82 | + selector: "memberLike", |
| 83 | + modifiers: ["private"], |
| 84 | + format: ["camelCase"], |
| 85 | + leadingUnderscore: "require", |
| 86 | + }, |
| 87 | + { |
| 88 | + selector: "property", |
| 89 | + modifiers: ["private"], |
| 90 | + format: ["camelCase"], |
| 91 | + leadingUnderscore: "require", |
| 92 | + }, |
| 93 | + { |
| 94 | + selector: "typeLike", |
| 95 | + format: ["PascalCase"], |
| 96 | + }, |
| 97 | + { |
| 98 | + selector: "variable", |
| 99 | + types: ["boolean"], |
| 100 | + format: ["PascalCase"], |
| 101 | + prefix: ["is", "should", "has", "can", "did", "will"], |
| 102 | + }, |
| 103 | + { |
| 104 | + selector: "parameter", |
| 105 | + format: ["camelCase"], |
| 106 | + leadingUnderscore: "allow", |
| 107 | + }, |
| 108 | + { |
| 109 | + selector: "property", |
| 110 | + format: ["camelCase", "PascalCase", "snake_case", "UPPER_CASE"], |
| 111 | + }, |
| 112 | + { |
| 113 | + selector: "enumMember", |
| 114 | + format: ["camelCase", "PascalCase", "snake_case", "UPPER_CASE"], |
| 115 | + }, |
| 116 | + ], |
| 117 | + "@typescript-eslint/no-magic-numbers": [ |
| 118 | + "warn", |
| 119 | + { |
| 120 | + ignoreEnums: true, |
| 121 | + ignoreNumericLiteralTypes: true, |
| 122 | + ignoreReadonlyClassProperties: true, |
| 123 | + ignoreArrayIndexes: true, |
| 124 | + ignore: [...Array.from(range(-10, 11)), 16, 32, 64, 128, 256, 512], |
| 125 | + }, |
| 126 | + ], |
| 127 | + "@typescript-eslint/no-unnecessary-boolean-literal-compare": "warn", |
| 128 | + "@typescript-eslint/prefer-for-of": "warn", |
| 129 | + "@typescript-eslint/prefer-function-type": "warn", |
| 130 | + "@typescript-eslint/prefer-optional-chain": "warn", |
| 131 | + |
| 132 | + // Typescript extension rules |
| 133 | + "@typescript-eslint/default-param-last": "warn", |
| 134 | + "@typescript-eslint/dot-notation": "warn", |
| 135 | + "@typescript-eslint/lines-between-class-members": ["warn", "always"], |
| 136 | + "@typescript-eslint/no-dupe-class-members": "warn", |
| 137 | + "@typescript-eslint/no-duplicate-imports": "warn", |
| 138 | + "@typescript-eslint/no-extra-semi": "off", |
| 139 | + "@typescript-eslint/no-shadow": "warn", |
| 140 | + "@typescript-eslint/no-unused-expressions": "warn", |
| 141 | + "@typescript-eslint/no-unused-vars": "off", |
| 142 | + "@typescript-eslint/no-unused-vars-experimental": "warn", |
| 143 | + "@typescript-eslint/no-use-before-define": "warn", |
| 144 | + |
| 145 | + // Preter arrow rules |
| 146 | + "prefer-arrow-callback": "warn", |
| 147 | + "prefer-arrow/prefer-arrow-functions": [ |
| 148 | + "warn", |
| 149 | + { |
| 150 | + disallowPrototype: true, |
| 151 | + singleReturnOnly: false, |
| 152 | + classPropertiesAllowed: true, |
| 153 | + allowStandaloneDeclarations: false, |
| 154 | + }, |
| 155 | + ], |
| 156 | + }, |
| 157 | +} |
0 commit comments