Skip to content

Commit 7c59a90

Browse files
authored
chore: Code style enforcement (1/n) (#7001)
1 parent fb8dd98 commit 7c59a90

45 files changed

Lines changed: 1315 additions & 1313 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@ coverage
44
e2e/docker
55
android
66
ios
7-
.eslintrc.js

.eslintrc.js

Lines changed: 65 additions & 190 deletions
Original file line numberDiff line numberDiff line change
@@ -5,53 +5,33 @@ module.exports = {
55
extensions: ['.ts', '.tsx', '.js', '.ios.js', '.android.js', '.native.js', '.ios.tsx', '.android.tsx']
66
},
77
typescript: {
8-
alwaysTryTypes: true,
98
project: './tsconfig.json'
109
}
1110
},
1211
'import/parsers': {
1312
'@typescript-eslint/parser': ['.ts', '.tsx']
14-
// plugins: ['@typescript-eslint'],
15-
// rules: {
16-
// '@typescript-eslint/consistent-type-imports': [
17-
// 'error',
18-
// {
19-
// prefer: 'type-imports', // enforce `import type`
20-
// disallowTypeAnnotations: true // disallow `import { type Foo }`
21-
// // fixStyle: 'inline-type-imports' // keeps type imports inline rather than grouped
22-
// }
23-
// ]
24-
// }
13+
},
14+
react: {
15+
version: 'detect'
2516
}
2617
},
2718
parser: '@babel/eslint-parser',
28-
extends: ['plugin:jest/recommended', '@rocket.chat/eslint-config', 'prettier', 'plugin:react-hooks/recommended'],
19+
extends: [
20+
'@rocket.chat/eslint-config',
21+
'plugin:react/recommended',
22+
'plugin:react-hooks/recommended',
23+
'plugin:prettier/recommended',
24+
'prettier'
25+
],
2926
parserOptions: {
3027
sourceType: 'module',
31-
ecmaVersion: 2017,
32-
ecmaFeatures: {
33-
experimentalObjectRestSpread: true,
34-
jsx: true,
35-
legacyDecorators: true
36-
}
28+
ecmaVersion: 2024
3729
},
38-
plugins: ['react', 'jsx-a11y', 'import', 'react-native', '@babel', 'react-hooks', 'jest'],
30+
plugins: ['import', 'react-native', '@babel'],
3931
env: {
40-
browser: true,
41-
commonjs: true,
42-
es6: true,
43-
node: true,
44-
jquery: true,
45-
mocha: true,
46-
jest: true,
47-
'jest/globals': true
32+
es6: true
4833
},
4934
rules: {
50-
'react-hooks/set-state-in-effect': 1,
51-
'react-hooks/immutability': 1,
52-
'react-hooks/refs': 1,
53-
'import/named': 'error',
54-
'import/no-unresolved': 'error',
5535
'import/extensions': [
5636
'error',
5737
'ignorePackages',
@@ -62,122 +42,34 @@ module.exports = {
6242
tsx: 'warning'
6343
}
6444
],
65-
'react/jsx-filename-extension': [
66-
1,
67-
{
68-
extensions: ['.js', '.jsx', '.ts', '.tsx']
69-
}
70-
],
71-
'react/require-default-props': [0],
72-
'ordered-imports': [0],
73-
'react/no-did-mount-set-state': 0,
74-
'react/no-multi-comp': [0],
75-
'react/jsx-indent-props': [2, 'tab'],
76-
'jsx-quotes': [2, 'prefer-single'],
77-
'jsx-a11y/href-no-hash': 0,
78-
'jsx-a11y/aria-role': 0,
79-
'import/prefer-default-export': 0,
80-
'import/no-cycle': 2,
45+
'import/named': 'error',
46+
'import/no-cycle': 'error',
47+
'import/no-unresolved': 'error',
8148
'import/order': [
8249
'error',
8350
{
8451
'newlines-between': 'ignore'
8552
}
8653
],
87-
camelcase: 0,
88-
'no-underscore-dangle': 0,
89-
'no-return-assign': 0,
90-
'no-param-reassign': 0,
91-
'no-tabs': 0,
92-
'no-multi-spaces': 2,
93-
'no-eval': 2,
94-
'no-extend-native': 2,
95-
'no-multi-str': 2,
96-
'no-use-before-define': 2,
97-
'no-const-assign': 2,
98-
'no-cond-assign': 2,
99-
'no-constant-condition': 2,
100-
'no-control-regex': 2,
101-
'no-debugger': 2,
102-
'no-delete-var': 2,
103-
'no-dupe-keys': 2,
104-
'no-dupe-args': 2,
105-
'no-dupe-class-members': 2,
106-
'no-duplicate-case': 2,
107-
'no-else-return': [0, { allowElseIf: true }],
108-
'no-empty': 2,
109-
'no-empty-character-class': 2,
110-
'no-ex-assign': 2,
111-
'no-extra-boolean-cast': 2,
112-
'no-extra-semi': 2,
113-
'no-fallthrough': 2,
114-
'no-func-assign': 2,
115-
'no-inner-declarations': [2, 'functions'],
116-
'no-invalid-regexp': 2,
117-
'no-irregular-whitespace': 2,
118-
'no-mixed-spaces-and-tabs': 1,
119-
'no-sparse-arrays': 2,
120-
'no-negated-in-lhs': 2,
121-
'no-obj-calls': 2,
122-
'no-octal': 2,
123-
'no-redeclare': 2,
124-
'no-regex-spaces': 2,
125-
'no-undef': 2,
126-
'no-unreachable': 2,
127-
'no-unused-expressions': 0,
54+
'react/display-name': 'off',
55+
'react/jsx-fragments': ['error', 'syntax'],
56+
'react/jsx-key': 'off',
57+
'react/no-direct-mutation-state': 'off',
58+
'react/prop-types': 'off',
59+
'react/react-in-jsx-scope': 'off',
60+
'react-hooks/set-state-in-effect': 'warn',
61+
'react-hooks/immutability': 'warn',
62+
'react-hooks/refs': 'warn',
63+
'react-native/no-color-literals': 'off',
64+
'react-native/no-inline-styles': 'off',
65+
'react-native/no-raw-text': 'off',
66+
'react-native/no-single-element-style-arrays': 'error',
67+
'react-native/no-unused-styles': 'error',
68+
'react-native/split-platform-components': 'off',
12869
'no-unused-vars': 'off',
129-
'max-len': 0,
130-
'react/jsx-uses-vars': 2,
131-
'no-void': 2,
132-
'no-var': 2,
133-
'one-var': [2, 'never'],
134-
'no-lonely-if': 2,
135-
'no-trailing-spaces': 2,
136-
complexity: [1, 31],
137-
'space-in-parens': [2, 'never'],
138-
'space-before-blocks': [2, 'always'],
139-
indent: 'off',
140-
'eol-last': [2, 'always'],
141-
'comma-dangle': [2, 'never'],
142-
'keyword-spacing': 2,
143-
'block-spacing': 2,
144-
'brace-style': [2, '1tbs', { allowSingleLine: true }],
145-
'computed-property-spacing': 2,
146-
'comma-spacing': 2,
147-
'comma-style': 2,
148-
'guard-for-in': 2,
149-
'wrap-iife': 2,
150-
'block-scoped-var': 2,
151-
curly: [2, 'all'],
152-
eqeqeq: [2, 'allow-null'],
153-
'new-cap': 'off',
154-
'use-isnan': 2,
155-
'valid-typeof': 2,
156-
'linebreak-style': 0,
157-
'prefer-template': 2,
158-
quotes: [1, 'single'],
159-
semi: [2, 'always'],
160-
'prefer-const': 2,
161-
'object-shorthand': 2,
162-
'consistent-return': 0,
163-
'global-require': 'off',
164-
'react-native/no-unused-styles': 2,
165-
'react/jsx-one-expression-per-line': 0,
166-
'require-await': 2,
167-
'func-names': 0,
168-
'react/static-property-placement': [0],
169-
'arrow-parens': ['warn', 'as-needed', { requireForBlockBody: true }],
170-
'react/jsx-curly-newline': [0],
171-
'react/state-in-constructor': [0],
172-
'no-async-promise-executor': [0],
173-
'max-classes-per-file': [0],
174-
'no-multiple-empty-lines': [0],
175-
'no-sequences': 'off',
176-
'react-hooks/rules-of-hooks': 'error',
177-
'react-hooks/exhaustive-deps': 'warn'
178-
},
179-
globals: {
180-
__DEV__: true
70+
'no-void': 'error',
71+
'new-cap': 'error',
72+
'require-await': 'error'
18173
},
18274
overrides: [
18375
{
@@ -186,50 +78,13 @@ module.exports = {
18678
'plugin:@typescript-eslint/recommended',
18779
'plugin:@typescript-eslint/eslint-recommended',
18880
'@rocket.chat/eslint-config',
81+
'plugin:prettier/recommended',
18982
'prettier'
19083
],
19184
parser: '@typescript-eslint/parser',
192-
parserOptions: {
193-
sourceType: 'module',
194-
ecmaVersion: 2018,
195-
warnOnUnsupportedTypeScriptVersion: false,
196-
ecmaFeatures: {
197-
experimentalObjectRestSpread: true,
198-
legacyDecorators: true
199-
}
200-
},
201-
plugins: ['react', '@typescript-eslint'],
20285
rules: {
203-
'@typescript-eslint/no-var-requires': 'off',
204-
'@typescript-eslint/no-empty-function': [0],
205-
'@typescript-eslint/ban-types': [0],
206-
'func-call-spacing': 'off',
207-
'jsx-quotes': ['error', 'prefer-single'],
208-
indent: 'off',
209-
'comma-dangle': [2, 'never'],
210-
'no-return-assign': 0,
211-
'no-dupe-class-members': 'off',
212-
'no-extra-parens': 'off',
213-
'no-spaced-func': 'off',
214-
'no-unused-vars': 'off',
215-
'no-useless-constructor': 'off',
216-
'no-use-before-define': 'off',
217-
'react/jsx-uses-react': 'error',
218-
'react/jsx-uses-vars': 'error',
219-
'react/jsx-no-undef': 'error',
220-
'react/jsx-fragments': ['error', 'syntax'],
22186
'@typescript-eslint/ban-ts-comment': 'off',
222-
'@typescript-eslint/indent': 'off',
223-
'@typescript-eslint/no-extra-parens': 'off',
224-
'@typescript-eslint/no-dupe-class-members': 'error',
225-
'@typescript-eslint/no-explicit-any': 'off',
226-
'@typescript-eslint/no-unused-vars': [
227-
'error',
228-
{
229-
argsIgnorePattern: '^_',
230-
ignoreRestSiblings: true
231-
}
232-
],
87+
'@typescript-eslint/ban-types': 'off',
23388
'@typescript-eslint/consistent-type-imports': [
23489
'error',
23590
{
@@ -238,14 +93,31 @@ module.exports = {
23893
fixStyle: 'inline-type-imports'
23994
}
24095
],
96+
'@typescript-eslint/indent': 'off',
97+
'@typescript-eslint/no-dupe-class-members': 'error',
98+
'@typescript-eslint/no-empty-function': 'off',
99+
'@typescript-eslint/no-explicit-any': 'off',
100+
'@typescript-eslint/no-extra-parens': 'off',
101+
'@typescript-eslint/no-unused-vars': [
102+
'error',
103+
{
104+
args: 'all',
105+
argsIgnorePattern: '^_'
106+
}
107+
],
108+
'@typescript-eslint/no-var-requires': 'off',
109+
'no-return-assign': 'off',
110+
'no-dupe-class-members': 'off',
111+
'no-extra-parens': 'off',
112+
'no-spaced-func': 'off',
113+
'no-unused-vars': 'off',
114+
'no-useless-constructor': 'off',
115+
'no-use-before-define': 'off',
241116
'new-cap': 'off',
242-
'lines-between-class-members': 'off',
243-
'react-hooks/rules-of-hooks': 'error',
244-
'react-hooks/exhaustive-deps': 'warn',
245-
'jest/no-conditional-expect': 'off'
117+
'lines-between-class-members': 'off'
246118
},
247119
globals: {
248-
JSX: true
120+
JSX: 'readonly'
249121
},
250122
settings: {
251123
'import/resolver': {
@@ -256,10 +128,13 @@ module.exports = {
256128
}
257129
},
258130
{
259-
files: ['e2e/**'],
260-
rules: {
261-
'no-await-in-loop': 0,
262-
'jest/expect-expect': 'off'
131+
files: ['jest.setup.js', '__mocks__/**/*.js', '**/*.test.{js,ts,tsx}'],
132+
extends: ['plugin:jest/recommended']
133+
},
134+
{
135+
files: ['index.js', 'app/**/*.{js,ts,tsx}'],
136+
env: {
137+
'react-native/react-native': true
263138
}
264139
}
265140
]

0 commit comments

Comments
 (0)