|
1 | | -import { fixupConfigRules } from '@eslint/compat'; |
2 | | -import { FlatCompat } from '@eslint/eslintrc'; |
3 | | -import js from '@eslint/js'; |
4 | | -import prettier from 'eslint-plugin-prettier'; |
5 | | -import { defineConfig } from 'eslint/config'; |
6 | | -import path from 'node:path'; |
7 | | -import { fileURLToPath } from 'node:url'; |
| 1 | +import { resolve } from "node:path"; |
8 | 2 |
|
9 | | -const __filename = fileURLToPath(import.meta.url); |
10 | | -const __dirname = path.dirname(__filename); |
11 | | -const compat = new FlatCompat({ |
12 | | - baseDirectory: __dirname, |
13 | | - recommendedConfig: js.configs.recommended, |
14 | | - allConfig: js.configs.all, |
15 | | -}); |
| 3 | +import eslint from "@eslint/js"; |
| 4 | +import prettier from "eslint-plugin-prettier/recommended"; |
| 5 | +import { globalIgnores } from "eslint/config"; |
| 6 | +import tseslint from "typescript-eslint"; |
16 | 7 |
|
17 | | -export default defineConfig([ |
| 8 | +export default tseslint.config( |
| 9 | + eslint.configs.recommended, |
| 10 | + tseslint.configs.strictTypeChecked, |
| 11 | + tseslint.configs.stylisticTypeChecked, |
| 12 | + prettier, |
| 13 | + { |
| 14 | + languageOptions: { |
| 15 | + parserOptions: { |
| 16 | + projectService: true, |
| 17 | + tsconfigRootDir: resolve("../"), |
| 18 | + }, |
| 19 | + }, |
| 20 | + }, |
| 21 | + globalIgnores([ |
| 22 | + "**/dist/*", |
| 23 | + ".yarn/*", |
| 24 | + "**/eslint.config.[cm]js", |
| 25 | + "**/prettier.config.[cm]js", |
| 26 | + "**/babel.config.js", |
| 27 | + "**/metro.config.js", |
| 28 | + ]), |
18 | 29 | { |
19 | | - extends: fixupConfigRules(compat.extends('@react-native', 'prettier')), |
20 | | - plugins: { prettier }, |
21 | 30 | rules: { |
22 | | - 'react/react-in-jsx-scope': 'off', |
23 | | - 'prettier/prettier': 'error', |
| 31 | + "prefer-const": [ |
| 32 | + "error", |
| 33 | + { |
| 34 | + destructuring: "all", |
| 35 | + }, |
| 36 | + ], |
| 37 | + "no-unused-vars": "off", |
| 38 | + "@typescript-eslint/no-unsafe-assignment": "off", |
| 39 | + "@typescript-eslint/no-explicit-any": "off", |
| 40 | + "@typescript-eslint/no-unsafe-call": "off", |
| 41 | + "@typescript-eslint/no-unsafe-return": "off", |
| 42 | + "@typescript-eslint/no-unsafe-member-access": "off", |
| 43 | + "@typescript-eslint/no-unsafe-member-access": "off", |
| 44 | + "@typescript-eslint/no-unsafe-argument": "off", |
| 45 | + "@typescript-eslint/no-unused-vars": [ |
| 46 | + "warn", |
| 47 | + { |
| 48 | + args: "after-used", |
| 49 | + ignoreRestSiblings: true, |
| 50 | + argsIgnorePattern: "^_", |
| 51 | + }, |
| 52 | + ], |
| 53 | + "@typescript-eslint/restrict-template-expressions": [ |
| 54 | + "error", |
| 55 | + { |
| 56 | + allow: [{ name: ["Error", "URL", "URLSearchParams"], from: "lib" }], |
| 57 | + allowAny: true, |
| 58 | + allowBoolean: true, |
| 59 | + allowNullish: true, |
| 60 | + allowNumber: true, |
| 61 | + allowRegExp: true, |
| 62 | + }, |
| 63 | + ], |
24 | 64 | }, |
25 | 65 | }, |
| 66 | + // Test file specific rules |
| 67 | + // These rules are causing false positives with @react-native/testing-library |
26 | 68 | { |
27 | | - ignores: ['node_modules/', 'lib/'], |
| 69 | + files: ["**/__tests__/**/*", "**/*.test.*", "**/*.spec.*"], |
| 70 | + rules: { |
| 71 | + "@typescript-eslint/no-unsafe-assignment": "off", |
| 72 | + "@typescript-eslint/no-unsafe-member-access": "off", |
| 73 | + }, |
28 | 74 | }, |
29 | | -]); |
| 75 | +); |
0 commit comments