|
| 1 | +// https://github.com/ark120202/eslint-config/blob/2c24f13fd99af7ccf29e56d5d936b3ab0f237db6/bases/typescript.js |
| 2 | +const typescriptBase = { |
| 3 | + "@typescript-eslint/adjacent-overload-signatures": "error", |
| 4 | + "@typescript-eslint/array-type": "error", |
| 5 | + "@typescript-eslint/await-thenable": "error", |
| 6 | + "@typescript-eslint/ban-types": [ |
| 7 | + "error", |
| 8 | + { |
| 9 | + types: { |
| 10 | + Function: null, |
| 11 | + CallableFunction: { fixWith: "(...args: any[]) => any" }, |
| 12 | + NewableFunction: { fixWith: "new (...args: any[]) => any" }, |
| 13 | + }, |
| 14 | + }, |
| 15 | + ], |
| 16 | + camelcase: "off", |
| 17 | + "@typescript-eslint/camelcase": ["error", { properties: "never", ignoreDestructuring: true }], |
| 18 | + "@typescript-eslint/class-name-casing": "error", |
| 19 | + "@typescript-eslint/consistent-type-assertions": [ |
| 20 | + "error", |
| 21 | + { assertionStyle: "as", objectLiteralTypeAssertions: "never" }, |
| 22 | + ], |
| 23 | + "@typescript-eslint/consistent-type-definitions": "error", |
| 24 | + "@typescript-eslint/explicit-member-accessibility": ["error", { overrides: { constructors: "no-public" } }], |
| 25 | + "@typescript-eslint/generic-type-naming": ["error", "^(T([A-Z][A-Za-z]*)?|U|P|K|V)$"], |
| 26 | + "@typescript-eslint/interface-name-prefix": "error", |
| 27 | + "no-array-constructor": "off", |
| 28 | + "@typescript-eslint/no-array-constructor": "error", |
| 29 | + "@typescript-eslint/no-empty-interface": "error", |
| 30 | + "@typescript-eslint/no-extra-non-null-assertion": "error", |
| 31 | + "@typescript-eslint/no-extraneous-class": "error", |
| 32 | + "@typescript-eslint/no-floating-promises": "error", |
| 33 | + "@typescript-eslint/no-for-in-array": "error", |
| 34 | + "@typescript-eslint/no-inferrable-types": "error", |
| 35 | + "@typescript-eslint/no-misused-new": "error", |
| 36 | + "@typescript-eslint/no-misused-promises": "error", |
| 37 | + "@typescript-eslint/no-namespace": "error", |
| 38 | + "@typescript-eslint/no-require-imports": "error", |
| 39 | + "@typescript-eslint/no-this-alias": "error", |
| 40 | + "no-throw-literal": "off", |
| 41 | + "@typescript-eslint/no-throw-literal": "error", |
| 42 | + "no-constant-condition": "off", |
| 43 | + "@typescript-eslint/no-unnecessary-condition": ["error", { ignoreRhs: true, allowConstantLoopConditions: true }], |
| 44 | + "@typescript-eslint/no-unnecessary-qualifier": "error", |
| 45 | + "@typescript-eslint/no-unnecessary-type-arguments": "error", |
| 46 | + "@typescript-eslint/no-unnecessary-type-assertion": "error", |
| 47 | + "no-unused-expressions": "off", |
| 48 | + "@typescript-eslint/no-unused-expressions": "error", |
| 49 | + "no-useless-constructor": "off", |
| 50 | + "@typescript-eslint/no-useless-constructor": "error", |
| 51 | + "@typescript-eslint/prefer-function-type": "error", |
| 52 | + "@typescript-eslint/prefer-includes": "error", |
| 53 | + "@typescript-eslint/prefer-optional-chain": "error", |
| 54 | + "@typescript-eslint/prefer-namespace-keyword": "error", |
| 55 | + "@typescript-eslint/prefer-readonly": "error", |
| 56 | + "@typescript-eslint/prefer-string-starts-ends-with": "error", |
| 57 | + "@typescript-eslint/promise-function-async": ["error", { checkArrowFunctions: false }], |
| 58 | + quotes: "off", |
| 59 | + "@typescript-eslint/quotes": ["error", "single", { avoidEscape: true, allowTemplateLiterals: false }], |
| 60 | + "@typescript-eslint/require-array-sort-compare": "error", |
| 61 | + "@typescript-eslint/require-await": "error", |
| 62 | + "@typescript-eslint/restrict-plus-operands": ["error", { checkCompoundAssignments: true }], |
| 63 | + "@typescript-eslint/return-await": "error", |
| 64 | + "@typescript-eslint/triple-slash-reference": "error", |
| 65 | + "@typescript-eslint/unified-signatures": "error", |
| 66 | +}; |
| 67 | + |
| 68 | +module.exports = { |
| 69 | + extends: ["plugin:jest/recommended", "plugin:jest/style"], |
| 70 | + parserOptions: { sourceType: "module", project: ["test/tsconfig.json", "src/lualib/tsconfig.json"] }, |
| 71 | + env: { es6: true, node: true }, |
| 72 | + plugins: ["import"], |
| 73 | + rules: { |
| 74 | + "arrow-body-style": "error", |
| 75 | + curly: ["error", "multi-line"], |
| 76 | + eqeqeq: ["error", "always", { null: "ignore" }], |
| 77 | + "no-caller": "error", |
| 78 | + "no-cond-assign": "error", |
| 79 | + "no-debugger": "error", |
| 80 | + "no-duplicate-case": "error", |
| 81 | + "no-new-wrappers": "error", |
| 82 | + "no-restricted-globals": ["error", "parseInt", "parseFloat"], |
| 83 | + "no-unused-labels": "error", |
| 84 | + "no-var": "error", |
| 85 | + "object-shorthand": "error", |
| 86 | + "prefer-const": ["error", { destructuring: "all" }], |
| 87 | + radix: "error", |
| 88 | + "use-isnan": "error", |
| 89 | + "object-shorthand": [ |
| 90 | + "error", |
| 91 | + "always", |
| 92 | + { avoidQuotes: true, ignoreConstructors: false, avoidExplicitReturnArrows: true }, |
| 93 | + ], |
| 94 | + "no-restricted-syntax": ["error", "ForInStatement", "LabeledStatement", "SequenceExpression"], |
| 95 | + "spaced-comment": [ |
| 96 | + "error", |
| 97 | + "always", |
| 98 | + { |
| 99 | + line: { exceptions: ["-", "+"], markers: ["=", "!", "/"] }, |
| 100 | + block: { exceptions: ["-", "+"], markers: ["=", "!", ":", "::"], balanced: true }, |
| 101 | + }, |
| 102 | + ], |
| 103 | + "no-delete-var": ["error"], |
| 104 | + "no-label-var": ["error"], |
| 105 | + yoda: ["error"], |
| 106 | + "prefer-numeric-literals": ["error"], |
| 107 | + "prefer-rest-params": ["error"], |
| 108 | + "prefer-spread": ["error"], |
| 109 | + "no-useless-computed-key": ["error"], |
| 110 | + "for-direction": ["error"], |
| 111 | + "no-compare-neg-zero": ["error"], |
| 112 | + "no-dupe-else-if": ["error"], |
| 113 | + "no-empty": ["error", { allowEmptyCatch: true }], |
| 114 | + "no-implicit-coercion": ["error", { boolean: true, number: true, string: true }], |
| 115 | + "operator-assignment": ["error"], |
| 116 | + "no-path-concat": ["error"], |
| 117 | + "no-compare-neg-zero": ["error"], |
| 118 | + "no-control-regex": ["error"], |
| 119 | + "no-unneeded-ternary": ["error", { defaultAssignment: false }], |
| 120 | + "one-var": ["error", "never"], |
| 121 | + "prefer-exponentiation-operator": ["error"], |
| 122 | + "prefer-object-spread": ["error"], |
| 123 | + "no-useless-call": ["off"], |
| 124 | + "no-useless-catch": ["error"], |
| 125 | + "no-useless-concat": ["error"], |
| 126 | + "no-useless-escape": ["error"], |
| 127 | + "no-useless-return": ["error"], |
| 128 | + |
| 129 | + "import/no-default-export": "error", |
| 130 | + |
| 131 | + "jest/expect-expect": "off", |
| 132 | + "jest/consistent-test-it": ["error", { fn: "test", withinDescribe: "test" }], |
| 133 | + "jest/no-expect-resolves": "error", |
| 134 | + "jest/no-test-return-statement": "error", |
| 135 | + "jest/no-truthy-falsy": "error", |
| 136 | + "jest/prefer-spy-on": "error", |
| 137 | + "jest/prefer-todo": "error", |
| 138 | + "jest/valid-title": "error", |
| 139 | + // TODO: |
| 140 | + // "jest/lowercase-name": "error", |
| 141 | + }, |
| 142 | + overrides: [ |
| 143 | + { |
| 144 | + files: "**/*.ts", |
| 145 | + extends: ["plugin:@typescript-eslint/base"], |
| 146 | + rules: { |
| 147 | + ...typescriptBase, |
| 148 | + "@typescript-eslint/array-type": ["error", { default: "array-simple" }], |
| 149 | + "@typescript-eslint/ban-types": ["error", { types: { null: null } }], |
| 150 | + "@typescript-eslint/no-namespace": ["error", { allowDeclarations: true }], |
| 151 | + "@typescript-eslint/no-require-imports": "off", |
| 152 | + "@typescript-eslint/no-unnecessary-condition": "off", |
| 153 | + "@typescript-eslint/prefer-for-of": "error", |
| 154 | + // TODO: https://github.com/typescript-eslint/typescript-eslint/issues/1265 |
| 155 | + // "@typescript-eslint/prefer-nullish-coalescing": "error", |
| 156 | + "@typescript-eslint/prefer-readonly": "off", |
| 157 | + "@typescript-eslint/quotes": ["error", "double", { avoidEscape: true, allowTemplateLiterals: false }], |
| 158 | + "@typescript-eslint/require-array-sort-compare": "off", |
| 159 | + "@typescript-eslint/camelcase": "off", |
| 160 | + |
| 161 | + // TODO: https://github.com/typescript-eslint/typescript-eslint/issues/1712 |
| 162 | + // "@typescript-eslint/naming-convention": [ |
| 163 | + // "error", |
| 164 | + // { |
| 165 | + // selector: "default", |
| 166 | + // format: ["camelCase"], |
| 167 | + // leadingUnderscore: "allow", |
| 168 | + // }, |
| 169 | + // { |
| 170 | + // selector: "variable", |
| 171 | + // format: ["camelCase", "UPPER_CASE"], |
| 172 | + // leadingUnderscore: "allow", |
| 173 | + // }, |
| 174 | + // { |
| 175 | + // selector: "typeLike", |
| 176 | + // format: ["PascalCase"], |
| 177 | + // }, |
| 178 | + // ], |
| 179 | + }, |
| 180 | + }, |
| 181 | + { |
| 182 | + files: "src/lualib/**/*.ts", |
| 183 | + rules: { |
| 184 | + "no-restricted-syntax": ["error", "LabeledStatement", "SequenceExpression"], |
| 185 | + "@typescript-eslint/no-throw-literal": "off", |
| 186 | + "@typescript-eslint/prefer-optional-chain": "off", |
| 187 | + }, |
| 188 | + }, |
| 189 | + ], |
| 190 | +}; |
0 commit comments