Skip to content

Commit

Permalink
ci(travis): add format check to CI lint job (#4059)
Browse files Browse the repository at this point in the history
* ci(travis): add format check to CI lint job
* style: run make format with upgraded prettier
  • Loading branch information
mcous authored Sep 17, 2019
1 parent 5c75152 commit b50e69a
Show file tree
Hide file tree
Showing 28 changed files with 90 additions and 152 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:
- make install-js
script:
- make test-js
- make lint-js lint-css
- make lint-js lint-css format
- make -C components
- make -C protocol-designer
- make -C labware-library
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ lint: lint-py lint-js lint-json lint-css check-js

.PHONY: format
format:
prettier --ignore-path .eslintignore --write ".*.@(js|yml)" "**/*.@(js|json|md|yml)"
prettier --ignore-path .eslintignore $(if $(CI),--check,--write) ".*.@(js|yml)" "**/*.@(js|json|md|yml)"

.PHONY: lint-py
lint-py:
Expand Down
20 changes: 8 additions & 12 deletions app-shell/src/buildroot/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,14 @@ export function registerBuildrootUpdate(dispatch: Dispatch) {
log.info('Starting robot premigration', { robot })

startPremigration(robot)
.then(
(): BuildrootAction => ({
type: 'buildroot:PREMIGRATION_DONE',
payload: robot.name,
})
)
.catch(
(error: Error): BuildrootAction => ({
type: 'buildroot:PREMIGRATION_ERROR',
payload: { message: error.message },
})
)
.then((): BuildrootAction => ({
type: 'buildroot:PREMIGRATION_DONE',
payload: robot.name,
}))
.catch((error: Error): BuildrootAction => ({
type: 'buildroot:PREMIGRATION_ERROR',
payload: { message: error.message },
}))
.then(dispatch)

break
Expand Down
8 changes: 2 additions & 6 deletions app/src/components/ModuleLiveStatusCards/ThermocyclerCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,12 @@ const ThermocyclerCard = ({
<LabeledValue
label="Cycle #"
className={styles.compact_labeled_value}
value={`${module.data.currentCycleIndex} / ${
module.data.totalCycleCount
}`}
value={`${module.data.currentCycleIndex} / ${module.data.totalCycleCount}`}
/>
<LabeledValue
label="Step #"
className={styles.compact_labeled_value}
value={`${module.data.currentStepIndex} / ${
module.data.totalStepCount
}`}
value={`${module.data.currentStepIndex} / ${module.data.totalStepCount}`}
/>
<span
className={cx(
Expand Down
40 changes: 19 additions & 21 deletions components/src/deck/Deck.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,29 +93,27 @@ function renderLabware(
return flatMap(
SLOTNAME_MATRIX,
(columns: Array<DeckSlotId>, row: number): Array<React.Node> => {
return columns.map(
(slot: DeckSlotId, col: number): React.Node => {
if (slot === TRASH_SLOTNAME) return null
return columns.map((slot: DeckSlotId, col: number): React.Node => {
if (slot === TRASH_SLOTNAME) return null

const props = {
slot,
width: SLOT_RENDER_WIDTH,
height: SLOT_RENDER_HEIGHT,
}
const transform = `translate(${[
SLOT_RENDER_WIDTH * col + SLOT_SPACING_MM * (col + 1),
SLOT_RENDER_HEIGHT * row + SLOT_SPACING_MM * (row + 1),
].join(',')})`

return (
// $FlowFixMe: (mc, 2019-04-18) don't know why flow doesn't like this, don't care because this is going away
<g key={slot} transform={transform}>
<EmptyDeckSlot {...props} />
{LabwareComponent && <LabwareComponent {...props} />}
</g>
)
const props = {
slot,
width: SLOT_RENDER_WIDTH,
height: SLOT_RENDER_HEIGHT,
}
)
const transform = `translate(${[
SLOT_RENDER_WIDTH * col + SLOT_SPACING_MM * (col + 1),
SLOT_RENDER_HEIGHT * row + SLOT_SPACING_MM * (row + 1),
].join(',')})`

return (
// $FlowFixMe: (mc, 2019-04-18) don't know why flow doesn't like this, don't care because this is going away
<g key={slot} transform={transform}>
<EmptyDeckSlot {...props} />
{LabwareComponent && <LabwareComponent {...props} />}
</g>
)
})
}
)
}
Expand Down
4 changes: 1 addition & 3 deletions components/src/deck/LabwareRender.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ export default function LabwareRender(props: LabwareRenderProps) {
const cornerOffsetFromSlot = props.definition.cornerOffsetFromSlot
return (
<g
transform={`translate(${cornerOffsetFromSlot.x}, ${
cornerOffsetFromSlot.y
})`}
transform={`translate(${cornerOffsetFromSlot.x}, ${cornerOffsetFromSlot.y})`}
>
<StaticLabware
definition={props.definition}
Expand Down
8 changes: 2 additions & 6 deletions components/src/deck/LabwareRender.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ const fixture_tiprack_300_ul = require('@opentrons/shared-data/labware/fixtures/
let definition = fixture_96_plate

;<RobotWorkSpace
viewBox={`0 0 ${definition.dimensions.xDimension} ${
definition.dimensions.yDimension
}`}
viewBox={`0 0 ${definition.dimensions.xDimension} ${definition.dimensions.yDimension}`}
>
{() => (
<LabwareRender
Expand All @@ -35,9 +33,7 @@ const fixture_tiprack_300_ul = require('@opentrons/shared-data/labware/fixtures/
let definition = fixture_tiprack_300_ul

;<RobotWorkSpace
viewBox={`0 0 ${definition.dimensions.xDimension} ${
definition.dimensions.yDimension
}`}
viewBox={`0 0 ${definition.dimensions.xDimension} ${definition.dimensions.yDimension}`}
>
{() => (
<LabwareRender
Expand Down
19 changes: 9 additions & 10 deletions labware-library/src/labware-creator/labwareFormSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,16 +164,15 @@ const labwareFormSchema = Yup.object()
brand: requiredString(LABELS.brand),
brandId: Yup.mixed()
.nullable()
.transform(
(
currentValue: ?string,
originalValue: ?string
): $PropertyType<ProcessedLabwareFields, 'brandId'> =>
(currentValue || '')
.trim()
.split(',')
.map(s => s.trim())
.filter(Boolean)
.transform((currentValue: ?string, originalValue: ?string): $PropertyType<
ProcessedLabwareFields,
'brandId'
> =>
(currentValue || '')
.trim()
.split(',')
.map(s => s.trim())
.filter(Boolean)
),

loadName: Yup.string()
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"enzyme-adapter-react-16": "^1.14.0",
"enzyme-to-json": "^3.3.5",
"eslint": "^6.0.1",
"eslint-config-prettier": "^6.0.0",
"eslint-config-prettier": "^6.3.0",
"eslint-config-standard": "^12.0.0",
"eslint-plugin-flowtype": "^3.11.1",
"eslint-plugin-import": "^2.18.0",
Expand Down Expand Up @@ -87,7 +87,7 @@
"postcss-cssnext": "^3.0.2",
"postcss-import": "^11.0.0",
"postcss-loader": "^3.0.0",
"prettier": "1.16.4",
"prettier": "1.18.2",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-snap": "^1.23.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ const LabwarePreview = (props: Props) => {
<div className={styles.labware_detail_row}>
<div className={styles.labware_render_wrapper}>
<RobotWorkSpace
viewBox={`0 0 ${labwareDef.dimensions.xDimension} ${
labwareDef.dimensions.yDimension
}`}
viewBox={`0 0 ${labwareDef.dimensions.xDimension} ${labwareDef.dimensions.yDimension}`}
>
{() => <LabwareRender definition={labwareDef} />}
</RobotWorkSpace>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ function getDisabledChangeTipOptions(
}
default: {
console.warn(
`getChangeTipOptions for stepType ${
rawForm.stepType
} not yet implemented!`
`getChangeTipOptions for stepType ${rawForm.stepType} not yet implemented!`
)
return null
}
Expand Down
4 changes: 1 addition & 3 deletions protocol-designer/src/components/labware/SingleLabware.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ type Props = React.ElementProps<typeof LabwareRender>
export default function SingleLabware(props: Props) {
return (
<RobotWorkSpace
viewBox={`0 0 ${props.definition.dimensions.xDimension} ${
props.definition.dimensions.yDimension
}`}
viewBox={`0 0 ${props.definition.dimensions.xDimension} ${props.definition.dimensions.yDimension}`}
>
{() => <LabwareRender {...props} />}
</RobotWorkSpace>
Expand Down
4 changes: 1 addition & 3 deletions protocol-designer/src/file-data/selectors/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,7 @@ export const getRobotStateTimeline: Selector<StepGeneration.Timeline> = createSe

if (!reducedCommandCreator) {
console.warn(
`commandCreatorFnName "${
stepArgs.commandCreatorFnName
}" not yet implemented for robotStateTimeline`
`commandCreatorFnName "${stepArgs.commandCreatorFnName}" not yet implemented for robotStateTimeline`
)
return acc
}
Expand Down
16 changes: 7 additions & 9 deletions protocol-designer/src/step-forms/reducers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -516,15 +516,13 @@ export const labwareInvariantProperties = handleActions<
state: NormalizedLabwareById,
action: ReplaceCustomLabwareDef
): NormalizedLabwareById =>
mapValues(
state,
(prev: NormalizedLabware): NormalizedLabware =>
action.payload.defURIToOverwrite === prev.labwareDefURI
? {
...prev,
labwareDefURI: getLabwareDefURI(action.payload.newDef),
}
: prev
mapValues(state, (prev: NormalizedLabware): NormalizedLabware =>
action.payload.defURIToOverwrite === prev.labwareDefURI
? {
...prev,
labwareDefURI: getLabwareDefURI(action.payload.newDef),
}
: prev
),
},
initialLabwareState
Expand Down
4 changes: 1 addition & 3 deletions protocol-designer/src/step-forms/selectors/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,7 @@ function _hydrateLabwareEntity(
const def = defsByURI[l.labwareDefURI]
assert(
def,
`could not hydrate labware ${labwareId}, missing def for URI ${
l.labwareDefURI
}`
`could not hydrate labware ${labwareId}, missing def for URI ${l.labwareDefURI}`
)
return {
...l,
Expand Down
4 changes: 1 addition & 3 deletions protocol-designer/src/step-forms/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ export function denormalizePipetteEntities(
const spec = getPipetteNameSpecs(pipette.name)
if (!spec) {
throw new Error(
`no pipette spec for pipette id "${pipetteId}", name "${
pipette.name
}"`
`no pipette spec for pipette id "${pipetteId}", name "${pipette.name}"`
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ const transfer = (args: TransferArgs): CompoundCommandCreator => (
*/
assert(
args.sourceWells.length === args.destWells.length,
`Transfer command creator expected N:N source-to-dest wells ratio. Got ${
args.sourceWells.length
}:${args.destWells.length}`
`Transfer command creator expected N:N source-to-dest wells ratio. Got ${args.sourceWells.length}:${args.destWells.length}`
)
// TODO Ian 2018-04-02 following ~10 lines are identical to first lines of consolidate.js...
const actionName = 'transfer'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ export default function getNextRobotStateAndWarnings(
default:
assert(
false,
`unknown command: ${
command.command
} passed to getNextRobotStateAndWarning`
`unknown command: ${command.command} passed to getNextRobotStateAndWarning`
)
return { robotState: prevRobotState, warnings: [] }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ export function getMaxDisposalVolumeForMultidispense(
if (!rawForm) return null
assert(
rawForm.path === 'multiDispense',
`getMaxDisposalVolumeForMultidispense expected multiDispense, got path ${
rawForm.path
}`
`getMaxDisposalVolumeForMultidispense expected multiDispense, got path ${rawForm.path}`
)
const volume = Number(rawForm.volume)
const pipetteEntity = pipetteEntities[rawForm.pipette]
Expand All @@ -85,9 +83,7 @@ export function volumeInCapacityForMulti(
const volume = Number(rawForm.volume)
assert(
rawForm.pipette in pipetteEntities,
`volumeInCapacityForMulti expected pipette ${
rawForm.pipette
} to be in pipetteEntities`
`volumeInCapacityForMulti expected pipette ${rawForm.pipette} to be in pipetteEntities`
)
const pipetteEntity = pipetteEntities[rawForm.pipette]
const pipetteCapacity = pipetteEntity && getPipetteCapacity(pipetteEntity)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ const moveLiquidFormToArgs = (
): MoveLiquidStepArgs => {
assert(
hydratedFormData.stepType === 'moveLiquid',
`moveLiquidFormToArgs called with stepType ${
hydratedFormData.stepType
}, expected "moveLiquid"`
`moveLiquidFormToArgs called with stepType ${hydratedFormData.stepType}, expected "moveLiquid"`
)

const fields = hydratedFormData.fields
Expand Down Expand Up @@ -187,9 +185,7 @@ const moveLiquidFormToArgs = (
sourceWellsUnordered.length === 1 ||
destWellsUnordered.length === 1 ||
sourceWellsUnordered.length === destWellsUnordered.length,
`cannot do moveLiquidFormToArgs. Mismatched wells (not 1:N, N:1, or N:N!) for path="single". Neither source (${
sourceWellsUnordered.length
}) nor dest (${destWellsUnordered.length}) equal 1`
`cannot do moveLiquidFormToArgs. Mismatched wells (not 1:N, N:1, or N:N!) for path="single". Neither source (${sourceWellsUnordered.length}) nor dest (${destWellsUnordered.length}) equal 1`
)

switch (path) {
Expand Down
4 changes: 1 addition & 3 deletions protocol-designer/src/steplist/generateSubsteps.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,7 @@ function transferLikeSubsteps(args: {|
} else {
// TODO Ian 2018-05-21 Use assert here. Should be unreachable
console.warn(
`transferLikeSubsteps got unsupported stepType "${
stepArgs.commandCreatorFnName
}"`
`transferLikeSubsteps got unsupported stepType "${stepArgs.commandCreatorFnName}"`
)
return null
}
Expand Down
8 changes: 2 additions & 6 deletions protocol-designer/src/steplist/substepTimeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ const substepTimelineSingle = (commandCreators: Array<CommandCreator>) => (
) {
assert(
nextFrame.commands.length === 1,
`substepTimeline expected nextFrame to have only single commands for ${
firstCommand.command
}`
`substepTimeline expected nextFrame to have only single commands for ${firstCommand.command}`
)

const commandGroup = firstCommand
Expand Down Expand Up @@ -145,9 +143,7 @@ const substepTimeline = (
) {
assert(
nextFrame.commands.length === 1,
`substepTimeline expected nextFrame to have only single commands for ${
firstCommand.command
}`
`substepTimeline expected nextFrame to have only single commands for ${firstCommand.command}`
)

const { well, volume, labware } = firstCommand.params
Expand Down
4 changes: 1 addition & 3 deletions protocol-designer/src/top-selectors/well-contents/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,7 @@ export const getAllWellContentsForActiveItem: Selector<WellContentsByLabware> =

assert(
timelineIdx !== -1,
`getAllWellContentsForActiveItem got unhandled terminal id: "${
activeItem.id
}"`
`getAllWellContentsForActiveItem got unhandled terminal id: "${activeItem.id}"`
)

const liquidState = timeline[timelineIdx].robotState.liquidState.labware
Expand Down
4 changes: 1 addition & 3 deletions protocol-designer/src/ui/steps/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,7 @@ const getHoveredStepLabware: Selector<Array<string>> = createSelector(
if (!(stepArgs.commandCreatorFnName === 'delay')) {
// TODO Ian 2018-05-08 use assert here
console.warn(
`getHoveredStepLabware does not support step type "${
stepArgs.commandCreatorFnName
}"`
`getHoveredStepLabware does not support step type "${stepArgs.commandCreatorFnName}"`
)
}

Expand Down
Loading

0 comments on commit b50e69a

Please sign in to comment.