Skip to content

Commit 90088d0

Browse files
committed
feat(eslint-config-react-native): enforce minimum id length
1 parent 71c104b commit 90088d0

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

packages/eslint-config-react-native/index.mjs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ const ignores = globalIgnores(['.expo/', 'expo-env.d.ts'])
99
const common = {
1010
name: '@strv/eslint-config-react-native',
1111
rules: {
12+
// Enforce minimum identifier length to improve code readability, see https://eslint.org/docs/latest/rules/id-length
13+
'id-length': ['error', { min: 2, exceptions: ['i', 't', 'b', '_', 'x', 'y', 'z'] }],
14+
1215
// Very expensive check, see https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/namespace.md
1316
'import/namespace': 'off',
1417
// 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 = {
1922
'import/no-named-as-default': 'off',
2023
// https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-named-as-default-member.md
2124
'import/no-named-as-default-member': 'off',
25+
2226
// Handled by TypeScript. Enable noUnusedLocals in your tsconfig.json, see https://www.typescriptlang.org/tsconfig/#noUnusedLocals
2327
// https://eslint.org/docs/latest/rules/no-unused-vars
2428
'no-unused-vars': 'off',
@@ -39,6 +43,8 @@ const react = {
3943
shorthandLast: true,
4044
},
4145
],
46+
// Only relevant in class components, see https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-direct-mutation-state.md
47+
'react/no-direct-mutation-state': 'off',
4248
// DisplayName is not required for React Native components, see https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/display-name.md
4349
'react/display-name': 'off',
4450
},
@@ -50,6 +56,14 @@ const typescript = defineConfig([
5056
{
5157
files: ['**/*.ts', '**/*.tsx'],
5258
rules: {
59+
// Enforce consistent type imports with inline style, see https://typescript-eslint.io/rules/consistent-type-imports/
60+
'@typescript-eslint/consistent-type-imports': [
61+
'error',
62+
{ prefer: 'type-imports', fixStyle: 'inline-type-imports' },
63+
],
64+
// Allow throwing non-Error objects, but only Promises are allowed in React codebases, see https://typescript-eslint.io/rules/only-throw-error/
65+
'@typescript-eslint/only-throw-error': ['error', { allow: ['Promise'] }],
66+
5367
// Handled by TypeScript. Enable noUnusedLocals in your tsconfig.json, see https://www.typescriptlang.org/tsconfig/#noUnusedLocals
5468
// https://typescript-eslint.io/rules/no-unused-vars/
5569
'@typescript-eslint/no-unused-vars': 'off',
@@ -73,14 +87,6 @@ const typescript = defineConfig([
7387
'@typescript-eslint/unbound-method': 'off',
7488
// Allows member access on any typed values, see https://typescript-eslint.io/rules/no-unsafe-member-access/
7589
'@typescript-eslint/no-unsafe-member-access': 'off',
76-
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'] }],
8490
},
8591
},
8692
])

0 commit comments

Comments
 (0)