Skip to content

Commit

Permalink
chore: start incremental migration to strictNullChecks (#2835)
Browse files Browse the repository at this point in the history
#### Description of changes

This PR, plus the scripts in [dbjorge/aiweb-strict-null-check-migration-tools](https://github.com/dbjorge/aiweb-strict-null-check-migration-tools), creates the initial infrastructure for an incremental migration to `strictNullChecks: true`, following the [same strategy that VS Code used](https://code.visualstudio.com/blogs/2019/05/23/strict-null).

* Adds a secondary `tsconfig` file at `tsconfig.strictNullChecks.json` which is the same as our main/normal tsconfig file except that it enables `strictNullChecks` and only runs on the already-compliant parts of our code
* Populates the initial `files` and `includes` of the `strictNullChecks` config with the subset of `/src/` that is already compliant (by using `autoAdd` from [aiweb-strict-null-check-migration-tools](https://github.com/dbjorge/aiweb-strict-null-check-migration-tools)
* Adds a new `yarn null:check` command to compile against the new strictNullChecks config (note, an especially useful option during cleanup work is `yarn null:check --watch`)
* Adds `yarn null:check` into `yarn fastpass`
* Adds `yarn null:check` into PR/CI build

The ongoing effort to incrementally bring the codebase to null safety would amount to iteratively using [aiweb-strict-null-check-migration-tools](https://github.com/dbjorge/aiweb-strict-null-check-migration-tools) to find the next candidate files, fixing up null safety issues there, and using that repo's `autoAdd` tool to bring in any transitively-fixed cases.

#### Pull request checklist
<!-- If a checklist item is not applicable to this change, write "n/a" in the checkbox -->
- [x] Addresses an existing issue: #2869 
- [x] Ran `yarn fastpass`
- [n/a] Added/updated relevant unit test(s) (and ran `yarn test`)
- [n/a] Verified code coverage for the changes made. Check coverage report at: `<rootDir>/test-results/unit/coverage`
- [x] PR title *AND* final merge commit title both start with a semantic tag (`fix:`, `chore:`, `feat(feature-name):`, `refactor:`). See `CONTRIBUTING.md`.
- [n/a] (UI changes only) Added screenshots/GIFs to description above
- [n/a] (UI changes only) Verified usability with NVDA/JAWS
  • Loading branch information
dbjorge authored Jun 16, 2020
1 parent 3db47b7 commit d29009d
Show file tree
Hide file tree
Showing 3 changed files with 294 additions and 1 deletion.
4 changes: 4 additions & 0 deletions build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ jobs:
displayName: generate typings for scss files
timeoutInMinutes: 3

- script: yarn null:check
displayName: check for strictNullChecks violations
timeoutInMinutes: 5

- script: yarn test --ci
displayName: run unit tests
timeoutInMinutes: 10
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@
"copyright:check": "license-check-and-add check -f copyright-header.config.json",
"copyright:fix": "license-check-and-add add -f copyright-header.config.json",
"download:electron-mirror": "node ./pipeline/scripts/download-electron-mirror.js",
"fastpass": "npm-run-all --print-label scss:clean --parallel copyright:check lint:check format:check && grunt ada-cat",
"fastpass": "npm-run-all --print-label --parallel copyright:check lint:check format:check null:check && grunt ada-cat",
"fastpass:fix": "npm-run-all --print-label --serial scss:clean copyright:fix lint:fix format:fix",
"format:check": "prettier --config prettier.config.js --check \"**/*\"",
"format:fix": "prettier --config prettier.config.js --write \"**/*\"",
"lint:check": "tslint -c ./tslint.json -p ./tsconfig.json",
"lint:fix": "tslint --fix -c ./tslint.json -p ./tsconfig.json",
"null:check": "tsc -p ./tsconfig.strictNullChecks.json",
"react-devtools": "react-devtools",
"scss:build": "tsm \"src/**/*.scss\"",
"scss:clean": "grunt clean:scss",
Expand Down
288 changes: 288 additions & 0 deletions tsconfig.strictNullChecks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,288 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"strictNullChecks": true
},
"files": [
"./src/DetailsView/bundled-details-view-styles.ts",
"./src/DetailsView/components/action-and-cancel-buttons-component.tsx",
"./src/DetailsView/components/assessment-instance-details-column.tsx",
"./src/DetailsView/components/assessment-instance-selected-button.tsx",
"./src/DetailsView/components/base-left-nav.tsx",
"./src/DetailsView/components/failure-instance-panel-details.tsx",
"./src/DetailsView/components/generic-dialog.tsx",
"./src/DetailsView/components/generic-panel.tsx",
"./src/DetailsView/components/generic-toggle.tsx",
"./src/DetailsView/components/left-nav/details-view-right-content-panel-type.ts",
"./src/DetailsView/components/left-nav/getting-started-nav-link.tsx",
"./src/DetailsView/components/left-nav/overview-left-nav-link.tsx",
"./src/DetailsView/components/left-nav/test-view-left-nav-link.tsx",
"./src/DetailsView/components/narrow-mode-detector.tsx",
"./src/DetailsView/components/no-content-available/no-content-available.tsx",
"./src/DetailsView/components/overview-content/overview-heading.tsx",
"./src/DetailsView/components/switcher-style-names.ts",
"./src/DetailsView/components/target-page-hidden-bar.tsx",
"./src/Devtools/target-page-inspector.ts",
"./src/ad-hoc-visualizations/issues/get-notification-message.ts",
"./src/assessments/audio-video-only/test-steps/test-steps.ts",
"./src/assessments/auto-pass-if-no-results.ts",
"./src/assessments/color/test-steps/test-steps.tsx",
"./src/assessments/common/assisted-test-record-your-results.tsx",
"./src/assessments/common/instructions-and-labels-note.tsx",
"./src/assessments/common/manual-test-record-your-results.tsx",
"./src/assessments/contrast/test-steps/test-steps.ts",
"./src/assessments/custom-widgets/design-pattern.ts",
"./src/assessments/custom-widgets/test-steps/test-steps.ts",
"./src/assessments/errors/test-steps/test-steps.ts",
"./src/assessments/headings/test-steps/test-steps.ts",
"./src/assessments/images/test-steps/test-steps.ts",
"./src/assessments/keyboard-interaction/test-steps/test-steps.ts",
"./src/assessments/landmarks/test-steps/test-steps.ts",
"./src/assessments/language/test-steps/test-steps.ts",
"./src/assessments/links/test-steps/test-steps.ts",
"./src/assessments/live-multimedia/test-steps/test-steps.ts",
"./src/assessments/markup.tsx",
"./src/assessments/native-widgets/test-steps/test-steps.ts",
"./src/assessments/page/test-steps/test-steps.ts",
"./src/assessments/parsing/test-steps/test-steps.ts",
"./src/assessments/pointer-motion/test-steps/test-steps.ts",
"./src/assessments/prerecorded-multimedia/test-steps/test-steps.ts",
"./src/assessments/repetitive-content/test-steps/test-steps.ts",
"./src/assessments/semantics/test-steps/test-steps.ts",
"./src/assessments/sequence/test-steps/test-steps.ts",
"./src/assessments/text-legibility/test-steps/test-step.ts",
"./src/assessments/timed-events/test-steps/test-steps.ts",
"./src/assessments/visible-focus-order/test-steps/test-steps.ts",
"./src/background/IndexedDBDataKeys.ts",
"./src/background/details-view-controller.ts",
"./src/background/feature-flag-checker.ts",
"./src/background/injector/content-script-injector.ts",
"./src/background/inspect-modes.ts",
"./src/background/install-data-generator.ts",
"./src/background/installation-data.ts",
"./src/background/instance-identifier-generator.ts",
"./src/background/local-storage-data-keys.ts",
"./src/background/scoping-input-types.ts",
"./src/background/shortcuts-page-controller.ts",
"./src/background/stores/side-panel.ts",
"./src/background/stores/store-hub.ts",
"./src/background/telemetry/multiplexing-telemetry-client.ts",
"./src/background/telemetry/telemetry-base-data.ts",
"./src/background/telemetry/telemetry-client.ts",
"./src/background/usage-logger.ts",
"./src/background/user-stored-data-cleaner.ts",
"./src/common/base-store.ts",
"./src/common/blob-provider.ts",
"./src/common/browser-adapters/app-data-adapter.ts",
"./src/common/browser-adapters/browser-adapter.ts",
"./src/common/browser-adapters/commands-adapter.ts",
"./src/common/browser-adapters/storage-adapter.ts",
"./src/common/components/blocking-dialog.tsx",
"./src/common/components/cards/card-interaction-support.ts",
"./src/common/components/cards/simple-card-row.tsx",
"./src/common/components/controls/insights-command-button.tsx",
"./src/common/components/external-link.tsx",
"./src/common/components/issue-filing-needs-settings-help-text.tsx",
"./src/common/components/left-nav-hamburger-button.tsx",
"./src/common/components/new-tab-link.tsx",
"./src/common/components/null-component.tsx",
"./src/common/components/privacy-statement-text.tsx",
"./src/common/components/scanning-spinner/scanning-spinner.tsx",
"./src/common/components/telemetry-notice.tsx",
"./src/common/components/visualization-toggle.tsx",
"./src/common/configs/adhoc-test-keys.ts",
"./src/common/configs/test-mode.ts",
"./src/common/configuration/configuration-defaults.ts",
"./src/common/configuration/configuration-types.ts",
"./src/common/date-provider.ts",
"./src/common/document-manipulator.ts",
"./src/common/enum-helper.ts",
"./src/common/fabric-icons.ts",
"./src/common/file-url-provider.ts",
"./src/common/flux/event-handler-list.ts",
"./src/common/get-inner-text-from-jsx-element.ts",
"./src/common/is-supported-browser.ts",
"./src/common/itab.ts",
"./src/common/message-creators/store-action-message-creator.ts",
"./src/common/message.ts",
"./src/common/messages.ts",
"./src/common/platform.ts",
"./src/common/stores/client-stores-hub.ts",
"./src/common/stores/store-names.ts",
"./src/common/types/deep-partial.ts",
"./src/common/types/details-view-pivot-type.ts",
"./src/common/types/dev-tools-open-message.ts",
"./src/common/types/idefault-constructor.ts",
"./src/common/types/link-component-type.ts",
"./src/common/types/manual-test-status.ts",
"./src/common/types/property-bag/column-value-bag.ts",
"./src/common/types/property-bag/contrast.ts",
"./src/common/types/property-bag/cues.ts",
"./src/common/types/property-bag/custom-widgets-property-bag.ts",
"./src/common/types/property-bag/default-widget.ts",
"./src/common/types/property-bag/image-function.ts",
"./src/common/types/property-bag/link-function-property-bag.ts",
"./src/common/types/property-bag/link-purpose-property-bag.ts",
"./src/common/types/property-bag/meaningful-image.ts",
"./src/common/types/property-bag/text-alternative-property-bag.ts",
"./src/common/types/property-bag/widget-function-property-bag.ts",
"./src/common/types/scan-incomplete-warnings.ts",
"./src/common/types/store-data/assessment-result-data.ts",
"./src/common/types/store-data/card-selection-store-data.ts",
"./src/common/types/store-data/command-store-data.ts",
"./src/common/types/store-data/current-panel.ts",
"./src/common/types/store-data/details-view-store-data.ts",
"./src/common/types/store-data/dev-tool-store-data.ts",
"./src/common/types/store-data/displayable-feature-flag.ts",
"./src/common/types/store-data/feature-flag-store-data.ts",
"./src/common/types/store-data/inspect-store-data.ts",
"./src/common/types/store-data/path-snippet-store-data.ts",
"./src/common/types/store-data/permissions-state-store-data.ts",
"./src/common/types/store-data/scoping-store-data.ts",
"./src/common/types/store-data/tab-store-data.ts",
"./src/common/types/store-data/user-configuration-store.ts",
"./src/common/types/store-data/visualization-store-data.ts",
"./src/common/types/store-type.ts",
"./src/common/types/store-update-message.ts",
"./src/common/types/visualization-type.ts",
"./src/common/uid-generator.ts",
"./src/common/url-validator.ts",
"./src/common/window-utils.ts",
"./src/content/guidance-tags.ts",
"./src/content/test/common/test-automatically-passed-notice.tsx",
"./src/content/test/contrast/state-changes.tsx",
"./src/electron/adapters/electron-storage-adapter.ts",
"./src/electron/adapters/null-details-view-controller.ts",
"./src/electron/adapters/null-store-action-message-creator.ts",
"./src/electron/common/electron-telemetry-events.ts",
"./src/electron/flux/action/device-action-payloads.ts",
"./src/electron/flux/action/route-payloads.ts",
"./src/electron/flux/action/window-frame-actions-payloads.ts",
"./src/electron/flux/action/window-state-payload.ts",
"./src/electron/flux/types/android-setup-store-data.ts",
"./src/electron/flux/types/device-connect-state.tsx",
"./src/electron/flux/types/device-store-data.ts",
"./src/electron/flux/types/scan-status.ts",
"./src/electron/flux/types/scan-store-data.ts",
"./src/electron/flux/types/window-state-store-data.ts",
"./src/electron/ipc/ipc-channel-names.ts",
"./src/electron/main/main-window-config.ts",
"./src/electron/main/main-window-renderer-message-handlers.ts",
"./src/electron/platform/android/android-service-apk-locator.ts",
"./src/electron/platform/android/android-service-configurator.ts",
"./src/electron/platform/android/appium-adb-creator.ts",
"./src/electron/platform/android/appium-service-configurator.ts",
"./src/electron/platform/android/device-config.ts",
"./src/electron/platform/android/live-appium-adb-creator.ts",
"./src/electron/platform/android/setup/android-setup-deps.ts",
"./src/electron/platform/android/setup/android-setup-step-id.ts",
"./src/electron/views/automated-checks/components/header-section.tsx",
"./src/electron/views/bundled-renderer-styles.ts",
"./src/electron/views/device-connect-view/components/android-setup/android-setup-spinner.tsx",
"./src/electron/views/device-connect-view/components/android-setup/android-setup-step-layout.tsx",
"./src/electron/views/device-connect-view/components/android-setup/folder-picker.tsx",
"./src/electron/views/device-connect-view/components/device-connect-header.tsx",
"./src/electron/views/device-connect-view/components/electron-external-link.tsx",
"./src/electron/views/device-disconnected-popup/status-caution-icon.tsx",
"./src/electron/views/report/unified-report-head.tsx",
"./src/electron/views/screenshot/screenshot.tsx",
"./src/injected/constants.ts",
"./src/injected/frameCommunicators/error-message-content.ts",
"./src/injected/frameCommunicators/window-message.ts",
"./src/injected/iframe-detector.ts",
"./src/injected/scan-incomplete-warning-detector.ts",
"./src/injected/stylesheet-init.ts",
"./src/injected/tab-order-property-bag.ts",
"./src/injected/visualization/focus-indicator.ts",
"./src/injected/visualization/point.ts",
"./src/injected/visualization/svg-constants.ts",
"./src/injected/visualization/tabbed-item.ts",
"./src/issue-filing/common/create-settings-getter.ts",
"./src/issue-filing/common/http-query-builder.ts",
"./src/issue-filing/common/markup/markup-formatter.ts",
"./src/issue-filing/common/markup/plain-text-formatter.ts",
"./src/issue-filing/common/markup/truncate-snippet.ts",
"./src/issue-filing/services/azure-boards/azure-boards-issue-filing-settings.tsx",
"./src/issue-filing/services/github/github-issue-filing-settings.tsx",
"./src/issue-filing/services/github/github-url-rectifier.ts",
"./src/popup/components/header.tsx",
"./src/popup/components/launch-pad-item-row.tsx",
"./src/reports/assessment-report.styles.ts",
"./src/reports/automated-checks-report.styles.ts",
"./src/reports/components/assessment-report-body-header.tsx",
"./src/reports/components/assessment-report-footer.tsx",
"./src/reports/components/formatted-date.tsx",
"./src/reports/components/inline-image.tsx",
"./src/reports/components/instance-outcome-type.ts",
"./src/reports/components/report-head.tsx",
"./src/reports/components/report-sections/body-section.tsx",
"./src/reports/components/report-sections/content-container.tsx",
"./src/reports/components/report-sections/report-footer.tsx",
"./src/reports/components/report-sections/title-section.tsx",
"./src/reports/react-static-renderer.ts",
"./src/reports/report-name-generator-builder.ts",
"./src/reports/report-name-generator.ts",
"./src/scanner/axe-options.ts",
"./src/scanner/axe-rule-overrides.ts",
"./src/scanner/document-utils.ts",
"./src/scanner/scan-options.ts",
"./src/tests/common/get-automation-id-selector.ts",
"./src/tests/electron/common/element-identifiers/common-selectors.ts",
"./src/tests/electron/common/view-controllers/spectron-async-client.ts",
"./src/tests/electron/setup/test-resource-server-config.ts",
"./src/tests/electron/setup/test-setup.ts",
"./src/tests/electron/setup/timeouts.ts",
"./src/tests/end-to-end/common/element-identifiers/common-selectors.ts",
"./src/tests/end-to-end/common/element-identifiers/popup-page-element-identifiers.ts",
"./src/tests/end-to-end/common/element-identifiers/target-page-selectors.ts",
"./src/tests/end-to-end/common/force-test-failure.ts",
"./src/tests/end-to-end/common/prepare-test-result-file-path.ts",
"./src/tests/end-to-end/common/timeouts.ts",
"./src/tests/end-to-end/setup/test-resource-server-config.ts",
"./src/tests/end-to-end/setup/test-setup.ts",
"./src/tests/miscellaneous/test-resource-server/resource-server-config.ts",
"./src/tests/miscellaneous/test-resource-server/resource-server.ts",
"./src/tests/unit/common/axe-internals.ts",
"./src/tests/unit/common/base-data-builder.ts",
"./src/tests/unit/common/event-stub-factory.ts",
"./src/tests/unit/common/html-collection-of-builder.ts",
"./src/tests/unit/common/it-is-function.ts",
"./src/tests/unit/common/node-list-builder.ts",
"./src/tests/unit/common/sample-test-data.ts",
"./src/tests/unit/common/test-document-creator.ts",
"./src/tests/unit/common/tick.ts",
"./src/tests/unit/common/typemoq-helper.ts",
"./src/tests/unit/jest-setup.ts",
"./src/tests/unit/mock-helpers/chrome-event-mock.ts",
"./src/tests/unit/mock-helpers/port-on-disconnect-mock.ts",
"./src/tests/unit/mock-helpers/port-on-message-mock.ts",
"./src/tests/unit/stubs/chrome-adapter-stub.ts",
"./src/tests/unit/stubs/port-stub.ts",
"./src/tests/unit/stubs/q-stub.ts",
"./src/tests/unit/tests/assessments/common/renderer-wrapper.tsx",
"./src/tests/unit/tests/electron/flux/action-creator/scan-result-example.ts",
"./src/tests/unit/tests/reports/package/scans/scan-issues.ts",
"./src/tests/unit/tests/reports/package/scans/scan-no-issues.ts",
"./src/views/content/guidance-title.tsx",
"./src/views/content/markup/code-example.tsx"
],
"include": [
"src/common/action/**/*",
"src/common/icons/**/*",
"src/common/constants/**/*",
"src/common/indexedDB/**/*",
"src/common/logging/**/*",
"src/common/promises/**/*",
"src/common/react/**/*",
"src/common/styles/**/*",
"src/content/settings/**/*",
"src/content/strings/**/*",
"src/debug-tools/controllers/**/*",
"src/electron/auto-update/**/*",
"src/report-export/services/**/*",
"src/report-export/types/**/*",
"src/icons/**/*",
"src/types/**/*",
"src/tests/miscellaneous/test-resource-server/**/*"
]
}

0 comments on commit d29009d

Please sign in to comment.