Skip to content

Commit 5181fc2

Browse files
MichaelDeBoeyCompuIves
authored andcommitted
Cleanup code (codesandbox#1874)
* Use includes * Use Boolean function instead of double negation
1 parent 2c65ca1 commit 5181fc2

File tree

35 files changed

+48
-48
lines changed

35 files changed

+48
-48
lines changed

packages/app/src/app/components/CodeEditor/VSCode/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class MonacoEditor extends React.Component<Props> implements Editor {
129129
const activeEditor = this.editor && this.editor.getActiveCodeEditor();
130130

131131
if (this.props.readOnly !== nextProps.readOnly && activeEditor) {
132-
activeEditor.updateOptions({ readOnly: !!nextProps.readOnly });
132+
activeEditor.updateOptions({ readOnly: Boolean(nextProps.readOnly) });
133133
}
134134

135135
return false;
@@ -1012,7 +1012,7 @@ class MonacoEditor extends React.Component<Props> implements Editor {
10121012

10131013
const mode = await getMode(title, this.monaco);
10141014
if (this.settings.lintEnabled) {
1015-
if (mode === 'javascript' || mode === 'typescript' || mode === 'vue') {
1015+
if (['javascript', 'typescript', 'vue'].includes(mode)) {
10161016
if (this.lintWorker) {
10171017
this.lintWorker.postMessage({
10181018
code,
@@ -1091,7 +1091,7 @@ class MonacoEditor extends React.Component<Props> implements Editor {
10911091
return {
10921092
...getSettings(settings),
10931093
ariaLabel: currentModule.title,
1094-
readOnly: !!this.props.readOnly,
1094+
readOnly: Boolean(this.props.readOnly),
10951095
};
10961096
};
10971097

packages/app/src/app/components/Preview/DevTools/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export default class DevTools extends React.PureComponent<Props, State> {
111111
constructor(props: Props) {
112112
super(props);
113113

114-
const isOpen = !!props.viewConfig.open;
114+
const isOpen = Boolean(props.viewConfig.open);
115115

116116
this.allViews = props.addedViews
117117
? { ...VIEWS, ...props.addedViews }

packages/app/src/app/overmind/effects/fsSync.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ export default {
142142

143143
fs.stat('/sandbox/tsconfig.json', (err, result) => {
144144
// If tsconfig exists we want to sync the types
145-
syncDependencyTypings(rv.toString(), !!err || !result);
145+
syncDependencyTypings(rv.toString(), Boolean(err) || !result);
146146
});
147147
});
148148
}

packages/app/src/app/overmind/effects/keybindingManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55

66
const isIOS =
77
typeof navigator !== 'undefined' &&
8-
!!navigator.platform.match(/(iPhone|iPod|iPad)/i);
8+
Boolean(navigator.platform.match(/(iPhone|iPod|iPad)/i));
99

1010
const state = {
1111
keybindings: null,

packages/app/src/app/pages/Dashboard/Content/SandboxCard/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ class SandboxItem extends React.PureComponent<Props, State> {
442442
// check for cmd click
443443
const cmd = event.ctrlKey || event.metaKey;
444444

445-
this.openSandbox(!!cmd);
445+
this.openSandbox(Boolean(cmd));
446446
}}
447447
onBlur={this.handleOnBlur}
448448
onFocus={this.handleOnFocus}

packages/app/src/app/pages/Dashboard/Content/routes/SearchSandboxes/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const SearchSandboxes = ({ store }) => (
6565
isLoading={loading}
6666
Header={Header}
6767
page="search"
68-
hideOrder={!!search}
68+
hideOrder={Boolean(search)}
6969
sandboxes={loading ? [] : sandboxes}
7070
possibleTemplates={possibleTemplates}
7171
/>

packages/app/src/app/pages/Sandbox/Editor/Workspace/WorkspaceItem/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export default class WorkspaceItem extends React.Component<Props, State> {
2727
constructor(props: Props) {
2828
super(props);
2929
this.state = {
30-
open: !!props.defaultOpen,
30+
open: Boolean(props.defaultOpen),
3131
};
3232
}
3333

packages/app/src/app/pages/Sandbox/Editor/Workspace/items/ConfigurationFiles/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const FileConfig = ({
3838
const { module, config } = info;
3939
return (
4040
<File
41-
created={!!module}
41+
created={Boolean(module)}
4242
key={path}
4343
onClick={
4444
openModule

packages/app/src/app/store/providers/FSSync.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ export default Provider({
141141

142142
fs.stat('/sandbox/tsconfig.json', (err, result) => {
143143
// If tsconfig exists we want to sync the types
144-
syncDependencyTypings(rv.toString(), !!err || !result);
144+
syncDependencyTypings(rv.toString(), Boolean(err) || !result);
145145
});
146146
});
147147
}

packages/app/src/app/vscode/dev-bootstrap.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ export default function(isVSCode = false, requiredModule?: string[]) {
478478
return '';
479479
})
480480
.filter(function(assignment) {
481-
return !!assignment;
481+
return Boolean(assignment);
482482
})
483483
.join('&');
484484
if (search.length > 0) {

0 commit comments

Comments
 (0)