Skip to content

Commit 8707a99

Browse files
lbogdanCompuIves
authored andcommitted
Fix all eslint warnings and errors. (codesandbox#169)
* [WIP] Fixed all eslint warnings and errors. * Fixed all eslint warning and errors (for src/app), take two. * PreferenceNumber: restored 'step' prop. * Updated jest snapshots.
1 parent 3956ffe commit 8707a99

File tree

59 files changed

+315
-258
lines changed

Some content is hidden

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

59 files changed

+315
-258
lines changed

.eslintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"import/no-extraneous-dependencies": 0,
1818
"arrow-parens": 0,
1919
"import/prefer-default-export": 0,
20-
"class-methods-use-this": 0
20+
"class-methods-use-this": 0,
21+
"no-console": ["error", { "allow": ["error"] } ]
2122
},
2223
"settings": {
2324
"import/resolver": {

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
"eslint-plugin-flowtype": "^2.34.0",
3939
"eslint-plugin-import": "^2.3.0",
4040
"eslint-plugin-jsx-a11y": "^5.0.3",
41-
"eslint-plugin-react": "^7.0.1",
41+
"eslint-plugin-react":
42+
"https://github.com/yannickcr/eslint-plugin-react.git#master",
4243
"express": "^4.15.3",
4344
"extract-text-webpack-plugin": "^2.1.0",
4445
"file-loader": "^0.11.1",
@@ -160,9 +161,9 @@
160161
"start": "cross-env LOCAL_SERVER=1 node scripts/start.js",
161162
"start:dev_api": "node scripts/start.js",
162163
"build": "cross-env NODE_ENV=production node scripts/build.js && gulp",
163-
"test": "jest --env=jsdom",
164+
"test": "npm run lint:app && jest --env=jsdom",
164165
"test:watch": "jest --watch --env=jsdom",
165-
"lint:app": "eslint src/app && npm run typecheck",
166+
"lint:app": "eslint src/app",
166167
"typecheck": "flow check",
167168
"lint:embed": "eslint src/embed",
168169
"add": "all-contributors add",

src/app/components/ConfirmLink.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default class ConfirmLink extends React.PureComponent<Props> {
1212
const { enabled, message } = this.props;
1313

1414
if (enabled) {
15-
const yes = confirm(message);
15+
const yes = confirm(message); // eslint-disable-line no-alert
1616

1717
if (!yes) {
1818
e.preventDefault();

src/app/components/Preference/PreferenceNumber.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ const StyledInput = styled(Input)`text-align: center;`;
88
type Props = {
99
value: boolean,
1010
setValue: boolean => any,
11+
style: Object,
12+
step: number,
1113
};
1214

1315
export default class PreferenceInput extends React.PureComponent {

src/app/components/Preference/PreferenceText.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import Input from 'app/components/Input';
55
type Props = {
66
value: boolean,
77
setValue: boolean => any,
8+
placeholder: string,
89
};
910

1011
export default class PreferenceText extends React.PureComponent {

src/app/components/sandbox/CodeEditor/CodeMirror.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ type Props = {
2828
preferences: Preferences,
2929
onlyViewMode: boolean,
3030
setCurrentModule: ?(sandboxId: string, moduleId: string) => void,
31+
sandboxId: string,
32+
modules: Array,
33+
directories: Array,
3134
};
3235

3336
const Container = styled.div`
@@ -322,7 +325,7 @@ export default class CodeEditor extends React.PureComponent<Props, State> {
322325
cm.toggleComment({ lineComment: '//' });
323326
});
324327
},
325-
'Cmd-P': cm => {
328+
'Cmd-P': () => {
326329
this.setState({ fuzzySearchEnabled: true });
327330
},
328331
};

src/app/components/sandbox/CodeEditor/Monaco.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ import { getModulePath } from 'app/store/entities/sandboxes/modules/selectors';
77

88
import theme from 'common/theme';
99

10+
/* eslint-disable import/no-webpack-loader-syntax */
1011
import SyntaxHighlightWorker from 'worker-loader!./monaco/workers/syntax-highlighter';
1112
import LinterWorker from 'worker-loader!./monaco/workers/linter';
1213
import TypingsFetcherWorker from 'worker-loader!./monaco/workers/fetch-dependency-typings';
14+
/* eslint-enable import/no-webpack-loader-syntax */
1315

1416
import enableEmmet from './monaco/enable-emmet';
1517
import Header from './Header';
@@ -46,13 +48,15 @@ const Container = styled.div`
4648
z-index: 30;
4749
`;
4850

51+
/*
4952
const fontFamilies = (...families) =>
5053
families
5154
.filter(Boolean)
5255
.map(
5356
family => (family.indexOf(' ') !== -1 ? JSON.stringify(family) : family)
5457
)
5558
.join(', ');
59+
*/
5660

5761
const CodeContainer = styled.div`
5862
position: relative;
@@ -125,10 +129,7 @@ const handleError = (
125129
monaco,
126130
editor,
127131
currentErrors: ?Array<ModuleError>,
128-
nextErrors: ?Array<ModuleError>,
129-
nextCode: ?string,
130-
prevId: string,
131-
nextId: string
132+
nextErrors: ?Array<ModuleError>
132133
) => {
133134
if (!monaco) return;
134135
if (nextErrors && nextErrors.length > 0) {
@@ -329,7 +330,6 @@ export default class CodeEditor extends React.PureComponent<Props, State> {
329330
swapDocuments = async ({
330331
currentId,
331332
nextId,
332-
nextCode,
333333
nextTitle,
334334
}: {
335335
currentId: string,
@@ -488,6 +488,7 @@ export default class CodeEditor extends React.PureComponent<Props, State> {
488488
this.editor = editor;
489489
this.monaco = monaco;
490490

491+
// eslint-disable-next-line no-underscore-dangle
491492
window._cs = {
492493
editor: this.editor,
493494
monaco: this.monaco,
@@ -544,7 +545,7 @@ export default class CodeEditor extends React.PureComponent<Props, State> {
544545
label: 'Open Module',
545546

546547
// An optional array of keybindings for the action.
547-
keybindings: [monaco.KeyMod.CtrlCmd | monaco.KeyCode.KEY_P],
548+
keybindings: [monaco.KeyMod.CtrlCmd | monaco.KeyCode.KEY_P], // eslint-disable-line no-bitwise
548549

549550
// A precondition for this action.
550551
precondition: null,
@@ -558,7 +559,7 @@ export default class CodeEditor extends React.PureComponent<Props, State> {
558559

559560
// Method that will be executed when the action is triggered.
560561
// @param editor The editor instance is passed in as a convinience
561-
run: ed => {
562+
run: () => {
562563
this.setState({
563564
fuzzySearchEnabled: true,
564565
});
@@ -579,7 +580,7 @@ export default class CodeEditor extends React.PureComponent<Props, State> {
579580

580581
addKeyCommands = () => {
581582
this.editor.addCommand(
582-
this.monaco.KeyMod.CtrlCmd | this.monaco.KeyCode.KEY_S,
583+
this.monaco.KeyMod.CtrlCmd | this.monaco.KeyCode.KEY_S, // eslint-disable-line no-bitwise
583584
() => {
584585
this.handleSaveCode();
585586
}

src/app/components/sandbox/CodeEditor/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
import React from 'react';
22
import Loadable from 'react-loadable';
3+
import { Preferences } from 'common/types';
34

45
import Monaco from './Monaco';
56

7+
type Props = {
8+
preferences: Preferences,
9+
};
10+
611
const CodeMirror = Loadable({
712
loader: () => import('./CodeMirror'),
813
LoadingComponent: 'div',
914
});
1015

11-
export default props => {
16+
export default (props: Props) => {
1217
// We are phasing towards Monaco, the only thing missing is vim mode. So use
1318
// CodeMirror until we have proper support
1419
if (props.preferences.vimMode || props.preferences.codeMirror) {

src/app/components/sandbox/CodeEditor/monaco/MonacoReactComponent.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable */
12
var _extends =
23
Object.assign ||
34
function(target) {

src/app/components/sandbox/CodeEditor/monaco/enable-emmet.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
import extractAbbreviation from '@emmetio/extract-abbreviation';
22
import { expand } from '@emmetio/expand-abbreviation';
33

4-
const field = (index, placeholder) => '';
4+
const field = () => '';
55

6-
const expandAbbreviation = (source, language) => {
7-
return expand(source.abbreviation, {
6+
const expandAbbreviation = (source, language) =>
7+
expand(source.abbreviation, {
88
field,
99
syntax: language,
1010
addons: {
1111
jsx: true,
1212
},
1313
});
14-
};
1514

1615
const enableEmmet = (editor, monaco) => {
1716
if (!editor) {
@@ -26,7 +25,7 @@ const enableEmmet = (editor, monaco) => {
2625
label: 'Emmet: Expand abbreviation',
2726

2827
// An optional array of keybindings for the action.
29-
keybindings: [monaco.KeyMod.CtrlCmd | monaco.KeyCode.F10],
28+
keybindings: [monaco.KeyMod.CtrlCmd | monaco.KeyCode.F10], // eslint-disable-line no-bitwise
3029

3130
// A precondition for this action.
3231
precondition: null,
@@ -39,8 +38,8 @@ const enableEmmet = (editor, monaco) => {
3938
contextMenuOrder: 1.5,
4039

4140
// Method that will be executed when the action is triggered.
42-
// @param editor The editor instance is passed in as a convinience
43-
run: function(ed) {
41+
// @param editor The editor instance is passed in as a convenience
42+
run: () => {
4443
let word = editor.model.getValueInRange(editor.getSelection());
4544
const pos = editor.getPosition();
4645
if (!word) {
@@ -66,12 +65,11 @@ const enableEmmet = (editor, monaco) => {
6665
forceMoveMarkers: true,
6766
};
6867
editor.executeEdits('', [op]);
69-
} else {
70-
return false;
68+
return null;
7169
}
72-
} else {
7370
return false;
7471
}
72+
return false;
7573
},
7674
});
7775
};

0 commit comments

Comments
 (0)