|
1 | | -import foxkit from "eslint-config-foxkit/configs/base.js"; |
2 | | -import prettier from "eslint-config-prettier"; |
| 1 | +import foxkit from "eslint-config-foxkit/flat.js"; |
| 2 | +import prettierCfg from "eslint-config-prettier"; |
| 3 | +import * as importPlugin from "eslint-plugin-import"; |
| 4 | +import tsEslint from "typescript-eslint"; |
3 | 5 |
|
4 | | -const __dirname = new URL(".", import.meta.url).pathname.slice(0, -1); |
| 6 | +/** |
| 7 | + * Patch import plugin config with custom file extensions and configure rules |
| 8 | + * @type {import("typescript-eslint").ConfigWithExtends} |
| 9 | + */ |
| 10 | +const importCfg = { |
| 11 | + name: "import/custom-config", |
| 12 | + files: ["**/*.?(m)js", "**/*.ts"], |
| 13 | + extends: [importPlugin.flatConfigs.recommended], |
| 14 | + rules: { |
| 15 | + "sort-imports": "off", |
| 16 | + "import/order": "off", |
| 17 | + "import/no-unresolved": "off", |
| 18 | + "import/first": "warn", |
| 19 | + "import/newline-after-import": "warn", |
| 20 | + "import/consistent-type-specifier-style": ["error", "prefer-top-level"], |
| 21 | + "import/no-duplicates": "off", |
| 22 | + "import/no-useless-path-segments": "error", |
| 23 | + "import/no-self-import": "error", |
| 24 | + "import/no-default-export": "error" |
| 25 | + }, |
| 26 | + languageOptions: { |
| 27 | + ecmaVersion: foxkit.base.languageOptions.ecmaVersion |
| 28 | + }, |
| 29 | + settings: { |
| 30 | + "import/internal-regex": "^~\\/", |
| 31 | + "import/parsers": { "@typescript-eslint/parser": [".ts", ".tsx"] }, |
| 32 | + "import/resolver": { |
| 33 | + node: { |
| 34 | + extensions: [".js", ".mjs", ".cjs", ".jsx", ".ts", ".tsx"] |
| 35 | + } |
| 36 | + } |
| 37 | + } |
| 38 | +}; |
| 39 | + |
| 40 | +/** |
| 41 | + * Allows config files (such as this very file) to default export again |
| 42 | + * @type {import("typescript-eslint").ConfigWithExtends} |
| 43 | + */ |
| 44 | +const importConfigsCfg = { |
| 45 | + name: "import/configs-may-default-export", |
| 46 | + files: ["**/*.config.?(m)js"], |
| 47 | + rules: { |
| 48 | + "import/no-default-export": "off" |
| 49 | + } |
| 50 | +}; |
5 | 51 |
|
6 | 52 | /** |
7 | 53 | * @see https://github.com/foxkit-js/eslint-config-foxkit/ for more information |
8 | 54 | */ |
9 | | -export default [ |
| 55 | +export default tsEslint.config([ |
10 | 56 | { ignores: ["dist/**"] }, |
11 | 57 | foxkit.base, |
12 | 58 | foxkit.typescript, |
13 | | - foxkit.configureTS({ tsconfigRootDir: __dirname }), |
14 | | - prettier |
15 | | -]; |
| 59 | + foxkit.configureTS({ tsconfigRootDir: import.meta.dirname }), |
| 60 | + importCfg, |
| 61 | + importConfigsCfg, |
| 62 | + prettierCfg |
| 63 | +]); |
0 commit comments