@@ -7,6 +7,7 @@ const ignores = globalIgnores(['.expo/', 'expo-env.d.ts'])
77
88/** @type {import("eslint").Linter.Config } */
99const common = {
10+ name : '@strv/eslint-config-react-native' ,
1011 rules : {
1112 // Very expensive check, see https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/namespace.md
1213 'import/namespace' : 'off' ,
@@ -44,45 +45,44 @@ const react = {
4445}
4546
4647/** @type {import("eslint").Linter.Config } */
47- const typescript = defineConfig ( [ typeScriptConfig , {
48- files : [ '**/*.ts' , '**/*.tsx' ] ,
49- rules : {
50- // Handled by TypeScript. Enable noUnusedLocals in your tsconfig.json, see https://www.typescriptlang.org/tsconfig/#noUnusedLocals
51- // https://typescript-eslint.io/rules/no-unused-vars/
52- '@typescript-eslint/no-unused-vars' : 'off' ,
53- // Its common in React Native to import types using require syntax, see https://reactnative.dev/docs/images#static-image-resources
54- // https://typescript-eslint.io/rules/no-require-imports/
55- '@typescript-eslint/no-require-imports' : 'off' ,
56- // Very expensive check, see https://typescript-eslint.io/rules/promise-function-async/
57- '@typescript-eslint/promise-function-async' : 'off' ,
48+ const typescript = defineConfig ( [
49+ typeScriptConfig ,
50+ {
51+ files : [ '**/*.ts' , '**/*.tsx' ] ,
52+ rules : {
53+ // Handled by TypeScript. Enable noUnusedLocals in your tsconfig.json, see https://www.typescriptlang.org/tsconfig/#noUnusedLocals
54+ // https://typescript-eslint.io/rules/no-unused-vars/
55+ '@typescript-eslint/no-unused-vars' : 'off' ,
56+ // Its common in React Native to import types using require syntax, see https://reactnative.dev/docs/images#static-image-resources
57+ // https://typescript-eslint.io/rules/no-require-imports/
58+ '@typescript-eslint/no-require-imports' : 'off' ,
59+ // Very expensive check, see https://typescript-eslint.io/rules/promise-function-async/
60+ '@typescript-eslint/promise-function-async' : 'off' ,
5861
59- // Allows variable shadowing in TypeScript contexts, see https://typescript-eslint.io/rules/no-shadow/
60- '@typescript-eslint/no-shadow' : 'off' ,
61- // Allows both interface and type definitions, see https://typescript-eslint.io/rules/consistent-type-definitions/
62- '@typescript-eslint/consistent-type-definitions' : 'off' ,
63- // Allows Promises in places where they might not be handled properly, see https://typescript-eslint.io/rules/no-misused-promises/
64- '@typescript-eslint/no-misused-promises' : 'off' ,
65- // Allows assignments of any typed values, see https://typescript-eslint.io/rules/no-unsafe-assignment/
66- '@typescript-eslint/no-unsafe-assignment' : 'off' ,
67- // Allows returning any typed values from functions, see https://typescript-eslint.io/rules/no-unsafe-return/
68- '@typescript-eslint/no-unsafe-return' : 'off' ,
69- // Allows unbound method references that may lose 'this' context, see https://typescript-eslint.io/rules/unbound-method/
70- '@typescript-eslint/unbound-method' : 'off' ,
71- // Allows member access on any typed values, see https://typescript-eslint.io/rules/no-unsafe-member-access/
72- '@typescript-eslint/no-unsafe-member-access' : 'off' ,
62+ // Allows variable shadowing in TypeScript contexts, see https://typescript-eslint.io/rules/no-shadow/
63+ '@typescript-eslint/no-shadow' : 'off' ,
64+ // Allows both interface and type definitions, see https://typescript-eslint.io/rules/consistent-type-definitions/
65+ '@typescript-eslint/consistent-type-definitions' : 'off' ,
66+ // Allows Promises in places where they might not be handled properly, see https://typescript-eslint.io/rules/no-misused-promises/
67+ '@typescript-eslint/no-misused-promises' : 'off' ,
68+ // Allows assignments of any typed values, see https://typescript-eslint.io/rules/no-unsafe-assignment/
69+ '@typescript-eslint/no-unsafe-assignment' : 'off' ,
70+ // Allows returning any typed values from functions, see https://typescript-eslint.io/rules/no-unsafe-return/
71+ '@typescript-eslint/no-unsafe-return' : 'off' ,
72+ // Allows unbound method references that may lose 'this' context, see https://typescript-eslint.io/rules/unbound-method/
73+ '@typescript-eslint/unbound-method' : 'off' ,
74+ // Allows member access on any typed values, see https://typescript-eslint.io/rules/no-unsafe-member-access/
75+ '@typescript-eslint/no-unsafe-member-access' : 'off' ,
7376
74- // Enforce consistent type imports with inline style, see https://typescript-eslint.io/rules/consistent-type-imports/
75- '@typescript-eslint/consistent-type-imports' : [
76- 'error' ,
77- { prefer : 'type-imports' , fixStyle : 'inline-type-imports' } ,
78- ] ,
77+ // Enforce consistent type imports with inline style, see https://typescript-eslint.io/rules/consistent-type-imports/
78+ '@typescript-eslint/consistent-type-imports' : [
79+ 'error' ,
80+ { prefer : 'type-imports' , fixStyle : 'inline-type-imports' } ,
81+ ] ,
82+ // Allow throwing non-Error objects, but only Promises are allowed in React codebases, see https://typescript-eslint.io/rules/only-throw-error/
83+ '@typescript-eslint/only-throw-error' : [ 'error' , { allow : [ 'Promise' ] } ] ,
84+ } ,
7985 } ,
80- } ] )
81-
82- export default defineConfig ( [
83- expoConfig ,
84- ignores ,
85- common ,
86- typescript ,
87- react ,
8886] )
87+
88+ export default defineConfig ( [ expoConfig , ignores , common , typescript , react ] )
0 commit comments