Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/eslint #33

Merged
merged 46 commits into from
Apr 24, 2019
Merged

feat/eslint #33

merged 46 commits into from
Apr 24, 2019

Conversation

varl
Copy link
Contributor

@varl varl commented Apr 19, 2019

I am working on adding ESLint to the JS standards.

Principles

I am careful to only include only essential rules, as any rules added will be considered errors.

In the case the rules require manual intervention, they should be backed by a decision.

Auto fixable rule adoption can be less strict, but should be carefully considered nonetheless.

Design

To allow for multiple tools to scan the same source for warts I have created the all-js.js module, which executes all the tools (eslint.js, prettier.js, etc.) on the given files.

The tools return an array of messages with violations for each file, which is then flattened before returning it, so all messages are grouped per file.

The check and apply command modules now use allJs.apply(files) and allJs.check(files) to execute their respective modes.

Example output

Errors with messages

d2-style js check --all
[ERROR] 4 file(s) violate the code standards:

seeds/mock/appversions_localized.js
[eslint] Arrow function has too many parameters (5). Maximum allowed is 3. (max-params)

src/data/getAppsByUuidAndStatus.js
[eslint] Arrow function has too many parameters (4). Maximum allowed is 3. (max-params)

test/data/index.js
[eslint] 'transaction' is never reassigned. Use 'const' instead. (prefer-const)
[eslint] 'transaction' is never reassigned. Use 'const' instead. (prefer-const)
[eslint] 'allApps' is never reassigned. Use 'const' instead. (prefer-const)

src/theme.js
[eslint] Expected 'multiple' syntax before 'single' syntax. (sort-imports)
[eslint] Member 'blue100' of the import declaration should be sorted alphabetically. (sort-imports)
[prettier] Not formatted according to standards.

echo $?
1

Apply all standards, with errors

d2-style js apply --all
[ERROR] 1 file(s) are in violation of code standards:

components/appVersion/VersionListEdit.jsx
Method 'handleValueChange' has too many parameters (4). Maximum allowed is 3. (max-params)

echo $?
1

Errors but quiet:

d2-style js check --all --quiet
seeds/mock/appversions_localized.js
src/data/getAppsByUuidAndStatus.js
test/data/index.js

echo $?
1

All Good

d2-style js check --all
19 file(s) pass the style checks.

echo $?
0

All Good & Quiet

d2-style js check --all --quiet

echo $?
0

Todo

  • De-dupe messages within a file
  • Find a better name for all-js
  • Relocate tools to another directory to indicate that they require a different kind of consistency
  • Extract a better Message object, perhaps a class to ensure consistency
    Went with a different option, simplified the message object.
  • Figure out a better way to set sourceType for ESLint
    Using babel-eslint seems to have fixed the problems with ESLint.
  • Return modified source to pass to next tool in chain instead of using the source for each tool

@varl
Copy link
Contributor Author

varl commented Apr 19, 2019

Refactored the Prettier runner and (and ESLint) to use the same function for check and apply, but only write the reformatted code if the apply argument equals true.

@varl varl requested a review from amcgee April 19, 2019 09:57
@amcgee
Copy link
Member

amcgee commented Apr 19, 2019

Nice, looks great so far! I really like having the output from different tools show up in the same place.

@varl since this is a draft PR are you looking for any specific feedback or assistance?

Also, how's the performance? I could see this slowing down with large numbers of files since the different parsers are run in series. We could try to parallelize them with streams or separate processes if it's slow, but if it's currently fast that would be premature.

@varl
Copy link
Contributor Author

varl commented Apr 20, 2019

Nice, looks great so far! I really like having the output from different tools show up in the same place.

Yeah, I think it's pretty nice getting a list of issues for each file. 💃

@varl since this is a draft PR are you looking for any specific feedback or assistance?

I decided to publish this as a draft to be transparent, and get some feedback on the way the feature is designed. It changes a bunch of internals and lays the foundation for additional tools that works on source code, so if something stands out as a Bad Idea™️ it would be nice to catch it early.

Also, how's the performance? I could see this slowing down with large numbers of files since the different parsers are run in series. We could try to parallelize them with streams or separate processes if it's slow, but if it's currently fast that would be premature.

Performance is OK for general (staged files) use. Needs more testing in various situations to make sure. I would like to defer running in parallel for now (more on that below).

That said, it is pretty slow when the amount of content to parse increases. When using --all, especially on Windows WSL is dog-slow but the fact that it loads the files from disk once, then passes the content to each parser, makes it bearable.

Maintenance app (28k LoC, 352 files):

time d2-style js check --all
9.83s user 1.22s system 135% cpu 8.146 total

Usage analytics (2.5k LoC, 54 files):

time d2-style js check --all
2.56s user 0.59s system 110% cpu 2.858 total

Parallel execution

Running the check command in parallel would be a nice performance boost and a simple case to implement as it doesn't need to write anything to disk and can do it all in memory.

The tricky part is running apply as each tool will produce different output after applying their fixes and will want to write their changes to disk.

The flow I think might make sense would be:

  • Load source code from disk
  • Pass source to first tool in chain
  • Pass modified source to next tool in chain
  • Repeat until source has been through entire chain
  • Write changed source to disk

Writing that down there's actually a problem with the implementation since it uses the same source as input to all the tools.

I think it makes sense to first let ESLint run, then return the modified (if apply) source, which then Prettier will run and reformat. Once the entire chain has run we can decide to write the source to disk (once) or just report errors.

Programmatically embedding the order of tools centrally will also make it easier to use.

@varl
Copy link
Contributor Author

varl commented Apr 20, 2019

  • Load source code from disk
  • Pass source to first tool in chain
  • Pass modified source to next tool in chain
  • Repeat until source has been through entire chain
  • Write changed source to disk

Implemented this and a nice side-effect is that it only writes (and thus stage) files if there are no errors which cannot automatically be fixed. This leaves the tree intact in case of any errors which is nice.

I'm going to clean it up the implementation a bit though.

@varl
Copy link
Contributor Author

varl commented Apr 21, 2019

Added some performance stats when run with --verbose. I think the performance is OK. Each check-file is for the entire chain of tools so ESLint + Prettier usually is around two-digit milliseconds, sometimes spiking to a couple of hundred of milliseconds.

This output is from running d2-style js check --all --verbose in Maintenance. The --all command for check and apply isn't the primary use-case in the workflow of making commits, so it shouldn't be a problem.

[DEBUG] .prettierrc.js: check-file: 0.27 sec.
[DEBUG] config/setup.js: check-file: 0.018 sec.
[DEBUG] jest.config.js: check-file: 0.017 sec.
[DEBUG] src/App/AccessDenied.component.js: check-file: 0.019 sec.
[DEBUG] src/App/App.component.js: check-file: 0.066 sec.
[DEBUG] src/App/app.theme.js: check-file: 0.018 sec.
[DEBUG] src/App/appStateStore.js: check-file: 0.07 sec.
[DEBUG] src/App/periodTypeStore.js: check-file: 0.011 sec.
[DEBUG] src/App/systemSettingsStore.js: check-file: 0.007 sec.
[DEBUG] src/Dialog/DialogRouter.js: check-file: 0.02 sec.
[DEBUG] src/Dialog/actions.js: check-file: 0.013 sec.
[DEBUG] src/Dialog/reducer.js: check-file: 0.013 sec.
[DEBUG] src/Dialog/selectors.js: check-file: 0.013 sec.
[DEBUG] src/Dialog/types.js: check-file: 0.008 sec.
[DEBUG] src/EditModel/BackButton.component.js: check-file: 0.018 sec.
[DEBUG] src/EditModel/CancelButton.component.js: check-file: 0.015 sec.
[DEBUG] src/EditModel/DataIndicatorGroupsAssignment.component.js: check-file: 0.047 sec.
[DEBUG] src/EditModel/EditDataEntryForm.component.js: check-file: 0.189 sec.
[DEBUG] src/EditModel/EditDataSetSections.component.js: check-file: 0.072 sec.
[DEBUG] src/EditModel/EditModel.component.js: check-file: 0.014 sec.
[DEBUG] src/EditModel/EditModelContainer.component.js: check-file: 0.011 sec.
[DEBUG] src/EditModel/EditModelForm.component.js: check-file: 0.055 sec.
[DEBUG] src/EditModel/EditOptionSet.component.js: check-file: 0.026 sec.
[DEBUG] src/EditModel/FormActionButtons.js: check-file: 0.013 sec.
[DEBUG] src/EditModel/FormButtons.component.js: check-file: 0.01 sec.
[DEBUG] src/EditModel/FormHeading.js: check-file: 0.016 sec.
[DEBUG] src/EditModel/FormSubHeading.js: check-file: 0.011 sec.
[DEBUG] src/EditModel/GreyFieldDialog.component.js: check-file: 0.081 sec.
[DEBUG] src/EditModel/IndicatorExpressionManagerContainer.component.js: check-file: 0.016 sec.
[DEBUG] src/EditModel/OperatorButtons.component.js: check-file: 0.019 sec.
[DEBUG] src/EditModel/SaveButton.component.js: check-file: 0.009 sec.
[DEBUG] src/EditModel/SectionDialog.component.js: check-file: 0.064 sec.
[DEBUG] src/EditModel/SharingNotification.component.js: check-file: 0.015 sec.
[DEBUG] src/EditModel/SingleModelStore.js: check-file: 0.031 sec.
[DEBUG] src/EditModel/__tests__/actions.spec.js: check-file: 0.008 sec.
[DEBUG] src/EditModel/actions.js: check-file: 0.007 sec.
[DEBUG] src/EditModel/componentHelpers.js: check-file: 0.011 sec.
[DEBUG] src/EditModel/data-element/DataElementGroupsAssignment.component.js: check-file: 0.024 sec.
[DEBUG] src/EditModel/data-element/dataElementGroupsStore.js: check-file: 0.007 sec.
[DEBUG] src/EditModel/epicHelpers.js: check-file: 0.024 sec.
[DEBUG] src/EditModel/event-program/EditEventProgram.component.js: check-file: 0.017 sec.
[DEBUG] src/EditModel/event-program/EditProgram.component.js: check-file: 0.016 sec.
[DEBUG] src/EditModel/event-program/EventActionButtons.js: check-file: 0.012 sec.
[DEBUG] src/EditModel/event-program/EventProgramStepper.js: check-file: 0.011 sec.
[DEBUG] src/EditModel/event-program/EventProgramStepperContent.js: check-file: 0.024 sec.
[DEBUG] src/EditModel/event-program/__tests__/actions.spec.js: check-file: 0.022 sec.
[DEBUG] src/EditModel/event-program/__tests__/eventProgramStore.spec.js: check-file: 0.031 sec.
[DEBUG] src/EditModel/event-program/__tests__/metadataimport-helpers.spec.js: check-file: 0.026 sec.
[DEBUG] src/EditModel/event-program/__tests__/reducers.spec.js: check-file: 0.023 sec.
[DEBUG] src/EditModel/event-program/__tests__/selectors.spec.js: check-file: 0.008 sec.
[DEBUG] src/EditModel/event-program/actions.js: check-file: 0.012 sec.
[DEBUG] src/EditModel/event-program/assign-data-elements/AssignDataElements.js: check-file: 0.044 sec.
[DEBUG] src/EditModel/event-program/assign-data-elements/__tests__/actions.spec.js: check-file: 0.023 sec.
[DEBUG] src/EditModel/event-program/assign-data-elements/__tests__/epics.spec.js: check-file: 0.07 sec.
[DEBUG] src/EditModel/event-program/assign-data-elements/actions.js: check-file: 0.011 sec.
[DEBUG] src/EditModel/event-program/assign-data-elements/epics.js: check-file: 0.025 sec.
[DEBUG] src/EditModel/event-program/create-data-entry-form/ActionButton.component.js: check-file: 0.008 sec.
[DEBUG] src/EditModel/event-program/create-data-entry-form/AddOrEditSection.component.js: check-file: 0.025 sec.
[DEBUG] src/EditModel/event-program/create-data-entry-form/CreateDataEntryForm.component.js: check-file: 0.032 sec.
[DEBUG] src/EditModel/event-program/create-data-entry-form/CustomForm.component.js: check-file: 0.007 sec.
[DEBUG] src/EditModel/event-program/create-data-entry-form/DataElementPicker.component.js: check-file: 0.016 sec.
[DEBUG] src/EditModel/event-program/create-data-entry-form/DefaultForm.component.js: check-file: 0.009 sec.
[DEBUG] src/EditModel/event-program/create-data-entry-form/DragHandle.component.js: check-file: 0.009 sec.
[DEBUG] src/EditModel/event-program/create-data-entry-form/Section.component.js: check-file: 0.026 sec.
[DEBUG] src/EditModel/event-program/create-data-entry-form/SectionForm.component.js: check-file: 0.032 sec.
[DEBUG] src/EditModel/event-program/create-data-entry-form/SectionList.component.js: check-file: 0.013 sec.
[DEBUG] src/EditModel/event-program/create-data-entry-form/SortableDataList.component.js: check-file: 0.014 sec.
[DEBUG] src/EditModel/event-program/create-data-entry-form/SortableSectionDataList.component.js: check-file: 0.015 sec.
[DEBUG] src/EditModel/event-program/create-data-entry-form/actions.js: check-file: 0.009 sec.
[DEBUG] src/EditModel/event-program/create-data-entry-form/epics.js: check-file: 0.029 sec.
[DEBUG] src/EditModel/event-program/create-data-entry-form/selectors.js: check-file: 0.009 sec.
[DEBUG] src/EditModel/event-program/data-entry-form/CKEditor.js: check-file: 0.017 sec.
[DEBUG] src/EditModel/event-program/data-entry-form/EditCustomFormProgramStage.js: check-file: 0.05 sec.
[DEBUG] src/EditModel/event-program/data-entry-form/EditCustomRegistrationForm.js: check-file: 0.044 sec.
[DEBUG] src/EditModel/event-program/data-entry-form/PaletteSection.js: check-file: 0.013 sec.
[DEBUG] src/EditModel/event-program/data-entry-form/__tests__/dataEntryFormUtils.spec.js: check-file: 0.011 sec.
[DEBUG] src/EditModel/event-program/data-entry-form/actions.js: check-file: 0.011 sec.
[DEBUG] src/EditModel/event-program/data-entry-form/dataEntryFormUtils.js: check-file: 0.033 sec.
[DEBUG] src/EditModel/event-program/data-entry-form/epics.js: check-file: 0.031 sec.
[DEBUG] src/EditModel/event-program/epics.js: check-file: 0.066 sec.
[DEBUG] src/EditModel/event-program/event-program-steps.js: check-file: 0.01 sec.
[DEBUG] src/EditModel/event-program/eventProgramStore.js: check-file: 0.035 sec.
[DEBUG] src/EditModel/event-program/metadataimport-helpers.js: check-file: 0.012 sec.
[DEBUG] src/EditModel/event-program/notifications/DeletingMessage.js: check-file: 0.009 sec.
[DEBUG] src/EditModel/event-program/notifications/EventProgramDeletionNotification.js: check-file: 0.009 sec.
[DEBUG] src/EditModel/event-program/notifications/EventProgramNotifications.js: check-file: 0.016 sec.
[DEBUG] src/EditModel/event-program/notifications/NotificationDeleteDialog.js: check-file: 0.015 sec.
[DEBUG] src/EditModel/event-program/notifications/NotificationDialog.js: check-file: 0.034 sec.
[DEBUG] src/EditModel/event-program/notifications/NotificationList.js: check-file: 0.013 sec.
[DEBUG] src/EditModel/event-program/notifications/NotificationSteps.js: check-file: 0.028 sec.
[DEBUG] src/EditModel/event-program/notifications/TrackerNotificationAddButton.js: check-file: 0.012 sec.
[DEBUG] src/EditModel/event-program/notifications/TrackerProgramNotifications.js: check-file: 0.027 sec.
[DEBUG] src/EditModel/event-program/notifications/actions.js: check-file: 0.014 sec.
[DEBUG] src/EditModel/event-program/notifications/epics.js: check-file: 0.035 sec.
[DEBUG] src/EditModel/event-program/notifications/reducers.js: check-file: 0.012 sec.
[DEBUG] src/EditModel/event-program/notifications/selectors.js: check-file: 0.018 sec.
[DEBUG] src/EditModel/event-program/program-access/ProgramAccess.js: check-file: 0.011 sec.
[DEBUG] src/EditModel/event-program/program-access/ProgramStagesAccess.js: check-file: 0.042 sec.
[DEBUG] src/EditModel/event-program/program-access/Toolbar.js: check-file: 0.01 sec.
[DEBUG] src/EditModel/event-program/program-access/utils.js: check-file: 0.022 sec.
[DEBUG] src/EditModel/event-program/reducers.js: check-file: 0.019 sec.
[DEBUG] src/EditModel/event-program/render-types.js: check-file: 0.036 sec.
[DEBUG] src/EditModel/event-program/selectors.js: check-file: 0.008 sec.
[DEBUG] src/EditModel/event-program/tracker-program/CustomRegistrationForm.js: check-file: 0.014 sec.
[DEBUG] src/EditModel/event-program/tracker-program/EditTrackerProgram.js: check-file: 0.012 sec.
[DEBUG] src/EditModel/event-program/tracker-program/EnrollmentStep.js: check-file: 0.011 sec.
[DEBUG] src/EditModel/event-program/tracker-program/TrackerProgramStepper.js: check-file: 0.009 sec.
[DEBUG] src/EditModel/event-program/tracker-program/TrackerProgramStepperContent.js: check-file: 0.017 sec.
[DEBUG] src/EditModel/event-program/tracker-program/assign-tracked-entity-attributes/AssignAttributes.js: check-file: 0.042 sec.
[DEBUG] src/EditModel/event-program/tracker-program/assign-tracked-entity-attributes/actions.js: check-file: 0.01 sec.
[DEBUG] src/EditModel/event-program/tracker-program/assign-tracked-entity-attributes/epics.js: check-file: 0.027 sec.
[DEBUG] src/EditModel/event-program/tracker-program/epics.js: check-file: 0.035 sec.
[DEBUG] src/EditModel/event-program/tracker-program/program-stages/AssignProgramStageDataElements.js: check-file: 0.009 sec.
[DEBUG] src/EditModel/event-program/tracker-program/program-stages/EditProgramStage.js: check-file: 0.012 sec.
[DEBUG] src/EditModel/event-program/tracker-program/program-stages/EditProgramStageDetails.js: check-file: 0.011 sec.
[DEBUG] src/EditModel/event-program/tracker-program/program-stages/ProgramStage.js: check-file: 0.011 sec.
[DEBUG] src/EditModel/event-program/tracker-program/program-stages/ProgramStageList.js: check-file: 0.032 sec.
[DEBUG] src/EditModel/event-program/tracker-program/program-stages/ProgramStageStepper.js: check-file: 0.012 sec.
[DEBUG] src/EditModel/event-program/tracker-program/program-stages/__tests__/programStageReducer.spec.js: check-file: 0.018 sec.
[DEBUG] src/EditModel/event-program/tracker-program/program-stages/actions.js: check-file: 0.014 sec.
[DEBUG] src/EditModel/event-program/tracker-program/program-stages/contextActions.js: check-file: 0.01 sec.
[DEBUG] src/EditModel/event-program/tracker-program/program-stages/programStageSteps.js: check-file: 0.008 sec.
[DEBUG] src/EditModel/event-program/tracker-program/program-stages/reducer.js: check-file: 0.009 sec.
[DEBUG] src/EditModel/event-program/tracker-program/program-stages/selectors.js: check-file: 0.01 sec.
[DEBUG] src/EditModel/event-program/tracker-program/program-stages/utils.js: check-file: 0.011 sec.
[DEBUG] src/EditModel/event-program/tracker-program/tracker-program-steps.js: check-file: 0.009 sec.
[DEBUG] src/EditModel/extraFields.js: check-file: 0.019 sec.
[DEBUG] src/EditModel/form-helpers/extractFirstErrorMessageFromServer.js: check-file: 0.008 sec.
[DEBUG] src/EditModel/form-helpers/fieldChecks.js: check-file: 0.007 sec.
[DEBUG] src/EditModel/form-helpers/schemaFieldConfigCreator.js: check-file: 0.017 sec.
[DEBUG] src/EditModel/form-helpers/schemaFormCreator.js: check-file: 0.011 sec.
[DEBUG] src/EditModel/form-helpers/validateFields.js: check-file: 0.014 sec.
[DEBUG] src/EditModel/form-rules/index.js: check-file: 0.027 sec.
[DEBUG] src/EditModel/formHelpers.js: check-file: 0.04 sec.
[DEBUG] src/EditModel/indicatorGroupsStore.js: check-file: 0.006 sec.
[DEBUG] src/EditModel/modelToEditStore.js: check-file: 0.006 sec.
[DEBUG] src/EditModel/objectActions.js: check-file: 0.07 sec.
[DEBUG] src/EditModel/option-set/OptionDialogForOptions/AddOptionDialog.component.js: check-file: 0.024 sec.
[DEBUG] src/EditModel/option-set/OptionDialogForOptions/OptionDialogForOptions.component.js: check-file: 0.015 sec.
[DEBUG] src/EditModel/option-set/OptionDialogForOptions/createUniqueOptionValidators.js: check-file: 0.011 sec.
[DEBUG] src/EditModel/option-set/OptionManagement.component.js: check-file: 0.034 sec.
[DEBUG] src/EditModel/option-set/OptionSorter/OptionSorter.component.js: check-file: 0.039 sec.
[DEBUG] src/EditModel/option-set/OptionSorter/OptionValue.component.js: check-file: 0.009 sec.
[DEBUG] src/EditModel/option-set/OptionSorter/SortDialog.component.js: check-file: 0.03 sec.
[DEBUG] src/EditModel/option-set/OptionSorter/optionSorter.js: check-file: 0.011 sec.
[DEBUG] src/EditModel/option-set/actions.js: check-file: 0.029 sec.
[DEBUG] src/EditModel/option-set/stores.js: check-file: 0.008 sec.
[DEBUG] src/EditModel/stepper/ArrowStepper.js: check-file: 0.009 sec.
[DEBUG] src/EditModel/stepper/__tests__/stepIterator.spec.js: check-file: 0.011 sec.
[DEBUG] src/EditModel/stepper/__tests__/stepper.spec.js: check-file: 0.036 sec.
[DEBUG] src/EditModel/stepper/stepIterator.js: check-file: 0.011 sec.
[DEBUG] src/EditModel/stepper/stepper.actions.js: check-file: 0.008 sec.
[DEBUG] src/EditModel/stepper/stepper.js: check-file: 0.024 sec.
[DEBUG] src/GroupEditor/GroupEditor.component.js: check-file: 0.008 sec.
[DEBUG] src/GroupEditor/GroupsForItemManager.component.js: check-file: 0.03 sec.
[DEBUG] src/GroupEditor/ItemSelector.component.js: check-file: 0.012 sec.
[DEBUG] src/GroupEditor/ItemsInGroupManager.component.js: check-file: 0.03 sec.
[DEBUG] src/GroupEditor/ModelTypeSelector.component.js: check-file: 0.013 sec.
[DEBUG] src/List/ContextActions.js: check-file: 0.044 sec.
[DEBUG] src/List/ContextMenuHeader.js: check-file: 0.014 sec.
[DEBUG] src/List/DetailsBox.component.js: check-file: 0.022 sec.
[DEBUG] src/List/DetailsBoxWithScroll.component.js: check-file: 0.013 sec.
[DEBUG] src/List/DownloadObjectDialog.js: check-file: 0.02 sec.
[DEBUG] src/List/HelpLink.component.js: check-file: 0.016 sec.
[DEBUG] src/List/List.component.js: check-file: 0.089 sec.
[DEBUG] src/List/ListActionBar.component.js: check-file: 0.017 sec.
[DEBUG] src/List/LoadingStatus.component.js: check-file: 0.007 sec.
[DEBUG] src/List/SearchBox.component.js: check-file: 0.015 sec.
[DEBUG] src/List/columns/AvailableColumnsList.js: check-file: 0.01 sec.
[DEBUG] src/List/columns/ColumnConfigDialog.js: check-file: 0.034 sec.
[DEBUG] src/List/columns/SortableColumns.js: check-file: 0.017 sec.
[DEBUG] src/List/columns/actions.js: check-file: 0.01 sec.
[DEBUG] src/List/columns/epics.js: check-file: 0.023 sec.
[DEBUG] src/List/columns/reducers.js: check-file: 0.012 sec.
[DEBUG] src/List/columns/selectors.js: check-file: 0.008 sec.
[DEBUG] src/List/compulsory-data-elements-dialog/CompulsoryDataElementOperandDialog.component.js: check-file: 0.04 sec.
[DEBUG] src/List/compulsory-data-elements-dialog/compulsoryDataElementStore.js: check-file: 0.008 sec.
[DEBUG] src/List/details.store.js: check-file: 0.005 sec.
[DEBUG] src/List/helpers/pagination.js: check-file: 0.011 sec.
[DEBUG] src/List/list.actions.js: check-file: 0.04 sec.
[DEBUG] src/List/list.store.js: check-file: 0.013 sec.
[DEBUG] src/List/listValueRenderers.js: check-file: 0.013 sec.
[DEBUG] src/List/organisation-unit-list/OrganisationUnitList.component.js: check-file: 0.021 sec.
[DEBUG] src/List/predictor-dialog/PredictorDialog.component.js: check-file: 0.024 sec.
[DEBUG] src/List/predictor-dialog/predictorDialogStore.js: check-file: 0.008 sec.
[DEBUG] src/List/sharing.store.js: check-file: 0.006 sec.
[DEBUG] src/List/translation-dialog/translationStore.js: check-file: 0.007 sec.
[DEBUG] src/MenuCards/MenuCards.component.js: check-file: 0.013 sec.
[DEBUG] src/MenuCards/MenuCardsForAllSections.component.js: check-file: 0.01 sec.
[DEBUG] src/MenuCards/MenuCardsForSection.component.js: check-file: 0.013 sec.
[DEBUG] src/MenuCards/menuCardsStore.js: check-file: 0.01 sec.
[DEBUG] src/OrganisationUnitHierarchy/OrganisationUnitHierarchy.component.js: check-file: 0.052 sec.
[DEBUG] src/OrganisationUnitHierarchy/index.js: check-file: 0.01 sec.
[DEBUG] src/OrganisationUnitHierarchy/searchForOrganisationUnitsWithinHierarchy.js: check-file: 0.008 sec.
[DEBUG] src/OrganisationUnitLevels/OrganisationUnitLevels.component.js: check-file: 0.029 sec.
[DEBUG] src/OrganisationUnitLevels/organisationUnitLevels.actions.js: check-file: 0.034 sec.
[DEBUG] src/OrganisationUnitLevels/organisationUnitLevels.store.js: check-file: 0.006 sec.
[DEBUG] src/OrganisationUnitTree/OrganisationUnitTreeWithSingleSelectionAndSearch.component.js: check-file: 0.013 sec.
[DEBUG] src/SideBar/MaintenanceSidebar.component.js: check-file: 0.009 sec.
[DEBUG] src/SideBar/SideBarContainer.component.js: check-file: 0.023 sec.
[DEBUG] src/SideBar/sideBarActions.js: check-file: 0.016 sec.
[DEBUG] src/SideBar/sideBarStore.js: check-file: 0.014 sec.
[DEBUG] src/Snackbar/SnackbarContainer.component.js: check-file: 0.011 sec.
[DEBUG] src/Snackbar/epics.js: check-file: 0.009 sec.
[DEBUG] src/Snackbar/snack.actions.js: check-file: 0.009 sec.
[DEBUG] src/Snackbar/snack.store.js: check-file: 0.005 sec.
[DEBUG] src/Snackbar/snackBarUtils.js: check-file: 0.008 sec.
[DEBUG] src/SqlView/SqlView.component.js: check-file: 0.026 sec.
[DEBUG] src/SqlView/index.js: check-file: 0.005 sec.
[DEBUG] src/TopBar/SectionTabs.component.js: check-file: 0.014 sec.
[DEBUG] src/TopBar/TopBarButtons.component.js: check-file: 0.012 sec.
[DEBUG] src/__fixtures__/fixtureUpdater.js: check-file: 0.018 sec.
[DEBUG] src/config/custom-models/index.js: check-file: 0.008 sec.
[DEBUG] src/config/custom-models/locale/LocaleModelDefinition.js: check-file: 0.016 sec.
[DEBUG] src/config/custom-models/locale/index.js: check-file: 0.007 sec.
[DEBUG] src/config/custom-models/locale/localeSchemaDefinition.js: check-file: 0.014 sec.
[DEBUG] src/config/disabled-on-edit/category.js: check-file: 0.006 sec.
[DEBUG] src/config/disabled-on-edit/categoryCombo.js: check-file: 0.005 sec.
[DEBUG] src/config/disabled-on-edit/categoryOptionCombo.js: check-file: 0.005 sec.
[DEBUG] src/config/disabled-on-edit/categoryOptionGroup.js: check-file: 0.005 sec.
[DEBUG] src/config/disabled-on-edit/categoryOptionGroupSet.js: check-file: 0.005 sec.
[DEBUG] src/config/disabled-on-edit/index.js: check-file: 0.009 sec.
[DEBUG] src/config/disabled-on-edit/optionGroup.js: check-file: 0.005 sec.
[DEBUG] src/config/disabled-on-edit/optionGroupSet.js: check-file: 0.005 sec.
[DEBUG] src/config/disabled-on-edit/optionSet.js: check-file: 0.006 sec.
[DEBUG] src/config/disabled-on-edit/programRule.js: check-file: 0.005 sec.
[DEBUG] src/config/field-config/field-defaults.js: check-file: 0.008 sec.
[DEBUG] src/config/field-config/field-groups.js: check-file: 0.016 sec.
[DEBUG] src/config/field-config/field-order.js: check-file: 0.02 sec.
[DEBUG] src/config/field-overrides/attribute/AttributeAssignment.js: check-file: 0.018 sec.
[DEBUG] src/config/field-overrides/attribute.js: check-file: 0.008 sec.
[DEBUG] src/config/field-overrides/categoryCombo.js: check-file: 0.009 sec.
[DEBUG] src/config/field-overrides/categoryOption.js: check-file: 0.009 sec.
[DEBUG] src/config/field-overrides/data-set/DataInputPeriods.component.js: check-file: 0.054 sec.
[DEBUG] src/config/field-overrides/data-set/DataSetElementCategoryComboSelectionDialog.component.js: check-file: 0.023 sec.
[DEBUG] src/config/field-overrides/data-set/DataSetElementField.component.js: check-file: 0.035 sec.
[DEBUG] src/config/field-overrides/data-set/DataSetElementList.component.js: check-file: 0.022 sec.
[DEBUG] src/config/field-overrides/data-set-notification-template/DataSetNotificationSubjectAndMessageTemplateFields.js: check-file: 0.008 sec.
[DEBUG] src/config/field-overrides/data-set-notification-template/RecipentUserGroup.js: check-file: 0.007 sec.
[DEBUG] src/config/field-overrides/dataApprovalLevel.js: check-file: 0.007 sec.
[DEBUG] src/config/field-overrides/dataApprovalWorkflow.js: check-file: 0.006 sec.
[DEBUG] src/config/field-overrides/dataElement.js: check-file: 0.006 sec.
[DEBUG] src/config/field-overrides/dataSet.js: check-file: 0.009 sec.
[DEBUG] src/config/field-overrides/dataSetNotificationTemplate.js: check-file: 0.007 sec.
[DEBUG] src/config/field-overrides/eventProgramStage.js: check-file: 0.006 sec.
[DEBUG] src/config/field-overrides/externalMapLayer.js: check-file: 0.01 sec.
[DEBUG] src/config/field-overrides/helpers/SubFieldWrap.js: check-file: 0.007 sec.
[DEBUG] src/config/field-overrides/helpers/constantNameConverter.js: check-file: 0.008 sec.
[DEBUG] src/config/field-overrides/helpers/switchOnBoolean.js: check-file: 0.008 sec.
[DEBUG] src/config/field-overrides/helpers/withSkipLogic.js: check-file: 0.007 sec.
[DEBUG] src/config/field-overrides/index.js: check-file: 0.015 sec.
[DEBUG] src/config/field-overrides/indicator.js: check-file: 0.006 sec.
[DEBUG] src/config/field-overrides/legendSet.js: check-file: 0.014 sec.
[DEBUG] src/config/field-overrides/locale/LocaleCountryDropDown.component.js: check-file: 0.007 sec.
[DEBUG] src/config/field-overrides/locale/LocaleDropDown.component.js: check-file: 0.009 sec.
[DEBUG] src/config/field-overrides/locale/LocaleLanguageDropDown.component.js: check-file: 0.006 sec.
[DEBUG] src/config/field-overrides/locale.js: check-file: 0.006 sec.
[DEBUG] src/config/field-overrides/optionGroup.js: check-file: 0.013 sec.
[DEBUG] src/config/field-overrides/optionGroupSet.js: check-file: 0.006 sec.
[DEBUG] src/config/field-overrides/organisationUnit.js: check-file: 0.009 sec.
[DEBUG] src/config/field-overrides/organisationUnitGroup.js: check-file: 0.013 sec.
[DEBUG] src/config/field-overrides/predictor.js: check-file: 0.023 sec.
[DEBUG] src/config/field-overrides/program-indicator/AnalyticsPeriodBoundaries.js: check-file: 0.025 sec.
[DEBUG] src/config/field-overrides/program-indicator/AttributeSelector.js: check-file: 0.009 sec.
[DEBUG] src/config/field-overrides/program-indicator/CollapsibleList.js: check-file: 0.009 sec.
[DEBUG] src/config/field-overrides/program-indicator/CollapsibleLists.js: check-file: 0.007 sec.
[DEBUG] src/config/field-overrides/program-indicator/ConstantSelector.js: check-file: 0.009 sec.
[DEBUG] src/config/field-overrides/program-indicator/DataElementSelectors.js: check-file: 0.014 sec.
[DEBUG] src/config/field-overrides/program-indicator/ExpressionFormulaWithErrorMessage.js: check-file: 0.009 sec.
[DEBUG] src/config/field-overrides/program-indicator/ExpressionStatusIcon.js: check-file: 0.011 sec.
[DEBUG] src/config/field-overrides/program-indicator/HelpText.js: check-file: 0.01 sec.
[DEBUG] src/config/field-overrides/program-indicator/ProgramIndicatorExpression.js: check-file: 0.016 sec.
[DEBUG] src/config/field-overrides/program-indicator/VariableSelector.js: check-file: 0.014 sec.
[DEBUG] src/config/field-overrides/program-indicator/createExpressionValidator.js: check-file: 0.015 sec.
[DEBUG] src/config/field-overrides/program-indicator/enums.js: check-file: 0.006 sec.
[DEBUG] src/config/field-overrides/program-notification-template/DeliveryChannels.js: check-file: 0.009 sec.
[DEBUG] src/config/field-overrides/program-notification-template/RelativeScheduledDays.js: check-file: 0.014 sec.
[DEBUG] src/config/field-overrides/program-rules/programRuleActionDialog.component.js: check-file: 0.063 sec.
[DEBUG] src/config/field-overrides/program-rules/programRuleActionList.component.js: check-file: 0.064 sec.
[DEBUG] src/config/field-overrides/program-rules/programRuleActionTypes.js: check-file: 0.024 sec.
[DEBUG] src/config/field-overrides/program-rules/programRuleBuiltInVariables.js: check-file: 0.006 sec.
[DEBUG] src/config/field-overrides/program-rules/programRuleConditionField.component.js: check-file: 0.037 sec.
[DEBUG] src/config/field-overrides/program-rules/programRuleFunctions.js: check-file: 0.007 sec.
[DEBUG] src/config/field-overrides/program-rules/programRuleProgramStage.js: check-file: 0.014 sec.
[DEBUG] src/config/field-overrides/program.js: check-file: 0.011 sec.
[DEBUG] src/config/field-overrides/programIndicator.js: check-file: 0.012 sec.
[DEBUG] src/config/field-overrides/programNotificationTemplate.js: check-file: 0.02 sec.
[DEBUG] src/config/field-overrides/programRule.js: check-file: 0.008 sec.
[DEBUG] src/config/field-overrides/programRuleVariable.js: check-file: 0.02 sec.
[DEBUG] src/config/field-overrides/programStage.js: check-file: 0.008 sec.
[DEBUG] src/config/field-overrides/pushAnalysis.js: check-file: 0.013 sec.
[DEBUG] src/config/field-overrides/relationshipType.js: check-file: 0.033 sec.
[DEBUG] src/config/field-overrides/sharedFields.js: check-file: 0.009 sec.
[DEBUG] src/config/field-overrides/sql-query/index.js: check-file: 0.007 sec.
[DEBUG] src/config/field-overrides/sqlView.js: check-file: 0.006 sec.
[DEBUG] src/config/field-overrides/tracked-entity-attribute/ConfidentialField.js: check-file: 0.007 sec.
[DEBUG] src/config/field-overrides/tracked-entity-attribute/InfoMessage.js: check-file: 0.008 sec.
[DEBUG] src/config/field-overrides/tracked-entity-attribute/OrgUnitScopeDropDown.js: check-file: 0.014 sec.
[DEBUG] src/config/field-overrides/tracked-entity-type/AssignTrackedEntityTypeAttributes.component.js: check-file: 0.029 sec.
[DEBUG] src/config/field-overrides/trackedEntityAttribute.js: check-file: 0.012 sec.
[DEBUG] src/config/field-overrides/trackedEntityType.js: check-file: 0.006 sec.
[DEBUG] src/config/field-overrides/validation-notification-template/SubjectAndMessageTemplateFields.js: check-file: 0.018 sec.
[DEBUG] src/config/field-overrides/validation-notification-template/VariableList.js: check-file: 0.014 sec.
[DEBUG] src/config/field-overrides/validation-rules/LeftSideExpressionField.js: check-file: 0.006 sec.
[DEBUG] src/config/field-overrides/validation-rules/MissingValueStrategy.js: check-file: 0.009 sec.
[DEBUG] src/config/field-overrides/validation-rules/RightSideExpressionField.js: check-file: 0.007 sec.
[DEBUG] src/config/field-overrides/validation-rules/SlidingWindow.js: check-file: 0.007 sec.
[DEBUG] src/config/field-overrides/validation-rules/ValidationRuleExpressionDialog.js: check-file: 0.015 sec.
[DEBUG] src/config/field-overrides/validation-rules/ValidationRuleExpressionField.js: check-file: 0.011 sec.
[DEBUG] src/config/field-overrides/validationNotificationTemplate.js: check-file: 0.008 sec.
[DEBUG] src/config/field-overrides/validationRule.js: check-file: 0.007 sec.
[DEBUG] src/config/field-rules.js: check-file: 0.045 sec.
[DEBUG] src/config/maintenance-models.js: check-file: 0.024 sec.
[DEBUG] src/forms/FormFieldsForModel.js: check-file: 0.023 sec.
[DEBUG] src/forms/FormFieldsManager.js: check-file: 0.01 sec.
[DEBUG] src/forms/__tests__/getMissingValuesForModelName.spec.js: check-file: 0.007 sec.
[DEBUG] src/forms/addRequiredIndicatorIfRequired.js: check-file: 0.006 sec.
[DEBUG] src/forms/fields.js: check-file: 0.024 sec.
[DEBUG] src/forms/form-fields/attribute-row.js: check-file: 0.012 sec.
[DEBUG] src/forms/form-fields/check-box.js: check-file: 0.012 sec.
[DEBUG] src/forms/form-fields/color-picker.js: check-file: 0.01 sec.
[DEBUG] src/forms/form-fields/coordinate-field.js: check-file: 0.02 sec.
[DEBUG] src/forms/form-fields/date-select.js: check-file: 0.014 sec.
[DEBUG] src/forms/form-fields/drop-down-async-getter.js: check-file: 0.015 sec.
[DEBUG] src/forms/form-fields/drop-down-async.js: check-file: 0.042 sec.
[DEBUG] src/forms/form-fields/drop-down.js: check-file: 0.04 sec.
[DEBUG] src/forms/form-fields/helpers/ColorPicker.js: check-file: 0.028 sec.
[DEBUG] src/forms/form-fields/helpers/FieldWrapper.js: check-file: 0.008 sec.
[DEBUG] src/forms/form-fields/helpers/IconPickerDialog/Icon.js: check-file: 0.011 sec.
[DEBUG] src/forms/form-fields/helpers/IconPickerDialog/IconPickerDialog.js: check-file: 0.032 sec.
[DEBUG] src/forms/form-fields/helpers/IconPickerDialog/filterIcons.js: check-file: 0.01 sec.
[DEBUG] src/forms/form-fields/helpers/IconPickerDialog/index.js: check-file: 0.007 sec.
[DEBUG] src/forms/form-fields/helpers/QuickAddLink.component.js: check-file: 0.014 sec.
[DEBUG] src/forms/form-fields/helpers/RefreshMask.component.js: check-file: 0.015 sec.
[DEBUG] src/forms/form-fields/icon-picker.js: check-file: 0.012 sec.
[DEBUG] src/forms/form-fields/multi-select.js: check-file: 0.044 sec.
[DEBUG] src/forms/form-fields/multi-toggle.js: check-file: 0.015 sec.
[DEBUG] src/forms/form-fields/orgunit-select-dialog-field.js: check-file: 0.016 sec.
[DEBUG] src/forms/form-fields/orgunit-tree-multi-select.js: check-file: 0.031 sec.
[DEBUG] src/forms/form-fields/period-type-drop-down.js: check-file: 0.008 sec.
[DEBUG] src/forms/form-fields/style-field.js: check-file: 0.011 sec.
[DEBUG] src/forms/form-fields/text-editor-field.js: check-file: 0.014 sec.
[DEBUG] src/forms/form-fields/text-field.js: check-file: 0.015 sec.
[DEBUG] src/forms/getMissingValuesForModelName.js: check-file: 0.014 sec.
[DEBUG] src/forms/mui-theme.mixin.js: check-file: 0.008 sec.
[DEBUG] src/loading-mask/LoadingMask.component.js: check-file: 0.006 sec.
[DEBUG] src/maintenance.js: check-file: 0.017 sec.
[DEBUG] src/router-utils.js: check-file: 0.009 sec.
[DEBUG] src/router.js: check-file: 0.032 sec.
[DEBUG] src/store.js: check-file: 0.01 sec.
[DEBUG] src/translationRegistration.js: check-file: 0.008 sec.
[DEBUG] src/utils/Auth.js: check-file: 0.009 sec.
[DEBUG] src/utils/LoadableComponent.js: check-file: 0.013 sec.
[DEBUG] src/utils/ObservedEvents.mixin.js: check-file: 0.012 sec.
[DEBUG] src/utils/ObserverRegistry.mixin.js: check-file: 0.007 sec.
[DEBUG] webpack.config.js: check-file: 0.021 sec.
[DEBUG] 356 file(s): check-all-files: 6.959 sec.

@varl varl marked this pull request as ready for review April 21, 2019 08:53
@varl
Copy link
Contributor Author

varl commented Apr 21, 2019

@amcgee This is ready for review.

@amcgee
Copy link
Member

amcgee commented Apr 23, 2019

apply --all correctly fixes the violation, but I get this (note the violations count still reads 0 even though it was corrected in the fix stage):

[DEBUG] Root directory: /Users/awm/dev/dhis2/cli/style
[DEBUG] Files to operate on:
/Users/awm/dev/dhis2/cli/style/.prettierrc.js,/Users/awm/dev/dhis2/cli/style/config/commitlint.config.js,/Users/awm/dev/dhis2/cli/style/config/eslint.config.js,/Users/awm/dev/dhis2/cli/style/config/prettier.config.js,/Users/awm/dev/dhis2/cli/style/index.js,/Users/awm/dev/dhis2/cli/style/src/cmds/commit_cmds/check.js,/Users/awm/dev/dhis2/cli/style/src/cmds/git-commit.js,/Users/awm/dev/dhis2/cli/style/src/cmds/javascript.js,/Users/awm/dev/dhis2/cli/style/src/cmds/js_cmds/apply.js,/Users/awm/dev/dhis2/cli/style/src/cmds/js_cmds/check.js,/Users/awm/dev/dhis2/cli/style/src/cmds/js_cmds/install.js,/Users/awm/dev/dhis2/cli/style/src/cmds.js,/Users/awm/dev/dhis2/cli/style/src/config.js,/Users/awm/dev/dhis2/cli/style/src/files.js,/Users/awm/dev/dhis2/cli/style/src/tools/git/commitlint.js,/Users/awm/dev/dhis2/cli/style/src/tools/git/index.js,/Users/awm/dev/dhis2/cli/style/src/tools/js/eslint.js,/Users/awm/dev/dhis2/cli/style/src/tools/js/index.js,/Users/awm/dev/dhis2/cli/style/src/tools/js/prettier.js
[DEBUG] .prettierrc.js: exec-file: 0.23 sec.
[DEBUG] config/commitlint.config.js: exec-file: 0.01 sec.
[DEBUG] config/eslint.config.js: exec-file: 0.02 sec.
[DEBUG] config/prettier.config.js: exec-file: 0.011 sec.
[DEBUG] index.js: exec-file: 0.013 sec.
[DEBUG] src/cmds/commit_cmds/check.js: exec-file: 0.018 sec.
[DEBUG] src/cmds/git-commit.js: exec-file: 0.018 sec.
[DEBUG] src/cmds/javascript.js: exec-file: 0.011 sec.
[DEBUG] src/cmds/js_cmds/apply.js: exec-file: 0.03 sec.
[DEBUG] src/cmds/js_cmds/check.js: exec-file: 0.026 sec.
[DEBUG] src/cmds/js_cmds/install.js: exec-file: 0.013 sec.
[DEBUG] src/cmds.js: exec-file: 0.011 sec.
[DEBUG] src/config.js: exec-file: 0.038 sec.
[DEBUG] src/files.js: exec-file: 0.038 sec.
[DEBUG] src/tools/git/commitlint.js: exec-file: 0.025 sec.
[DEBUG] src/tools/git/index.js: exec-file: 0.02 sec.
[DEBUG] src/tools/js/eslint.js: exec-file: 0.019 sec.
[DEBUG] src/tools/js/index.js: exec-file: 0.054 sec.
[DEBUG] src/tools/js/prettier.js: exec-file: 0.019 sec.
[DEBUG] 19 file(s): exec-all-files: 0.631 sec.
[DEBUG] Violations: 0
19 file(s) pass the style checks.
[DEBUG] /Users/awm/dev/dhis2/cli/style/.prettierrc.js written successfully: true
[DEBUG] /Users/awm/dev/dhis2/cli/style/config/commitlint.config.js written successfully: true
[DEBUG] /Users/awm/dev/dhis2/cli/style/config/eslint.config.js written successfully: true
[DEBUG] /Users/awm/dev/dhis2/cli/style/config/prettier.config.js written successfully: true
[DEBUG] /Users/awm/dev/dhis2/cli/style/index.js written successfully: true
[DEBUG] /Users/awm/dev/dhis2/cli/style/src/cmds/commit_cmds/check.js written successfully: true
[DEBUG] /Users/awm/dev/dhis2/cli/style/src/cmds/git-commit.js written successfully: true
[DEBUG] /Users/awm/dev/dhis2/cli/style/src/cmds/javascript.js written successfully: true
[DEBUG] /Users/awm/dev/dhis2/cli/style/src/cmds/js_cmds/apply.js written successfully: true
[DEBUG] /Users/awm/dev/dhis2/cli/style/src/cmds/js_cmds/check.js written successfully: true
[DEBUG] /Users/awm/dev/dhis2/cli/style/src/cmds/js_cmds/install.js written successfully: true
[DEBUG] /Users/awm/dev/dhis2/cli/style/src/cmds.js written successfully: true
[DEBUG] /Users/awm/dev/dhis2/cli/style/src/config.js written successfully: true
[DEBUG] /Users/awm/dev/dhis2/cli/style/src/files.js written successfully: true
[DEBUG] /Users/awm/dev/dhis2/cli/style/src/tools/git/commitlint.js written successfully: true
[DEBUG] /Users/awm/dev/dhis2/cli/style/src/tools/git/index.js written successfully: true
[DEBUG] /Users/awm/dev/dhis2/cli/style/src/tools/js/eslint.js written successfully: true
[DEBUG] /Users/awm/dev/dhis2/cli/style/src/tools/js/index.js written successfully: true
[DEBUG] /Users/awm/dev/dhis2/cli/style/src/tools/js/prettier.js written successfully: true
19 file(s) automatically fixed.
[DEBUG] Staging /Users/awm/dev/dhis2/cli/style/.prettierrc.js...
[DEBUG] Staging /Users/awm/dev/dhis2/cli/style/config/commitlint.config.js...
[DEBUG] Staging /Users/awm/dev/dhis2/cli/style/config/eslint.config.js...
[DEBUG] Staging /Users/awm/dev/dhis2/cli/style/config/prettier.config.js...
[DEBUG] Staging /Users/awm/dev/dhis2/cli/style/index.js...
[DEBUG] Staging /Users/awm/dev/dhis2/cli/style/src/cmds/commit_cmds/check.js...
[DEBUG] Staging /Users/awm/dev/dhis2/cli/style/src/cmds/git-commit.js...
[DEBUG] Staging /Users/awm/dev/dhis2/cli/style/src/cmds/javascript.js...
[DEBUG] Staging /Users/awm/dev/dhis2/cli/style/src/cmds/js_cmds/apply.js...
[DEBUG] Staging /Users/awm/dev/dhis2/cli/style/src/cmds/js_cmds/check.js...
[DEBUG] Staging /Users/awm/dev/dhis2/cli/style/src/cmds/js_cmds/install.js...
[DEBUG] Staging /Users/awm/dev/dhis2/cli/style/src/cmds.js...
[DEBUG] Staging /Users/awm/dev/dhis2/cli/style/src/config.js...
[DEBUG] Staging /Users/awm/dev/dhis2/cli/style/src/files.js...
[DEBUG] Staging /Users/awm/dev/dhis2/cli/style/src/tools/git/commitlint.js...
[DEBUG] Staging /Users/awm/dev/dhis2/cli/style/src/tools/git/index.js...
[DEBUG] Staging /Users/awm/dev/dhis2/cli/style/src/tools/js/eslint.js...
[DEBUG] Staging /Users/awm/dev/dhis2/cli/style/src/tools/js/index.js...
[DEBUG] Staging /Users/awm/dev/dhis2/cli/style/src/tools/js/prettier.js...
Staged 19 file(s).

When only the single file was actually changed.

Also, maybe we should call report.summary something like report.summarize to make it clear it's a function and not a property?

@varl
Copy link
Contributor Author

varl commented Apr 23, 2019

@amcgee it's not reporting the style error because it can be automatically fixed. I've broken it during the refactor. Allow me to fix..

e: Fixed in 663c90a

@varl
Copy link
Contributor Author

varl commented Apr 23, 2019

@amcgee Ok try out the changes in 1527f8d. I've changed the response object from the tools to track if the source code has been modified or not, and only write and staged the files that were modified:

[varl@jessika src]$ ~/dev/dhis2/libs/cli-style/bin/d2-style js apply --all --verbose
[DEBUG] Root directory: /home/varl/dev/dhis2/libs/cli-style/src 
[DEBUG] Files to operate on:
...truncated....
[DEBUG] .prettierrc.js: exec-file: 0.054 sec. 
[DEBUG] cmds/commit_cmds/check.js: exec-file: 0.113 sec. 
[DEBUG] cmds/git-commit.js: exec-file: 0.012 sec. 
[DEBUG] cmds/javascript.js: exec-file: 0.016 sec. 
[DEBUG] cmds/js_cmds/apply.js: exec-file: 0.019 sec. 
[DEBUG] cmds/js_cmds/check.js: exec-file: 0.016 sec. 
[DEBUG] cmds/js_cmds/install.js: exec-file: 0.009 sec. 
[DEBUG] cmds.js: exec-file: 0.012 sec. 
[DEBUG] config.js: exec-file: 0.034 sec. 
[DEBUG] files.js: exec-file: 0.034 sec. 
[DEBUG] git-files.js: exec-file: 0.028 sec. 
[DEBUG] tools/git/commitlint.js: exec-file: 0.021 sec. 
[DEBUG] tools/git/index.js: exec-file: 0.011 sec. 
[DEBUG] tools/js/eslint.js: exec-file: 0.039 sec. 
[DEBUG] tools/js/index.js: exec-file: 0.04 sec. 
[DEBUG] tools/js/prettier.js: exec-file: 0.023 sec. 
[DEBUG] 16 file(s): exec-all-files: 0.488 sec. 
[DEBUG] Violations: 0 
16 file(s) pass the style checks. 
[DEBUG] 0 file(s) automatically fixed. 
Staged 0 file(s). 

@varl
Copy link
Contributor Author

varl commented Apr 23, 2019

ESLint strips out any violations that can be automatically applied from its report, so it is easier for us to align Prettier with this than the other way around.

Or, we have to run ESLint twice: one with fix: false so it reports the errors, then with fix: true so we can get the fixed source code. Then we can do the same with Prettier where we first run the check function to get any violations, and then the format function to get the modified source.

The reason I did not go this route is simply because it takes twice as long to run.

@varl
Copy link
Contributor Author

varl commented Apr 23, 2019

Also, maybe we should call report.summary something like report.summarize to make it clear it's a function and not a property?

Good idea, done in b99e55d

@varl
Copy link
Contributor Author

varl commented Apr 23, 2019

@amcgee This should give correct results now.

@varl varl requested a review from amcgee April 23, 2019 15:39
Copy link
Member

@amcgee amcgee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, nice work!

Added one minor comment to clean up logging in the --no-stage case. We may want to move all informational (non-debug) logging to the command file at some point, but for now i think this is fine.

src/cmds/js_cmds/apply.js Show resolved Hide resolved
@amcgee
Copy link
Member

amcgee commented Apr 24, 2019

LGTM!!

@varl varl merged commit 85cf53a into master Apr 24, 2019
@varl varl deleted the feat/eslint branch April 24, 2019 09:56
dhis2-bot pushed a commit that referenced this pull request Apr 24, 2019
# [3.1.0](v3.0.1...v3.1.0) (2019-04-24)

### Features

* add support for eslint for code style enforcement ([#33](#33)) ([85cf53a](85cf53a))
@dhis2-bot
Copy link
Contributor

🎉 This PR is included in version 3.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants