Skip to content

Commit

Permalink
chore(js): addlint rules for import order
Browse files Browse the repository at this point in the history
Closes #5624
  • Loading branch information
IanLondon committed Jun 30, 2020
1 parent 628049c commit 26a085b
Show file tree
Hide file tree
Showing 511 changed files with 907 additions and 1,067 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module.exports = {
'react-hooks/exhaustive-deps': 'warn',
'no-extra-boolean-cast': 'off',
'import/no-default-export': 'error',
'import/order': 'error',
},

globals: {},
Expand Down
10 changes: 5 additions & 5 deletions app-shell/src/buildroot/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@ import { readFile, ensureDir } from 'fs-extra'
import { app } from 'electron'

import { UI_INITIALIZED } from '@opentrons/app/src/shell/actions'
import type {
BuildrootUpdateInfo,
BuildrootAction,
} from '@opentrons/app/src/buildroot/types'
import { createLogger } from '../log'
import { getConfig } from '../config'
import { CURRENT_VERSION } from '../update'
import type { Action, Dispatch } from '../types'
import { downloadManifest, getReleaseSet } from './release-manifest'
import {
getReleaseFiles,
Expand All @@ -16,12 +21,7 @@ import {
} from './release-files'
import { startPremigration, uploadSystemFile } from './update'

import type { Action, Dispatch } from '../types'
import type { ReleaseSetUrls, ReleaseSetFilepaths } from './types'
import type {
BuildrootUpdateInfo,
BuildrootAction,
} from '@opentrons/app/src/buildroot/types'

const log = createLogger('buildroot/index')

Expand Down
2 changes: 1 addition & 1 deletion app-shell/src/buildroot/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import path from 'path'

import { fetch, postFile } from '../http'
import type { RobotHost } from '@opentrons/app/src/robot-api/types'
import { fetch, postFile } from '../http'

const PREMIGRATION_WHL_DIR = path.join(
// NOTE: __dirname refers to output directory
Expand Down
2 changes: 1 addition & 1 deletion app-shell/src/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import { UI_INITIALIZED } from '@opentrons/app/src/shell/actions'
import * as Cfg from '@opentrons/app/src/config'

import { createLogger } from '../log'
import type { Action, Dispatch, Logger } from '../types'
import { DEFAULTS_V0, migrate } from './migrate'
import { shouldUpdate, getNextValue } from './update'

import type { Action, Dispatch, Logger } from '../types'
import type { Config, Overrides } from './types'

export type * from './types'
Expand Down
3 changes: 1 addition & 2 deletions app-shell/src/config/migrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ import { app } from 'electron'
import uuid from 'uuid/v4'
import { CONFIG_VERSION_LATEST } from '@opentrons/app/src/config'

import pkg from '../../package.json'

import type {
Config,
ConfigV0,
ConfigV1,
} from '@opentrons/app/src/config/types'
import pkg from '../../package.json'

// base config v0 defaults
// any default values for later config versions are specified in the migration
Expand Down
2 changes: 1 addition & 1 deletion app-shell/src/config/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import {
SUBTRACT_VALUE,
} from '@opentrons/app/src/config'

import type { ConfigValueChangeAction } from '@opentrons/app/src/config/types'
import { DEFAULTS } from './migrate'

import type { ConfigValueChangeAction } from '@opentrons/app/src/config/types'
import type { Config, Overrides } from './types'

export function shouldUpdate(path: string, overrides: Overrides): boolean {
Expand Down
3 changes: 1 addition & 2 deletions app-shell/src/discovery.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ import {
CLEAR_CACHE,
} from '@opentrons/app/src/discovery/actions'

import type { Service } from '@opentrons/discovery-client'
import { getConfig, getOverrides, handleConfigChange } from './config'
import { createLogger } from './log'
import { createNetworkInterfaceMonitor } from './system-info'

import type { Service } from '@opentrons/discovery-client'

import type { Action, Dispatch } from './types'

const log = createLogger('discovery')
Expand Down
12 changes: 5 additions & 7 deletions app-shell/src/labware/__tests__/dispatch.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,20 @@

import fse from 'fs-extra'
import electron from 'electron'
import * as Cfg from '../../config'
import * as Dialogs from '../../dialogs'
import * as Defs from '../definitions'
import * as Val from '../validation'
import { registerLabware } from '..'

import { uiInitialized } from '@opentrons/app/src/shell/actions'
import * as CustomLabware from '@opentrons/app/src/custom-labware'
import * as CustomLabwareFixtures from '@opentrons/app/src/custom-labware/__fixtures__'

import type { Config } from '@opentrons/app/src/config/types'
import type {
UncheckedLabwareFile,
CheckedLabwareFile,
DuplicateLabwareFile,
} from '@opentrons/app/src/custom-labware/types'
import * as Cfg from '../../config'
import * as Dialogs from '../../dialogs'
import * as Defs from '../definitions'
import * as Val from '../validation'
import { registerLabware } from '..'

jest.mock('fs-extra')
jest.mock('electron')
Expand Down
2 changes: 1 addition & 1 deletion app-shell/src/labware/__tests__/validation.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// @flow
import { validateLabwareFiles, validateNewLabwareFile } from '../validation'

import validLabwareA from '@opentrons/shared-data/labware/fixtures/2/fixture_96_plate.json'
import validLabwareB from '@opentrons/shared-data/labware/fixtures/2/fixture_12_trough.json'
import { validateLabwareFiles, validateNewLabwareFile } from '../validation'

describe('validateLabwareFiles', () => {
it('handles unparseable and invalid labware files', () => {
Expand Down
2 changes: 1 addition & 1 deletion app-shell/src/labware/definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import path from 'path'
import fs from 'fs-extra'
import { shell } from 'electron'

import type { Dirent } from '../types'
import type { UncheckedLabwareFile } from '@opentrons/app/src/custom-labware/types'
import type { Dirent } from '../types'

const RE_JSON_EXT = /\.json$/i

Expand Down
13 changes: 5 additions & 8 deletions app-shell/src/labware/index.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
// @flow
import fse from 'fs-extra'
import { app, shell } from 'electron'
import { getFullConfig, handleConfigChange } from '../config'
import { showOpenDirectoryDialog, showOpenFileDialog } from '../dialogs'
import * as Definitions from './definitions'
import { validateLabwareFiles, validateNewLabwareFile } from './validation'
import { sameIdentity } from './compare'

import { UI_INITIALIZED } from '@opentrons/app/src/shell/actions'
import * as CustomLabware from '@opentrons/app/src/custom-labware'
import * as ConfigActions from '@opentrons/app/src/config'

import type {
UncheckedLabwareFile,
DuplicateLabwareFile,
CustomLabwareListActionSource as ListSource,
} from '@opentrons/app/src/custom-labware/types'

import { getFullConfig, handleConfigChange } from '../config'
import { showOpenDirectoryDialog, showOpenFileDialog } from '../dialogs'
import type { Action, Dispatch } from '../types'
import * as Definitions from './definitions'
import { validateLabwareFiles, validateNewLabwareFile } from './validation'
import { sameIdentity } from './compare'

const ensureDir: (dir: string) => Promise<void> = fse.ensureDir

Expand Down
2 changes: 1 addition & 1 deletion app-shell/src/labware/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import Ajv from 'ajv'
import sortBy from 'lodash/sortBy'
import labwareSchema from '@opentrons/shared-data/labware/schemas/2.json'
import { sameIdentity } from './compare'

import {
INVALID_LABWARE_FILE,
Expand All @@ -18,6 +17,7 @@ import type {
ValidLabwareFile,
OpentronsLabwareFile,
} from '@opentrons/app/src/custom-labware/types'
import { sameIdentity } from './compare'

const ajv = new Ajv()
const validateDefinition = ajv.compile(labwareSchema)
Expand Down
4 changes: 2 additions & 2 deletions app-shell/src/log.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// create logger function
import { app } from 'electron'
import { inspect } from 'util'
import fse from 'fs-extra'
import path from 'path'
import { app } from 'electron'
import fse from 'fs-extra'
import dateFormat from 'dateformat'
import winston from 'winston'

Expand Down
2 changes: 1 addition & 1 deletion app-shell/src/system-info/__tests__/dispatch.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { uiInitialized } from '@opentrons/app/src/shell'
import * as OS from '../../os'
import * as UsbDevices from '../usb-devices'
import * as NetworkInterfaces from '../network-interfaces'
import { registerSystemInfo } from '..'

import type {
Device,
Expand All @@ -20,6 +19,7 @@ import type {
NetworkInterfaceMonitor,
NetworkInterfaceMonitorOptions,
} from '../network-interfaces'
import { registerSystemInfo } from '..'

jest.mock('../../os')
jest.mock('../usb-devices')
Expand Down
4 changes: 2 additions & 2 deletions app-shell/src/system-info/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
import { app } from 'electron'
import { UI_INITIALIZED } from '@opentrons/app/src/shell/actions'
import * as SystemInfo from '@opentrons/app/src/system-info'
import type { UsbDevice } from '@opentrons/app/src/system-info/types'
import { createLogger } from '../log'
import { isWindows } from '../os'
import type { Action, Dispatch } from '../types'
import { createUsbDeviceMonitor, getWindowsDriverVersion } from './usb-devices'
import {
createNetworkInterfaceMonitor,
getActiveInterfaces,
} from './network-interfaces'

import type { UsbDevice } from '@opentrons/app/src/system-info/types'
import type { Action, Dispatch } from '../types'
import type { UsbDeviceMonitor, Device } from './usb-devices'
import type { NetworkInterfaceMonitor } from './network-interfaces'

Expand Down
3 changes: 1 addition & 2 deletions app-shell/src/system-info/usb-devices.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
import assert from 'assert'
import execa from 'execa'
import usbDetection from 'usb-detection'
import type { Device } from 'usb-detection'
import { isWindows } from '../os'
import { createLogger } from '../log'

import type { Device } from 'usb-detection'

export type { Device }

export type UsbDeviceMonitorOptions = $Shape<{|
Expand Down
2 changes: 1 addition & 1 deletion app-shell/src/ui.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// sets up the main window ui
import { app, shell, BrowserWindow } from 'electron'
import path from 'path'
import { app, shell, BrowserWindow } from 'electron'
import { getConfig } from './config'
import { createLogger } from './log'

Expand Down
2 changes: 1 addition & 1 deletion app-shell/src/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import { autoUpdater as updater } from 'electron-updater'

import { UI_INITIALIZED } from '@opentrons/app/src/shell/actions'
import type { UpdateInfo } from '@opentrons/app/src/shell/types'
import { createLogger } from './log'
import { getConfig } from './config'

import type { UpdateInfo } from '@opentrons/app/src/shell/types'
import type { Action, Dispatch, PlainError } from './types'

updater.logger = createLogger('update')
Expand Down
2 changes: 1 addition & 1 deletion app/src/alerts/epic.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import { filter, map } from 'rxjs/operators'

import { addUniqueConfigValue } from '../config'
import type { Action, Epic } from '../types'
import { ALERT_DISMISSED } from './constants'

import type { Action, Epic } from '../types'
import type { AlertDismissedAction } from './types'

// dispatch an updateConfig action to add the alertId to the permanent ignore
Expand Down
2 changes: 1 addition & 1 deletion app/src/alerts/reducer.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// @flow
import union from 'lodash/union'
import without from 'lodash/without'
import type { Action } from '../types'
import * as Constants from './constants'

import type { Action } from '../types'
import type { AlertsState } from './types'

const INITIAL_STATE = {
Expand Down
4 changes: 2 additions & 2 deletions app/src/analytics/epic.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ import {
} from 'rxjs/operators'

import * as Cfg from '../config'
import type { State, Action, Epic } from '../types'
import type { ConfigInitializedAction } from '../config/types'
import { getAnalyticsConfig } from './selectors'
import { initializeMixpanel, setMixpanelTracking, trackEvent } from './mixpanel'
import { makeEvent } from './make-event'

import type { State, Action, Epic } from '../types'
import type { ConfigInitializedAction } from '../config/types'
import type { TrackEventArgs, AnalyticsEvent, AnalyticsConfig } from './types'

const initialzeAnalyticsEpic: Epic = (action$, state$) => {
Expand Down
2 changes: 1 addition & 1 deletion app/src/analytics/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import { useSelector } from 'react-redux'

import { getConfig } from '../config'
import type { State } from '../types'
import { trackEvent } from './mixpanel'

import type { State } from '../types'
import type { AnalyticsEvent } from './types'

/**
Expand Down
2 changes: 1 addition & 1 deletion app/src/analytics/make-event.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import * as CustomLabware from '../custom-labware'
import * as SystemInfo from '../system-info'
import * as brActions from '../buildroot/constants'
import * as Sessions from '../sessions'
import type { State, Action } from '../types'
import {
getProtocolAnalyticsData,
getRobotAnalyticsData,
getBuildrootAnalyticsData,
} from './selectors'

import type { State, Action } from '../types'
import type { AnalyticsEvent } from './types'

const log = createLogger(__filename)
Expand Down
5 changes: 2 additions & 3 deletions app/src/analytics/selectors.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// @flow
import { createSelector } from 'reselect'

import type { OutputSelector } from 'reselect'
import {
getProtocolType,
getProtocolCreatorApp,
Expand Down Expand Up @@ -29,10 +30,8 @@ import { getRobotSettings } from '../robot-settings'
import { getAttachedPipettes } from '../pipettes'
import { getPipettes, getModules } from '../robot/selectors'

import { hash } from './hash'

import type { OutputSelector } from 'reselect'
import type { State } from '../types'
import { hash } from './hash'

import type {
AnalyticsConfig,
Expand Down
2 changes: 1 addition & 1 deletion app/src/buildroot/actions.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @flow
import type { RobotHost } from '../robot-api/types'
import * as Constants from './constants'

import type { RobotHost } from '../robot-api/types'
import type {
BuildrootAction,
UpdateSessionStep,
Expand Down
7 changes: 3 additions & 4 deletions app/src/buildroot/epic.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ import { GET, POST, fetchRobotApi } from '../robot-api'
import { RESTART_PATH } from '../robot-admin'
import { actions as robotActions } from '../robot'

import type { State, Epic } from '../types'
import type { ViewableRobot } from '../discovery/types'
import type { RobotApiResponse } from '../robot-api/types'
import {
getBuildrootTargetVersion,
getBuildrootSession,
Expand Down Expand Up @@ -61,10 +64,6 @@ import {
BR_CREATE_SESSION_SUCCESS,
} from './constants'

import type { State, Epic } from '../types'
import type { ViewableRobot } from '../discovery/types'
import type { RobotApiResponse } from '../robot-api/types'

import type {
BuildrootAction,
StartBuildrootUpdateAction,
Expand Down
2 changes: 1 addition & 1 deletion app/src/buildroot/reducer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @flow
import type { Action } from '../types'
import * as Constants from './constants'

import type { Action } from '../types'
import type { BuildrootState, BuildrootUpdateSession } from './types'

export const INITIAL_STATE: BuildrootState = {
Expand Down
Loading

0 comments on commit 26a085b

Please sign in to comment.