|
1 | 1 | import type { ESLint } from "eslint";
|
2 | 2 |
|
3 |
| -import { GLOB_DTS, GLOB_MJS, GLOB_MTS, GLOB_SRC_EXT, GLOB_TS, GLOB_TSX } from "../globs"; |
| 3 | +import { GLOB_DTS, GLOB_MJS, GLOB_MTS, GLOB_SRC, GLOB_SRC_EXT, GLOB_TS, GLOB_TSX } from "../globs"; |
4 | 4 | import type {
|
5 | 5 | FlatConfigItem,
|
6 | 6 | OptionsHasTypeScript,
|
| 7 | + OptionsMode, |
7 | 8 | OptionsTypeScriptParserOptions,
|
8 | 9 | RequiredOptionsStylistic,
|
9 | 10 | } from "../types";
|
10 | 11 | import { loadPackages } from "../utils";
|
11 | 12 |
|
12 | 13 | export async function imports(
|
13 |
| - options: Readonly<Required<RequiredOptionsStylistic & OptionsTypeScriptParserOptions & OptionsHasTypeScript>>, |
| 14 | + options: Readonly< |
| 15 | + Required<RequiredOptionsStylistic & OptionsTypeScriptParserOptions & OptionsHasTypeScript & OptionsMode> |
| 16 | + >, |
14 | 17 | ): Promise<FlatConfigItem[]> {
|
15 | 18 | const { stylistic, parserOptions, typescript } = options;
|
16 | 19 |
|
@@ -191,5 +194,24 @@ export async function imports(
|
191 | 194 | },
|
192 | 195 | ]
|
193 | 196 | : []) satisfies FlatConfigItem[]),
|
| 197 | + ...((options.mode === "library" |
| 198 | + ? [ |
| 199 | + { |
| 200 | + files: [GLOB_SRC], |
| 201 | + rules: { |
| 202 | + // Use non-sloppy imports. See: https://jsr.io/docs/publishing-packages#relative-imports |
| 203 | + "import/extensions": [ |
| 204 | + "error", |
| 205 | + "always", |
| 206 | + { |
| 207 | + checkTypeImports: true, |
| 208 | + ignorePackages: true, |
| 209 | + }, |
| 210 | + ], |
| 211 | + "import/no-useless-path-segments": ["error", { noUselessIndex: false }], |
| 212 | + }, |
| 213 | + }, |
| 214 | + ] |
| 215 | + : []) satisfies FlatConfigItem[]), |
194 | 216 | ];
|
195 | 217 | }
|
0 commit comments