From 58417412f101c07ef862402f7f1587eb4c3a4530 Mon Sep 17 00:00:00 2001 From: Zach Pomerantz Date: Mon, 24 Apr 2023 16:00:04 -0700 Subject: [PATCH] build: tighten tsconfig (to include build cache, exclude watch folders) (#6375) * build: extend cypress tsconfig from build tsconfig * build: exclude node_modules from watch to improve typechecking perf * fix: even tighter tsconfigs * fix: even tighter * fix: tailor cypress tsconfig to testing * fix: split them up again * fix: pr comments --- cypress.release.config.ts | 8 -------- cypress/e2e/service-worker.test.ts | 2 +- cypress/release.ts | 21 --------------------- cypress/support/e2e.ts | 5 +++-- cypress/tsconfig.json | 16 ++++++++++++---- package.json | 2 +- tsconfig.json | 10 ++++++---- 7 files changed, 23 insertions(+), 41 deletions(-) delete mode 100644 cypress.release.config.ts delete mode 100644 cypress/release.ts diff --git a/cypress.release.config.ts b/cypress.release.config.ts deleted file mode 100644 index 54117eeed3..0000000000 --- a/cypress.release.config.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { defineConfig } from 'cypress' - -export default defineConfig({ - projectId: 'yp82ef', - e2e: { - specPattern: 'cypress/release.ts', - }, -}) diff --git a/cypress/e2e/service-worker.test.ts b/cypress/e2e/service-worker.test.ts index 4e2450c3bb..95f9db0655 100644 --- a/cypress/e2e/service-worker.test.ts +++ b/cypress/e2e/service-worker.test.ts @@ -1,4 +1,4 @@ -import assert = require('assert') +import assert from 'assert' describe('Service Worker', () => { before(() => { diff --git a/cypress/release.ts b/cypress/release.ts deleted file mode 100644 index f639f6587c..0000000000 --- a/cypress/release.ts +++ /dev/null @@ -1,21 +0,0 @@ -const ONE_MINUTE = 60_000 - -describe( - 'Release', - { - pageLoadTimeout: ONE_MINUTE, - retries: 30, - }, - () => { - it('loads swap page', () => { - // TODO: We *must* wait in order to space out the retry attempts. Find a better way to do this. - // eslint-disable-next-line cypress/no-unnecessary-waiting - cy.wait(ONE_MINUTE) - .visit('/', { - retryOnStatusCodeFailure: true, - retryOnNetworkFailure: true, - }) - .get('#swap-page') - }) - } -) diff --git a/cypress/support/e2e.ts b/cypress/support/e2e.ts index fc3bbf1791..6ef7b6670c 100644 --- a/cypress/support/e2e.ts +++ b/cypress/support/e2e.ts @@ -6,11 +6,12 @@ // *********************************************************** // Import commands.ts using ES2015 syntax: -import { injected } from './ethereum' -import assert = require('assert') import '@cypress/code-coverage/support' +import assert from 'assert' + import { FeatureFlag } from '../../src/featureFlags/flags/featureFlags' +import { injected } from './ethereum' declare global { // eslint-disable-next-line @typescript-eslint/no-namespace diff --git a/cypress/tsconfig.json b/cypress/tsconfig.json index f9d46408ff..4ad8507c8b 100644 --- a/cypress/tsconfig.json +++ b/cypress/tsconfig.json @@ -1,9 +1,17 @@ { "compilerOptions": { + "esModuleInterop": true, + "incremental": true, + "lib": ["DOM", "DOM.Iterable", "ESNext"], + "noEmit": true, "strict": true, - "target": "es5", - "lib": ["es5", "dom"], - "types": ["cypress"] + "target": "ES5", + "tsBuildInfoFile": "../node_modules/.cache/tsbuildinfo/cypress", // avoid clobbering the build tsbuildinfo + "types": ["cypress", "node"] }, - "include": ["**/*.ts"] + "exclude": ["node_modules"], + "include": ["**/*.ts"], + "watchOptions": { + "excludeDirectories": ["node_modules"] + } } diff --git a/package.json b/package.json index 7ee0933112..6c716100db 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "analyze": "source-map-explorer 'build/static/js/*.js'", "serve": "serve build -l 3000", "lint": "yarn eslint --ignore-path .gitignore --cache --cache-location node_modules/.cache/eslint/ .", - "typecheck": "tsc --noEmit", + "typecheck": "tsc", "test": "craco test --coverage", "test:size": "node scripts/test-size.js", "cypress:open": "cypress open --browser chrome --e2e", diff --git a/tsconfig.json b/tsconfig.json index 0af1aa8827..c8273bc97d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,7 +8,6 @@ "downlevelIteration": true, "esModuleInterop": true, "forceConsistentCasingInFileNames": true, - "incremental": true, "isolatedModules": true, "jsx": "react-jsx", "lib": ["DOM", "DOM.Iterable", "ESNext"], @@ -25,10 +24,13 @@ "strict": true, "strictNullChecks": true, "target": "ESNext", - "tsBuildInfoFile": "node_modules/.cache/.tsbuildinfo", + "tsBuildInfoFile": "node_modules/.cache/tsbuildinfo/build", // avoid clobbering the cypress tsbuildinfo "types": ["jest"], "useUnknownInCatchVariables": false }, - "exclude": ["node_modules", "cypress"], - "include": ["src/**/*", "src/**/*.json"] + "exclude": ["node_modules"], + "include": ["src/**/*", "src/**/*.json"], + "watchOptions": { + "excludeDirectories": ["node_modules"] + } }