|
1 |
| -import globals from 'globals' |
2 |
| -import eslintjs from "@eslint/js"; |
3 |
| -import prettier from "eslint-plugin-prettier/recommended"; |
| 1 | +import { fixupPluginRules } from "@eslint/compat"; |
| 2 | +import { FlatCompat } from "@eslint/eslintrc"; |
| 3 | +import js from "@eslint/js"; |
| 4 | +import typescriptEslint from "@typescript-eslint/eslint-plugin"; |
| 5 | +import tsParser from "@typescript-eslint/parser"; |
| 6 | +import _import from "eslint-plugin-import"; |
4 | 7 | import react from "eslint-plugin-react";
|
5 | 8 | import reactHooks from "eslint-plugin-react-hooks";
|
6 |
| -import tseslint from "typescript-eslint"; |
| 9 | +import globals from "globals"; |
| 10 | +import path from "node:path"; |
| 11 | +import { fileURLToPath } from "node:url"; |
7 | 12 |
|
8 |
| -export default tseslint.config( |
9 |
| - eslintjs.configs.recommended, |
10 |
| - tseslint.configs.recommended, |
11 |
| - prettier, |
| 13 | +const __filename = fileURLToPath(import.meta.url); |
| 14 | +const __dirname = path.dirname(__filename); |
| 15 | +const compat = new FlatCompat({ |
| 16 | + baseDirectory: __dirname, |
| 17 | + recommendedConfig: js.configs.recommended, |
| 18 | + allConfig: js.configs.all, |
| 19 | +}); |
| 20 | + |
| 21 | +export default [ |
| 22 | + { |
| 23 | + ignores: [ |
| 24 | + "**/*.js", |
| 25 | + // Built files |
| 26 | + "**/dist/*", |
| 27 | + "**/build/*", |
| 28 | + "**/node_modules/*", |
| 29 | + // Doc and examples |
| 30 | + "**/storybook-static/*", |
| 31 | + "**/typedoc", |
| 32 | + "**/.docusaurus", |
| 33 | + ], |
| 34 | + }, |
| 35 | + ...compat.extends( |
| 36 | + "eslint:recommended", |
| 37 | + "plugin:@typescript-eslint/recommended", |
| 38 | + "plugin:@typescript-eslint/eslint-recommended", |
| 39 | + "prettier", |
| 40 | + ), |
12 | 41 | {
|
13 |
| - ignores: ["**/build/*", "**/dist/*", "**/lib/*"], |
14 |
| - files: ["**/*.{ts,tsx}"], |
15 | 42 | plugins: {
|
16 |
| - "react": react, |
| 43 | + import: fixupPluginRules(_import), |
| 44 | + "@typescript-eslint": typescriptEslint, |
| 45 | + react: react, |
17 | 46 | "react-hooks": reactHooks,
|
18 | 47 | },
|
| 48 | + |
19 | 49 | settings: {
|
20 | 50 | react: {
|
21 | 51 | version: "detect",
|
22 | 52 | },
|
23 | 53 | },
|
| 54 | + |
24 | 55 | languageOptions: {
|
25 |
| - ecmaVersion: 2020, |
26 |
| - globals: globals.browser, |
27 |
| - parserOptions: { |
28 |
| - ecmaFeatures: { |
29 |
| - jsx: true, |
30 |
| - }, |
| 56 | + globals: { |
| 57 | + ...globals.jest, |
| 58 | + ...globals.browser, |
31 | 59 | },
|
| 60 | + |
| 61 | + parser: tsParser, |
32 | 62 | },
|
| 63 | + |
33 | 64 | rules: {
|
34 | 65 | ...react.configs.recommended.rules,
|
35 | 66 | ...reactHooks.configs.recommended.rules,
|
36 | 67 | "react/react-in-jsx-scope": "off",
|
37 |
| - 'react/prop-types': 'off', |
| 68 | + "react/prop-types": "off", |
38 | 69 | "react/display-name": "off",
|
39 |
| - "@typescript-eslint/no-unused-vars": ["warn", { |
40 |
| - "args": "all", |
41 |
| - "argsIgnorePattern": "^_", |
42 |
| - "caughtErrors": "all", |
43 |
| - "caughtErrorsIgnorePattern": "^_", |
44 |
| - "destructuredArrayIgnorePattern": "^_", |
45 |
| - "varsIgnorePattern": "^_", |
46 |
| - "ignoreRestSiblings": true |
47 |
| - }], |
| 70 | + "@typescript-eslint/no-unused-vars": [ |
| 71 | + "warn", |
| 72 | + { |
| 73 | + args: "all", |
| 74 | + argsIgnorePattern: "^_", |
| 75 | + caughtErrors: "all", |
| 76 | + caughtErrorsIgnorePattern: "^_", |
| 77 | + destructuredArrayIgnorePattern: "^_", |
| 78 | + varsIgnorePattern: "^_", |
| 79 | + ignoreRestSiblings: true, |
| 80 | + }, |
| 81 | + ], |
48 | 82 | "no-extra-boolean-cast": "off",
|
49 | 83 | },
|
50 | 84 | },
|
51 |
| -); |
| 85 | + { |
| 86 | + files: ["**/dist/*.d.ts", "**/dist/**/*.d.ts", "**/dist/*.d.mts", "**/dist/**/*.d.mts"], |
| 87 | + |
| 88 | + rules: { |
| 89 | + "import/extensions": "off", |
| 90 | + "@typescript-eslint/no-explicit-any": "off", |
| 91 | + }, |
| 92 | + }, |
| 93 | +]; |
0 commit comments