|
| 1 | +import globals from "globals"; |
| 2 | +import tsParser from "@typescript-eslint/parser"; |
| 3 | +import tsPlugin from "@typescript-eslint/eslint-plugin"; |
| 4 | +import eslintJsPlugin from "@eslint/js"; |
| 5 | +import importNewlines from "eslint-plugin-import-newlines"; |
| 6 | + |
| 7 | +const commonConfig = { |
| 8 | + plugins: { |
| 9 | + "@typescript-eslint": tsPlugin, |
| 10 | + "import-newlines": importNewlines, |
| 11 | + }, |
| 12 | + rules: { |
| 13 | + ...tsPlugin.configs.recommended.rules, |
| 14 | + "@typescript-eslint/array-type": [ |
| 15 | + "error", |
| 16 | + { |
| 17 | + default: "generic", |
| 18 | + }, |
| 19 | + ], |
| 20 | + |
| 21 | + "@typescript-eslint/consistent-type-assertions": [ |
| 22 | + "error", |
| 23 | + { |
| 24 | + assertionStyle: "as", |
| 25 | + objectLiteralTypeAssertions: "never", |
| 26 | + }, |
| 27 | + ], |
| 28 | + |
| 29 | + "block-spacing": "error", |
| 30 | + "brace-style": ["error", "1tbs"], |
| 31 | + "comma-dangle": ["error", "never"], |
| 32 | + |
| 33 | + "comma-spacing": [ |
| 34 | + "error", |
| 35 | + { |
| 36 | + before: false, |
| 37 | + after: true, |
| 38 | + }, |
| 39 | + ], |
| 40 | + |
| 41 | + "dot-location": ["error", "property"], |
| 42 | + "eol-last": ["error", "always"], |
| 43 | + eqeqeq: "error", |
| 44 | + "func-call-spacing": "error", |
| 45 | + |
| 46 | + "func-style": [ |
| 47 | + "error", |
| 48 | + "declaration", |
| 49 | + { |
| 50 | + allowArrowFunctions: true, |
| 51 | + }, |
| 52 | + ], |
| 53 | + |
| 54 | + "import-newlines/enforce": [ |
| 55 | + "error", |
| 56 | + { |
| 57 | + items: 3, |
| 58 | + "max-len": 120, |
| 59 | + semi: false, |
| 60 | + }, |
| 61 | + ], |
| 62 | + |
| 63 | + indent: [ |
| 64 | + "error", |
| 65 | + 2, |
| 66 | + { |
| 67 | + SwitchCase: 1, |
| 68 | + }, |
| 69 | + ], |
| 70 | + |
| 71 | + "max-len": ["error", 120], |
| 72 | + "no-multi-spaces": "error", |
| 73 | + |
| 74 | + "no-multiple-empty-lines": [ |
| 75 | + "error", |
| 76 | + { |
| 77 | + max: 1, |
| 78 | + }, |
| 79 | + ], |
| 80 | + |
| 81 | + "no-trailing-spaces": "error", |
| 82 | + "object-curly-spacing": ["error", "never"], |
| 83 | + |
| 84 | + quotes: [ |
| 85 | + "error", |
| 86 | + "double", |
| 87 | + { |
| 88 | + allowTemplateLiterals: true, |
| 89 | + avoidEscape: true, |
| 90 | + }, |
| 91 | + ], |
| 92 | + |
| 93 | + semi: ["error", "never"], |
| 94 | + }, |
| 95 | +}; |
| 96 | + |
| 97 | +export default [ |
| 98 | + { |
| 99 | + ignores: ["**/lib/*", "**/coverage/*"], |
| 100 | + }, |
| 101 | + { |
| 102 | + rules: eslintJsPlugin.configs.recommended.rules, |
| 103 | + }, |
| 104 | + { |
| 105 | + files: ["**/*.ts"], |
| 106 | + |
| 107 | + languageOptions: { |
| 108 | + parser: tsParser, |
| 109 | + globals: { |
| 110 | + ...globals.node, |
| 111 | + }, |
| 112 | + }, |
| 113 | + ...commonConfig, |
| 114 | + }, |
| 115 | + { |
| 116 | + files: ["**/tests/**/*.ts"], |
| 117 | + |
| 118 | + languageOptions: { |
| 119 | + parser: tsParser, |
| 120 | + globals: { |
| 121 | + ...globals.jest, |
| 122 | + ...globals.node, |
| 123 | + }, |
| 124 | + }, |
| 125 | + ...commonConfig, |
| 126 | + }, |
| 127 | +]; |
0 commit comments