Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linter improvements #1613

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion services/app/apps/codebattle/.eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins:
- jsx-a11y
- jest
- react-hooks
- sort-destructure-keys
env:
node: true
browser: true
Expand All @@ -15,6 +16,7 @@ parser: "@babel/eslint-parser"
extends:
- "airbnb"
- "plugin:jest/recommended"
- "plugin:prettier/recommended"

rules:
no-console: 0
Expand Down Expand Up @@ -43,13 +45,31 @@ rules:
group: internal
pathGroupsExcludedImportTypes:
- internal
import/extensions:
- error
- js: never
jsx: never
no-param-reassign: 0
arrow-parens:
- 2
- "as-needed"
- "always"
react/jsx-props-no-spreading: 0
react/static-property-placement: 0
react/state-in-constructor: 0
react/function-component-definition: "off"
react/jsx-sort-props:
- 1
- callbacksLast: true
shorthandFirst: true
shorthandLast: false
ignoreCase: false
noSortAlphabetically: false
reservedFirst: true
multiline: last
react/no-unstable-nested-components:
- warn
- allowAsProps: true
class-methods-use-this: "off"
jest/no-disabled-tests: "warn"
jest/no-focused-tests: "error"
jest/no-identical-title: "error"
Expand All @@ -60,3 +80,6 @@ rules:
template-curly-spacing: "off"
indent: "off"
max-len: ["error", 140, 2]
sort-destructure-keys/sort-destructure-keys:
- 1
- caseSensitive: false
9 changes: 9 additions & 0 deletions services/app/apps/codebattle/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"printWidth": 100,
"trailingComma": "all",
"tabWidth": 2,
"singleQuote": true,
"jsxSingleQuote": false,
"bracketSameLine": false,
"arrowParens": "always"
}
20 changes: 7 additions & 13 deletions services/app/apps/codebattle/assets/js/__mocks__/react-select.jsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,26 @@
import React, { useState } from 'react';

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

return (
<div>
{options
.filter(option => (
filterOption({ value: { name: option.value.name } }, selectInput)
))
.map(option => (
.filter((option) => filterOption({ value: { name: option.value.name } }, selectInput))
.map((option) => (
<button
key={option.value.name}
type="button"
onClick={() => onChange({ value: option.value })}
key={option.value.name}
>
{option.value.name}
</button>
))}
<button
type="button"
onClick={() => setSelectInput('nAme')}
key="filterOption"
>
))}
<button key="filterOption" type="button" onClick={() => setSelectInput('nAme')}>
filter tasks by name
</button>
</div>
);
};
}

export default Select;
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React, { useState, useEffect } from 'react';

const AsyncSelect = ({ loadOptions, onChange }) => {
function AsyncSelect({ loadOptions, onChange }) {
const [entities, setEntities] = useState([]);

useEffect(() => {
const callback = options => {
setEntities(options.map(option => option.value));
const callback = (options) => {
setEntities(options.map((option) => option.value));
};

loadOptions('test', callback);
Expand All @@ -14,17 +14,13 @@ const AsyncSelect = ({ loadOptions, onChange }) => {

return (
<div>
{entities.map(entity => (
<button
type="button"
onClick={() => onChange({ value: entity })}
key={entity.name}
>
{entities.map((entity) => (
<button key={entity.name} type="button" onClick={() => onChange({ value: entity })}>
{entity.name}
</button>
))}
</div>
);
};
}

export default AsyncSelect;
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,20 @@ import { Provider } from 'react-redux';
import ContributorsList from '../widgets/pages/game/ContributorsList';
import reducers from '../widgets/slices';

jest.mock('gon', () => {
const gonParams = { local: 'en' };
return { getAsset: type => gonParams[type] };
}, { virtual: true });
jest.mock(
'gon',
() => {
const gonParams = { local: 'en' };
return { getAsset: (type) => gonParams[type] };
},
{ virtual: true },
);

jest.mock('axios');
const users = [];
axios.get.mockResolvedValue({ data: users });

test('test rendering ContributorsList', async () => {
test('rendering of ContributorsList', async () => {
const reducer = combineReducers(reducers);

const preloadedState = {
Expand All @@ -28,6 +32,10 @@ test('test rendering ContributorsList', async () => {
reducer,
preloadedState,
});
const { findByText } = render(<Provider store={store}><ContributorsList /></Provider>);
expect(await findByText(/This users have contributed to this task:/)).toBeInTheDocument();
const { findByText } = render(
<Provider store={store}>
<ContributorsList />
</Provider>,
);
expect(await findByText(/This users have contributed to this task:/)).toBeInTheDocument();
});
Loading
Loading