Disallow var

Summary: We're ES6 and `var`s scoping rules are weird. Let's block this.

Reviewed By: jknoxville

Differential Revision: D16131290

fbshipit-source-id: ba67d16bb8a185a4bb59a657a97b00230dbacafe
This commit is contained in:
Pascal Hartig
2019-07-09 04:15:32 -07:00
committed by Facebook Github Bot
parent af8fbf2b46
commit 662db20948
9 changed files with 12 additions and 11 deletions

View File

@@ -21,6 +21,7 @@ module.exports = {
'no-catch-shadow': 0, // only relevant for IE8 and below 'no-catch-shadow': 0, // only relevant for IE8 and below
'no-bitwise': 0, // bitwise operations needed in some places 'no-bitwise': 0, // bitwise operations needed in some places
'consistent-return': 0, 'consistent-return': 0,
'no-var': 2,
'max-len': 0, // let's take prettier take care of this 'max-len': 0, // let's take prettier take care of this
indent: 0, // let's take prettier take care of this indent: 0, // let's take prettier take care of this
'no-console': 0, // we're setting window.console in App.js 'no-console': 0, // we're setting window.console in App.js

View File

@@ -146,7 +146,7 @@ async function exitActions(
store: Store, store: Store,
): Promise<void> { ): Promise<void> {
const {metrics, exit} = userArguments; const {metrics, exit} = userArguments;
for (var exitAction of exitClosures) { for (let exitAction of exitClosures) {
try { try {
const action = await exitAction(userArguments, store); const action = await exitAction(userArguments, store);
if (action.exit) { if (action.exit) {

View File

@@ -37,8 +37,8 @@ beforeAll(() => {
}); });
test('Device can connect successfully', done => { test('Device can connect successfully', done => {
var testFinished = false; let testFinished = false;
var disconnectedTooEarly = false; let disconnectedTooEarly = false;
const registeredClients = []; const registeredClients = [];
server.addListener('new-client', (client: Client) => { server.addListener('new-client', (client: Client) => {
// Check there is a connected device that has the same device_id as the new client // Check there is a connected device that has the same device_id as the new client

View File

@@ -12,7 +12,7 @@ import MacDevice from '../devices/MacDevice';
import WindowsDevice from '../devices/WindowsDevice'; import WindowsDevice from '../devices/WindowsDevice';
export default (store: Store, logger: Logger) => { export default (store: Store, logger: Logger) => {
var device; let device;
if (process.platform === 'darwin') { if (process.platform === 'darwin') {
device = new MacDevice(); device = new MacDevice();
} else if (process.platform === 'win32') { } else if (process.platform === 'win32') {

View File

@@ -9,7 +9,7 @@ import type {TrackType, Logger} from '../fb-interfaces/Logger';
import type {Store} from '../reducers/index'; import type {Store} from '../reducers/index';
import ScribeLogger from './ScribeLogger'; import ScribeLogger from './ScribeLogger';
var instance: ?StubLogger = null; let instance: ?StubLogger = null;
type Args = { type Args = {
isHeadless?: boolean, isHeadless?: boolean,

View File

@@ -6,7 +6,7 @@
*/ */
import {FlipperDevicePlugin, Device} from 'flipper'; import {FlipperDevicePlugin, Device} from 'flipper';
var adb = require('adbkit-fb'); let adb = require('adbkit-fb');
import TemperatureTable from './TemperatureTable.js'; import TemperatureTable from './TemperatureTable.js';
import { import {

View File

@@ -165,7 +165,7 @@ function transformRow(
index: number, index: number,
): TableBodyRow { ): TableBodyRow {
const transformedColumns = {}; const transformedColumns = {};
for (var i = 0; i < columns.length; i++) { for (let i = 0; i < columns.length; i++) {
transformedColumns[columns[i]] = {value: renderValue(row[i])}; transformedColumns[columns[i]] = {value: renderValue(row[i])};
} }
return {key: String(index), columns: transformedColumns}; return {key: String(index), columns: transformedColumns};

View File

@@ -334,7 +334,7 @@ class ConnectionTracker {
logConnectionAttempt(client: ClientQuery) { logConnectionAttempt(client: ClientQuery) {
const key = `${client.os}-${client.device}-${client.app}`; const key = `${client.os}-${client.device}-${client.app}`;
const time = Date.now(); const time = Date.now();
var entry = this.connectionAttempts.get(key) || []; let entry = this.connectionAttempts.get(key) || [];
entry.push(time); entry.push(time);
entry = entry.filter(t => t >= time - this.timeWindowMillis); entry = entry.filter(t => t >= time - this.timeWindowMillis);

View File

@@ -5,10 +5,10 @@
* @format * @format
*/ */
var babylon = require('@babel/parser'); let babylon = require('@babel/parser');
var fs = require('fs'); let fs = require('fs');
var electronStubs = babylon.parseExpression( let electronStubs = babylon.parseExpression(
fs.readFileSync('static/electron-stubs.notjs').toString(), fs.readFileSync('static/electron-stubs.notjs').toString(),
); );