From 893ee65e54db599e7b8486dd78999402739e53ef Mon Sep 17 00:00:00 2001 From: Yulong Wang <7679871+fs-eire@users.noreply.github.com> Date: Thu, 17 Feb 2022 22:34:38 -0800 Subject: [PATCH] [js/web] fix lint error when run without ort-web TS types (#10429) * [js/web] fix lint error when run without ort-web TS types * update CI to run linter before 'npm ci' in /js/web --- js/web/lib/wasm/proxy-worker/main.ts | 2 +- js/web/script/build.ts | 4 ++-- .../github/azure-pipelines/templates/win-web-ci.yml | 6 +++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/js/web/lib/wasm/proxy-worker/main.ts b/js/web/lib/wasm/proxy-worker/main.ts index 876b0572e1..1e343f890a 100644 --- a/js/web/lib/wasm/proxy-worker/main.ts +++ b/js/web/lib/wasm/proxy-worker/main.ts @@ -10,7 +10,7 @@ import {initializeWebAssembly} from '../wasm-factory'; self.onmessage = (ev: MessageEvent): void => { switch (ev.data.type) { case 'init-wasm': - initializeWebAssembly(ev.data.in!) + initializeWebAssembly(ev.data.in) .then( () => postMessage({type: 'init-wasm'} as OrtWasmMessage), err => postMessage({type: 'init-wasm', err} as OrtWasmMessage)); diff --git a/js/web/script/build.ts b/js/web/script/build.ts index e3f9723f26..294e84520e 100644 --- a/js/web/script/build.ts +++ b/js/web/script/build.ts @@ -99,7 +99,7 @@ if (WASM) { } fs.writeFileSync(WASM_BINDING_THREADED_MIN_JS_PATH, terser.stdout); - fs.writeFileSync(WASM_THREADED_JS_PATH, COPYRIGHT_BANNER + terser.stdout); + fs.writeFileSync(WASM_THREADED_JS_PATH, `${COPYRIGHT_BANNER}${terser.stdout}`); validateFile(WASM_BINDING_THREADED_MIN_JS_PATH); validateFile(WASM_THREADED_JS_PATH); @@ -124,7 +124,7 @@ if (WASM) { } fs.writeFileSync(WASM_BINDING_THREADED_MIN_WORKER_JS_PATH, terser.stdout); - fs.writeFileSync(WASM_THREADED_WORKER_JS_PATH, COPYRIGHT_BANNER + terser.stdout); + fs.writeFileSync(WASM_THREADED_WORKER_JS_PATH, `${COPYRIGHT_BANNER}${terser.stdout}`); validateFile(WASM_BINDING_THREADED_MIN_WORKER_JS_PATH); validateFile(WASM_THREADED_WORKER_JS_PATH); diff --git a/tools/ci_build/github/azure-pipelines/templates/win-web-ci.yml b/tools/ci_build/github/azure-pipelines/templates/win-web-ci.yml index b7691af037..564e361b22 100644 --- a/tools/ci_build/github/azure-pipelines/templates/win-web-ci.yml +++ b/tools/ci_build/github/azure-pipelines/templates/win-web-ci.yml @@ -72,6 +72,10 @@ jobs: npm ci workingDirectory: '$(Build.SourcesDirectory)\js' displayName: 'npm ci /js/' + - script: | + npm run lint + workingDirectory: '$(Build.SourcesDirectory)\js' + displayName: 'run ESLint without TS type populated' - script: | npm ci workingDirectory: '$(Build.SourcesDirectory)\js\common' @@ -83,7 +87,7 @@ jobs: - script: | npm run lint workingDirectory: '$(Build.SourcesDirectory)\js' - displayName: 'ESLint' + displayName: 'run ESLint' - script: | npm run format workingDirectory: '$(Build.SourcesDirectory)\js'