diff --git a/package-lock.json b/package-lock.json index 54b8f32..998b705 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2167,7 +2167,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -2184,7 +2183,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -2201,7 +2199,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -2218,7 +2215,6 @@ "cpu": [ "arm" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -2235,7 +2231,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -2252,7 +2247,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -2269,7 +2263,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -2286,7 +2279,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -2303,7 +2295,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -2320,7 +2311,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -6874,6 +6864,29 @@ "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", "license": "MIT" }, + "node_modules/encoding": { + "version": "0.1.13", + "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.13.tgz", + "integrity": "sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A==", + "license": "MIT", + "optional": true, + "dependencies": { + "iconv-lite": "^0.6.2" + } + }, + "node_modules/encoding/node_modules/iconv-lite": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "license": "MIT", + "optional": true, + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/end-of-stream": { "version": "1.4.4", "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", @@ -19936,7 +19949,6 @@ "version": "3.19.3", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.19.3.tgz", "integrity": "sha512-v3Xu+yuwBXisp6QYTcH4UbH+xYJXqnq2m/LtQVWKWzYc1iehYnLixoQDN9FH6/j9/oybfd6W9Ghwkl8+UMKTKQ==", - "dev": true, "license": "BSD-2-Clause", "optional": true, "bin": { diff --git a/packages/eslint-config-react-native/index.mjs b/packages/eslint-config-react-native/index.mjs index c1e4758..e645177 100644 --- a/packages/eslint-config-react-native/index.mjs +++ b/packages/eslint-config-react-native/index.mjs @@ -9,6 +9,9 @@ const ignores = globalIgnores(['.expo/', 'expo-env.d.ts']) const common = { name: '@strv/eslint-config-react-native', rules: { + // Enforce minimum identifier length to improve code readability, see https://eslint.org/docs/latest/rules/id-length + 'id-length': ['error', { min: 2, exceptions: ['i', 't', 'b', '_', 'x', 'y', 'z'] }], + // Very expensive check, see https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/namespace.md 'import/namespace': 'off', // Very expensive check, see https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-duplicates.md @@ -19,6 +22,7 @@ const common = { 'import/no-named-as-default': 'off', // https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-named-as-default-member.md 'import/no-named-as-default-member': 'off', + // Handled by TypeScript. Enable noUnusedLocals in your tsconfig.json, see https://www.typescriptlang.org/tsconfig/#noUnusedLocals // https://eslint.org/docs/latest/rules/no-unused-vars 'no-unused-vars': 'off', @@ -39,6 +43,8 @@ const react = { shorthandLast: true, }, ], + // Only relevant in class components, see https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-direct-mutation-state.md + 'react/no-direct-mutation-state': 'off', // DisplayName is not required for React Native components, see https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/display-name.md 'react/display-name': 'off', }, @@ -50,6 +56,14 @@ const typescript = defineConfig([ { files: ['**/*.ts', '**/*.tsx'], rules: { + // Enforce consistent type imports with inline style, see https://typescript-eslint.io/rules/consistent-type-imports/ + '@typescript-eslint/consistent-type-imports': [ + 'error', + { prefer: 'type-imports', fixStyle: 'inline-type-imports' }, + ], + // Allow throwing non-Error objects, but only Promises are allowed in React codebases, see https://typescript-eslint.io/rules/only-throw-error/ + '@typescript-eslint/only-throw-error': ['error', { allow: ['Promise'] }], + // Handled by TypeScript. Enable noUnusedLocals in your tsconfig.json, see https://www.typescriptlang.org/tsconfig/#noUnusedLocals // https://typescript-eslint.io/rules/no-unused-vars/ '@typescript-eslint/no-unused-vars': 'off', @@ -73,14 +87,6 @@ const typescript = defineConfig([ '@typescript-eslint/unbound-method': 'off', // Allows member access on any typed values, see https://typescript-eslint.io/rules/no-unsafe-member-access/ '@typescript-eslint/no-unsafe-member-access': 'off', - - // Enforce consistent type imports with inline style, see https://typescript-eslint.io/rules/consistent-type-imports/ - '@typescript-eslint/consistent-type-imports': [ - 'error', - { prefer: 'type-imports', fixStyle: 'inline-type-imports' }, - ], - // Allow throwing non-Error objects, but only Promises are allowed in React codebases, see https://typescript-eslint.io/rules/only-throw-error/ - '@typescript-eslint/only-throw-error': ['error', { allow: ['Promise'] }], }, }, ])