Skip to content

Commit 74dc133

Browse files
committed
add and address new eslint rules
1 parent 14ca458 commit 74dc133

35 files changed

+142
-75
lines changed

.eslintrc

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,23 @@
1616
"import/no-unresolved": 0,
1717
"import/no-named-as-default": 0,
1818
"import/no-named-as-default-member": 0,
19+
"import/no-useless-path-segments": 1,
20+
"import/no-cycle":1,
21+
"import/no-import-module-exports": 1,
1922
"comma-dangle": 0, // not sure why airbnb turned this on. gross!
23+
"default-param-last": 0,
24+
"no-else-return" :0,
2025
"indent": 0,
2126
"no-console": 0,
2227
"no-alert": 0,
28+
"no-import-assign": 2,
29+
"no-promise-executor-return": 1,
30+
"no-restricted-exports": 1,
2331
"no-underscore-dangle": 0,
2432
"no-useless-catch": 2,
33+
"prefer-object-spread": 0,
2534
"max-len": [1, 120, 2, {"ignoreComments": true, "ignoreTemplateLiterals": true}],
35+
"max-classes-per-file": 0,
2636
"quote-props": [1, "as-needed"],
2737
"no-unused-vars": [1, {"vars": "local", "args": "none"}],
2838
"consistent-return": ["error", { "treatUndefinedAsUnspecified": true }],
@@ -36,7 +46,19 @@
3646
{ "ignorePureComponents": true
3747
}],
3848
"class-methods-use-this": 0,
39-
"react/jsx-no-bind": [2, {"allowBind": true, "allowArrowFunctions": true}],
49+
"react/button-has-type": 0,
50+
"react/destructuring-assignment":0,
51+
"react/function-component-definition": 0,
52+
"react/jsx-curly-newline":0,
53+
"react/jsx-fragments":0,
54+
"react/jsx-no-useless-fragment":1,
55+
"react/jsx-one-expression-per-line": 0,
56+
"react/jsx-props-no-spreading": 0,
57+
"react/jsx-wrap-multilines": 0,
58+
"react/jsx-no-bind": [2, {"allowBind": true, "allowArrowFunctions": true, "allowFunctions": true}],
59+
"react/no-deprecated": 1,
60+
"react/no-unused-class-component-methods": 1,
61+
"react/sort-comp": 0,
4062
"no-return-assign": [2, "except-parens"],
4163
"jsx-a11y/anchor-is-valid": [
4264
"error",
@@ -49,6 +71,8 @@
4971
]
5072
}
5173
],
74+
"jsx-a11y/control-has-associated-label": 1,
75+
"jsx-a11y/label-has-associated-control": 1,
5276
"jsx-a11y/label-has-for": [
5377
2,
5478
{

client/common/useKeyDownHandlers.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,7 @@ export const DocumentKeyDown = ({ handlers }) => {
6666
DocumentKeyDown.propTypes = {
6767
handlers: PropTypes.objectOf(PropTypes.func)
6868
};
69+
70+
DocumentKeyDown.defaultProps = {
71+
handlers: {}
72+
};

client/index.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ script.src = 'https://foundation-donate-banner.netlify.app/static/js/main.js';
3535
document.body.appendChild(script);
3636

3737
const App = () => (
38-
<>
38+
<div>
3939
<Router history={browserHistory}>
4040
<SkipLink targetId="play-sketch" text="PlaySketch" />
4141
<Routing />
4242
</Router>
43-
</>
43+
</div>
4444
);
4545

4646
render(

client/modules/IDE/components/AssetList.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const AssetList = () => {
4646
<th>{t('AssetList.HeaderName')}</th>
4747
<th>{t('AssetList.HeaderSize')}</th>
4848
<th>{t('AssetList.HeaderSketch')}</th>
49-
<th scope="col"></th>
49+
<th aria-label="dropdown" scope="col"></th>
5050
</tr>
5151
</thead>
5252
<tbody>

client/modules/IDE/components/CollectionList/CollectionList.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ const CollectionList = ({
183183
context: mobile ? 'mobile' : ''
184184
})
185185
)}
186-
<th scope="col"></th>
186+
<th aria-label="dropdown" scope="col"></th>
187187
</tr>
188188
</thead>
189189
<tbody>

client/modules/IDE/components/Console.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import ConsoleInput from './ConsoleInput';
99
import UpArrowIcon from '../../../images/up-arrow.svg';
1010
import DownArrowIcon from '../../../images/down-arrow.svg';
1111

12-
import * as IDEActions from '../../IDE/actions/ide';
13-
import * as ConsoleActions from '../../IDE/actions/console';
12+
import * as IDEActions from '../actions/ide';
13+
import * as ConsoleActions from '../actions/console';
1414
import { useDidUpdate } from '../hooks/custom-hooks';
1515
import useHandleMessageEvent from '../hooks/useHandleMessageEvent';
1616
import { listen } from '../../../utils/dispatcher';

client/modules/IDE/components/ConsoleInput.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { useDispatch } from 'react-redux';
55
import { Encode } from 'console-feed';
66

77
import RightArrowIcon from '../../../images/right-arrow.svg';
8-
import { dispatchConsoleEvent } from '../../IDE/actions/console';
8+
import { dispatchConsoleEvent } from '../actions/console';
99
import { dispatchMessage, MessageTypes } from '../../../utils/dispatcher';
1010

1111
// heavily inspired by

client/modules/IDE/components/Editor/index.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ class Editor extends React.Component {
226226
});
227227
}
228228

229+
/* eslint-disable react/no-deprecated */
229230
componentWillUpdate(nextProps) {
230231
// check if files have changed
231232
if (this.props.files[0].id !== nextProps.files[0].id) {

client/modules/IDE/components/Header/MobileNav.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
} from '../../actions/ide';
2828
import { logoutUser } from '../../../User/actions';
2929
import { useSketchActions, useWhatPage } from '../../hooks';
30+
// eslint-disable-next-line import/no-cycle
3031
import { CmControllerContext } from '../../pages/IDEView';
3132
import { selectSketchPath } from '../../selectors/project';
3233
import { availableLanguages, languageKeyToLabel } from '../../../../i18n';

client/modules/IDE/components/Header/Nav.jsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
stopSketch
2828
} from '../../actions/ide';
2929
import { logoutUser } from '../../../User/actions';
30+
// eslint-disable-next-line import/no-cycle
3031
import { CmControllerContext } from '../../pages/IDEView';
3132
import MobileNav from './MobileNav';
3233
import useIsMobile from '../../hooks/useIsMobile';
@@ -37,14 +38,12 @@ const Nav = ({ layout }) => {
3738
return isMobile ? (
3839
<MobileNav />
3940
) : (
40-
<>
41-
<header className="nav__header">
42-
<Menubar>
43-
<LeftLayout layout={layout} />
44-
<UserMenu />
45-
</Menubar>
46-
</header>
47-
</>
41+
<header className="nav__header">
42+
<Menubar>
43+
<LeftLayout layout={layout} />
44+
<UserMenu />
45+
</Menubar>
46+
</header>
4847
);
4948
};
5049

client/modules/IDE/components/Header/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import PropTypes from 'prop-types';
33
import { useSelector } from 'react-redux';
44
import useIsMobile from '../../hooks/useIsMobile';
5-
5+
// eslint-disable-next-line import/no-cycle
66
import Nav from './Nav';
77
import Toolbar from './Toolbar';
88

client/modules/IDE/components/IDEOverlays.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import Feedback from './Feedback';
1515
import KeyboardShortcutModal from './KeyboardShortcutModal';
1616
import NewFileModal from './NewFileModal';
1717
import NewFolderModal from './NewFolderModal';
18+
// eslint-disable-next-line import/no-cycle
1819
import Preferences from './Preferences';
1920
import { CollectionSearchbar } from './Searchbar';
2021
import ShareModal from './ShareModal';

client/modules/IDE/components/NewFileForm.jsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,20 @@ function NewFileForm() {
3939
<div className="new-file-form__input-wrapper">
4040
<Field name="name">
4141
{(field) => (
42-
<React.Fragment>
42+
<div>
4343
<label className="new-file-form__name-label" htmlFor="name">
4444
Name:
45+
<input
46+
className="new-file-form__name-input"
47+
id="name"
48+
type="text"
49+
placeholder={t('NewFileForm.Placeholder')}
50+
maxLength="128"
51+
{...field.input}
52+
ref={fileNameInput}
53+
/>
4554
</label>
46-
<input
47-
className="new-file-form__name-input"
48-
id="name"
49-
type="text"
50-
placeholder={t('NewFileForm.Placeholder')}
51-
maxLength="128"
52-
{...field.input}
53-
ref={fileNameInput}
54-
/>
55-
</React.Fragment>
55+
</div>
5656
)}
5757
</Field>
5858
<Field name="submitButton">

client/modules/IDE/components/NewFolderForm.jsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,20 @@ function NewFolderForm() {
3636
<div className="new-folder-form__input-wrapper">
3737
<Field name="name">
3838
{(field) => (
39-
<React.Fragment>
39+
<div>
4040
<label className="new-folder-form__name-label" htmlFor="name">
4141
Name:
42+
<input
43+
className="new-folder-form__name-input"
44+
id="name"
45+
type="text"
46+
maxLength="128"
47+
placeholder={t('NewFolderForm.Placeholder')}
48+
ref={folderNameInput}
49+
{...field.input}
50+
/>
4251
</label>
43-
<input
44-
className="new-folder-form__name-input"
45-
id="name"
46-
type="text"
47-
maxLength="128"
48-
placeholder={t('NewFolderForm.Placeholder')}
49-
ref={folderNameInput}
50-
{...field.input}
51-
/>
52-
</React.Fragment>
52+
</div>
5353
)}
5454
</Field>
5555
<Field name="submitButton">

client/modules/IDE/components/Preferences/index.jsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
setPreferencesTab
2323
} from '../../actions/preferences';
2424
import { p5SoundURL, p5URL, useP5Version } from '../../hooks/useP5Version';
25+
// eslint-disable-next-line import/no-cycle
2526
import VersionPicker from '../VersionPicker';
2627
import { updateFileContent } from '../../actions/files';
2728
import { CmControllerContext } from '../../pages/IDEView';
@@ -115,6 +116,7 @@ export default function Preferences() {
115116
};
116117

117118
const markdownComponents = useMemo(() => {
119+
// eslint-disable-next-line react/no-unstable-nested-components
118120
const ExternalLink = ({ children, ...props }) => (
119121
<a {...props} target="_blank">
120122
{children}
@@ -127,6 +129,7 @@ export default function Preferences() {
127129
children: undefined
128130
};
129131

132+
// eslint-disable-next-line react/no-unstable-nested-components
130133
const Paragraph = ({ children, ...props }) => (
131134
<p className="preference__paragraph" {...props}>
132135
{children}

client/modules/IDE/components/Sidebar.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ export default function SideBar() {
7676
<FileDrawer>
7777
{ide.sidebarIsExpanded && (
7878
<button
79+
aria-label="Close sidebar"
7980
data-backdrop="filedrawer"
8081
onClick={() => {
8182
dispatch(collapseSidebar());

client/modules/IDE/components/SketchList.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ const SketchList = ({
145145
context: mobile ? 'mobile' : ''
146146
})
147147
)}
148-
<th scope="col"></th>
148+
<th aria-label="dropdown" scope="col"></th>
149149
</tr>
150150
</thead>
151151
<tbody>

client/modules/IDE/components/VersionPicker.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ import { useP5Version, p5Versions } from '../hooks/useP5Version';
99
import MenuItem from '../../../components/Dropdown/MenuItem';
1010
import DropdownMenu from '../../../components/Dropdown/DropdownMenu';
1111
import { updateFileContent } from '../actions/files';
12+
// eslint-disable-next-line import/no-cycle
1213
import { CmControllerContext } from '../pages/IDEView';
13-
import { DropdownArrowIcon } from '../.././../common/icons';
14+
import { DropdownArrowIcon } from '../../../common/icons';
1415

1516
const VersionPickerButton = styled.div`
1617
display: flex;

client/modules/IDE/components/__snapshots__/SketchList.unit.test.jsx.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ exports[`<Sketchlist /> snapshot testing 1`] = `
8080
</button>
8181
</th>
8282
<th
83+
aria-label="dropdown"
8384
scope="col"
8485
/>
8586
</tr>

client/modules/IDE/hooks/useP5Version.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ export function P5VersionProvider(props) {
311311
return null;
312312
}, [indexSrc]);
313313

314+
// eslint-disable-next-line react/jsx-no-constructed-context-values
314315
const value = { indexID, versionInfo };
315316

316317
return (

client/modules/IDE/pages/IDEView.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@ import {
1818
} from '../actions/project';
1919
import { getIsUserOwner } from '../selectors/users';
2020
import RootPage from '../../../components/RootPage';
21+
// eslint-disable-next-line import/no-cycle
2122
import Header from '../components/Header';
2223
import FloatingActionButton from '../components/FloatingActionButton';
2324
import Editor from '../components/Editor';
2425
import {
2526
EditorSidebarWrapper,
2627
PreviewWrapper
2728
} from '../components/Editor/MobileEditor';
29+
// eslint-disable-next-line import/no-cycle
2830
import IDEOverlays from '../components/IDEOverlays';
2931
import useIsMobile from '../hooks/useIsMobile';
3032
import { P5VersionProvider } from '../hooks/useP5Version';

client/modules/IDE/utils/consoleStyles.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -160,14 +160,6 @@ const getConsoleFeedStyle = (theme, fontSize) => {
160160
};
161161

162162
switch (theme) {
163-
case 'light':
164-
default:
165-
return Object.assign(
166-
CONSOLE_FEED_LIGHT_STYLES || {},
167-
CONSOLE_FEED_LIGHT_ICONS,
168-
CONSOLE_FEED_SIZES,
169-
style
170-
);
171163
case 'dark':
172164
return Object.assign(
173165
CONSOLE_FEED_DARK_STYLES || {},
@@ -182,6 +174,14 @@ const getConsoleFeedStyle = (theme, fontSize) => {
182174
CONSOLE_FEED_SIZES,
183175
style
184176
);
177+
case 'light':
178+
default:
179+
return Object.assign(
180+
CONSOLE_FEED_LIGHT_STYLES || {},
181+
CONSOLE_FEED_LIGHT_ICONS,
182+
CONSOLE_FEED_SIZES,
183+
style
184+
);
185185
}
186186
};
187187

client/modules/User/actions.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ export function initiateResetPassword(formValues) {
165165
dispatch({
166166
type: ActionTypes.RESET_PASSWORD_INITIATE
167167
});
168-
return apiClient
168+
apiClient
169169
.post('/reset-password', formValues)
170170
.then(() => resolve())
171171
.catch((error) => {
@@ -246,7 +246,7 @@ export function validateResetPasswordToken(token) {
246246

247247
export function updatePassword(formValues, token) {
248248
return (dispatch) =>
249-
new Promise((resolve) =>
249+
new Promise((resolve) => {
250250
apiClient
251251
.post(`/reset-password/${token}`, formValues)
252252
.then((response) => {
@@ -259,8 +259,8 @@ export function updatePassword(formValues, token) {
259259
type: ActionTypes.INVALID_RESET_PASSWORD_TOKEN
260260
});
261261
resolve({ error });
262-
})
263-
);
262+
});
263+
});
264264
}
265265

266266
export function updateSettingsSuccess(user) {

0 commit comments

Comments
 (0)