|
4 | 4 | "parserOptions": { |
5 | 5 | "ecmaVersion": 6, |
6 | 6 | "sourceType": "module", |
7 | | - "project": "./tsconfig.json" |
| 7 | + "project": true |
8 | 8 | }, |
9 | | - "plugins": ["@typescript-eslint", "prettier"], |
| 9 | + "plugins": ["@typescript-eslint", "prettier", "import"], |
10 | 10 | "extends": [ |
11 | 11 | "eslint:recommended", |
12 | 12 | "plugin:@typescript-eslint/recommended", |
|
15 | 15 | "plugin:md/prettier", |
16 | 16 | "prettier" |
17 | 17 | ], |
| 18 | + "ignorePatterns": ["out", "dist", "**/*.d.ts"], |
| 19 | + "settings": { |
| 20 | + "import/resolver": { |
| 21 | + "typescript": { "project": "./tsconfig.json" } |
| 22 | + }, |
| 23 | + "import/internal-regex": "^@/" |
| 24 | + }, |
18 | 25 | "overrides": [ |
| 26 | + { |
| 27 | + "files": ["test/**/*.{ts,tsx}", "**/*.{test,spec}.ts?(x)"], |
| 28 | + "settings": { |
| 29 | + "import/resolver": { |
| 30 | + "typescript": { |
| 31 | + // In tests, resolve using the test tsconfig |
| 32 | + "project": "test/tsconfig.json" |
| 33 | + } |
| 34 | + } |
| 35 | + } |
| 36 | + }, |
19 | 37 | { |
20 | 38 | "files": ["*.ts"], |
21 | 39 | "rules": { |
22 | 40 | "require-await": "off", |
23 | | - "@typescript-eslint/require-await": "error" |
| 41 | + "@typescript-eslint/require-await": "error", |
| 42 | + "@typescript-eslint/consistent-type-imports": [ |
| 43 | + "error", |
| 44 | + { |
| 45 | + "disallowTypeAnnotations": false, // Used in tests |
| 46 | + "prefer": "type-imports", |
| 47 | + "fixStyle": "inline-type-imports" |
| 48 | + } |
| 49 | + ] |
24 | 50 | } |
25 | 51 | }, |
26 | 52 | { |
|
42 | 68 | "import/order": [ |
43 | 69 | "error", |
44 | 70 | { |
45 | | - "alphabetize": { |
46 | | - "order": "asc" |
47 | | - }, |
48 | | - "groups": [["builtin", "external", "internal"], "parent", "sibling"] |
| 71 | + "groups": [ |
| 72 | + ["builtin", "external"], |
| 73 | + "internal", |
| 74 | + "parent", |
| 75 | + ["sibling", "index"], |
| 76 | + "type" |
| 77 | + ], |
| 78 | + "pathGroups": [ |
| 79 | + { "pattern": "@/**", "group": "internal", "position": "before" } |
| 80 | + ], |
| 81 | + "pathGroupsExcludedImportTypes": ["builtin", "external"], |
| 82 | + "newlines-between": "always", |
| 83 | + "alphabetize": { "order": "asc", "caseInsensitive": true }, |
| 84 | + "sortTypesGroup": true |
49 | 85 | } |
50 | 86 | ], |
| 87 | + // Prevent duplicates and prefer merging into a single import |
| 88 | + "no-duplicate-imports": "off", |
| 89 | + "import/no-duplicates": ["error", { "prefer-inline": true }], |
51 | 90 | "import/no-unresolved": [ |
52 | 91 | "error", |
53 | 92 | { |
|
68 | 107 | } |
69 | 108 | } |
70 | 109 | ] |
71 | | - }, |
72 | | - "ignorePatterns": ["out", "dist", "**/*.d.ts"] |
| 110 | + } |
73 | 111 | } |
0 commit comments