From ee8449aff3c8469e2bdc730c4a42aa446dccfe23 Mon Sep 17 00:00:00 2001 From: Dennis Kigen Date: Wed, 6 Sep 2023 17:05:29 +0300 Subject: [PATCH] (chore) Setup prettier --- .eslintrc.json | 25 +- .github/pull_request_template.md | 6 +- .github/workflows/main.yml | 22 +- .prettierrc | 4 +- README.md | 7 +- package.json | 11 +- projects/ngx-formentry/src/adult.json | 2 +- .../ngx-pick-datetime/sass/picker.scss | 110 +-- .../ngx-remote-select.component.ts | 2 +- .../number-input/number-input.module.ts | 2 +- .../radio-button/radio.component.html | 2 +- .../radio-button/radio.component.ts | 22 +- .../directives/historical-value.directive.ts | 2 +- .../src/form-entry/form-factory/form-node.ts | 6 +- .../form-factory/form.factory.spec.ts | 4 +- .../form-factory/validation.factory.ts | 8 +- .../historical-expression-helper-service.ts | 2 +- .../helpers/js-expression-helper.spec.ts | 32 +- .../helpers/js-expression-helper.ts | 55 +- .../form-entry/helpers/risk-dataset-table.ts | 70 +- .../interfaces/diagnosis-question-options.ts | 2 +- .../max-length-validation.model.ts | 4 +- .../min-length-validation.model.ts | 4 +- .../validators/max-length.validator.ts | 2 +- .../validators/min-length.validator.ts | 2 +- .../value-adapters/diagnosis.adapter.spec.ts | 86 +- .../value-adapters/diagnosis.adapter.ts | 136 ++- .../value-adapters/encounter.adapter.spec.ts | 26 +- .../value-adapters/encounter.adapter.ts | 19 +- .../value-adapters/obs-adapter-helper.ts | 8 +- .../patient-identifier.adapter.spec.ts | 190 ++-- .../patient-identifier.adapter.ts | 147 ++- projects/ngx-formentry/src/lib/index.ts | 2 +- .../ngx-formentry/styles/ngx-formentry.css | 2 +- proxy.conf.json | 10 +- src/app/adult-1.4.json | 10 +- src/app/app.component.ts | 25 +- src/app/mock/mock-translations.ts | 123 ++- src/app/mock/obs.json | 17 +- src/app/ncd-registration-1.0.json | 866 +++++++++--------- src/app/translate/translate.module.ts | 8 +- src/tsconfig.app.json | 17 +- tsconfig.json | 19 +- yarn.lock | 5 + 44 files changed, 1117 insertions(+), 1007 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 4afdb750..73f75258 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,24 +1,17 @@ { "root": true, - "ignorePatterns": [ - "projects/**/*", - "**/*.spec.ts" - ], + "ignorePatterns": ["projects/**/*", "**/*.spec.ts"], "overrides": [ { - "files": [ - "*.ts" - ], + "files": ["*.ts"], "parserOptions": { - "project": [ - "tsconfig.json", - "e2e/tsconfig.json" - ], + "project": ["tsconfig.json", "e2e/tsconfig.json"], "createDefaultProgram": true }, "extends": [ "plugin:@angular-eslint/recommended", - "plugin:@angular-eslint/template/process-inline-templates" + "plugin:@angular-eslint/template/process-inline-templates", + "prettier" ], "rules": { "@angular-eslint/component-selector": [ @@ -44,12 +37,8 @@ } }, { - "files": [ - "*.html" - ], - "extends": [ - "plugin:@angular-eslint/template/recommended" - ], + "files": ["*.html"], + "extends": ["plugin:@angular-eslint/template/recommended"], "rules": {} } ] diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index a8dfecb2..159bdbe3 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,18 +1,22 @@ -## Requirements +# Requirements - [ ] This PR has a title that briefly describes the work done, including the ticket number if there is a ticket. - [ ] My work conforms to the [OpenMRS 3.0 Styleguide](https://om.rs/styleguide) and [design documentation](https://zeroheight.com/23a080e38/p/880723-introduction). - [ ] My work includes tests or is validated by existing tests. ## Summary + ## Screenshots + ## Related Issue + ## Other + diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 20122360..73af817d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,9 +2,9 @@ name: Form Entry CI on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] release: types: - created @@ -18,8 +18,8 @@ jobs: - name: Use Node.js uses: actions/setup-node@v3 with: - node-version: "16" - cache: "npm" + node-version: '16' + cache: 'npm' - run: yarn install --frozen-lockfile - name: Setup a local cache server for Turborepo @@ -27,11 +27,11 @@ jobs: with: repo-token: ${{ secrets.GITHUB_TOKEN }} server-token: ${{ secrets.TURBO_SERVER_TOKEN }} - + - name: Run lint run: yarn turbo lint --color --concurrency=5 --api="http://127.0.0.1:9080" --token="${{ secrets.TURBO_SERVER_TOKEN }}" --team="${{ github.repository_owner }}" - - name: Run tests + - name: Run tests run: yarn turbo test --color --concurrency=5 --api="http://127.0.0.1:9080" --token="${{ secrets.TURBO_SERVER_TOKEN }}" --team="${{ github.repository_owner }}" - name: Run build @@ -47,11 +47,11 @@ jobs: - name: Use Node.js uses: actions/setup-node@v3 with: - node-version: "16" - cache: "npm" + node-version: '16' + cache: 'npm' - run: yarn install --frozen-lockfile - run: export NEW_VERSION="$(node -e "console.log(require('semver').inc(require('./package.json').version, 'patch'))")-pre.${{ github.run_number }}" && yarn version --new-version $NEW_VERSION --no-git-tag-version && cd projects/ngx-formentry && yarn version --new-version $NEW_VERSION --no-git-tag-version - - run: yarn turbo build:lib --color --concurrency=5 + - run: yarn turbo build:lib --color --concurrency=5 - run: git config user.email "info@openmrs.org" && git config user.name "OpenMRS CI" - run: git add . && git commit -m "Prerelease version" --no-verify - run: yarn publish dist/ngx-formentry --tag next --access public @@ -74,8 +74,8 @@ jobs: - name: Use Node.js uses: actions/setup-node@v3 with: - node-version: "16" - cache: "npm" + node-version: '16' + cache: 'npm' - run: yarn install --frozen-lockfile - name: Build diff --git a/.prettierrc b/.prettierrc index 7ca0d159..02a74cac 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,6 +1,6 @@ { - "trailingComma": "none", + "semi": true, "singleQuote": true, "tabWidth": 2, - "semi": true + "trailingComma": "none" } diff --git a/README.md b/README.md index a3ad271a..a274b8fe 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ Which is should be fine if your are not working on custom components (Make sure `$ git clone https://github.com/AMPATH/ngx-openmrs-formentry` -`$ cd ngx-openmrs-formentry ` +`$ cd ngx-openmrs-formentry` `$ yarn` @@ -93,11 +93,12 @@ Which is should be fine if your are not working on custom components (Make sure `$ yarn run build:lib` ### Linking ngx-formentry with form-entry-app in patient chart + While you have your patient chart and ngx-formentry repo open locally, -Build the ngx-formentry project by +Build the ngx-formentry project by running `$yarn run build:lib` -Then cd into the `dist/ngx-formentry` directory created from the previous step. +Then cd into the `dist/ngx-formentry` directory created from the previous step. Run `$ pwd | pbcopy` to copy that path. On the patient chart repo cd into `esm-form-entry-app` diff --git a/package.json b/package.json index ba04211f..b9a23035 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "test": "ng test ngx-formentry --watch=false", "test:watch": "ng test ngx-formentry", "lint": "TIMING=1 ng lint", + "prettier": "prettier --config .prettierrc --write \"projects/**/*.{html,js,ts,css,scss}\" \"src/**/*.{html,js,ts,css,scss}\" --ignore-unknown", "e2e": "ng e2e" }, "peerDependencies": { @@ -68,6 +69,7 @@ "@typescript-eslint/parser": "^4.26.0", "browserslist-config-openmrs": "^1.0.1", "eslint": "^7.6.0", + "eslint-config-prettier": "^9.0.0", "husky": "^4.3.0", "jasmine-core": "^3.8.0", "jasmine-spec-reporter": "~5.0.0", @@ -77,7 +79,6 @@ "karma-firefox-launcher": "^1.1.0", "karma-jasmine": "~4.0.0", "karma-jasmine-html-reporter": "^1.7.0", - "lint-staged": "^10.4.0", "ng-packagr": "^12.2.7", "prettier": "2.1.2", "protractor": "~7.0.0", @@ -91,14 +92,8 @@ ], "husky": { "hooks": { - "pre-commit": "yarn run lint", + "pre-commit": "yarn run prettier && yarn run lint", "pre-push": "yarn run test" } - }, - "lint-staged": { - "*.{ts,js,css,md}": [ - "prettier --write", - "yarn run lint" - ] } } diff --git a/projects/ngx-formentry/src/adult.json b/projects/ngx-formentry/src/adult.json index 36b354fa..20822d09 100644 --- a/projects/ngx-formentry/src/adult.json +++ b/projects/ngx-formentry/src/adult.json @@ -295,7 +295,7 @@ "identifierType": "dfacd928-0370-4315-99d7-6ec1c9f7ae76" } }, - + { "type": "obs", "label": "If non-Ampath, specify:", diff --git a/projects/ngx-formentry/src/components/ngx-pick-datetime/sass/picker.scss b/projects/ngx-formentry/src/components/ngx-pick-datetime/sass/picker.scss index babd3d85..c6f3030b 100644 --- a/projects/ngx-formentry/src/components/ngx-pick-datetime/sass/picker.scss +++ b/projects/ngx-formentry/src/components/ngx-pick-datetime/sass/picker.scss @@ -12,7 +12,8 @@ $cdk-overlay-dark-backdrop-background: rgba(0, 0, 0, 0.288); $backdrop-animation-duration: 400ms !default; $backdrop-animation-timing-function: cubic-bezier(0.25, 0.8, 0.25, 1) !default; -.cdk-overlay-container, .cdk-global-overlay-wrapper { +.cdk-overlay-container, +.cdk-global-overlay-wrapper { // Disable events from being captured on the overlay container. pointer-events: none; @@ -72,7 +73,8 @@ $backdrop-animation-timing-function: cubic-bezier(0.25, 0.8, 0.25, 1) !default; z-index: $cdk-z-index-overlay-backdrop; pointer-events: auto; -webkit-tap-highlight-color: transparent; - transition: opacity $backdrop-animation-duration $backdrop-animation-timing-function; + transition: opacity $backdrop-animation-duration + $backdrop-animation-timing-function; opacity: 0; &.cdk-overlay-backdrop-showing { @@ -97,7 +99,8 @@ $backdrop-animation-timing-function: cubic-bezier(0.25, 0.8, 0.25, 1) !default; // capturing the user's mouse scroll events. Since we also can't use something like // `rgba(0, 0, 0, 0)`, we work around the inconsistency by not setting the background at // all and using `opacity` to make the element transparent. - &, &.cdk-overlay-backdrop-showing { + &, + &.cdk-overlay-backdrop-showing { opacity: 0; } } @@ -144,12 +147,11 @@ $backdrop-animation-timing-function: cubic-bezier(0.25, 0.8, 0.25, 1) !default; display: block; padding: 1.5em; box-shadow: 0 11px 15px -7px rgba(0, 0, 0, 0.2), - 0px 24px 38px 3px rgba(0, 0, 0, 0.14), - 0px 9px 46px 8px rgba(0, 0, 0, 0.12); + 0px 24px 38px 3px rgba(0, 0, 0, 0.14), 0px 9px 46px 8px rgba(0, 0, 0, 0.12); border-radius: 2px; overflow: auto; background: #fff; - color: rgba(0, 0, 0, .87); + color: rgba(0, 0, 0, 0.87); width: 100%; height: 100%; outline: none; @@ -171,7 +173,7 @@ $theme-color: #3f51b5; } .owl-dt-container-row { - border-bottom: 1px solid rgba(0, 0, 0, .12); + border-bottom: 1px solid rgba(0, 0, 0, 0.12); &:last-child { border-bottom: none; @@ -189,7 +191,7 @@ $theme-color: #3f51b5; align-items: center; font-size: 1em; width: 100%; - padding: .5em; + padding: 0.5em; color: #000000; .owl-dt-calendar-control-content { @@ -199,10 +201,10 @@ $theme-color: #3f51b5; align-items: center; .owl-dt-calendar-control-button { - padding: 0 .8em; + padding: 0 0.8em; &:hover { - background-color: rgba(0, 0, 0, .12);; + background-color: rgba(0, 0, 0, 0.12); } } } @@ -212,7 +214,7 @@ $theme-color: #3f51b5; display: flex; flex-direction: column; flex: 1 1 auto; - padding: 0 .5em .5em; + padding: 0 0.5em 0.5em; outline: 0; } @@ -229,7 +231,7 @@ $theme-color: #3f51b5; width: calc(100% - 3em); .owl-dt-calendar-header th { - padding-bottom: .25em; + padding-bottom: 0.25em; } } } @@ -240,11 +242,11 @@ $theme-color: #3f51b5; border-spacing: 0; .owl-dt-calendar-header { - color: rgba(0, 0, 0, .4); + color: rgba(0, 0, 0, 0.4); .owl-dt-weekdays { th { - font-size: .7em; + font-size: 0.7em; font-weight: 400; text-align: center; padding-bottom: 1em; @@ -254,16 +256,16 @@ $theme-color: #3f51b5; .owl-dt-calendar-table-divider { position: relative; height: 1px; - padding-bottom: .5em; + padding-bottom: 0.5em; &:after { content: ''; position: absolute; top: 0; - left: -.5em; - right: -.5em; + left: -0.5em; + right: -0.5em; height: 1px; - background: rgba(0, 0, 0, .12); + background: rgba(0, 0, 0, 0.12); } } } @@ -274,7 +276,7 @@ $theme-color: #3f51b5; line-height: 0; text-align: center; outline: 0; - color: rgba(0, 0, 0, .85); + color: rgba(0, 0, 0, 0.85); -webkit-appearance: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); -webkit-tap-highlight-color: transparent; @@ -290,7 +292,7 @@ $theme-color: #3f51b5; box-sizing: border-box; width: 90%; height: 90%; - font-size: .8em; + font-size: 0.8em; line-height: 1; border: 1px solid transparent; border-radius: 999px; @@ -299,19 +301,19 @@ $theme-color: #3f51b5; } .owl-dt-calendar-cell-out { - opacity: .2; + opacity: 0.2; } .owl-dt-calendar-cell-today:not(.owl-dt-calendar-cell-selected) { - border-color: rgba(0, 0, 0, .4); + border-color: rgba(0, 0, 0, 0.4); } .owl-dt-calendar-cell-selected { - color: hsla(0, 0%, 100%, .85); + color: hsla(0, 0%, 100%, 0.85); background-color: $theme-color; &.owl-dt-calendar-cell-today { - box-shadow: inset 0 0 0 1px hsla(0, 0%, 100%, .85); + box-shadow: inset 0 0 0 1px hsla(0, 0%, 100%, 0.85); } } @@ -319,25 +321,27 @@ $theme-color: #3f51b5; cursor: default; & > .owl-dt-calendar-cell-content:not(.owl-dt-calendar-cell-selected) { - color: rgba(0, 0, 0, .4); + color: rgba(0, 0, 0, 0.4); } & > .owl-dt-calendar-cell-content.owl-dt-calendar-cell-selected { - opacity: .4; + opacity: 0.4; } & > .owl-dt-calendar-cell-today:not(.owl-dt-calendar-cell-selected) { - border-color: rgba(0, 0, 0, .2); + border-color: rgba(0, 0, 0, 0.2); } } - .owl-dt-calendar-cell-active:focus > .owl-dt-calendar-cell-content:not(.owl-dt-calendar-cell-selected), - :not(.owl-dt-calendar-cell-disabled):hover > .owl-dt-calendar-cell-content:not(.owl-dt-calendar-cell-selected) { - background-color: rgba(0, 0, 0, .04); + .owl-dt-calendar-cell-active:focus + > .owl-dt-calendar-cell-content:not(.owl-dt-calendar-cell-selected), + :not(.owl-dt-calendar-cell-disabled):hover + > .owl-dt-calendar-cell-content:not(.owl-dt-calendar-cell-selected) { + background-color: rgba(0, 0, 0, 0.04); } .owl-dt-calendar-cell-in-range { - background: rgba($theme-color, .2); + background: rgba($theme-color, 0.2); &.owl-dt-calendar-cell-range-from { border-top-left-radius: 999px; @@ -356,7 +360,7 @@ $theme-color: #3f51b5; justify-content: center; width: 100%; height: 7em; - padding: .5em; + padding: 0.5em; outline: none; } @@ -375,17 +379,17 @@ $theme-color: #3f51b5; justify-content: center; align-items: center; width: 100%; - margin: .2em 0; + margin: 0.2em 0; .owl-dt-timer-input { display: block; width: 2em; text-align: center; - border: 1px solid rgba(0, 0, 0, .5); + border: 1px solid rgba(0, 0, 0, 0.5); border-radius: 3px; outline: medium none; font-size: 1.2em; - padding: .2em; + padding: 0.2em; } } @@ -393,16 +397,16 @@ $theme-color: #3f51b5; display: inline-block; align-self: flex-end; position: absolute; - width: .6em; + width: 0.6em; height: 100%; - left: -.3em; + left: -0.3em; &:before, &:after { content: ''; display: inline-block; - width: .35em; - height: .35em; + width: 0.35em; + height: 0.35em; position: absolute; left: 50%; border-radius: 50%; @@ -447,13 +451,13 @@ $theme-color: #3f51b5; .owl-dt-control-period-button { .owl-dt-control-button-content { height: 1.5em; - padding: 0 .5em; + padding: 0 0.5em; border-radius: 3px; transition: background-color 100ms linear; } &:hover > .owl-dt-control-button-content { - background-color: rgba(0, 0, 0, .12); + background-color: rgba(0, 0, 0, 0.12); } .owl-dt-control-button-arrow { @@ -462,7 +466,7 @@ $theme-color: #3f51b5; align-items: center; width: 1em; height: 1em; - margin: .1em; + margin: 0.1em; transition: transform 200ms ease; } } @@ -476,7 +480,7 @@ $theme-color: #3f51b5; } &[disabled] { - color: rgba(0, 0, 0, .4); + color: rgba(0, 0, 0, 0.4); cursor: default; } @@ -491,9 +495,8 @@ $theme-color: #3f51b5; .owl-dt-popup-container { position: relative; width: 18.5em; - box-shadow: 0 5px 5px -3px rgba(0, 0, 0, .2), - 0 8px 10px 1px rgba(0, 0, 0, .14), - 0 3px 14px 2px rgba(0, 0, 0, .12); + box-shadow: 0 5px 5px -3px rgba(0, 0, 0, 0.2), + 0 8px 10px 1px rgba(0, 0, 0, 0.14), 0 3px 14px 2px rgba(0, 0, 0, 0.12); .owl-dt-calendar, .owl-dt-timer { @@ -569,13 +572,13 @@ $theme-color: #3f51b5; &:hover { .owl-dt-control-button-content { - background-color: rgba(0, 0, 0, .1); + background-color: rgba(0, 0, 0, 0.1); } } } .owl-dt-container-info { - padding: 0 .5em; + padding: 0 0.5em; cursor: pointer; -webkit-tap-highlight-color: transparent; @@ -585,8 +588,8 @@ $theme-color: #3f51b5; .owl-dt-container-range-content { display: flex; justify-content: space-between; - padding: .5em 0; - font-size: .8em; + padding: 0.5em 0; + font-size: 0.8em; } &:last-child { @@ -621,10 +624,11 @@ $theme-color: #3f51b5; .owl-dt-control-button-content { width: 100%; height: 100%; - padding: .5em; + padding: 0.5em; } - &:focus, &:hover { + &:focus, + &:hover { .owl-dt-control-button-content { background: $theme-color; color: #ffffff; @@ -653,7 +657,7 @@ $theme-color: #3f51b5; } &:focus > .owl-dt-control-content { - background-color: rgba(0, 0, 0, .12); + background-color: rgba(0, 0, 0, 0.12); } &:not(:-moz-focusring):focus > .owl-dt-control-content { diff --git a/projects/ngx-formentry/src/components/ngx-remote-select/ngx-remote-select.component.ts b/projects/ngx-formentry/src/components/ngx-remote-select/ngx-remote-select.component.ts index a949efb6..a7d25829 100644 --- a/projects/ngx-formentry/src/components/ngx-remote-select/ngx-remote-select.component.ts +++ b/projects/ngx-formentry/src/components/ngx-remote-select/ngx-remote-select.component.ts @@ -5,7 +5,7 @@ import { forwardRef, Output, EventEmitter, - Renderer2, + Renderer2 } from '@angular/core'; import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; import { concat, Observable, of, Subject } from 'rxjs'; diff --git a/projects/ngx-formentry/src/components/number-input/number-input.module.ts b/projects/ngx-formentry/src/components/number-input/number-input.module.ts index fd3a6790..5964cddf 100644 --- a/projects/ngx-formentry/src/components/number-input/number-input.module.ts +++ b/projects/ngx-formentry/src/components/number-input/number-input.module.ts @@ -8,7 +8,7 @@ import { NumberInputDirective } from './number.directive'; @NgModule({ imports: [CommonModule, FormsModule], exports: [NumberInputComponent], - declarations: [NumberInputComponent,NumberInputDirective], + declarations: [NumberInputComponent, NumberInputDirective], providers: [] }) export class NumberInputModule {} diff --git a/projects/ngx-formentry/src/components/radio-button/radio.component.html b/projects/ngx-formentry/src/components/radio-button/radio.component.html index 7df25fc4..0906ae12 100644 --- a/projects/ngx-formentry/src/components/radio-button/radio.component.html +++ b/projects/ngx-formentry/src/components/radio-button/radio.component.html @@ -2,7 +2,7 @@