Skip to content

Commit

Permalink
[js] resolve CodeQL warnings for force strict mode (#8645)
Browse files Browse the repository at this point in the history
  • Loading branch information
fs-eire authored Aug 7, 2021
1 parent 419fd5c commit c86b813
Show file tree
Hide file tree
Showing 26 changed files with 55 additions and 0 deletions.
5 changes: 5 additions & 0 deletions js/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

'use strict';

module.exports = {
root: true,
ignorePatterns: ['**/*.js', 'node_modules/', 'types/', 'dist/'],
Expand Down
5 changes: 5 additions & 0 deletions js/common/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

'use strict';

const path = require('path');
const webpack = require('webpack');
const TerserPlugin = require("terser-webpack-plugin");
Expand Down
2 changes: 2 additions & 0 deletions js/react_native/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

module.exports = {
presets: ['module:metro-react-native-babel-preset'],
};
2 changes: 2 additions & 0 deletions js/react_native/example/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

const path = require('path');
const pak = require('../package.json');

Expand Down
2 changes: 2 additions & 0 deletions js/react_native/example/metro.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

const path = require('path');
const blacklist = require('metro-config/src/defaults/blacklist');
const escape = require('escape-string-regexp');
Expand Down
2 changes: 2 additions & 0 deletions js/react_native/scripts/bootstrap.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

const path = require('path');
const child_process = require('child_process');

Expand Down
2 changes: 2 additions & 0 deletions js/web/karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

'use strict';

const bundleMode = require('minimist')(process.argv)['bundle-mode'] || 'dev'; // 'dev'|'perf'|undefined;
const karmaPlugins = require('minimist')(process.argv)['karma-plugins'] || undefined;
const timeoutMocha = require('minimist')(process.argv)['timeout-mocha'] || 60000;
Expand Down
2 changes: 2 additions & 0 deletions js/web/test/e2e/browser-test-wasm-no-threads.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

'use strict';

it('Browser E2E testing - WebAssembly backend (no threads)', async function () {
ort.env.wasm.numThreads = 1;
await testFunction(ort, { executionProviders: ['wasm'] });
Expand Down
2 changes: 2 additions & 0 deletions js/web/test/e2e/browser-test-wasm-path-override-filename.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

'use strict';

it('Browser E2E testing - WebAssembly backend (path override filename)', async function () {
// disable SIMD and multi-thread
ort.env.wasm.numThreads = 1;
Expand Down
2 changes: 2 additions & 0 deletions js/web/test/e2e/browser-test-wasm-path-override-prefix.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

'use strict';

it('Browser E2E testing - WebAssembly backend (path override prefix)', async function () {

// disable SIMD and multi-thread
Expand Down
2 changes: 2 additions & 0 deletions js/web/test/e2e/browser-test-wasm.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

'use strict';

it('Browser E2E testing - WebAssembly backend', async function () {
await testFunction(ort, { executionProviders: ['wasm'] });
});
2 changes: 2 additions & 0 deletions js/web/test/e2e/browser-test-webgl.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

'use strict';

it('Browser E2E testing - WebGL backend', async function () {
await testFunction(ort, { executionProviders: ['webgl'] });
});
2 changes: 2 additions & 0 deletions js/web/test/e2e/common.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

'use strict';

function assert(cond) {
if (!cond) throw new Error();
}
Expand Down
2 changes: 2 additions & 0 deletions js/web/test/e2e/karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

'use strict';

const args = require('minimist')(process.argv.slice(2));
const SELF_HOST = !!args['self-host'];
const TEST_MAIN = args['test-main'];
Expand Down
2 changes: 2 additions & 0 deletions js/web/test/e2e/node-test-main-no-threads.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

'use strict';

const ort = require('onnxruntime-web');
const testFunction = require('./common');

Expand Down
2 changes: 2 additions & 0 deletions js/web/test/e2e/node-test-main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

'use strict';

const ort = require('onnxruntime-web');
const testFunction = require('./common');

Expand Down
2 changes: 2 additions & 0 deletions js/web/test/e2e/node-test-wasm-path-override-filename.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

'use strict';

const path = require('path');
const ort = require('onnxruntime-web');
const testFunction = require('./common');
Expand Down
2 changes: 2 additions & 0 deletions js/web/test/e2e/node-test-wasm-path-override-prefix.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

'use strict';

const path = require('path');
const ort = require('onnxruntime-web');
const testFunction = require('./common');
Expand Down
2 changes: 2 additions & 0 deletions js/web/test/e2e/run.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

'use strict';

const path = require('path');
const fs = require('fs-extra');
const globby = require('globby');
Expand Down
2 changes: 2 additions & 0 deletions js/web/test/e2e/simple-http-server.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

'use strict';

// this is a simple HTTP server that enables CORS.
// following code is based on https://developer.mozilla.org/en-US/docs/Learn/Server-side/Node_server_without_framework

Expand Down
2 changes: 2 additions & 0 deletions js/web/test/unittests/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

'use strict';

if (typeof window !== 'undefined') {
require('./backends/webgl/test-glsl-function-inliner');
require('./backends/webgl/test-conv-new');
Expand Down
2 changes: 2 additions & 0 deletions js/web/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

'use strict';

const path = require('path');
const webpack = require('webpack');
const NodePolyfillPlugin = require('node-polyfill-webpack-plugin');
Expand Down
2 changes: 2 additions & 0 deletions onnxruntime/test/wasm/dump-test-result-in-nodejs.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

'use strict';

// This file is used to be injected into "onnxruntime_test_all" as specified by flag "--pre-js" by emcc.
// It dumps the test report file from emscripten's MEMFS to real file system

Expand Down
1 change: 1 addition & 0 deletions samples/nodejs/01_basic-usage/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use strict';
const ort = require('onnxruntime');

// use an async context to call onnxruntime functions.
Expand Down
1 change: 1 addition & 0 deletions samples/nodejs/02_create-tensor/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use strict';
const Tensor = require('onnxruntime').Tensor;

//
Expand Down
1 change: 1 addition & 0 deletions samples/nodejs/04_create-inference-session/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use strict';
const fs = require('fs');
const util = require('util');
const InferenceSession = require('onnxruntime').InferenceSession;
Expand Down

0 comments on commit c86b813

Please sign in to comment.