|
| 1 | +// @ts-check |
1 | 2 | "use strict"; |
2 | 3 |
|
3 | | -module.exports = { |
4 | | - env: { |
5 | | - node: true, |
6 | | - "react-native/react-native": true, |
7 | | - }, |
| 4 | +const { defineConfig } = require("eslint-define-config"); |
| 5 | + |
| 6 | +module.exports = defineConfig({ |
| 7 | + ignorePatterns: [ |
| 8 | + ".cache", // tsc/eslint/metro cache |
| 9 | + ".expo-shared", |
| 10 | + ".expo", |
| 11 | + ".yarn", // yarn 3 |
| 12 | + "android", // react-native |
| 13 | + "ios", // react-native |
| 14 | + "coverage", // jest |
| 15 | + "dist", // expo updates |
| 16 | + "node_modules", |
| 17 | + ], |
8 | 18 | extends: [ |
9 | 19 | "eslint:recommended", |
10 | 20 | "plugin:@typescript-eslint/recommended", |
11 | 21 | "plugin:react/recommended", |
| 22 | + "plugin:react/jsx-runtime", // Disables the rules that require importing react when using JSX |
12 | 23 | "plugin:react-native/all", |
| 24 | + "plugin:react-hooks/recommended", |
| 25 | + "plugin:prettier/recommended", // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array. |
13 | 26 | ], |
| 27 | + rules: { |
| 28 | + "@typescript-eslint/ban-ts-comment": "warn", |
| 29 | + "@typescript-eslint/explicit-function-return-type": "off", |
| 30 | + "@typescript-eslint/indent": "off", |
| 31 | + "@typescript-eslint/no-explicit-any": "error", |
| 32 | + "@typescript-eslint/no-unused-vars": "error", |
| 33 | + "no-console": ["error", { allow: ["warn", "error"] }], |
| 34 | + "no-return-await": "error", |
| 35 | + "prettier/prettier": ["error", { printWidth: 80 }], |
| 36 | + "react-hooks/exhaustive-deps": "error", |
| 37 | + "react-native/no-color-literals": "off", |
| 38 | + "react-native/no-raw-text": ["error", { skip: ["Trans"] }], |
| 39 | + "react-native/sort-styles": "off", |
| 40 | + "react/no-unstable-nested-components": "error", |
| 41 | + "react/prop-types": "off", |
| 42 | + }, |
| 43 | + env: { |
| 44 | + node: true, |
| 45 | + "react-native/react-native": true, |
| 46 | + }, |
14 | 47 | parser: "@typescript-eslint/parser", |
15 | 48 | parserOptions: { |
16 | 49 | ecmaVersion: "latest", |
| 50 | + sourceType: "module", |
17 | 51 | ecmaFeatures: { |
18 | 52 | jsx: true, |
19 | 53 | }, |
20 | 54 | }, |
21 | | - plugins: ["@typescript-eslint", "react-native"], |
22 | 55 | settings: { |
23 | 56 | react: { |
24 | 57 | version: "detect", |
25 | 58 | }, |
26 | 59 | }, |
27 | | -}; |
| 60 | + overrides: [ |
| 61 | + { |
| 62 | + files: ["**/*.ts?(x)"], |
| 63 | + parserOptions: { |
| 64 | + project: "tsconfig.json", |
| 65 | + }, |
| 66 | + rules: { |
| 67 | + // Note: disable the base rule as it can report incorrect errors |
| 68 | + "no-return-await": "off", |
| 69 | + "@typescript-eslint/return-await": "error", |
| 70 | + }, |
| 71 | + }, |
| 72 | + ], |
| 73 | +}); |
0 commit comments