diff --git a/package.json b/package.json index 212c6966016f..ea32db1732e1 100644 --- a/package.json +++ b/package.json @@ -273,6 +273,7 @@ "**/sharp": "0.29.3", "**/socket.io-parser": "4.0.5", "**/ua-parser-js": "0.7.33", + "@types/react": "17.0.83", "browserify-sign": "4.2.2", "devtools-protocol": "0.0.1346313", "sharp": "0.29.3", diff --git a/packages/app/package.json b/packages/app/package.json index caf28bb0cc2c..2ec7625ab1c6 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -4,7 +4,7 @@ "private": true, "scripts": { "build": "vite build", - "check-ts": "vue-tsc --noEmit", + "check-ts": "vue-tsc --noEmit && yarn -s tslint", "clean": "rimraf dist && echo 'cleaned'", "clean-deps": "rimraf node_modules", "cypress:launch": "yarn cypress:run-cypress-in-cypress gulp open --project .", @@ -17,6 +17,7 @@ "lint": "eslint --ext .js,.jsx,.ts,.tsx,.json, .", "start": "echo \"run 'yarn dev' or 'yarn watch' from the root\" && exit 1", "test": "echo 'ok'", + "tslint": "tslint --config ../ts/tslint.json --project .", "watch": "echo \"run 'yarn dev' or 'yarn watch' from the root\" && exit 1" }, "dependencies": {}, diff --git a/packages/app/src/composables/useCloudSpecData.ts b/packages/app/src/composables/useCloudSpecData.ts index ed0756c0da11..ad51f3467c95 100644 --- a/packages/app/src/composables/useCloudSpecData.ts +++ b/packages/app/src/composables/useCloudSpecData.ts @@ -105,8 +105,8 @@ export function useCloudSpecData ( */ watch( [debouncedDisplayedSpecIds, isOffline, isProjectDisconnected, mostRecentUpdate], - () => { - fetchDisplayedCloudData() + async () => { + await fetchDisplayedCloudData() }, { flush: 'post' }, ) diff --git a/packages/app/src/composables/usePreferences.ts b/packages/app/src/composables/usePreferences.ts index f0dcad5635b7..ca74c786f0c0 100644 --- a/packages/app/src/composables/usePreferences.ts +++ b/packages/app/src/composables/usePreferences.ts @@ -15,11 +15,11 @@ export function usePreferences () { const runnerUiStore = useRunnerUiStore() const setPreferences = useMutation(Preferences_SetPreferencesDocument) - function update (preference: K, value: RunnerUiState[K]) { + async function update (preference: K, value: RunnerUiState[K]) { if (runnerUiStore[preference] !== value) { // only set the value and trigger the mutation if the value has actually changed runnerUiStore.setPreference(preference, value) - setPreferences.executeMutation({ value: JSON.stringify({ [preference]: value }) }) + await setPreferences.executeMutation({ value: JSON.stringify({ [preference]: value }) }) } } diff --git a/packages/app/src/composables/useRecordEvent.ts b/packages/app/src/composables/useRecordEvent.ts index dbc0d08ff6cf..39b115162754 100644 --- a/packages/app/src/composables/useRecordEvent.ts +++ b/packages/app/src/composables/useRecordEvent.ts @@ -20,8 +20,8 @@ type EventParams = { export function useRecordEvent () { const recordEventMutation = useMutation(UseRecordEvent_RecordEventDocument) - function record (params: EventParams) { - recordEventMutation.executeMutation({ + async function record (params: EventParams) { + await recordEventMutation.executeMutation({ ...params, messageId: nanoid(), includeMachineId: params.includeMachineId ?? false, diff --git a/packages/app/src/composables/useSpecFilter.ts b/packages/app/src/composables/useSpecFilter.ts index af2acd4ea05f..9ada7673640a 100644 --- a/packages/app/src/composables/useSpecFilter.ts +++ b/packages/app/src/composables/useSpecFilter.ts @@ -23,18 +23,19 @@ export function useSpecFilter (savedFilter?: string) { const debouncedSpecFilterModel = useDebounce(specFilterModel, 200) - function setSpecFilter (specFilter: string) { + async function setSpecFilter (specFilter: string) { if (specStore.specFilter !== specFilter) { specStore.setSpecFilter(specFilter) - saveSpecFilter.executeMutation({ value: JSON.stringify({ specFilter }) }) + await saveSpecFilter.executeMutation({ value: JSON.stringify({ specFilter }) }) } } - watch(() => debouncedSpecFilterModel?.value, (newVal) => { - setSpecFilter(newVal ?? '') + watch(() => debouncedSpecFilterModel?.value, async (newVal) => { + await setSpecFilter(newVal ?? '') }) // initialize spec filter in store + // tslint:disable:no-floating-promises setSpecFilter(specFilterModel.value) return { diff --git a/packages/app/src/composables/useTestingType.cy.tsx b/packages/app/src/composables/useTestingType.cy.tsx index 289e4cc2b169..aee4f5fe0509 100644 --- a/packages/app/src/composables/useTestingType.cy.tsx +++ b/packages/app/src/composables/useTestingType.cy.tsx @@ -48,7 +48,7 @@ describe('useTestingType', () => { }) it('supplies expected query data', () => { - mountComposable(useTestingType).then((value) => { + mountComposable(useTestingType).then(async (value) => { const result = value as unknown as ReturnType expect(result.activeTestingType.value).to.eql('e2e') @@ -69,12 +69,12 @@ describe('useTestingType', () => { }) it('should toggle viewed mode', () => { - mountComposable(useTestingType).then((value) => { + mountComposable(useTestingType).then(async (value) => { const result = value as unknown as ReturnType expect(result.viewedTestingType.value).to.eql('e2e') - result.viewTestingType('component') + await result.viewTestingType('component') expect(result.viewedTestingType.value).to.eql('component') }) @@ -92,24 +92,24 @@ describe('useTestingType', () => { }) it('should toggle active mode if not active mode', () => { - mountComposable(useTestingType).then((value) => { + mountComposable(useTestingType).then(async (value) => { const result = value as unknown as ReturnType expect(result.viewedTestingType.value).to.eql('e2e') - result.viewTestingType('component') + await result.viewTestingType('component') }) cy.get('@activateTestingType').should('have.been.calledOnce') }) it('should toggle viewed mode if active mode', () => { - mountComposable(useTestingType).then((value) => { + mountComposable(useTestingType).then(async (value) => { const result = value as unknown as ReturnType expect(result.viewedTestingType.value).to.eql('e2e') - result.viewTestingType('e2e') + await result.viewTestingType('e2e') }) cy.get('@activateTestingType').should('not.have.been.called') diff --git a/packages/app/src/main.ts b/packages/app/src/main.ts index e95d4ad4512e..d7abd430f7b1 100644 --- a/packages/app/src/main.ts +++ b/packages/app/src/main.ts @@ -40,7 +40,7 @@ app.use(Toast, { closeOnClick: false, }) -makeUrqlClient({ target: 'app', namespace: config.namespace, socketIoRoute: config.socketIoRoute }).then((client) => { +await makeUrqlClient({ target: 'app', namespace: config.namespace, socketIoRoute: config.socketIoRoute }).then((client) => { app.use(urql, client) app.use(createRouter()) app.use(createI18n()) diff --git a/packages/app/src/runner/event-manager.ts b/packages/app/src/runner/event-manager.ts index ea8585fef3ad..ebd6065d01db 100644 --- a/packages/app/src/runner/event-manager.ts +++ b/packages/app/src/runner/event-manager.ts @@ -875,9 +875,9 @@ export class EventManager { } _studioCopyToClipboard (cb) { - this.ws.emit('studio:get:commands:text', this.studioStore.logs, (commandsText) => { - this.studioStore.copyToClipboard(commandsText) - .then(cb) + this.ws.emit('studio:get:commands:text', this.studioStore.logs, async (commandsText) => { + await this.studioStore.copyToClipboard(commandsText) + cb() }) } diff --git a/packages/app/src/runner/events/capture-protocol.ts b/packages/app/src/runner/events/capture-protocol.ts index 3559cf291c38..f03576969b64 100644 --- a/packages/app/src/runner/events/capture-protocol.ts +++ b/packages/app/src/runner/events/capture-protocol.ts @@ -25,7 +25,7 @@ export const addCaptureProtocolListeners = (Cypress: Cypress.Cypress) => { }) }) - Cypress.on('log:added', (attributes) => { + Cypress.on('log:added', async (attributes) => { // TODO: UNIFY-1318 - Race condition in unified runner - we should not need this null check if (!Cypress.runner) { return @@ -38,10 +38,10 @@ export const addCaptureProtocolListeners = (Cypress: Cypress.Cypress) => { timestamp: performance.now() + performance.timeOrigin, }) - Cypress.backend('protocol:command:log:added', protocolProps) + await Cypress.backend('protocol:command:log:added', protocolProps) }) - Cypress.on('log:changed', (attributes) => { + Cypress.on('log:changed', async (attributes) => { // TODO: UNIFY-1318 - Race condition in unified runner - we should not need this null check if (!Cypress.runner) { return @@ -54,10 +54,10 @@ export const addCaptureProtocolListeners = (Cypress: Cypress.Cypress) => { timestamp: performance.now() + performance.timeOrigin, }) - Cypress.backend('protocol:command:log:changed', protocolProps) + await Cypress.backend('protocol:command:log:changed', protocolProps) }) - const viewportChangedHandler = (viewport) => { + const viewportChangedHandler = async (viewport) => { const timestamp = performance.timeOrigin + performance.now() attachCypressProtocolInfo({ @@ -65,7 +65,7 @@ export const addCaptureProtocolListeners = (Cypress: Cypress.Cypress) => { timestamp, }) - Cypress.backend('protocol:viewport:changed', { + await Cypress.backend('protocol:viewport:changed', { viewport: { width: viewport.viewportWidth, height: viewport.viewportHeight, @@ -92,7 +92,7 @@ export const addCaptureProtocolListeners = (Cypress: Cypress.Cypress) => { }) }) - Cypress.on('url:changed', (url) => { + Cypress.on('url:changed', async (url) => { const timestamp = performance.timeOrigin + performance.now() attachCypressProtocolInfo({ @@ -100,10 +100,10 @@ export const addCaptureProtocolListeners = (Cypress: Cypress.Cypress) => { timestamp, }) - Cypress.backend('protocol:url:changed', { url, timestamp }) + await Cypress.backend('protocol:url:changed', { url, timestamp }) }) - Cypress.on('page:loading', (loading) => { + Cypress.on('page:loading', async (loading) => { const timestamp = performance.timeOrigin + performance.now() attachCypressProtocolInfo({ @@ -111,7 +111,7 @@ export const addCaptureProtocolListeners = (Cypress: Cypress.Cypress) => { timestamp, }) - Cypress.backend('protocol:page:loading', { loading, timestamp }) + await Cypress.backend('protocol:page:loading', { loading, timestamp }) }) Cypress.on('test:before:after:run:async', async (attributes, _test, options) => { diff --git a/packages/app/src/runner/index.ts b/packages/app/src/runner/index.ts index 3d6655838919..b150604e09bd 100644 --- a/packages/app/src/runner/index.ts +++ b/packages/app/src/runner/index.ts @@ -292,7 +292,7 @@ function setSpecForDriver (spec: SpecFile) { * a Spec IFrame to load the spec's source code, and * initialize Cypress on the AUT. */ -function runSpecE2E (config, spec: SpecFile) { +async function runSpecE2E (config, spec: SpecFile) { const $runnerRoot = getRunnerElement() // clear AUT, if there is one. @@ -315,7 +315,7 @@ function runSpecE2E (config, spec: SpecFile) { el.remove() }) - autIframe.visitBlankPage() + await autIframe.visitBlankPage() // create Spec IFrame const specSrc = getSpecUrl({ diff --git a/packages/app/src/runner/unifiedRunner.ts b/packages/app/src/runner/unifiedRunner.ts index 95869cbf4e6e..8a583237b144 100644 --- a/packages/app/src/runner/unifiedRunner.ts +++ b/packages/app/src/runner/unifiedRunner.ts @@ -25,8 +25,8 @@ export function useUnifiedRunner () { initialized.value = true }) - onBeforeUnmount(() => { - UnifiedRunnerAPI.teardown() + onBeforeUnmount(async () => { + await UnifiedRunnerAPI.teardown() initialized.value = false }) diff --git a/packages/app/src/runner/useEventManager.ts b/packages/app/src/runner/useEventManager.ts index 1ef7cd72a603..3a56d712cf20 100644 --- a/packages/app/src/runner/useEventManager.ts +++ b/packages/app/src/runner/useEventManager.ts @@ -13,23 +13,23 @@ export function useEventManager () { const studioStore = useStudioStore() const router = useRouter() - function runSpec (isRerun: boolean = false) { + async function runSpec (isRerun: boolean = false) { if (!specStore.activeSpec) { throw Error(`Cannot run spec when specStore.active spec is null or undefined!`) } autStore.setScriptError(null) - UnifiedRunnerAPI.executeSpec(specStore.activeSpec, isRerun) + await UnifiedRunnerAPI.executeSpec(specStore.activeSpec, isRerun) } function initializeRunnerLifecycleEvents () { // these events do not use GraphQL - eventManager.on('restart', () => { + eventManager.on('restart', async () => { // If we get the event to restart but have already navigated away from the runner, don't execute the spec if (specStore.activeSpec) { const isRerun = true - runSpec(isRerun) + await runSpec(isRerun) } }) @@ -49,8 +49,8 @@ export function useEventManager () { getAutIframeModel().reattachStudio() }) - eventManager.on('visit:blank', ({ testIsolation }) => { - getAutIframeModel().visitBlankPage(testIsolation) + eventManager.on('visit:blank', async ({ testIsolation }) => { + await getAutIframeModel().visitBlankPage(testIsolation) }) eventManager.on('run:end', () => { @@ -61,20 +61,20 @@ export function useEventManager () { eventManager.on('expect:origin', addCrossOriginIframe) - eventManager.on('testFilter:cloudDebug:dismiss', () => { + eventManager.on('testFilter:cloudDebug:dismiss', async () => { const currentRoute = router.currentRoute.value const { mode, ...query } = currentRoute.query // Delete runId from query which will remove the test filter and trigger a rerun - router.replace({ ...currentRoute, query }) + await router.replace({ ...currentRoute, query }) }) } const startSpecWatcher = () => { - return watch(() => specStore.activeSpec, () => { + return watch(() => specStore.activeSpec, async () => { if (specStore.activeSpec) { - runSpec() + await runSpec() } }, { immediate: true, flush: 'post' }) } diff --git a/packages/app/src/runner/useRunnerStyle.ts b/packages/app/src/runner/useRunnerStyle.ts index f30065e76f72..a990347458ca 100644 --- a/packages/app/src/runner/useRunnerStyle.ts +++ b/packages/app/src/runner/useRunnerStyle.ts @@ -114,11 +114,11 @@ export const useRunnerStyle = () => { export function useResizablePanels () { const preferences = usePreferences() - const handleResizeEnd = (panel: DraggablePanel) => { + const handleResizeEnd = async (panel: DraggablePanel) => { if (panel === 'panel1') { - preferences.update('specListWidth', specListWidth.value) + await preferences.update('specListWidth', specListWidth.value) } else { - preferences.update('reporterWidth', reporterWidth.value) + await preferences.update('reporterWidth', reporterWidth.value) } } diff --git a/packages/app/src/runs/useProjectRuns.ts b/packages/app/src/runs/useProjectRuns.ts index 6ecefab19984..7a0382aa75b6 100644 --- a/packages/app/src/runs/useProjectRuns.ts +++ b/packages/app/src/runs/useProjectRuns.ts @@ -90,6 +90,7 @@ export const useProjectRuns = (online: Ref): RunsComposable => { function startPolling () { timeout = window.setTimeout(function fetchNewerRuns () { if (variables.value && online.value) { + // tslint:disable:no-floating-promises refetcher.executeMutation(variables.value) .then(() => { startPolling() @@ -100,10 +101,10 @@ export const useProjectRuns = (online: Ref): RunsComposable => { }, POLL_FOR_LATEST) } - onMounted(() => { + onMounted(async () => { // Always fetch when the component mounts, and we're not already fetching if (online.value && !refetcher.fetching) { - refetcher.executeMutation(variables.value) + await refetcher.executeMutation(variables.value) } startPolling() diff --git a/packages/app/src/specs/SpecsListBanners.cy.tsx b/packages/app/src/specs/SpecsListBanners.cy.tsx index b78bd3f49009..fbc3744947f1 100644 --- a/packages/app/src/specs/SpecsListBanners.cy.tsx +++ b/packages/app/src/specs/SpecsListBanners.cy.tsx @@ -1,3 +1,5 @@ +import { camelCase, assignIn, set } from 'lodash' +import { defaultMessages } from '@cy/i18n' import SpecsListBanners from './SpecsListBanners.vue' import { ref } from 'vue' import type { Ref } from 'vue' @@ -5,7 +7,6 @@ import { SpecsListBannersFragment, SpecsListBannersFragmentDoc, UseCohorts_Deter import interval from 'human-interval' import { CloudUserStubs, CloudProjectStubs } from '@packages/graphql/test/stubCloudTypes' import { AllowedState, BannerIds } from '@packages/types' -import { assignIn, set } from 'lodash' import { UserProjectStatusStore, useUserProjectStatusStore } from '@packages/frontend-shared/src/store/user-project-status-store' import type { UserProjectStatusState } from '@packages/frontend-shared/src/store/user-project-status-store' @@ -120,19 +121,19 @@ describe('', { viewportHeight: 260, defaultCommandTimeout: 1 } const bannerTrueConditions: Record> = { - 'login-banner': {}, - 'create-organization-banner': { + 'login': {}, + 'create-organization': { user: { isLoggedIn: true, isOrganizationLoaded: true }, }, - 'connect-project-banner': { + 'connect-project': { user: { isLoggedIn: true, isMemberOfOrganization: true }, project: { isConfigLoaded: true }, }, - 'record-banner': { + 'record': { user: { isLoggedIn: true, isMemberOfOrganization: true }, project: { isProjectConnected: true, hasNoRecordedRuns: true, hasNonExampleSpec: true, isConfigLoaded: true }, }, - 'component-testing-banner': { + 'component-testing': { testingType: 'e2e', user: { isLoggedIn: true, isMemberOfOrganization: true }, project: { isProjectConnected: true, hasNonExampleSpec: true, isConfigLoaded: true, hasDetectedCtFramework: true }, @@ -153,7 +154,20 @@ describe('', { viewportHeight: 260, defaultCommandTimeout: 1 } }) - cy.get(`[data-cy="${bannerTestId}"]`).should('be.visible') + cy.get(`[data-cy="${bannerTestId}-banner"]`) + .should('be.visible') + + // The ct title has dynamic content and seems complicated to set here, so ignoring + let ctBannerTitle = defaultMessages.specPage.banners.componentTesting.title + + if (ctBannerTitle) { + defaultMessages.specPage.banners.componentTesting.title = ctBannerTitle.replace('{0}', 'React') + } + + cy.wrap(Object.entries(defaultMessages.specPage.banners[camelCase(bannerTestId)])).each((entry) => { + // @ts-expect-error + cy.contains(entry[1]).should('be.visible') + }) }) it('should be preempted by spec not found banner', () => { @@ -382,7 +396,7 @@ describe('', { viewportHeight: 260, defaultCommandTimeout: 1 } as any, } - validateSmartNotificationBehaviors(BannerIds.ACI_082022_LOGIN, 'login-banner', gql) + validateSmartNotificationBehaviors(BannerIds.ACI_082022_LOGIN, 'login', gql) }) describe('create organization', () => { @@ -404,7 +418,7 @@ describe('', { viewportHeight: 260, defaultCommandTimeout: 1 cy.gqlStub.Query.cloudViewer = gql.cloudViewer as any }) - validateSmartNotificationBehaviors(BannerIds.ACI_082022_CREATE_ORG, 'create-organization-banner', gql) + validateSmartNotificationBehaviors(BannerIds.ACI_082022_CREATE_ORG, 'create-organization', gql) }) describe('connect project', () => { @@ -423,7 +437,7 @@ describe('', { viewportHeight: 260, defaultCommandTimeout: 1 } as any, } - validateSmartNotificationBehaviors(BannerIds.ACI_082022_CONNECT_PROJECT, 'connect-project-banner', gql) + validateSmartNotificationBehaviors(BannerIds.ACI_082022_CONNECT_PROJECT, 'connect-project', gql) }) describe('record', () => { @@ -456,7 +470,7 @@ describe('', { viewportHeight: 260, defaultCommandTimeout: 1 cy.gqlStub.Query.cloudViewer = gql.cloudViewer as any }) - validateSmartNotificationBehaviors(BannerIds.ACI_082022_RECORD, 'record-banner', gql) + validateSmartNotificationBehaviors(BannerIds.ACI_082022_RECORD, 'record', gql) }) describe('component testing', () => { @@ -525,7 +539,7 @@ describe('', { viewportHeight: 260, defaultCommandTimeout: 1 ) validateCloseControl() - validateSmartNotificationBehaviors(BannerIds.CT_052023_AVAILABLE, 'component-testing-banner', gql) + validateSmartNotificationBehaviors(BannerIds.CT_052023_AVAILABLE, 'component-testing', gql) it('should not render when another smart banner has been dismissed within two days', () => { userProjectStatusStore.setBannersState({ diff --git a/packages/app/src/specs/SpecsListBanners.vue b/packages/app/src/specs/SpecsListBanners.vue index 222eec9465a3..cffcb6bf8c19 100644 --- a/packages/app/src/specs/SpecsListBanners.vue +++ b/packages/app/src/specs/SpecsListBanners.vue @@ -133,7 +133,7 @@ import ConnectIcon from '~icons/cy/chain-link_x16.svg' import WarningIcon from '~icons/cy/warning_x16.svg' import RefreshIcon from '~icons/cy/action-restart_x16' import { useRoute } from 'vue-router' -import { computed, reactive, ref, watch, Ref } from 'vue' +import { computed, reactive, ref, watch } from 'vue' import RequestAccessButton from './RequestAccessButton.vue' import { gql } from '@urql/vue' import { SpecsListBannersFragment, SpecsListBanners_CheckCloudOrgMembershipDocument } from '../generated/graphql' @@ -285,12 +285,13 @@ const bannerCohortOptions: BannerCohortOptions = { const cohortBuilder = useCohorts() -const getCohortForBanner = (bannerId: BannerId): Ref => { +const getCohortForBanner = (bannerId: BannerId) => { const cohortConfig: CohortConfig = { name: bannerId, options: bannerCohortOptions[bannerId] || [], } + // tslint:disable-next-line:no-floating-promises return cohortBuilder.getCohort(cohortConfig) } diff --git a/packages/app/src/specs/banners/ComponentTestingAvailableBanner.cy.tsx b/packages/app/src/specs/banners/ComponentTestingAvailableBanner.cy.tsx index 64253ee0a95e..172be4c545de 100644 --- a/packages/app/src/specs/banners/ComponentTestingAvailableBanner.cy.tsx +++ b/packages/app/src/specs/banners/ComponentTestingAvailableBanner.cy.tsx @@ -25,7 +25,7 @@ describe('', { viewportWidth: 1200 }, () => { ) cy.findByTestId('alert-prefix-icon').should('be.visible') - cy.contains(defaultMessages.specPage.banners.ct.title.replace('{0}', framework.name)).should('be.visible') + cy.contains(defaultMessages.specPage.banners.componentTesting.title.replace('{0}', framework.name)).should('be.visible') }) }) diff --git a/packages/app/src/specs/banners/ComponentTestingAvailableBanner.vue b/packages/app/src/specs/banners/ComponentTestingAvailableBanner.vue index b3b75b72d704..0b6d8ab7543c 100644 --- a/packages/app/src/specs/banners/ComponentTestingAvailableBanner.vue +++ b/packages/app/src/specs/banners/ComponentTestingAvailableBanner.vue @@ -16,7 +16,7 @@ > @@ -89,7 +89,7 @@ const props = defineProps<{ const { t } = useI18n() const bannerId = BannerIds.CT_052023_AVAILABLE -const title = computed(() => t('specPage.banners.ct.title', [props.framework?.name])) +const title = computed(() => t('specPage.banners.componentTesting.title', [props.framework?.name])) const iconFromType = computed(() => FrameworkBundlerLogos[props.framework?.type]) const handlePrimary = async (bannerInstanceId: string) => { diff --git a/packages/app/src/store/run-all-specs-store.ts b/packages/app/src/store/run-all-specs-store.ts index 6db879c452d8..6ad090b38899 100644 --- a/packages/app/src/store/run-all-specs-store.ts +++ b/packages/app/src/store/run-all-specs-store.ts @@ -43,7 +43,7 @@ export const useRunAllSpecsStore = defineStore('runAllSpecs', () => { // Won't execute unless we are testing since the browser gets killed. In testing, // we can stub `launchProject` to verify the functionality is working - router.push({ path: '/specs/runner', query: { file: RUN_ALL_SPECS_KEY } }) + await router.push({ path: '/specs/runner', query: { file: RUN_ALL_SPECS_KEY } }) } async function runAllSpecs () { diff --git a/packages/app/tsconfig.json b/packages/app/tsconfig.json index 347deb1bb0be..2f9761855c5e 100644 --- a/packages/app/tsconfig.json +++ b/packages/app/tsconfig.json @@ -20,6 +20,7 @@ "@cy/store/*": ["../frontend-shared/src/store/*"], "@packages/*": ["../*"] }, + "target": "ES2022", "types": [ "cypress", "cypress-real-events", diff --git a/packages/app/vite.config.mjs b/packages/app/vite.config.mjs index cebb1c2ceec8..02b0c05f11c4 100644 --- a/packages/app/vite.config.mjs +++ b/packages/app/vite.config.mjs @@ -20,7 +20,13 @@ export default makeConfig({ '@popperjs/core', '@opentelemetry/*', ], + esbuildOptions: { + target: "ES2022" + } }, + build: { + target: "ES2022" + } }, { plugins: [ Layouts(), @@ -32,7 +38,7 @@ export default makeConfig({ }], }), Legacy({ - targets: ['Chrome >= 80', 'Firefox >= 86', 'Edge >= 80'], + targets: ['last 3 major versions'], modernPolyfills: true, renderLegacyChunks: false, }), diff --git a/packages/config/package.json b/packages/config/package.json index 80aafa51ee8e..73b71a9858c9 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -7,14 +7,15 @@ "browser": "src/browser.ts", "scripts": { "build-prod": "tsc || echo 'built, with errors'", - "check-ts": "tsc --noEmit", + "check-ts": "tsc --noEmit && yarn -s tslint", "clean": "rimraf --glob ./src/*.js ./src/**/*.js ./src/**/**/*.js ./test/!**__fixtures__**/**/*.js || echo 'cleaned'", "clean-deps": "rimraf node_modules", "lint": "eslint --ext .js,.ts,.json, .", "test": "yarn test-unit", "test-debug": "yarn test-unit --inspect-brk=5566", "test-unit": "mocha --reporter mocha-multi-reporters --reporter-options configFile=../../mocha-reporter-config.json -r @packages/ts/register 'test/**/*.spec.ts' --exit --timeout 5000", - "test:clean": "find ./test/__fixtures__ -depth -name 'output.*' -type f -exec rm {} \\;" + "test:clean": "find ./test/__fixtures__ -depth -name 'output.*' -type f -exec rm {} \\;", + "tslint": "tslint --config ../ts/tslint.json --project ." }, "dependencies": { "@babel/core": "^7.25.2", diff --git a/packages/driver/cypress/e2e/commands/net_stubbing.cy.ts b/packages/driver/cypress/e2e/commands/net_stubbing.cy.ts index 81dc0b86e7d5..91b64ceb3470 100644 --- a/packages/driver/cypress/e2e/commands/net_stubbing.cy.ts +++ b/packages/driver/cypress/e2e/commands/net_stubbing.cy.ts @@ -1749,6 +1749,7 @@ describe('network stubbing', { retries: 15 }, function () { }).as('create') cy.then(() => { + // tslint:disable:no-floating-promises fetch('/post-only', { method: 'POST', // *GET, POST, PUT, DELETE, etc. }) diff --git a/packages/driver/cypress/e2e/cypress/proxy-logging.cy.ts b/packages/driver/cypress/e2e/cypress/proxy-logging.cy.ts index 8bfd6367e565..b5bcb77ec9b4 100644 --- a/packages/driver/cypress/e2e/cypress/proxy-logging.cy.ts +++ b/packages/driver/cypress/e2e/cypress/proxy-logging.cy.ts @@ -50,6 +50,7 @@ describe('Proxy Logging', () => { // TODO(webkit): fix+unskip for webkit release browser: '!webkit', }, (done) => { + // tslint:disable:no-floating-promises fetch('/some-url') // trigger: Cypress.Log() called @@ -137,6 +138,7 @@ describe('Proxy Logging', () => { // delay the fetch call by 100ms to ensure it gets // triggered during the cy.wait() below + // tslint:disable:no-floating-promises setTimeout(() => { fetch('/some-url') }, 100) @@ -187,6 +189,7 @@ describe('Proxy Logging', () => { it('intercept log has consoleProps with intercept info', (done) => { cy.intercept('/some-url', 'stubbed response').as('alias') .then(() => { + // tslint:disable:no-floating-promises fetch('/some-url') }) diff --git a/packages/driver/cypress/e2e/e2e/origin/cypress_api.cy.ts b/packages/driver/cypress/e2e/e2e/origin/cypress_api.cy.ts index c0fbc950d41c..f17364970d28 100644 --- a/packages/driver/cypress/e2e/e2e/origin/cypress_api.cy.ts +++ b/packages/driver/cypress/e2e/e2e/origin/cypress_api.cy.ts @@ -212,6 +212,7 @@ describe('cy.origin Cypress API', { browser: '!webkit' }, () => { }) cy.origin('http://www.foobar.com:3500', () => { + // tslint:disable:no-floating-promises Cypress.session.clearAllSavedSessions() }) }) diff --git a/packages/driver/cypress/e2e/e2e/origin/patches.cy.ts b/packages/driver/cypress/e2e/e2e/origin/patches.cy.ts index a1d82d7d3e45..2bdc0fbdb6b3 100644 --- a/packages/driver/cypress/e2e/e2e/origin/patches.cy.ts +++ b/packages/driver/cypress/e2e/e2e/origin/patches.cy.ts @@ -309,6 +309,7 @@ describe('src/cross-origin/patches', { browser: '!webkit', defaultCommandTimeout let url = new URL('/test-request', 'http://app.foobar.com:3500').toString() return new Promise((resolve, reject) => { + // tslint:disable:no-floating-promises fetch(url, { credentials: 'include', headers: { diff --git a/packages/driver/cypress/e2e/e2e/origin/uncaught_errors.cy.ts b/packages/driver/cypress/e2e/e2e/origin/uncaught_errors.cy.ts index 097c254430c4..12a27d114263 100644 --- a/packages/driver/cypress/e2e/e2e/origin/uncaught_errors.cy.ts +++ b/packages/driver/cypress/e2e/e2e/origin/uncaught_errors.cy.ts @@ -229,6 +229,7 @@ describe('cy.origin - uncaught errors', { browser: '!webkit' }, () => { }) cy.origin('http://www.foobar.com:3500', () => { + // tslint:disable:no-floating-promises Promise.reject(new Error('rejected promise')) // add the cy.wait here to keep commands streaming in, forcing the @@ -249,6 +250,7 @@ describe('cy.origin - uncaught errors', { browser: '!webkit' }, () => { }) cy.origin('http://www.foobar.com:3500', () => { + // tslint:disable:no-floating-promises Promise.reject(new Error('rejected promise')) }) diff --git a/packages/driver/package.json b/packages/driver/package.json index 3547683eade9..e79dfc55b711 100644 --- a/packages/driver/package.json +++ b/packages/driver/package.json @@ -3,13 +3,14 @@ "version": "0.0.0-development", "private": true, "scripts": { - "check-ts": "tsc --noEmit", + "check-ts": "tsc --noEmit && yarn -s tslint", "clean-deps": "rimraf node_modules", "cypress:open": "node ../../scripts/cypress open", "cypress:run": "node ../../scripts/cypress run", "postinstall": "patch-package", "lint": "eslint --ext .js,.jsx,.ts,.tsx,.json, .", - "start": "node -e 'console.log(require(`chalk`).red(`\nError:\n\tRunning \\`yarn start\\` is no longer needed for driver/cypress tests.\n\tWe now automatically spawn the server in e2e.setupNodeEvents config.\n\tChanges to the server will be watched and reloaded automatically.`))'" + "start": "node -e 'console.log(require(`chalk`).red(`\nError:\n\tRunning \\`yarn start\\` is no longer needed for driver/cypress tests.\n\tWe now automatically spawn the server in e2e.setupNodeEvents config.\n\tChanges to the server will be watched and reloaded automatically.`))'", + "tslint": "tslint --config ../ts/tslint.json --project ." }, "dependencies": {}, "devDependencies": { diff --git a/packages/driver/src/cy/commands/navigation.ts b/packages/driver/src/cy/commands/navigation.ts index fc636fd04744..29d8f5626579 100644 --- a/packages/driver/src/cy/commands/navigation.ts +++ b/packages/driver/src/cy/commands/navigation.ts @@ -457,14 +457,14 @@ export default (Commands, Cypress, cy, state, config) => { Cypress.on('test:before:run', reset) - Cypress.on('stability:changed', (bool, event) => { + Cypress.on('stability:changed', async (bool, event) => { // only send up page loading events when we're // not stable! - stabilityChanged(Cypress, state, config, bool) + await stabilityChanged(Cypress, state, config, bool) }) - Cypress.on('navigation:changed', (source, arg) => { - navigationChanged(Cypress, cy, state, source, arg) + Cypress.on('navigation:changed', async (source, arg) => { + await navigationChanged(Cypress, cy, state, source, arg) }) Cypress.on('form:submitted', (e) => { diff --git a/packages/driver/src/cy/commands/origin/index.ts b/packages/driver/src/cy/commands/origin/index.ts index 8426dcd237c8..9661d5a4dc82 100644 --- a/packages/driver/src/cy/commands/origin/index.ts +++ b/packages/driver/src/cy/commands/origin/index.ts @@ -2,6 +2,7 @@ import Bluebird from 'bluebird' import $errUtils from '../../../cypress/error_utils' import $stackUtils from '../../../cypress/stack_utils' import { Validator } from './validator' +import { isFunction } from 'lodash' import { createUnserializableSubjectProxy } from './unserializable_subject_proxy' import { serializeRunnable } from './util' import { preprocessConfig, preprocessEnv, syncConfigToCurrentOrigin, syncEnvToCurrentOrigin } from '../../../util/config' @@ -185,8 +186,7 @@ export default (Commands, Cypress: Cypress.Cypress, cy: Cypress.cy, state: State // Attach the spec bridge to the window to be tested. communicator.toSpecBridge(origin, 'attach:to:window') - - const fn = _.isFunction(callbackFn) ? callbackFn.toString() : callbackFn + const fn = isFunction(callbackFn) ? callbackFn.toString() : callbackFn const file = $stackUtils.getSourceDetailsForFirstLine(userInvocationStack, config('projectRoot'))?.absoluteFile try { diff --git a/packages/driver/src/cy/commands/origin/validator.ts b/packages/driver/src/cy/commands/origin/validator.ts index 35bef1d09793..b8c95d165d52 100644 --- a/packages/driver/src/cy/commands/origin/validator.ts +++ b/packages/driver/src/cy/commands/origin/validator.ts @@ -1,6 +1,6 @@ import $utils from '../../../cypress/utils' import $errUtils from '../../../cypress/error_utils' -import { difference, isPlainObject, isString } from 'lodash' +import { difference, isPlainObject, isString, isFunction } from 'lodash' import type { LocationObject } from '../../../cypress/location' import * as cors from '@packages/network/lib/cors' @@ -51,18 +51,18 @@ export class Validator { } _isValidCallbackFn (callbackFn) { - if (_.isFunction(callbackFn)) return true + if (isFunction(callbackFn)) return true // the user must pass a function, but at runtime the function may be // replaced with an object in the form // { callbackName: string, outputFilePath: string } // by the webpack-preprocessor. if it doesn't have that form, it's // an invalid input by the user - if (_.isPlainObject(callbackFn)) { + if (isPlainObject(callbackFn)) { return ( Object.keys(callbackFn).length === 2 - && _.isString(callbackFn.callbackName) - && _.isString(callbackFn.outputFilePath) + && isString(callbackFn.callbackName) + && isString(callbackFn.outputFilePath) ) } diff --git a/packages/driver/src/cy/commands/sessions/origins.ts b/packages/driver/src/cy/commands/sessions/origins.ts index 56d30f655cdb..538a5c970079 100644 --- a/packages/driver/src/cy/commands/sessions/origins.ts +++ b/packages/driver/src/cy/commands/sessions/origins.ts @@ -1,5 +1,6 @@ import Bluebird from 'bluebird' import { $Location } from '../../../cypress/location' +import _ from 'lodash' export async function mapOrigins (Cypress: Cypress.Cypress, origins: string | string[]): Promise { const getOrigins = Bluebird.map( diff --git a/packages/driver/src/cy/listeners.ts b/packages/driver/src/cy/listeners.ts index eff5b04a354f..f12ced5e36f0 100644 --- a/packages/driver/src/cy/listeners.ts +++ b/packages/driver/src/cy/listeners.ts @@ -83,14 +83,14 @@ export const bindToListeners = (contentWindow, callbacks: BoundCallbacks) => { callbacks.onLoad(e) }) - addListener(contentWindow, 'beforeunload', (e) => { + addListener(contentWindow, 'beforeunload', async (e) => { // bail if we've canceled this event (from another source) // or we've set a returnValue on the original event if (e.defaultPrevented || eventHasReturnValue(e)) { return } - callbacks.onBeforeUnload(e) + await callbacks.onBeforeUnload(e) }) // While we must move to pagehide for Chromium, it does not work for our diff --git a/packages/driver/src/cy/net-stubbing/events/before-request.ts b/packages/driver/src/cy/net-stubbing/events/before-request.ts index fae78c6c3a80..51e0325c5d4c 100644 --- a/packages/driver/src/cy/net-stubbing/events/before-request.ts +++ b/packages/driver/src/cy/net-stubbing/events/before-request.ts @@ -49,6 +49,7 @@ export const onBeforeRequest: HandlerFn = (Cypre debug('created request subscription %o', { eventName, request, subscription, handler }) + // tslint:disable:no-floating-promises emitNetEvent('subscribe', { requestId, subscription } as NetEvent.ToServer.Subscribe) } @@ -165,6 +166,7 @@ export const onBeforeRequest: HandlerFn = (Cypre queryObj = createQueryObject() queryProxy = createQueryProxy(queryObj) }, + // tslint:disable:no-floating-promises on (eventName, handler) { if (!validEvents.includes(eventName)) { $errUtils.throwErrByPath('net_stubbing.request_handling.unknown_event', { @@ -179,6 +181,7 @@ export const onBeforeRequest: HandlerFn = (Cypre $errUtils.throwErrByPath('net_stubbing.request_handling.event_needs_handler') } + // tslint:disable:no-floating-promises subscribe(eventName, handler) return userReq @@ -203,6 +206,7 @@ export const onBeforeRequest: HandlerFn = (Cypre } // allow `req` to be sent outgoing, then pass the response body to `responseHandler` + // tslint:disable:no-floating-promises subscribe('response:callback', responseHandler) return finish(true) diff --git a/packages/driver/src/cy/net-stubbing/events/index.ts b/packages/driver/src/cy/net-stubbing/events/index.ts index dfdcced33dd6..0391e989291f 100644 --- a/packages/driver/src/cy/net-stubbing/events/index.ts +++ b/packages/driver/src/cy/net-stubbing/events/index.ts @@ -56,6 +56,7 @@ export function registerEvents (Cypress: Cypress.Cypress, cy: Cypress.cy) { } function sendStaticResponse (requestId: string, staticResponse: StaticResponse) { + // tslint:disable:no-floating-promises emitNetEvent('send:static:response', { requestId, staticResponse: getBackendStaticResponse(staticResponse), @@ -93,6 +94,7 @@ export function registerEvents (Cypress: Cypress.Cypress, cy: Cypress.cy) { if (!route) { if (frame.subscription.await) { // route not found, just resolve so the request can continue + // tslint:disable:no-floating-promises emitResolved(frame.data) } diff --git a/packages/driver/src/cy/stability.ts b/packages/driver/src/cy/stability.ts index 8e213adb3c82..8b67b3214784 100644 --- a/packages/driver/src/cy/stability.ts +++ b/packages/driver/src/cy/stability.ts @@ -20,11 +20,11 @@ export const create = (Cypress: ICypress, state: StateFunc) => ({ } Cypress.action('cy:before:stability:release') - .then(() => { + .then(async () => { const whenStable = state('whenStable') if (whenStable) { - whenStable() + await whenStable() } }) }, diff --git a/packages/driver/src/cy/video-recorder.ts b/packages/driver/src/cy/video-recorder.ts index 008d4cb6c8d4..6aa6db137007 100644 --- a/packages/driver/src/cy/video-recorder.ts +++ b/packages/driver/src/cy/video-recorder.ts @@ -1,4 +1,4 @@ -export const initVideoRecorder = (Cypress) => { +export const initVideoRecorder = async (Cypress) => { // Only start recording with getUserMedia API if we're in firefox and video-enabled and run mode. // TODO: this logic should be cleaned up or gotten from some video-specific config value if ( @@ -8,7 +8,7 @@ export const initVideoRecorder = (Cypress) => { // navigator.mediaDevices will be undefined if the browser does not support display capture && window.navigator.mediaDevices ) { - window.navigator.mediaDevices.getUserMedia({ + await window.navigator.mediaDevices.getUserMedia({ audio: false, video: { // mediaSource "browser" is supported by a firefox user preference diff --git a/packages/driver/src/cypress/cy.ts b/packages/driver/src/cypress/cy.ts index 3c350e73dd7a..cbcf391c9080 100644 --- a/packages/driver/src/cypress/cy.ts +++ b/packages/driver/src/cypress/cy.ts @@ -218,6 +218,8 @@ export class $Cy extends EventEmitter2 implements ITimeouts, IStability, IAssert this.config = config this.Cypress = Cypress this.Cookies = Cookies + // TODO: this should be awaited + /* tslint:disable:no-floating-promises */ initVideoRecorder(Cypress) this.testConfigOverride = new TestConfigOverride() diff --git a/packages/driver/tsconfig.json b/packages/driver/tsconfig.json index 33203e370049..bcf2dea7271d 100644 --- a/packages/driver/tsconfig.json +++ b/packages/driver/tsconfig.json @@ -1,16 +1,10 @@ { "extends": "./../ts/tsconfig.json", "compilerOptions": { - "target": "ES2016", + "target": "ES2017", "lib": ["ES2021", "DOM", "DOM.Iterable"], - "allowJs": true, "noImplicitThis": false, - "strictFunctionTypes": true, "preserveWatchOutput": true, - "sourceMap": true, - "strictNullChecks": true, - "forceConsistentCasingInFileNames": true, - "noEmit": true, "outDir": "dist", "noErrorTruncation": true, "types": [] diff --git a/packages/errors/package.json b/packages/errors/package.json index 51c153843cc6..b06f937c47c8 100644 --- a/packages/errors/package.json +++ b/packages/errors/package.json @@ -7,7 +7,7 @@ "scripts": { "build": "../../scripts/run-if-ci.sh tsc || echo 'type errors'", "build-prod": "tsc", - "check-ts": "tsc --noEmit", + "check-ts": "tsc --noEmit && yarn -s tslint", "clean": "rimraf ./src/*.js ./src/**/*.js ./src/**/**/*.js ./test/**/*.js || echo 'cleaned'", "clean-deps": "rimraf node_modules", "comparison": "node -r @packages/ts/register test/support/error-comparison-tool.ts", @@ -15,7 +15,8 @@ "test": "yarn test-unit", "test-electron": "HTML_IMAGE_CONVERSION=1 xvfb-maybe electron --no-sandbox ./node_modules/.bin/_mocha", "pretest-unit": "yarn clean", - "test-unit": "mocha" + "test-unit": "mocha", + "tslint": "tslint --config ../ts/tslint.json --project ." }, "dependencies": { "ansi_up": "5.0.0", diff --git a/packages/extension/package.json b/packages/extension/package.json index ba078faa6b93..8959c254229a 100644 --- a/packages/extension/package.json +++ b/packages/extension/package.json @@ -5,6 +5,7 @@ "main": "index.js", "scripts": { "build": "gulp build", + "check-ts": "tsc --noEmit && yarn -s tslint", "clean": "gulp clean", "clean-deps": "rimraf node_modules", "postinstall": "echo '@packages/extension needs: yarn build'", @@ -13,6 +14,7 @@ "test-debug": "yarn test-unit --inspect-brk=5566", "test-unit": "cross-env NODE_ENV=test mocha -r @packages/ts/register --reporter mocha-multi-reporters --reporter-options configFile=../../mocha-reporter-config.json", "test-watch": "yarn test-unit --watch", + "tslint": "tslint --config ../ts/tslint.json --project .", "watch": "yarn build && chokidar 'app/**/*.*' 'app/*.*' -c 'yarn build'" }, "dependencies": { diff --git a/packages/extension/tsconfig.json b/packages/extension/tsconfig.json index aa782866197b..11aa7d670ce6 100644 --- a/packages/extension/tsconfig.json +++ b/packages/extension/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "../ts/tsconfig.json", "compilerOptions": { - "target": "es2015", + "target": "es2020", "strict": false } } diff --git a/packages/frontend-shared/cypress/support/common.ts b/packages/frontend-shared/cypress/support/common.ts index 13c7c04f3aa5..2499db8e8fc1 100644 --- a/packages/frontend-shared/cypress/support/common.ts +++ b/packages/frontend-shared/cypress/support/common.ts @@ -32,5 +32,4 @@ import { initHighlighter } from '@cy/components/highlight' // Make sure highlighter is initialized before // we show any code to avoid jank at rendering -// @ts-ignore -initHighlighter() +await initHighlighter() diff --git a/packages/frontend-shared/package.json b/packages/frontend-shared/package.json index cb688dca6793..877dd4fda025 100644 --- a/packages/frontend-shared/package.json +++ b/packages/frontend-shared/package.json @@ -4,7 +4,7 @@ "private": true, "scripts": { "build": "node ./script/build.js", - "check-ts": "vue-tsc --noEmit", + "check-ts": "vue-tsc --noEmit && yarn -s tslint", "clean": "rimraf dist ./node_modules/.vite src/*.js src/**/*.js && echo 'cleaned'", "clean-deps": "rimraf node_modules", "cypress:open": "cross-env TZ=America/New_York node ../../scripts/cypress open --component --project .", @@ -15,7 +15,8 @@ "generate-stub-specs": "node ./script/generate-stub-specs.js", "postinstall": "patch-package", "lint": "eslint --ext .js,.jsx,.ts,.tsx,.json,.vue .", - "test": "yarn cypress:run && yarn types" + "test": "yarn cypress:run && yarn types", + "tslint": "tslint --config ../ts/tslint.json --project ." }, "dependencies": { "@packages/data-context": "0.0.0-development" diff --git a/packages/frontend-shared/src/components/ShikiHighlight.cy.tsx b/packages/frontend-shared/src/components/ShikiHighlight.cy.tsx index 509e0886849e..93af3847ea28 100644 --- a/packages/frontend-shared/src/components/ShikiHighlight.cy.tsx +++ b/packages/frontend-shared/src/components/ShikiHighlight.cy.tsx @@ -33,7 +33,7 @@ module.exports = defineConfig({ describe('', { viewportWidth: 800, viewportHeight: 500 }, () => { beforeEach(async () => { - initHighlighter() + await initHighlighter() }) it('playground', () => { diff --git a/packages/frontend-shared/src/custom.d.ts b/packages/frontend-shared/src/custom.d.ts new file mode 100644 index 000000000000..a97fbda78483 --- /dev/null +++ b/packages/frontend-shared/src/custom.d.ts @@ -0,0 +1,4 @@ +declare module '*.svg' { + const content: string + export default content +} diff --git a/packages/frontend-shared/src/gql-components/composables/useCohorts.ts b/packages/frontend-shared/src/gql-components/composables/useCohorts.ts index fffc2ab8748f..4cd5506e744f 100644 --- a/packages/frontend-shared/src/gql-components/composables/useCohorts.ts +++ b/packages/frontend-shared/src/gql-components/composables/useCohorts.ts @@ -78,6 +78,7 @@ export const useCohorts = () => { cohortOptionSelected.value = options.find((option) => option.cohort === cohortSelected.data?.determineCohort?.cohort) } + // tslint:disable:no-floating-promises fetchCohort() } diff --git a/packages/frontend-shared/src/locales/en-US.json b/packages/frontend-shared/src/locales/en-US.json index 572adb0646d4..b05f8afb34dc 100644 --- a/packages/frontend-shared/src/locales/en-US.json +++ b/packages/frontend-shared/src/locales/en-US.json @@ -219,7 +219,7 @@ "title": "Record your first run", "content": "Record a run to see your test results in Cypress Cloud. You can then optimize your test suite, debug failing and flaky tests, and integrate with your favorite tools." }, - "ct": { + "componentTesting": { "title": "{0} component testing is available for this project", "content": "You can now use Cypress to develop and test individual components without running your whole application. Generate the config in just a few clicks.", "primaryAction": "Quick setup", diff --git a/packages/icons/package.json b/packages/icons/package.json index 516e82f2e27b..246e3116e1f3 100644 --- a/packages/icons/package.json +++ b/packages/icons/package.json @@ -6,10 +6,11 @@ "main": "index.js", "scripts": { "build": "ts-node ./scripts/build.ts && ts-node ./scripts/ico.ts", - "check-ts": "tsc --noEmit", + "check-ts": "tsc --noEmit && yarn -s tslint", "lint": "eslint --ext .js,.jsx,.ts,.tsx,.json, .", "test": "yarn test-unit", - "test-unit": "NODE_ENV=test mocha -r @packages/ts/register test/*.ts" + "test-unit": "NODE_ENV=test mocha -r @packages/ts/register test/*.ts", + "tslint": "tslint --config ../ts/tslint.json --project ." }, "devDependencies": { "@types/mocha": "^8.0.3", diff --git a/packages/icons/scripts/build.ts b/packages/icons/scripts/build.ts index 05fbee295bec..c7d26e4a2d74 100644 --- a/packages/icons/scripts/build.ts +++ b/packages/icons/scripts/build.ts @@ -24,4 +24,5 @@ async function build () { await fs.remove(iconsetPath) } +// tslint:disable:no-floating-promises build() diff --git a/packages/icons/scripts/ico.ts b/packages/icons/scripts/ico.ts index 5fd77a0a4e34..ac0ed018abde 100644 --- a/packages/icons/scripts/ico.ts +++ b/packages/icons/scripts/ico.ts @@ -11,6 +11,7 @@ const files = [ fs.readFileSync('./assets/icons/icon_256x256.png'), ] +// tslint:disable:no-floating-promises toIco(files).then((buf) => { fs.writeFileSync('./dist/icons/cypress.ico', buf) }) diff --git a/packages/launcher/package.json b/packages/launcher/package.json index 28be4853c393..42fc65fd7727 100644 --- a/packages/launcher/package.json +++ b/packages/launcher/package.json @@ -4,14 +4,15 @@ "private": true, "scripts": { "build-prod": "tsc --project .", - "check-ts": "tsc --noEmit", + "check-ts": "tsc --noEmit && yarn -s tslint", "clean": "rimraf --glob \"lib/*.js\" && rimraf --glob \"lib/**/*.js\" || true", "clean-deps": "rimraf node_modules", "clean-js": "yarn clean", "lint": "eslint --ext .js,.jsx,.ts,.tsx,.json, .", "size": "t=\"cypress-v0.0.0.tgz\"; yarn pack --filename \"${t}\"; wc -c \"cli/${t}\"; tar tvf \"${t}\"; rm \"${t}\";", "test": "yarn test-unit", - "test-unit": "mocha --reporter mocha-multi-reporters --reporter-options configFile=../../mocha-reporter-config.json" + "test-unit": "mocha --reporter mocha-multi-reporters --reporter-options configFile=../../mocha-reporter-config.json", + "tslint": "tslint --config ../ts/tslint.json --project ." }, "dependencies": { "bluebird": "3.5.3", diff --git a/packages/launchpad/cypress/e2e/open-mode.cy.ts b/packages/launchpad/cypress/e2e/open-mode.cy.ts index a782e776178d..f522042eb2a6 100644 --- a/packages/launchpad/cypress/e2e/open-mode.cy.ts +++ b/packages/launchpad/cypress/e2e/open-mode.cy.ts @@ -58,8 +58,8 @@ describe('Launchpad: Open Mode', () => { o.sinon.spy(ctx.util.fetch) }) - cy.withCtx((ctx, o) => { - ctx.config.localSettingsApi.setPreferences({ + cy.withCtx(async (ctx, o) => { + await ctx.config.localSettingsApi.setPreferences({ notifyWhenRunCompletes: ['failed'], }) }) diff --git a/packages/launchpad/package.json b/packages/launchpad/package.json index f0fa325261c6..21a85a45de3d 100644 --- a/packages/launchpad/package.json +++ b/packages/launchpad/package.json @@ -4,7 +4,7 @@ "private": true, "scripts": { "build": "vite build", - "check-ts": "vue-tsc --noEmit", + "check-ts": "vue-tsc --noEmit && yarn -s tslint", "clean": "rimraf dist && rimraf dist-e2e && echo 'cleaned'", "clean-deps": "rimraf node_modules", "cypress:open": "yarn cypress:run-cypress-in-cypress gulp open --project .", @@ -16,6 +16,7 @@ "lint": "eslint --ext .js,.jsx,.ts,.tsx,.json, .", "start": "echo 'run yarn dev from the root' && exit 1", "test": "yarn cypress:run:ct && yarn types", + "tslint": "tslint --config ../ts/tslint.json --project .", "watch": "echo 'run yarn dev from the root' && exit 1" }, "dependencies": {}, diff --git a/packages/net-stubbing/lib/server/middleware/request.ts b/packages/net-stubbing/lib/server/middleware/request.ts index 132d060522cf..81fa2b5d6453 100644 --- a/packages/net-stubbing/lib/server/middleware/request.ts +++ b/packages/net-stubbing/lib/server/middleware/request.ts @@ -96,7 +96,7 @@ export const InterceptRequest: RequestMiddleware = async function () { }) as CyHttpMessages.IncomingRequest request.res.once('finish', async () => { - request.handleSubscriptions({ + await request.handleSubscriptions({ eventName: 'after:response', data: request.includeBodyInAfterResponse ? { finalResBody: request.res.body!, diff --git a/packages/net-stubbing/package.json b/packages/net-stubbing/package.json index 351c2b7cc5d6..50c70f84570a 100644 --- a/packages/net-stubbing/package.json +++ b/packages/net-stubbing/package.json @@ -5,10 +5,11 @@ "main": "./lib/server", "scripts": { "build-prod": "tsc --project .", - "check-ts": "tsc --noEmit", + "check-ts": "tsc --noEmit && yarn -s tslint", "clean-deps": "rimraf node_modules", "lint": "eslint --ext .ts,.json, .", - "test": "CYPRESS_INTERNAL_ENV=test mocha -r @packages/ts/register --reporter mocha-multi-reporters --reporter-options configFile=../../mocha-reporter-config.json --exit test/unit/*" + "test": "CYPRESS_INTERNAL_ENV=test mocha -r @packages/ts/register --reporter mocha-multi-reporters --reporter-options configFile=../../mocha-reporter-config.json --exit test/unit/*", + "tslint": "tslint --config ../ts/tslint.json --project ." }, "dependencies": { "@types/mime-types": "2.1.0", diff --git a/packages/network/lib/agent.ts b/packages/network/lib/agent.ts index 36fea530ed7c..2da40113217e 100644 --- a/packages/network/lib/agent.ts +++ b/packages/network/lib/agent.ts @@ -325,7 +325,7 @@ class HttpsAgent extends https.Agent { super(opts) } - addRequest (req: http.ClientRequest, options: https.RequestOptions) { + async addRequest (req: http.ClientRequest, options: https.RequestOptions) { // Ensure we have a proper port defined otherwise node has assumed we are port 80 // (https://github.com/nodejs/node/blob/master/lib/_http_client.js#L164) since we are a combined agent // rather than an http or https agent. This will cause issues with fetch requests (@cypress/request already handles it: @@ -338,7 +338,7 @@ class HttpsAgent extends https.Agent { if (baseCaOptions) { super.addRequest(req, mergeCAOptions(options, baseCaOptions)) } else { - baseCaOptionsPromise.then((caOptions) => { + await baseCaOptionsPromise.then((caOptions) => { super.addRequest(req, mergeCAOptions(options, caOptions)) }) } diff --git a/packages/network/package.json b/packages/network/package.json index df1bca41ab26..852cff4928c1 100644 --- a/packages/network/package.json +++ b/packages/network/package.json @@ -5,14 +5,15 @@ "main": "index.js", "scripts": { "build-prod": "tsc --project .", - "check-ts": "tsc --noEmit", + "check-ts": "tsc --noEmit && yarn -s tslint", "clean": "rimraf 'lib/**/*.js'", "clean-deps": "rimraf node_modules", "lint": "eslint --ext .js,.jsx,.ts,.tsx,.json, .", "test": "yarn test-unit", "test-debug": "yarn test-unit --inspect-brk=5566", "test-unit": "mocha --reporter mocha-multi-reporters --reporter-options configFile=../../mocha-reporter-config.json", - "test-watch": "yarn test-unit --watch" + "test-watch": "yarn test-unit --watch", + "tslint": "tslint --config ../ts/tslint.json --project ." }, "dependencies": { "@cypress/parse-domain": "2.4.0", diff --git a/packages/proxy/lib/http/index.ts b/packages/proxy/lib/http/index.ts index 35478d333e33..0b5281a04066 100644 --- a/packages/proxy/lib/http/index.ts +++ b/packages/proxy/lib/http/index.ts @@ -367,7 +367,7 @@ export class Http { getCurrentBrowser: this.getCurrentBrowser, } - const onError = (error: Error): Promise => { + const onError = async (error: Error): Promise => { const pendingRequest = ctx.pendingRequest as PendingRequest | undefined if (pendingRequest) { @@ -391,7 +391,7 @@ export class Http { } ctx.debug('Re-using pre-request data %o', preRequest) - this.addPendingBrowserPreRequest(preRequest) + await this.addPendingBrowserPreRequest(preRequest) } return _runStage(HttpStages.Error, ctx, onError) diff --git a/packages/proxy/lib/http/util/service-worker-injector.ts b/packages/proxy/lib/http/util/service-worker-injector.ts index 69767294e03e..afe0598d0766 100644 --- a/packages/proxy/lib/http/util/service-worker-injector.ts +++ b/packages/proxy/lib/http/util/service-worker-injector.ts @@ -88,7 +88,7 @@ export const injectIntoServiceWorker = (body: Buffer) => { } function wrapListener (listener: FetchListener): FetchListener { - return (event) => { + return async (event) => { // we want to override the respondWith method so we can track if it was called // to determine if the service worker handled the request const oldRespondWith = event.respondWith @@ -111,7 +111,7 @@ export const injectIntoServiceWorker = (body: Buffer) => { if (returnValue instanceof Promise) { // if the listener returns a promise, we need to wait for it to resolve // before we can determine if the service worker handled the request - returnValue.then(() => { + await returnValue.then(() => { sendFetchRequest({ url: event.request.url, isControlled: respondWithCalled }) }) } else { diff --git a/packages/proxy/lib/network-proxy.ts b/packages/proxy/lib/network-proxy.ts index 227919a8aa6e..b353458da633 100644 --- a/packages/proxy/lib/network-proxy.ts +++ b/packages/proxy/lib/network-proxy.ts @@ -43,7 +43,7 @@ export class NetworkProxy { this.http.handleServiceWorkerClientEvent(event) } - handleHttpRequest (req, res) { + async handleHttpRequest (req, res) { const span = telemetry.startSpan({ name: 'network:proxy:handleHttpRequest', opts: { @@ -55,13 +55,13 @@ export class NetworkProxy { isVerbose: true, }) - this.http.handleHttpRequest(req, res, span).finally(() => { + await this.http.handleHttpRequest(req, res, span).finally(() => { span?.end() }) } - handleSourceMapRequest (req, res) { - this.http.handleSourceMapRequest(req, res) + async handleSourceMapRequest (req, res) { + await this.http.handleSourceMapRequest(req, res) } setHttpBuffer (buffer) { diff --git a/packages/proxy/package.json b/packages/proxy/package.json index 2be98702ac77..8d35805555d5 100644 --- a/packages/proxy/package.json +++ b/packages/proxy/package.json @@ -5,14 +5,15 @@ "main": "index.js", "scripts": { "build-prod": "tsc --project .", - "check-ts": "tsc --noEmit", + "check-ts": "tsc --noEmit && yarn -s tslint", "clean": "rimraf 'lib/**/*.js'", "clean-deps": "rimraf node_modules", "lint": "eslint --ext .js,.jsx,.ts,.tsx,.json, .", "run-mocha": "mocha -r @packages/ts/register -r test/pretest.ts --reporter mocha-multi-reporters --reporter-options configFile=../../mocha-reporter-config.json", "test": "CYPRESS_INTERNAL_ENV=test yarn run-mocha \"test/integration/*.spec.ts\" \"test/unit/**/*.spec.ts\"", "test-integration": "CYPRESS_INTERNAL_ENV=test yarn run-mocha \"test/integration/*.spec.ts\"", - "test-unit": "CYPRESS_INTERNAL_ENV=test yarn run-mocha \"test/unit/**/*.spec.ts\"" + "test-unit": "CYPRESS_INTERNAL_ENV=test yarn run-mocha \"test/unit/**/*.spec.ts\"", + "tslint": "tslint --config ../ts/tslint.json --project ." }, "dependencies": { "bluebird": "3.5.3", diff --git a/packages/reporter/package.json b/packages/reporter/package.json index f7dc24ccde8f..13e724ab150b 100644 --- a/packages/reporter/package.json +++ b/packages/reporter/package.json @@ -5,11 +5,13 @@ "browser": "src/main.tsx", "scripts": { "build-for-tests": "node ../../scripts/run-webpack", + "check-ts": "yarn -s tslint", "clean-deps": "rimraf node_modules", "cypress:open": "node ../../scripts/cypress open --project .", "cypress:run": "node ../../scripts/cypress run --project .", "cypress:run:ct": "cross-env TZ=America/New_York node ../../scripts/cypress run --component --project .", "lint": "eslint --ext .js,.jsx,.ts,.tsx,.json, .", + "tslint": "tslint --config ../ts/tslint.json --project .", "watch": "yarn build-for-tests --watch --progress" }, "devDependencies": { @@ -18,6 +20,7 @@ "@fontsource/open-sans": "4.3.0", "@fortawesome/fontawesome-free": "6.0.0", "@packages/driver": "0.0.0-development", + "@packages/frontend-shared": "0.0.0-development", "@packages/types": "0.0.0-development", "@packages/web-config": "0.0.0-development", "@reach/dialog": "0.10.5", diff --git a/packages/reporter/src/agents/agents.tsx b/packages/reporter/src/agents/agents.tsx index 877105e76bf6..771c38483de3 100644 --- a/packages/reporter/src/agents/agents.tsx +++ b/packages/reporter/src/agents/agents.tsx @@ -4,8 +4,8 @@ import { observer } from 'mobx-react' import React from 'react' import Collapsible from '../collapsible/collapsible' -import AgentModel from './agent-model' -import { Alias } from '../instruments/instrument-model' +import type AgentModel from './agent-model' +import type { Alias } from '../instruments/instrument-model' export interface AgentProps { model: AgentModel diff --git a/packages/reporter/src/attempts/attempt-model.ts b/packages/reporter/src/attempts/attempt-model.ts index 585f4fca25df..5367b51c804a 100644 --- a/packages/reporter/src/attempts/attempt-model.ts +++ b/packages/reporter/src/attempts/attempt-model.ts @@ -5,12 +5,12 @@ import Agent, { AgentProps } from '../agents/agent-model' import Command, { CommandProps } from '../commands/command-model' import Err from '../errors/err-model' import Route, { RouteProps } from '../routes/route-model' -import Test, { UpdatableTestProps, TestProps } from '../test/test-model' -import type { TestState } from '@packages/types' +import type Test from '../test/test-model' +import type { UpdatableTestProps, TestProps } from '../test/test-model' +import type { TestState, FileDetails } from '@packages/types' import Hook, { HookName } from '../hooks/hook-model' -import { FileDetails } from '@packages/types' -import { LogProps } from '../runnables/runnables-store' -import Log from '../instruments/instrument-model' +import type { LogProps } from '../runnables/runnables-store' +import type Log from '../instruments/instrument-model' import Session, { SessionProps } from '../sessions/sessions-model' export default class Attempt { diff --git a/packages/reporter/src/attempts/attempts.tsx b/packages/reporter/src/attempts/attempts.tsx index 1d86f6518db8..a1b974872986 100644 --- a/packages/reporter/src/attempts/attempts.tsx +++ b/packages/reporter/src/attempts/attempts.tsx @@ -2,14 +2,14 @@ import cs from 'classnames' import { observer } from 'mobx-react' import React, { Component } from 'react' -import { TestState } from '@packages/types' +import type { TestState } from '@packages/types' import Agents from '../agents/agents' import Collapsible from '../collapsible/collapsible' import Hooks from '../hooks/hooks' import Routes from '../routes/routes' import TestError from '../errors/test-error' -import TestModel from '../test/test-model' -import AttemptModel from './attempt-model' +import type TestModel from '../test/test-model' +import type AttemptModel from './attempt-model' import Sessions from '../sessions/sessions' import CollapseIcon from '@packages/frontend-shared/src/assets/icons/collapse_x16.svg' diff --git a/packages/reporter/src/commands/command-model.ts b/packages/reporter/src/commands/command-model.ts index c3f45a18719e..85f3a1191142 100644 --- a/packages/reporter/src/commands/command-model.ts +++ b/packages/reporter/src/commands/command-model.ts @@ -4,7 +4,7 @@ import { action, computed, observable, makeObservable } from 'mobx' import Err, { ErrProps } from '../errors/err-model' import Instrument, { InstrumentProps } from '../instruments/instrument-model' import type { TimeoutID } from '../lib/types' -import { SessionProps } from '../sessions/sessions-model' +import type { SessionProps } from '../sessions/sessions-model' const LONG_RUNNING_THRESHOLD = 1000 diff --git a/packages/reporter/src/commands/command.tsx b/packages/reporter/src/commands/command.tsx index 77b79bba0daf..d518fddcd715 100644 --- a/packages/reporter/src/commands/command.tsx +++ b/packages/reporter/src/commands/command.tsx @@ -11,12 +11,13 @@ import events, { Events } from '../lib/events' import FlashOnClick from '../lib/flash-on-click' import StateIcon from '../lib/state-icon' import Tag from '../lib/tag' -import { TimeoutID } from '../lib/types' +import type { TimeoutID } from '../lib/types' import runnablesStore, { RunnablesStore } from '../runnables/runnables-store' -import { Alias, AliasObject } from '../instruments/instrument-model' +import type { Alias, AliasObject } from '../instruments/instrument-model' import { determineTagType } from '../sessions/utils' -import CommandModel, { RenderProps } from './command-model' +import type CommandModel from './command-model' +import type { RenderProps } from './command-model' import TestError from '../errors/test-error' import ChevronIcon from '@packages/frontend-shared/src/assets/icons/chevron-down-small_x8.svg' diff --git a/packages/reporter/src/errors/error-code-frame.tsx b/packages/reporter/src/errors/error-code-frame.tsx index bea4d28cd572..ec4fa4bf0cde 100644 --- a/packages/reporter/src/errors/error-code-frame.tsx +++ b/packages/reporter/src/errors/error-code-frame.tsx @@ -2,7 +2,7 @@ import React, { Component } from 'react' import { observer } from 'mobx-react' import Prism from 'prismjs' -import { CodeFrame } from './err-model' +import type { CodeFrame } from './err-model' import FileNameOpener from '../lib/file-name-opener' interface Props { diff --git a/packages/reporter/src/errors/error-stack.tsx b/packages/reporter/src/errors/error-stack.tsx index bf3b65499d17..f675a3a0466e 100644 --- a/packages/reporter/src/errors/error-stack.tsx +++ b/packages/reporter/src/errors/error-stack.tsx @@ -3,7 +3,8 @@ import { observer } from 'mobx-react' import React, { ReactElement } from 'react' import FileNameOpener from '../lib/file-name-opener' -import Err, { ParsedStackFileLine, ParsedStackMessageLine } from './err-model' +import type Err from './err-model' +import type { ParsedStackFileLine, ParsedStackMessageLine } from './err-model' const cypressLineRegex = /(cypress:\/\/|cypress_runner\.js)/ diff --git a/packages/reporter/src/errors/test-error.tsx b/packages/reporter/src/errors/test-error.tsx index 0526e1be31af..26ee4772a0b6 100644 --- a/packages/reporter/src/errors/test-error.tsx +++ b/packages/reporter/src/errors/test-error.tsx @@ -11,7 +11,7 @@ import ErrorStack from '../errors/error-stack' import events from '../lib/events' import FlashOnClick from '../lib/flash-on-click' import { onEnterOrSpace } from '../lib/util' -import Err from './err-model' +import type Err from './err-model' import { formattedMessage } from '../commands/command' import WarningIcon from '@packages/frontend-shared/src/assets/icons/warning_x8.svg' diff --git a/packages/reporter/src/header/controls.tsx b/packages/reporter/src/header/controls.tsx index 5e4629d9fa9e..9e508632ee36 100755 --- a/packages/reporter/src/header/controls.tsx +++ b/packages/reporter/src/header/controls.tsx @@ -6,7 +6,7 @@ import React from 'react' import Tooltip from '@cypress/react-tooltip' import defaultEvents, { Events } from '../lib/events' -import { AppState } from '../lib/app-state' +import type { AppState } from '../lib/app-state' import ChevronDownIcon from '@packages/frontend-shared/src/assets/icons/chevron-down-small_x16.svg' import ChevronUpIcon from '@packages/frontend-shared/src/assets/icons/chevron-up-small_x16.svg' diff --git a/packages/reporter/src/header/header.tsx b/packages/reporter/src/header/header.tsx index fee2fb154d0f..d69a7cbca786 100644 --- a/packages/reporter/src/header/header.tsx +++ b/packages/reporter/src/header/header.tsx @@ -6,14 +6,14 @@ import Tooltip from '@cypress/react-tooltip' import MenuExpandRightIcon from '@packages/frontend-shared/src/assets/icons/menu-expand-right_x16.svg' import defaultEvents, { Events } from '../lib/events' -import { AppState } from '../lib/app-state' +import type { AppState } from '../lib/app-state' import { action } from 'mobx' import Controls from './controls' import Stats from './stats' -import { StatsStore } from './stats-store' +import type { StatsStore } from './stats-store' import { DebugDismiss } from './DebugDismiss' -import { RunnablesStore } from '../runnables/runnables-store' +import type { RunnablesStore } from '../runnables/runnables-store' export interface ReporterHeaderProps { appState: AppState diff --git a/packages/reporter/src/header/stats-store.ts b/packages/reporter/src/header/stats-store.ts index aaef3375a3a8..180d0a68775e 100644 --- a/packages/reporter/src/header/stats-store.ts +++ b/packages/reporter/src/header/stats-store.ts @@ -1,7 +1,7 @@ import _ from 'lodash' import { action, computed, observable, makeObservable } from 'mobx' import { TestState } from '../test/test-model' -import { IntervalID } from '../lib/types' +import type { IntervalID } from '../lib/types' import type { StatsStoreStartInfo } from '@packages/types' diff --git a/packages/reporter/src/header/stats.tsx b/packages/reporter/src/header/stats.tsx index b5220abdc56c..835c3ce43d1a 100644 --- a/packages/reporter/src/header/stats.tsx +++ b/packages/reporter/src/header/stats.tsx @@ -2,7 +2,7 @@ import cs from 'classnames' import { observer } from 'mobx-react' import React from 'react' -import { StatsStore } from './stats-store' +import type { StatsStore } from './stats-store' import FailedIcon from '@packages/frontend-shared/src/assets/icons/status-failed_x12.svg' import PassedIcon from '@packages/frontend-shared/src/assets/icons/status-passed_x12.svg' diff --git a/packages/reporter/src/hooks/hook-model.ts b/packages/reporter/src/hooks/hook-model.ts index 02a57008f07b..d07d2220f2fc 100644 --- a/packages/reporter/src/hooks/hook-model.ts +++ b/packages/reporter/src/hooks/hook-model.ts @@ -1,11 +1,10 @@ import _ from 'lodash' import { observable, computed, makeObservable } from 'mobx' -import { FileDetails } from '@packages/types' - -import { Alias } from '../instruments/instrument-model' -import Err from '../errors/err-model' -import CommandModel from '../commands/command-model' +import type{ FileDetails } from '@packages/types' +import type { Alias } from '../instruments/instrument-model' +import type Err from '../errors/err-model' +import type CommandModel from '../commands/command-model' export type HookName = 'before all' | 'before each' | 'after all' | 'after each' | 'test body' | 'studio commands' diff --git a/packages/reporter/src/hooks/hooks.tsx b/packages/reporter/src/hooks/hooks.tsx index 41f6138a0e51..95933b4cd39c 100644 --- a/packages/reporter/src/hooks/hooks.tsx +++ b/packages/reporter/src/hooks/hooks.tsx @@ -2,12 +2,13 @@ import cs from 'classnames' import _ from 'lodash' import { observer } from 'mobx-react' import React from 'react' -import { FileDetails } from '@packages/types' +import type { FileDetails } from '@packages/types' import appState, { AppState } from '../lib/app-state' import Command from '../commands/command' import Collapsible from '../collapsible/collapsible' -import HookModel, { HookName } from './hook-model' +import type HookModel from './hook-model' +import type { HookName } from './hook-model' import ArrowRightIcon from '@packages/frontend-shared/src/assets/icons/arrow-right_x16.svg' import OpenIcon from '@packages/frontend-shared/src/assets/icons/technology-code-editor_x16.svg' diff --git a/packages/reporter/src/instruments/instrument-model.ts b/packages/reporter/src/instruments/instrument-model.ts index 0e13d733c2ab..a655913f516d 100644 --- a/packages/reporter/src/instruments/instrument-model.ts +++ b/packages/reporter/src/instruments/instrument-model.ts @@ -1,5 +1,5 @@ import { observable, makeObservable } from 'mobx' -import { Instrument, TestState } from '@packages/types' +import type { Instrument, TestState } from '@packages/types' export interface AliasObject { name: string diff --git a/packages/reporter/src/lib/events.ts b/packages/reporter/src/lib/events.ts index 6ee477bfe8a9..1d25f9aca4bc 100644 --- a/packages/reporter/src/lib/events.ts +++ b/packages/reporter/src/lib/events.ts @@ -4,8 +4,8 @@ import appState, { AppState } from './app-state' import runnablesStore, { RunnablesStore, LogProps, RootRunnable } from '../runnables/runnables-store' import statsStore, { StatsStore } from '../header/stats-store' import scroller, { Scroller } from './scroller' -import { UpdatableTestProps, UpdateTestCallback, TestProps } from '../test/test-model' -import Err from '../errors/err-model' +import type { UpdatableTestProps, UpdateTestCallback, TestProps } from '../test/test-model' +import type Err from '../errors/err-model' import type { ReporterStartInfo, ReporterRunState } from '@packages/types' diff --git a/packages/reporter/src/lib/file-name-opener.tsx b/packages/reporter/src/lib/file-name-opener.tsx index 7f52ce7e77b4..16052bba9681 100644 --- a/packages/reporter/src/lib/file-name-opener.tsx +++ b/packages/reporter/src/lib/file-name-opener.tsx @@ -1,7 +1,6 @@ import { observer } from 'mobx-react' import React from 'react' -import { FileDetails } from '@packages/types' -// @ts-ignore +import type { FileDetails } from '@packages/types' import Tooltip from '@cypress/react-tooltip' import TextIcon from '@packages/frontend-shared/src/assets/icons/document-text_x16.svg' diff --git a/packages/reporter/src/lib/state-icon.tsx b/packages/reporter/src/lib/state-icon.tsx index 47234faf31cc..2e01a97c414d 100644 --- a/packages/reporter/src/lib/state-icon.tsx +++ b/packages/reporter/src/lib/state-icon.tsx @@ -2,7 +2,7 @@ import cs from 'classnames' import { observer } from 'mobx-react' import React from 'react' -import { TestState } from '@packages/types' +import type { TestState } from '@packages/types' import FailedIcon from '@packages/frontend-shared/src/assets/icons/status-failed_x12.svg' import PassedIcon from '@packages/frontend-shared/src/assets/icons/status-passed_x12.svg' import PendingIcon from '@packages/frontend-shared/src/assets/icons/status-pending_x12.svg' diff --git a/packages/reporter/src/main.tsx b/packages/reporter/src/main.tsx index fbc2fed10517..4771fbad8ab2 100644 --- a/packages/reporter/src/main.tsx +++ b/packages/reporter/src/main.tsx @@ -7,7 +7,7 @@ import { render } from 'react-dom' // @ts-ignore import EQ from 'css-element-queries/src/ElementQueries' -import { RunnablesErrorModel } from './runnables/runnable-error' +import type { RunnablesErrorModel } from './runnables/runnable-error' import appState, { AppState } from './lib/app-state' import events, { Runner, Events } from './lib/events' import runnablesStore, { RunnablesStore } from './runnables/runnables-store' diff --git a/packages/reporter/src/preferences/testing-preferences.tsx b/packages/reporter/src/preferences/testing-preferences.tsx index 90675a2c46b6..8a58ee07ceeb 100644 --- a/packages/reporter/src/preferences/testing-preferences.tsx +++ b/packages/reporter/src/preferences/testing-preferences.tsx @@ -2,7 +2,7 @@ import { action } from 'mobx' import { observer } from 'mobx-react' import React from 'react' -import { AppState } from '../lib/app-state' +import type { AppState } from '../lib/app-state' import defaultEvents, { Events } from '../lib/events' import Switch from '../lib/switch' diff --git a/packages/reporter/src/routes/routes.tsx b/packages/reporter/src/routes/routes.tsx index cf6bdfb406b0..55aeac947bdd 100644 --- a/packages/reporter/src/routes/routes.tsx +++ b/packages/reporter/src/routes/routes.tsx @@ -7,7 +7,7 @@ import Tooltip from '@cypress/react-tooltip' import Collapsible from '../collapsible/collapsible' import Tag from '../lib/tag' -import RouteModel from './route-model' +import type RouteModel from './route-model' export interface RouteProps { model: RouteModel diff --git a/packages/reporter/src/runnables/runnable-and-suite.tsx b/packages/reporter/src/runnables/runnable-and-suite.tsx index c5321b7f9655..e7743a5a2d36 100644 --- a/packages/reporter/src/runnables/runnable-and-suite.tsx +++ b/packages/reporter/src/runnables/runnable-and-suite.tsx @@ -10,8 +10,8 @@ import events, { Events } from '../lib/events' import Test from '../test/test' import Collapsible from '../collapsible/collapsible' -import SuiteModel from './suite-model' -import TestModel from '../test/test-model' +import type SuiteModel from './suite-model' +import type TestModel from '../test/test-model' import { LaunchStudioIcon } from '../components/LaunchStudioIcon' diff --git a/packages/reporter/src/runnables/runnable-header.tsx b/packages/reporter/src/runnables/runnable-header.tsx index 355c5b150dda..e28ee9512e0e 100644 --- a/packages/reporter/src/runnables/runnable-header.tsx +++ b/packages/reporter/src/runnables/runnable-header.tsx @@ -1,7 +1,7 @@ import { observer } from 'mobx-react' import React, { Component, ReactElement } from 'react' -import { StatsStore } from '../header/stats-store' +import type { StatsStore } from '../header/stats-store' import { formatDuration, getFilenameParts } from '../lib/util' import FileNameOpener from '../lib/file-name-opener' diff --git a/packages/reporter/src/runnables/runnable-model.ts b/packages/reporter/src/runnables/runnable-model.ts index d96f7e8e7780..9a10212f6b50 100644 --- a/packages/reporter/src/runnables/runnable-model.ts +++ b/packages/reporter/src/runnables/runnable-model.ts @@ -1,5 +1,5 @@ import { observable, makeObservable } from 'mobx' -import { HookProps } from '../hooks/hook-model' +import type { HookProps } from '../hooks/hook-model' export interface RunnableProps { id: string diff --git a/packages/reporter/src/runnables/runnables-store.ts b/packages/reporter/src/runnables/runnables-store.ts index 8ba60a6ad1f3..25e462ae5b4a 100644 --- a/packages/reporter/src/runnables/runnables-store.ts +++ b/packages/reporter/src/runnables/runnables-store.ts @@ -1,14 +1,17 @@ -import { TestFilter } from '@packages/types' +import type { TestFilter } from '@packages/types' import _ from 'lodash' import { action, observable, makeObservable } from 'mobx' -import AgentModel, { AgentProps } from '../agents/agent-model' -import CommandModel, { CommandProps } from '../commands/command-model' -import { HookProps } from '../hooks/hook-model' +import type AgentModel from '../agents/agent-model' +import type { AgentProps } from '../agents/agent-model' +import type CommandModel from '../commands/command-model' +import type { CommandProps } from '../commands/command-model' +import type { HookProps } from '../hooks/hook-model' import appState, { AppState } from '../lib/app-state' import scroller, { Scroller } from '../lib/scroller' -import RouteModel, { RouteProps } from '../routes/route-model' +import type RouteModel from '../routes/route-model' +import type { RouteProps } from '../routes/route-model' import TestModel, { TestProps, UpdatableTestProps, UpdateTestCallback } from '../test/test-model' -import RunnableModel from './runnable-model' +import type RunnableModel from './runnable-model' import SuiteModel, { SuiteProps } from './suite-model' const defaults = { diff --git a/packages/reporter/src/runnables/runnables.tsx b/packages/reporter/src/runnables/runnables.tsx index cff9a0996270..3bde4ec38b12 100644 --- a/packages/reporter/src/runnables/runnables.tsx +++ b/packages/reporter/src/runnables/runnables.tsx @@ -7,9 +7,9 @@ import events, { Events } from '../lib/events' import { RunnablesError, RunnablesErrorModel } from './runnable-error' import Runnable from './runnable-and-suite' import RunnableHeader from './runnable-header' -import { RunnablesStore, RunnableArray } from './runnables-store' +import type { RunnablesStore, RunnableArray } from './runnables-store' import statsStore, { StatsStore } from '../header/stats-store' -import { Scroller, UserScrollCallback } from '../lib/scroller' +import type { Scroller, UserScrollCallback } from '../lib/scroller' import type { AppState } from '../lib/app-state' import OpenFileInIDE from '../lib/open-file-in-ide' diff --git a/packages/reporter/src/runnables/suite-model.ts b/packages/reporter/src/runnables/suite-model.ts index 3f175b3b2b81..2fdb3d79e621 100644 --- a/packages/reporter/src/runnables/suite-model.ts +++ b/packages/reporter/src/runnables/suite-model.ts @@ -1,8 +1,9 @@ import _ from 'lodash' import { computed, observable, makeObservable } from 'mobx' import Runnable, { RunnableProps } from './runnable-model' -import TestModel, { TestProps } from '../test/test-model' -import { TestState } from '@packages/types' +import type TestModel from '../test/test-model' +import type { TestProps } from '../test/test-model' +import type { TestState } from '@packages/types' export interface SuiteProps extends RunnableProps { suites: Array diff --git a/packages/reporter/src/sessions/sessions.tsx b/packages/reporter/src/sessions/sessions.tsx index 7955e2aecb34..7e6495300fea 100644 --- a/packages/reporter/src/sessions/sessions.tsx +++ b/packages/reporter/src/sessions/sessions.tsx @@ -3,7 +3,7 @@ import React from 'react' import { observer } from 'mobx-react' import GlobeIcon from '@packages/frontend-shared/src/assets/icons/globe_x12.svg' -import SessionsModel from './sessions-model' +import type SessionsModel from './sessions-model' import events from '../lib/events' import Collapsible from '../collapsible/collapsible' import Tag from '../lib/tag' diff --git a/packages/reporter/src/test/test-model.ts b/packages/reporter/src/test/test-model.ts index 2d856ed7a930..09070b111806 100644 --- a/packages/reporter/src/test/test-model.ts +++ b/packages/reporter/src/test/test-model.ts @@ -4,12 +4,12 @@ import { action, computed, observable, makeObservable } from 'mobx' import { FileDetails, TestState } from '@packages/types' import Attempt from '../attempts/attempt-model' import Err, { ErrProps } from '../errors/err-model' -import { HookProps } from '../hooks/hook-model' +import type { HookProps } from '../hooks/hook-model' import Runnable, { RunnableProps } from '../runnables/runnable-model' -import { CommandProps } from '../commands/command-model' -import { AgentProps } from '../agents/agent-model' -import { RouteProps } from '../routes/route-model' -import { RunnablesStore, LogProps } from '../runnables/runnables-store' +import type { CommandProps } from '../commands/command-model' +import type { AgentProps } from '../agents/agent-model' +import type { RouteProps } from '../routes/route-model' +import type { RunnablesStore, LogProps } from '../runnables/runnables-store' export type UpdateTestCallback = () => void diff --git a/packages/reporter/tsconfig.json b/packages/reporter/tsconfig.json index be6c7cd941b3..0d43b6f20311 100644 --- a/packages/reporter/tsconfig.json +++ b/packages/reporter/tsconfig.json @@ -4,7 +4,8 @@ "types": [ "node", "cypress", - "cypress-real-events" + "cypress-real-events", + "react" ], /* Type declaration files to be included in compilation. */ "importsNotUsedAsValues": "remove", "lib": ["DOM"] diff --git a/packages/resolve-dist/package.json b/packages/resolve-dist/package.json index 905ff18acfae..f46e18bfe6a5 100644 --- a/packages/resolve-dist/package.json +++ b/packages/resolve-dist/package.json @@ -5,10 +5,11 @@ "main": "index.js", "scripts": { "build-prod": "tsc --project .", - "check-ts": "tsc --noEmit", + "check-ts": "tsc --noEmit && yarn -s tslint", "clean": "rimraf 'lib/**/*.js'", "clean-deps": "rimraf node_modules", - "lint": "eslint --ext .js,.jsx,.ts,.tsx,.json, ." + "lint": "eslint --ext .js,.jsx,.ts,.tsx,.json, .", + "tslint": "tslint --config ../ts/tslint.json --project ." }, "dependencies": { "fs-extra": "9.1.0" diff --git a/packages/rewriter/package.json b/packages/rewriter/package.json index 25cee374656f..8784e6076ba9 100644 --- a/packages/rewriter/package.json +++ b/packages/rewriter/package.json @@ -6,11 +6,12 @@ "scripts": { "build-prod": "tsc --project .", "build-test": "yarn build-prod --noEmit", - "check-ts": "tsc --noEmit", + "check-ts": "tsc --noEmit && yarn -s tslint", "clean": "rimraf 'lib/**/*.js'", "clean-deps": "rimraf node_modules", "lint": "eslint --ext .js,.jsx,.ts,.tsx,.json, .", - "test": "mocha --reporter mocha-multi-reporters --reporter-options configFile=../../mocha-reporter-config.json" + "test": "mocha --reporter mocha-multi-reporters --reporter-options configFile=../../mocha-reporter-config.json", + "tslint": "tslint --config ../ts/tslint.json --project ." }, "dependencies": { "ast-types": "0.13.3", diff --git a/packages/runner/injection/patches/cookies.ts b/packages/runner/injection/patches/cookies.ts index 6b190556474b..fa066b482053 100644 --- a/packages/runner/injection/patches/cookies.ts +++ b/packages/runner/injection/patches/cookies.ts @@ -4,7 +4,7 @@ import { automationCookieToToughCookie, SerializableAutomationCookie, } from '@packages/server/lib/util/cookies' -import { Cookie as ToughCookie } from 'tough-cookie' +import type { Cookie as ToughCookie } from 'tough-cookie' function isHostOnlyCookie (domain) { return domain[0] !== '.' diff --git a/packages/runner/package.json b/packages/runner/package.json index cf36e9b04fc7..b0400e3b7de4 100644 --- a/packages/runner/package.json +++ b/packages/runner/package.json @@ -7,11 +7,13 @@ "prebuild": "rimraf ./dist", "build": "node ../../scripts/run-webpack", "build-prod": "cross-env NODE_ENV=production yarn build", + "check-ts": "yarn -s tslint", "clean-deps": "rimraf node_modules", "cypress:open": "echo \"These tests have been moved to @packages/app. \" && exit 1", "cypress:run": "echo \"These tests have been moved to @packages/app. \" && exit 1", "postinstall": "echo '@packages/runner needs: yarn build'", "lint": "eslint --ext .js,.jsx,.ts,.tsx,.json, .", + "tslint": "tslint --config ../ts/tslint.json --project .", "watch": "node ../../scripts/run-webpack --watch --progress" }, "devDependencies": { diff --git a/packages/runner/tsconfig.json b/packages/runner/tsconfig.json index ee2ec713e52f..07ad26bbf33b 100644 --- a/packages/runner/tsconfig.json +++ b/packages/runner/tsconfig.json @@ -1,59 +1,19 @@ { + "extends": "../ts/tsconfig.json", "compilerOptions": { - /* Basic Options */ - "target": "es2015", - "module": "commonjs", - /* - * Allow javascript files to be compiled. - * Override this in modules that need JS - */ - "allowJs": true, + "target": "es2017", "jsx": "react", "outDir": "dist", - "noImplicitAny": false, "noImplicitThis": false, "preserveWatchOutput": true, - // "checkJs": true, /* Report errors in .js files. */ - // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ - /* Generates corresponding '.d.ts' file. */ - // "declaration": true, - // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ - /* Generates corresponding '.map' file. */ - "sourceMap": true, - /* Import emit helpers from 'tslib'. */ - "importHelpers": true, - "strictNullChecks": true, - // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ - // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ - /* Strict Type-Checking Options */ - // "traceResolution": true, "strict": false, - "forceConsistentCasingInFileNames": true, - "skipLibCheck": true, - /** - * Skip type checking of all declaration files (*.d.ts). - * TODO: Look into changing this in the future - */ - /* Additional Checks */ - /* Report errors on unused locals. */ - // "noEmit": true, - "noUnusedLocals": false, - // "noUnusedParameters": true, /* Report errors on unused parameters. */ - /* Report error when not all code paths in function return a value. */ - "noImplicitReturns": true, - // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ - /* Module Resolution Options */ - // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ - // "baseUrl": "../", /* Base directory to resolve non-absolute module names. */ - // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ - // "rootDirs": ["../driver/src"], /* List of root folders whose combined content represents the structure of the project at runtime. */ - "types": [], /* Type declaration files to be included in compilation. */ - "allowSyntheticDefaultImports": true, - "esModuleInterop": true, - "noErrorTruncation": true, - "experimentalDecorators": true, - // "noResolve": true - "resolveJsonModule": true + "types": [ + "node", + "cypress", + "cypress-real-events", + "react", + ], /* Type declaration files to be included in compilation. */ + "noErrorTruncation": true }, "exclude": [ "dist", diff --git a/packages/scaffold-config/package.json b/packages/scaffold-config/package.json index ec6c3263b1ba..0ce5a7e01a73 100644 --- a/packages/scaffold-config/package.json +++ b/packages/scaffold-config/package.json @@ -6,12 +6,13 @@ "browser": "src/index.ts", "scripts": { "build-prod": "tsc || echo 'built, with errors'", - "check-ts": "tsc --noEmit", + "check-ts": "tsc --noEmit && yarn -s tslint", "clean": "rimraf ./src/*.js ./src/**/*.js ./src/**/**/*.js ./test/**/*.js || echo 'cleaned'", "clean-deps": "rimraf node_modules", "lint": "eslint --ext .js,.jsx,.ts,.tsx,.json, .", "test": "yarn test-unit", - "test-unit": "mocha -r @packages/ts/register 'test/unit/**' --config ./test/.mocharc.js --exit --reporter mocha-multi-reporters --reporter-options configFile=../../mocha-reporter-config.json" + "test-unit": "mocha -r @packages/ts/register 'test/unit/**' --config ./test/.mocharc.js --exit --reporter mocha-multi-reporters --reporter-options configFile=../../mocha-reporter-config.json", + "tslint": "tslint --config ../ts/tslint.json --project ." }, "dependencies": { "compare-versions": "4.1.3", diff --git a/packages/server/lib/routes.ts b/packages/server/lib/routes.ts index 7751f4a2b87b..76360fd205ca 100644 --- a/packages/server/lib/routes.ts +++ b/packages/server/lib/routes.ts @@ -151,8 +151,8 @@ export const createCommonRoutes = ({ res.sendFile(path.join(__dirname, './html/set-local-storage.html')) }) - router.get(`/${config.namespace}/source-maps/:id.map`, (req, res) => { - networkProxy.handleSourceMapRequest(req, res) + router.get(`/${config.namespace}/source-maps/:id.map`, async (req, res) => { + await networkProxy.handleSourceMapRequest(req, res) }) // special fallback - serve dist'd (bundled/static) files from the project path folder @@ -274,8 +274,8 @@ export const createCommonRoutes = ({ }) } - router.all('*', (req, res) => { - networkProxy.handleHttpRequest(req, res) + router.all('*', async (req, res) => { + await networkProxy.handleHttpRequest(req, res) }) // when we experience uncaught errors diff --git a/packages/server/lib/socket-base.ts b/packages/server/lib/socket-base.ts index 21b872c02a92..242228861127 100644 --- a/packages/server/lib/socket-base.ts +++ b/packages/server/lib/socket-base.ts @@ -159,9 +159,9 @@ export class SocketBase { const cdpIo = this._cdpIo = this.createCDPIo(socketIoRoute) automation.use({ - onPush: (message, data) => { + onPush: async (message, data) => { socketIo.emit('automation:push:message', message, data) - cdpIo.emit('automation:push:message', message, data) + await cdpIo.emit('automation:push:message', message, data) }, }) diff --git a/packages/socket/lib/browser.ts b/packages/socket/lib/browser.ts index 1ca9ccc205f1..c097f3eca969 100644 --- a/packages/socket/lib/browser.ts +++ b/packages/socket/lib/browser.ts @@ -26,6 +26,7 @@ export function client (uri: string, opts?: Partial { + const send = async (payload: string) => { const parsed = JSON.parse(payload) - decode(parsed).then((decoded: any) => { + await decode(parsed).then(async (decoded: any) => { const [event, callbackEvent, args] = decoded super.emit(event, ...args) - this.emit(callbackEvent) + await this.emit(callbackEvent) }) } @@ -52,7 +52,8 @@ export class CDPBrowserSocket extends Emitter implements SocketShape { }, 0) } - emit = (event: string, ...args: any[]) => { + // @ts-expect-error TODO: fix emit type + emit = async (event: string, ...args: any[]) => { // Generate a unique key for this event const uuid = uuidv4() let callback @@ -65,7 +66,7 @@ export class CDPBrowserSocket extends Emitter implements SocketShape { this.once(uuid, callback) } - encode([event, uuid, args], this._namespace).then((encoded: any) => { + await encode([event, uuid, args], this._namespace).then((encoded: any) => { window[`cypressSendToServer-${this._namespace}`](JSON.stringify(encoded)) }) diff --git a/packages/socket/lib/cdp-socket.ts b/packages/socket/lib/cdp-socket.ts index f042cd14b81e..15acf3347af0 100644 --- a/packages/socket/lib/cdp-socket.ts +++ b/packages/socket/lib/cdp-socket.ts @@ -34,7 +34,8 @@ export class CDPSocketServer extends EventEmitter { super.emit('connection', this._cdpSocket) } - emit = (event: string, ...args: any[]) => { + // @ts-expect-error TODO: fix emit type + emit = async (event: string, ...args: any[]) => { this._cdpSocket?.emit(event, ...args) return true @@ -100,7 +101,8 @@ export class CDPSocket extends EventEmitter { return } - emit = (event: string, ...args: any[]) => { + // @ts-expect-error TODO: fix emit type + emit = async (event: string, ...args: any[]) => { // Generate a unique callback event name const uuid = randomUUID() let callback: ((...args: any[]) => void) | undefined @@ -113,7 +115,7 @@ export class CDPSocket extends EventEmitter { this.once(uuid, callback) } - encode([event, uuid, args], this._namespace).then((encoded: any) => { + await encode([event, uuid, args], this._namespace).then((encoded: any) => { const expression = ` if (window['cypressSocket-${this._namespace}'] && window['cypressSocket-${this._namespace}'].send) { window['cypressSocket-${this._namespace}'].send('${JSON.stringify(encoded).replaceAll('\\', '\\\\').replaceAll('\'', '\\\'')}') @@ -158,12 +160,12 @@ export class CDPSocket extends EventEmitter { const data = JSON.parse(payload) - decode(data).then((decoded: any) => { + await decode(data).then((decoded: any) => { const [event, callbackEvent, args] = decoded - const callback = (...callbackArgs: any[]) => { + const callback = async (...callbackArgs: any[]) => { debugVerbose('emitting callback from browser %o', { callbackEvent, callbackArgs }) - this.emit(callbackEvent, ...callbackArgs) + await this.emit(callbackEvent, ...callbackArgs) } debugVerbose('emitting message from browser %o', { event, callbackEvent, args }) diff --git a/packages/socket/package.json b/packages/socket/package.json index 56e99d97fbe6..1f40105288a1 100644 --- a/packages/socket/package.json +++ b/packages/socket/package.json @@ -5,7 +5,7 @@ "browser": "lib/browser.ts", "scripts": { "build-prod": "tsc || echo 'built, with type errors' && rm lib/browser.js", - "check-ts": "tsc --noEmit", + "check-ts": "tsc --noEmit && yarn -s tslint", "clean": "rimraf lib/*.js", "clean-deps": "rimraf node_modules", "postinstall": "patch-package", @@ -13,7 +13,8 @@ "test": "yarn test-unit", "test-debug": "yarn test-unit --inspect-brk=5566", "test-unit": "cross-env NODE_ENV=test mocha -r @packages/ts/register --reporter mocha-multi-reporters --reporter-options configFile=../../mocha-reporter-config.json", - "test-watch": "cross-env NODE_ENV=test mocha -r @packages/ts/register --watch" + "test-watch": "cross-env NODE_ENV=test mocha -r @packages/ts/register --watch", + "tslint": "tslint --config ../ts/tslint.json --project ." }, "dependencies": { "engine.io": "6.4.2", diff --git a/packages/ts/tslint.json b/packages/ts/tslint.json index 8fce41d89b27..f35806c837f1 100644 --- a/packages/ts/tslint.json +++ b/packages/ts/tslint.json @@ -1,5 +1,8 @@ { "rules": { "no-floating-promises": true + }, + "jsRules": { + "no-empty": true } } diff --git a/packages/web-config/tsconfig.json b/packages/web-config/tsconfig.json index 2935a947d693..de6dea6ad5dd 100644 --- a/packages/web-config/tsconfig.json +++ b/packages/web-config/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { /* Basic Options */ - "target": "es2015", + "target": "es2017", "module": "commonjs", /* * Allow javascript files to be compiled.