Skip to content

Commit d992ede

Browse files
committed
Update user stats and upgrade pnpm packages
1 parent 2cdc0b3 commit d992ede

File tree

272 files changed

+8176
-6785
lines changed

Some content is hidden

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

272 files changed

+8176
-6785
lines changed
Lines changed: 97 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,113 @@
11
---
22
root: true
33

4-
plugins:
5-
- react
6-
- jsx-a11y
7-
- jest
8-
- react-hooks
94
env:
105
node: true
116
browser: true
7+
jest: true
128

139
parser: "@babel/eslint-parser"
1410

11+
parserOptions:
12+
requireConfigFile: false
13+
ecmaVersion: latest
14+
sourceType: module
15+
ecmaFeatures:
16+
jsx: true
17+
18+
plugins:
19+
- react
20+
- jsx-a11y
21+
- jest
22+
- react-hooks
23+
1524
extends:
16-
- "airbnb"
17-
- "plugin:jest/recommended"
25+
- airbnb
26+
- plugin:jest/recommended
27+
28+
settings:
29+
react:
30+
version: detect
31+
import/resolver:
32+
alias:
33+
map:
34+
- ["@", "./assets/js"]
35+
extensions:
36+
- ".js"
37+
- ".jsx"
38+
- ".json"
1839

1940
rules:
20-
no-console: 0
21-
react/prop-types: 0
22-
react/no-unused-prop-types: 0
23-
import/no-unresolved: 0
41+
# --- general ---
42+
no-console: off
43+
no-param-reassign: off
44+
class-methods-use-this: off
45+
default-param-last: off
46+
indent: off
47+
template-curly-spacing: off
48+
max-len: ["error", 140, 2]
49+
50+
# --- imports ---
51+
import/no-unresolved: off
52+
import/extensions: off
2453
import/no-extraneous-dependencies:
25-
- 2
54+
- error
2655
- devDependencies: true
2756
import/order:
28-
- 2
29-
- newlines-between: always
30-
alphabetize:
31-
order: asc
32-
caseInsensitive: true
33-
groups:
34-
- builtin
35-
- external
36-
- internal
37-
- parent
38-
- sibling
39-
- index
40-
pathGroups:
41-
- pattern: react
42-
group: builtin
43-
- pattern: '@/**'
44-
group: internal
45-
pathGroupsExcludedImportTypes:
46-
- internal
47-
no-param-reassign: 0
48-
arrow-parens:
49-
- 2
50-
- "as-needed"
51-
react/jsx-props-no-spreading: 0
52-
react/static-property-placement: 0
53-
react/state-in-constructor: 0
54-
jest/no-disabled-tests: "warn"
55-
jest/no-focused-tests: "error"
56-
jest/no-identical-title: "error"
57-
jest/prefer-to-have-length: "warn"
58-
jest/valid-expect: "error"
59-
react-hooks/rules-of-hooks: "error"
60-
react-hooks/exhaustive-deps: "warn"
61-
template-curly-spacing: "off"
62-
indent: "off"
63-
max-len: ["error", 140, 2]
57+
- error
58+
- newlines-between: always
59+
alphabetize:
60+
order: asc
61+
caseInsensitive: true
62+
groups:
63+
- builtin
64+
- external
65+
- internal
66+
- parent
67+
- sibling
68+
- index
69+
pathGroups:
70+
- pattern: react
71+
group: builtin
72+
- pattern: "@/**"
73+
group: internal
74+
pathGroupsExcludedImportTypes:
75+
- internal
76+
77+
# --- react ---
78+
react/prop-types: off
79+
react/no-unused-prop-types: off
80+
react/jsx-props-no-spreading: off
81+
react/static-property-placement: off
82+
react/state-in-constructor: off
83+
react/jsx-no-useless-fragment: off
84+
react/no-unstable-nested-components: off
85+
react/jsx-no-constructed-context-values: warn
86+
87+
# --- hooks ---
88+
react-hooks/rules-of-hooks: error
89+
react-hooks/exhaustive-deps: warn
90+
91+
# --- jest ---
92+
jest/no-disabled-tests: warn
93+
jest/no-focused-tests: error
94+
jest/no-identical-title: error
95+
jest/prefer-to-have-length: warn
96+
jest/valid-expect: error
97+
98+
# --- a11y ---
6499
jsx-a11y/label-has-associated-control:
65-
- 2
66-
- assert: "either"
100+
- error
101+
- assert: either
102+
103+
# --- safety (keep these ON) ---
104+
no-unsafe-optional-chaining: error
105+
106+
overrides:
107+
- files:
108+
- "**/__tests__/**/*.{js,jsx}"
109+
- "**/*.{test,spec}.{js,jsx}"
110+
rules:
111+
func-names: off
112+
no-constructor-return: off
113+
react/jsx-no-useless-fragment: off

services/app/apps/codebattle/assets/js/__mocks__/react-select.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ import React, { useState } from 'react';
22

33
const { createFilter } = jest.requireActual('react-select');
44

5-
const Select = ({ options, onChange, filterOption }) => {
5+
function Select({ options, onChange, filterOption }) {
66
const [selectInput, setSelectInput] = useState('task');
77

88
return (
99
<div>
1010
{options
1111
.filter(({ name }) => (filterOption({ data: { name } }, selectInput)))
12-
.map(option => (
12+
.map((option) => (
1313
<button
1414
type="button"
1515
onClick={() => onChange(option)}
@@ -27,7 +27,7 @@ const Select = ({ options, onChange, filterOption }) => {
2727
</button>
2828
</div>
2929
);
30-
};
30+
}
3131

3232
export { createFilter };
3333
export default Select;
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import React, { useState, useEffect } from 'react';
22

3-
const AsyncSelect = ({ loadOptions, onChange }) => {
3+
function AsyncSelect({ loadOptions, onChange }) {
44
const [entities, setEntities] = useState([]);
55

66
useEffect(() => {
7-
const callback = options => {
8-
setEntities(options.map(option => option.value));
7+
const callback = (options) => {
8+
setEntities(options.map((option) => option.value));
99
};
1010

1111
loadOptions('test', callback);
@@ -14,7 +14,7 @@ const AsyncSelect = ({ loadOptions, onChange }) => {
1414

1515
return (
1616
<div>
17-
{entities.map(entity => (
17+
{entities.map((entity) => (
1818
<button
1919
type="button"
2020
onClick={() => onChange({ value: entity })}
@@ -25,6 +25,6 @@ const AsyncSelect = ({ loadOptions, onChange }) => {
2525
))}
2626
</div>
2727
);
28-
};
28+
}
2929

3030
export default AsyncSelect;

services/app/apps/codebattle/assets/js/__tests__/ContributorsList.test.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ import axios from 'axios';
1111

1212
jest.mock('gon', () => {
1313
const gonParams = { local: 'en' };
14-
return { getAsset: type => gonParams[type] };
14+
return { getAsset: (type) => gonParams[type] };
1515
}, { virtual: true });
1616

1717
jest.mock('axios');
1818
const users = [];
1919
axios.get.mockResolvedValue({ data: users });
2020
//
21-
test('test rendering ContributorsList', async () => {
21+
test('rendering ContributorsList', async () => {
2222
// const reducer = combineReducers(reducers);
2323
//
2424
// const preloadedState = {

services/app/apps/codebattle/assets/js/__tests__/CreateGameDialog.test.jsx

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jest.mock(
2424
current_user: { id: 1, sound_settings: {} },
2525
task_tags: ['math', 'string', 'asd', 'rest'],
2626
};
27-
return { getAsset: type => gonParams[type] };
27+
return { getAsset: (type) => gonParams[type] };
2828
},
2929
{ virtual: true },
3030
);
@@ -105,7 +105,7 @@ const store = configureStore({
105105
preloadedState,
106106
});
107107

108-
const setup = jsx => ({
108+
const setup = (jsx) => ({
109109
user: userEvent.setup(),
110110
...render(jsx),
111111
});
@@ -227,13 +227,13 @@ test('filter tasks by level', async () => {
227227

228228
const easyLevelButton = await findByTitle('easy');
229229

230-
elementaryTasksFromBackend.forEach(task => expect(queryByRole('button', { name: task.name })).toBeInTheDocument());
231-
easyTasksFromBackend.forEach(task => expect(queryByRole('button', { name: task.name })).not.toBeInTheDocument());
230+
elementaryTasksFromBackend.forEach((task) => expect(queryByRole('button', { name: task.name })).toBeInTheDocument());
231+
easyTasksFromBackend.forEach((task) => expect(queryByRole('button', { name: task.name })).not.toBeInTheDocument());
232232

233233
await user.click(easyLevelButton);
234234

235-
easyTasksFromBackend.forEach(task => expect(queryByRole('button', { name: task.name })).toBeInTheDocument());
236-
elementaryTasksFromBackend.forEach(task => expect(queryByRole('button', { name: task.name })).not.toBeInTheDocument());
235+
easyTasksFromBackend.forEach((task) => expect(queryByRole('button', { name: task.name })).toBeInTheDocument());
236+
elementaryTasksFromBackend.forEach((task) => expect(queryByRole('button', { name: task.name })).not.toBeInTheDocument());
237237
});
238238

239239
test('filter tasks by tags', async () => {
@@ -262,33 +262,33 @@ test('filter tasks by tags', async () => {
262262
await user.click(await findByRole('button', { name: /random task/ }));
263263

264264
await waitFor(() => {
265-
tasksMatchingRestTags.forEach(task => expect(getByRole('button', { name: task.name })).toBeInTheDocument());
265+
tasksMatchingRestTags.forEach((task) => expect(getByRole('button', { name: task.name })).toBeInTheDocument());
266266

267-
tasksUnsuitableForRestTags.forEach(task => (
267+
tasksUnsuitableForRestTags.forEach((task) => (
268268
expect(queryByRole('button', { name: task.name })).not.toBeInTheDocument()
269269
));
270270
});
271271

272272
await user.click(restTag);
273273

274274
await waitFor(() => {
275-
elementaryTasksFromBackend.forEach(task => expect(getByRole('button', { name: task.name })).toBeInTheDocument());
275+
elementaryTasksFromBackend.forEach((task) => expect(getByRole('button', { name: task.name })).toBeInTheDocument());
276276
});
277277

278278
await user.click(mathTag);
279279

280280
await waitFor(() => {
281-
tasksMatchingMathTag.forEach(task => expect(getByRole('button', { name: task.name })).toBeInTheDocument());
282-
tasksUnsuitableForMathTag.forEach(task => (
281+
tasksMatchingMathTag.forEach((task) => expect(getByRole('button', { name: task.name })).toBeInTheDocument());
282+
tasksUnsuitableForMathTag.forEach((task) => (
283283
expect(queryByRole('button', { name: task.name })).not.toBeInTheDocument()
284284
));
285285
});
286286

287287
await user.click(stringTag);
288288

289289
await waitFor(() => {
290-
tasksMatchingMathAndStringTags.forEach(task => expect(getByRole('button', { name: task.name })).toBeInTheDocument());
291-
tasksUnsuitableForMathAndStringTags.forEach(task => (
290+
tasksMatchingMathAndStringTags.forEach((task) => expect(getByRole('button', { name: task.name })).toBeInTheDocument());
291+
tasksUnsuitableForMathAndStringTags.forEach((task) => (
292292
expect(queryByRole('button', { name: task.name })).not.toBeInTheDocument()
293293
));
294294
});
@@ -297,7 +297,7 @@ test('filter tasks by tags', async () => {
297297
await user.click(stringTag);
298298

299299
await waitFor(() => {
300-
elementaryTasksFromBackend.forEach(task => expect(getByRole('button', { name: task.name })).toBeInTheDocument());
300+
elementaryTasksFromBackend.forEach((task) => expect(getByRole('button', { name: task.name })).toBeInTheDocument());
301301
});
302302
}, 6000);
303303

@@ -309,8 +309,8 @@ test('filter tasks by name', async () => {
309309
await user.click(await findByRole('button', { name: 'filter tasks by name' }));
310310

311311
await waitFor(() => {
312-
tasksFilteredByName.forEach(task => expect(getByRole('button', { name: task.name })).toBeInTheDocument());
313-
tasksEliminatedByName.forEach(task => expect(queryByRole('button', { name: task.name })).not.toBeInTheDocument());
312+
tasksFilteredByName.forEach((task) => expect(getByRole('button', { name: task.name })).toBeInTheDocument());
313+
tasksEliminatedByName.forEach((task) => expect(queryByRole('button', { name: task.name })).not.toBeInTheDocument());
314314
});
315315
});
316316

@@ -322,8 +322,8 @@ test('filter tasks by name and tags', async () => {
322322
await user.click(await findByRole('button', { name: 'filter tasks by name' }));
323323
await user.click(getByRole('button', { name: 'math' }));
324324

325-
tasksFilteredByNameAndTag.forEach(task => expect(queryByRole('button', { name: task.name })).toBeInTheDocument());
326-
tasksEliminatedByNameAndTag.forEach(task => (
325+
tasksFilteredByNameAndTag.forEach((task) => expect(queryByRole('button', { name: task.name })).toBeInTheDocument());
326+
tasksEliminatedByNameAndTag.forEach((task) => (
327327
expect(queryByRole('button', { name: task.name })).not.toBeInTheDocument()
328328
));
329329
});

services/app/apps/codebattle/assets/js/__tests__/Registration.test.jsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/**
2+
* @jest-environment jsdom
3+
* @jest-environment-options {"url": "http://localhost/users/new"}
4+
*/
15
import React from 'react';
26

37
import { render, waitFor } from '@testing-library/react';
@@ -16,7 +20,7 @@ const { data, route, headers } = validData;
1620

1721
jest.mock('gon', () => {
1822
const gonParams = { local: 'en', current_user: { sound_settings: {} } };
19-
return { getAsset: type => gonParams[type] };
23+
return { getAsset: (type) => gonParams[type] };
2024
}, { virtual: true });
2125

2226
describe('sign up', () => {
@@ -28,12 +32,6 @@ describe('sign up', () => {
2832
}
2933

3034
beforeAll(() => {
31-
Object.defineProperty(window, 'location', {
32-
writable: true,
33-
value: {
34-
pathname: '/users/new',
35-
},
36-
});
3735
document.head.innerHTML = '<meta name="csrf-token" content="test-csrf-token">';
3836
});
3937

0 commit comments

Comments
 (0)