Skip to content

Commit 382b09f

Browse files
MichaelDeBoeySaraVieira
authored andcommitted
Use Array.includes instead of Array.indexOf (codesandbox#2339)
1 parent ddb0329 commit 382b09f

File tree

33 files changed

+75
-85
lines changed

33 files changed

+75
-85
lines changed

packages/app/src/app/components/CodeEditor/CodeMirror/elements.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ const fontFamilies = (...families) =>
1010
families
1111
.filter(Boolean)
1212
.map(family => (family === 'Dank Mono' ? 'dm' : family))
13-
.map(family =>
14-
family.indexOf(' ') !== -1 ? JSON.stringify(family) : family
15-
)
13+
.map(family => (family.includes(' ') ? JSON.stringify(family) : family))
1614
.join(', ');
1715

1816
export const Container = styled.div`

packages/app/src/app/components/CodeEditor/Monaco/MonacoReactComponent.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@ class MonacoEditor extends React.PureComponent {
106106

107107
render() {
108108
const { width, height } = this.props;
109-
const fixedWidth =
110-
width.toString().indexOf('%') !== -1 ? width : `${width}px`;
111-
const fixedHeight =
112-
height.toString().indexOf('%') !== -1 ? height : `${height}px`;
109+
const fixedWidth = width.toString().includes('%') ? width : `${width}px`;
110+
const fixedHeight = height.toString().includes('%')
111+
? height
112+
: `${height}px`;
113113
const style = {
114114
width: fixedWidth,
115115
height: fixedHeight,

packages/app/src/app/components/CodeEditor/Monaco/workers/fetch-dependency-typings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ async function fetchAndAddDependencies(dependencies) {
236236
await Promise.all(
237237
depNames.map(async dep => {
238238
try {
239-
if (loadedTypings.indexOf(dep) === -1) {
239+
if (!loadedTypings.includes(dep)) {
240240
loadedTypings.push(dep);
241241

242242
const depVersion = await doFetch(

packages/app/src/app/components/CodeEditor/Monaco/workers/linter/monkeypatch-babel-eslint.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export default function monkeypatch(modules, eslintOptions) {
5555
]);
5656
var visitorKeysMap = Object.keys(t.VISITOR_KEYS).reduce(function(acc, key) {
5757
var value = t.VISITOR_KEYS[key];
58-
if (flowFlippedAliasKeys.indexOf(value) === -1) {
58+
if (!flowFlippedAliasKeys.includes(value)) {
5959
acc[key] = value;
6060
}
6161
return acc;

packages/app/src/app/components/CodeEditor/VSCode/MonacoReactComponent.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ class MonacoEditor extends React.PureComponent {
185185
document.getElementById('root').className = document
186186
.getElementById('root')
187187
.className.split(' ')
188-
.filter(x => ['monaco-shell', 'vs-dark'].indexOf(x) === -1)
188+
.filter(x => !['monaco-shell', 'vs-dark'].includes(x))
189189
.join(' ');
190190

191191
Promise.all(groupsToClose.map(g => g.closeAllEditors()))
@@ -212,9 +212,9 @@ class MonacoEditor extends React.PureComponent {
212212
render() {
213213
const { width, height } = this.props;
214214
const fixedWidth =
215-
width && width.toString().indexOf('%') !== -1 ? width : `${width}px`;
215+
width && width.toString().includes('%') ? width : `${width}px`;
216216
const fixedHeight =
217-
height && height.toString().indexOf('%') !== -1 ? height : `${height}px`;
217+
height && height.toString().includes('%') ? height : `${height}px`;
218218
const style = {
219219
width: fixedWidth,
220220
height: fixedHeight,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export default {
4444
);
4545

4646
return modules
47-
.filter(m => localKeys.indexOf(getKey(currentId, m.shortid)) > -1)
47+
.filter(m => localKeys.includes(getKey(currentId, m.shortid)))
4848
.map(module => {
4949
const key = getKey(currentId, module.shortid);
5050

packages/app/src/app/overmind/namespaces/live/state.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,16 @@ export const state: State = {
4545
return (
4646
state.isLive &&
4747
(state.roomInfo.mode === 'open' ||
48-
state.roomInfo.ownerIds.indexOf(liveUserId) > -1 ||
49-
state.roomInfo.editorIds.indexOf(liveUserId) > -1)
48+
state.roomInfo.ownerIds.includes(liveUserId) ||
49+
state.roomInfo.editorIds.includes(liveUserId))
5050
);
5151
},
5252
isCurrentEditor: state => {
5353
return state.isEditor(state.liveUserId);
5454
},
5555

5656
isOwner: state => {
57-
return (
58-
state.isLive && state.roomInfo.ownerIds.indexOf(state.liveUserId) > -1
59-
);
57+
return state.isLive && state.roomInfo.ownerIds.includes(state.liveUserId);
6058
},
6159
liveUsersByModule: state => {
6260
const usersByModule = {};

packages/app/src/app/pages/Dashboard/Content/SandboxGrid/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ class SandboxGrid extends React.Component<*, State> {
6060
const indexedSandboxes = sandboxes.map((sandbox, i) => ({ sandbox, i }));
6161

6262
// We need to select a range
63-
const firstIndexInfo = indexedSandboxes.find(
64-
({ sandbox }) => selectedSandboxes.indexOf(sandbox.id) > -1
63+
const firstIndexInfo = indexedSandboxes.find(({ sandbox }) =>
64+
selectedSandboxes.includes(sandbox.id)
6565
);
6666

6767
const [id] = ids;
@@ -88,10 +88,10 @@ class SandboxGrid extends React.Component<*, State> {
8888
if (additive) {
8989
track('Dashboard - Sandbox Additive Selection');
9090
sandboxIds = store.dashboard.selectedSandboxes.filter(
91-
id => ids.indexOf(id) === -1
91+
id => !ids.includes(id)
9292
);
9393
const additiveIds = ids.filter(
94-
id => store.dashboard.selectedSandboxes.indexOf(id) === -1
94+
id => !store.dashboard.selectedSandboxes.includes(id)
9595
);
9696

9797
sandboxIds = uniq([...sandboxIds, ...additiveIds]);

packages/app/src/app/pages/Dashboard/Content/routes/TeamView/AddTeamMember/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const AddTeamMember = ({ teamId, signals }) => (
2626
e.preventDefault();
2727
e.stopPropagation();
2828

29-
let isEmail = input.value.indexOf('@') > -1;
29+
let isEmail = input.value.includes('@');
3030

3131
track('Team - Add Member', { email: isEmail });
3232

packages/app/src/app/pages/Dashboard/Sidebar/SandboxesItem/folder-drop-target.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function addSandboxesToCollection(props, item) {
7373
});
7474

7575
oldFolderCacheData.me.collection.sandboxes = oldFolderCacheData.me.collection.sandboxes.filter(
76-
x => selectedSandboxes.indexOf(x.id) === -1
76+
x => !selectedSandboxes.includes(x.id)
7777
);
7878

7979
cache.writeQuery({

0 commit comments

Comments
 (0)