Fixes for eslint & precommit configuration (#2352)

* Fixed some codacy configs, fixed commiting with lint-stage

* Improved code

* Fixed header

* Fixed headers

* Removed extra dependencies

* Updated some packages (fixed critical vulnerabilities)
main
Boris Sekachev 5 years ago committed by GitHub
parent 7512fd6883
commit 0576cb7872
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation // Copyright (C) 2018-2020 Intel Corporation
// //
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
@ -9,15 +9,16 @@ module.exports = {
es6: true, es6: true,
jquery: true, jquery: true,
qunit: true, qunit: true,
'jest/globals': true,
'cypress/globals': true,
}, },
parserOptions: { parserOptions: {
sourceType: 'script', sourceType: 'script',
}, },
plugins: ['requirejs', 'jest', 'cypress', 'eslint-plugin-header'], plugins: ['eslint-plugin-header'],
extends: ['eslint:recommended', 'plugin:requirejs/recommended', 'prettier'], extends: ['eslint:recommended', 'prettier'],
rules: { rules: {
'header/header': [2, '.header.js'], 'header/header': [2, 'line', [{
pattern: ' {1}Copyright \\(C\\) (?:20\\d{2}-)?2020 Intel Corporation',
template: ' Copyright (C) 2020 Intel Corporation'
}, '', ' SPDX-License-Identifier: MIT']],
}, },
}; };

@ -1,3 +0,0 @@
// Copyright (C) 2020 Intel Corporation
//
// SPDX-License-Identifier: MIT

@ -1,12 +1,10 @@
// Copyright (C) 2020 Intel Corporation // Copyright (C) 2019-2020 Intel Corporation
// //
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
module.exports = { module.exports = {
env: { env: {
node: true, node: true,
browser: true,
es6: true,
}, },
parserOptions: { parserOptions: {
parser: '@typescript-eslint/parser', parser: '@typescript-eslint/parser',

@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation // Copyright (C) 2019-2020 Intel Corporation
// //
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT

@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation // Copyright (C) 2018-2020 Intel Corporation
// //
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
@ -9,13 +9,14 @@ module.exports = {
es6: true, es6: true,
jquery: true, jquery: true,
qunit: true, qunit: true,
'jest/globals': true,
}, },
parserOptions: { parserOptions: {
parser: 'babel-eslint', parser: 'babel-eslint',
sourceType: 'module', sourceType: 'module',
ecmaVersion: 2018, ecmaVersion: 2018,
}, },
plugins: ['security', 'no-unsanitized', 'no-unsafe-innerhtml'], plugins: ['security', 'jest', 'no-unsanitized', 'no-unsafe-innerhtml'],
extends: ['eslint:recommended', 'plugin:security/recommended', 'plugin:no-unsanitized/DOM', 'airbnb-base'], extends: ['eslint:recommended', 'plugin:security/recommended', 'plugin:no-unsanitized/DOM', 'airbnb-base'],
rules: { rules: {
'no-await-in-loop': [0], 'no-await-in-loop': [0],

@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation // Copyright (C) 2019-2020 Intel Corporation
// //
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT

@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation // Copyright (C) 2019-2020 Intel Corporation
// //
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT

@ -1232,6 +1232,32 @@
"@types/yargs": "^13.0.0" "@types/yargs": "^13.0.0"
} }
}, },
"@nodelib/fs.scandir": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.3.tgz",
"integrity": "sha512-eGmwYQn3gxo4r7jdQnkrrN6bY478C3P+a/y72IJukF8LjB6ZHeB3c+Ehacj3sYeSmUXGlnA67/PmbM9CVwL7Dw==",
"dev": true,
"requires": {
"@nodelib/fs.stat": "2.0.3",
"run-parallel": "^1.1.9"
}
},
"@nodelib/fs.stat": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.3.tgz",
"integrity": "sha512-bQBFruR2TAwoevBEd/NWMoAAtNGzTRgdrqnYCc7dhzfoNvqPzLyqlEQnzZ3kVnNrSp25iyxE00/3h2fqGAGArA==",
"dev": true
},
"@nodelib/fs.walk": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.4.tgz",
"integrity": "sha512-1V9XOY4rDW0rehzbrcqAmHnz8e7SKvX27gh8Gt2WgB0+pdzdiLV83p72kZPU+jvMbS1qU5mauP2iOvO8rhmurQ==",
"dev": true,
"requires": {
"@nodelib/fs.scandir": "2.1.3",
"fastq": "^1.6.0"
}
},
"@types/babel__core": { "@types/babel__core": {
"version": "7.1.9", "version": "7.1.9",
"resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.9.tgz", "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.9.tgz",
@ -1315,6 +1341,89 @@
"resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-15.0.0.tgz", "resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-15.0.0.tgz",
"integrity": "sha512-FA/BWv8t8ZWJ+gEOnLLd8ygxH/2UFbAvgEonyfN6yWGLKc7zVjbpl2Y4CTjid9h2RfgPP6SEt6uHwEOply00yw==" "integrity": "sha512-FA/BWv8t8ZWJ+gEOnLLd8ygxH/2UFbAvgEonyfN6yWGLKc7zVjbpl2Y4CTjid9h2RfgPP6SEt6uHwEOply00yw=="
}, },
"@typescript-eslint/experimental-utils": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.5.0.tgz",
"integrity": "sha512-bW9IpSAKYvkqDGRZzayBXIgPsj2xmmVHLJ+flGSoN0fF98pGoKFhbunIol0VF2Crka7z984EEhFi623Rl7e6gg==",
"dev": true,
"requires": {
"@types/json-schema": "^7.0.3",
"@typescript-eslint/scope-manager": "4.5.0",
"@typescript-eslint/types": "4.5.0",
"@typescript-eslint/typescript-estree": "4.5.0",
"eslint-scope": "^5.0.0",
"eslint-utils": "^2.0.0"
},
"dependencies": {
"eslint-utils": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.1.0.tgz",
"integrity": "sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==",
"dev": true,
"requires": {
"eslint-visitor-keys": "^1.1.0"
}
}
}
},
"@typescript-eslint/scope-manager": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.5.0.tgz",
"integrity": "sha512-C0cEO0cTMPJ/w4RA/KVe4LFFkkSh9VHoFzKmyaaDWAnPYIEzVCtJ+Un8GZoJhcvq+mPFXEsXa01lcZDHDG6Www==",
"dev": true,
"requires": {
"@typescript-eslint/types": "4.5.0",
"@typescript-eslint/visitor-keys": "4.5.0"
}
},
"@typescript-eslint/types": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.5.0.tgz",
"integrity": "sha512-n2uQoXnyWNk0Les9MtF0gCK3JiWd987JQi97dMSxBOzVoLZXCNtxFckVqt1h8xuI1ix01t+iMY4h4rFMj/303g==",
"dev": true
},
"@typescript-eslint/typescript-estree": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.5.0.tgz",
"integrity": "sha512-gN1mffq3zwRAjlYWzb5DanarOPdajQwx5MEWkWCk0XvqC8JpafDTeioDoow2L4CA/RkYZu7xEsGZRhqrTsAG8w==",
"dev": true,
"requires": {
"@typescript-eslint/types": "4.5.0",
"@typescript-eslint/visitor-keys": "4.5.0",
"debug": "^4.1.1",
"globby": "^11.0.1",
"is-glob": "^4.0.1",
"lodash": "^4.17.15",
"semver": "^7.3.2",
"tsutils": "^3.17.1"
},
"dependencies": {
"semver": {
"version": "7.3.2",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz",
"integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==",
"dev": true
}
}
},
"@typescript-eslint/visitor-keys": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.5.0.tgz",
"integrity": "sha512-UHq4FSa55NDZqscRU//O5ROFhHa9Hqn9KWTEvJGTArtTQp5GKv9Zqf6d/Q3YXXcFv4woyBml7fJQlQ+OuqRcHA==",
"dev": true,
"requires": {
"@typescript-eslint/types": "4.5.0",
"eslint-visitor-keys": "^2.0.0"
},
"dependencies": {
"eslint-visitor-keys": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.0.0.tgz",
"integrity": "sha512-QudtT6av5WXels9WjIM7qz1XD1cWGvX4gGXvp/zBn9nXG02D0utdU3Em2m/QjTnrsk6bBjmCygl3rmj118msQQ==",
"dev": true
}
}
},
"@webassemblyjs/ast": { "@webassemblyjs/ast": {
"version": "1.9.0", "version": "1.9.0",
"resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.9.0.tgz", "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.9.0.tgz",
@ -1644,6 +1753,12 @@
"is-string": "^1.0.5" "is-string": "^1.0.5"
} }
}, },
"array-union": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz",
"integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==",
"dev": true
},
"array-unique": { "array-unique": {
"version": "0.3.2", "version": "0.3.2",
"resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz",
@ -2708,8 +2823,8 @@
"cvat-data": { "cvat-data": {
"version": "file:../cvat-data", "version": "file:../cvat-data",
"requires": { "requires": {
"async-mutex": "^0.1.4", "async-mutex": "^0.2.4",
"jszip": "3.1.5" "jszip": "3.5.0"
}, },
"dependencies": { "dependencies": {
"@babel/cli": { "@babel/cli": {
@ -9429,6 +9544,23 @@
} }
} }
}, },
"debug": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.2.0.tgz",
"integrity": "sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg==",
"dev": true,
"requires": {
"ms": "2.1.2"
},
"dependencies": {
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
"dev": true
}
}
},
"decamelize": { "decamelize": {
"version": "1.2.0", "version": "1.2.0",
"resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz",
@ -9544,6 +9676,23 @@
} }
} }
}, },
"dir-glob": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz",
"integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==",
"dev": true,
"requires": {
"path-type": "^4.0.0"
},
"dependencies": {
"path-type": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz",
"integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==",
"dev": true
}
}
},
"doctrine": { "doctrine": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz",
@ -10165,6 +10314,15 @@
} }
} }
}, },
"eslint-plugin-jest": {
"version": "24.1.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-24.1.0.tgz",
"integrity": "sha512-827YJ+E8B9PvXu/0eiVSNFfxxndbKv+qE/3GSMhdorCaeaOehtqHGX2YDW9B85TEOre9n/zscledkFW/KbnyGg==",
"dev": true,
"requires": {
"@typescript-eslint/experimental-utils": "^4.0.1"
}
},
"eslint-plugin-no-unsafe-innerhtml": { "eslint-plugin-no-unsafe-innerhtml": {
"version": "1.0.16", "version": "1.0.16",
"resolved": "https://registry.npmjs.org/eslint-plugin-no-unsafe-innerhtml/-/eslint-plugin-no-unsafe-innerhtml-1.0.16.tgz", "resolved": "https://registry.npmjs.org/eslint-plugin-no-unsafe-innerhtml/-/eslint-plugin-no-unsafe-innerhtml-1.0.16.tgz",
@ -10858,6 +11016,74 @@
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q=="
}, },
"fast-glob": {
"version": "3.2.4",
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.4.tgz",
"integrity": "sha512-kr/Oo6PX51265qeuCYsyGypiO5uJFgBS0jksyG7FUeCyQzNwYnzrNIMR1NXfkZXsMYXYLRAHgISHBz8gQcxKHQ==",
"dev": true,
"requires": {
"@nodelib/fs.stat": "^2.0.2",
"@nodelib/fs.walk": "^1.2.3",
"glob-parent": "^5.1.0",
"merge2": "^1.3.0",
"micromatch": "^4.0.2",
"picomatch": "^2.2.1"
},
"dependencies": {
"braces": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz",
"integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==",
"dev": true,
"requires": {
"fill-range": "^7.0.1"
}
},
"fill-range": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
"integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==",
"dev": true,
"requires": {
"to-regex-range": "^5.0.1"
}
},
"glob-parent": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.1.tgz",
"integrity": "sha512-FnI+VGOpnlGHWZxthPGR+QhR78fuiK0sNLkHQv+bL9fQi57lNNdquIbna/WrfROrolq8GK5Ek6BiMwqL/voRYQ==",
"dev": true,
"requires": {
"is-glob": "^4.0.1"
}
},
"is-number": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
"dev": true
},
"micromatch": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.2.tgz",
"integrity": "sha512-y7FpHSbMUMoyPbYUSzO6PaZ6FyRnQOpHuKwbo1G+Knck95XVU4QAiKdGEnj5wwoS7PlOgthX/09u5iFJ+aYf5Q==",
"dev": true,
"requires": {
"braces": "^3.0.1",
"picomatch": "^2.0.5"
}
},
"to-regex-range": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
"integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
"dev": true,
"requires": {
"is-number": "^7.0.0"
}
}
}
},
"fast-json-stable-stringify": { "fast-json-stable-stringify": {
"version": "2.1.0", "version": "2.1.0",
"resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz",
@ -10868,6 +11094,15 @@
"resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz",
"integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=" "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc="
}, },
"fastq": {
"version": "1.8.0",
"resolved": "https://registry.npmjs.org/fastq/-/fastq-1.8.0.tgz",
"integrity": "sha512-SMIZoZdLh/fgofivvIkmknUXyPnvxRE3DhtZ5Me3Mrsk5gyPL42F0xr51TdRXskBxHfMp+07bcYzfsYEsSQA9Q==",
"dev": true,
"requires": {
"reusify": "^1.0.4"
}
},
"fb-watchman": { "fb-watchman": {
"version": "2.0.1", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/fb-watchman/-/fb-watchman-2.0.1.tgz", "resolved": "https://registry.npmjs.org/fb-watchman/-/fb-watchman-2.0.1.tgz",
@ -11197,6 +11432,34 @@
"resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz",
"integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==" "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA=="
}, },
"globby": {
"version": "11.0.1",
"resolved": "https://registry.npmjs.org/globby/-/globby-11.0.1.tgz",
"integrity": "sha512-iH9RmgwCmUJHi2z5o2l3eTtGBtXek1OYlHrbcxOYugyHLmAsZrPj43OtHThd62Buh/Vv6VyCBD2bdyWcGNQqoQ==",
"dev": true,
"requires": {
"array-union": "^2.1.0",
"dir-glob": "^3.0.1",
"fast-glob": "^3.1.1",
"ignore": "^5.1.4",
"merge2": "^1.3.0",
"slash": "^3.0.0"
},
"dependencies": {
"ignore": {
"version": "5.1.8",
"resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.8.tgz",
"integrity": "sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw==",
"dev": true
},
"slash": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz",
"integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==",
"dev": true
}
}
},
"graceful-fs": { "graceful-fs": {
"version": "4.2.4", "version": "4.2.4",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.4.tgz", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.4.tgz",
@ -12743,6 +13006,12 @@
"resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz",
"integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==" "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w=="
}, },
"merge2": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz",
"integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==",
"dev": true
},
"micromatch": { "micromatch": {
"version": "3.1.10", "version": "3.1.10",
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz",
@ -13383,8 +13652,7 @@
"version": "2.2.2", "version": "2.2.2",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz",
"integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==", "integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==",
"dev": true, "dev": true
"optional": true
}, },
"pify": { "pify": {
"version": "3.0.0", "version": "3.0.0",
@ -13946,6 +14214,12 @@
"resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz",
"integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==" "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg=="
}, },
"reusify": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz",
"integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==",
"dev": true
},
"rimraf": { "rimraf": {
"version": "2.6.3", "version": "2.6.3",
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz",
@ -13976,6 +14250,12 @@
"integrity": "sha512-tvVnVv01b8c1RrA6Ep7JkStj85Guv/YrMcwqYQnwjsAS2cTmmPGBBjAjpCW7RrSodNSoE2/qg9O4bceNvUuDgQ==", "integrity": "sha512-tvVnVv01b8c1RrA6Ep7JkStj85Guv/YrMcwqYQnwjsAS2cTmmPGBBjAjpCW7RrSodNSoE2/qg9O4bceNvUuDgQ==",
"dev": true "dev": true
}, },
"run-parallel": {
"version": "1.1.9",
"resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.1.9.tgz",
"integrity": "sha512-DEqnSRTDw/Tc3FXf49zedI638Z9onwUotBMiUFKmrO2sdFKIbXamXGQ3Axd4qgphxKB4kw/qP1w5kTxnfU1B9Q==",
"dev": true
},
"run-queue": { "run-queue": {
"version": "1.0.3", "version": "1.0.3",
"resolved": "https://registry.npmjs.org/run-queue/-/run-queue-1.0.3.tgz", "resolved": "https://registry.npmjs.org/run-queue/-/run-queue-1.0.3.tgz",
@ -14792,6 +15072,15 @@
"integrity": "sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==", "integrity": "sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==",
"dev": true "dev": true
}, },
"tsutils": {
"version": "3.17.1",
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.17.1.tgz",
"integrity": "sha512-kzeQ5B8H3w60nFY2g8cJIuH7JDpsALXySGtwGJ0p2LSjLgay3NdIpqq5SoOBe46bKDW2iq25irHCr8wjomUS2g==",
"dev": true,
"requires": {
"tslib": "^1.8.1"
}
},
"tty-browserify": { "tty-browserify": {
"version": "0.0.0", "version": "0.0.0",
"resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz", "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz",

@ -25,6 +25,7 @@
"eslint-plugin-no-unsafe-innerhtml": "^1.0.16", "eslint-plugin-no-unsafe-innerhtml": "^1.0.16",
"eslint-plugin-no-unsanitized": "^3.0.2", "eslint-plugin-no-unsanitized": "^3.0.2",
"eslint-plugin-security": "^1.4.0", "eslint-plugin-security": "^1.4.0",
"eslint-plugin-jest": "^24.1.0",
"jest": "^24.8.0", "jest": "^24.8.0",
"jest-junit": "^6.4.0", "jest-junit": "^6.4.0",
"jsdoc": "^3.6.4", "jsdoc": "^3.6.4",

@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation // Copyright (C) 2019-2020 Intel Corporation
// //
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT

@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation // Copyright (C) 2019-2020 Intel Corporation
// //
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
@ -25,7 +25,9 @@
const { Label } = require('./labels'); const { Label } = require('./labels');
const { DataError, ArgumentError, ScriptingError } = require('./exceptions'); const { DataError, ArgumentError, ScriptingError } = require('./exceptions');
const { HistoryActions, ObjectShape, ObjectType, colors } = require('./enums'); const {
HistoryActions, ObjectShape, ObjectType, colors,
} = require('./enums');
const ObjectState = require('./object-state'); const ObjectState = require('./object-state');
function shapeFactory(shapeData, clientID, injection) { function shapeFactory(shapeData, clientID, injection) {
@ -34,23 +36,23 @@
let shapeModel = null; let shapeModel = null;
switch (type) { switch (type) {
case 'rectangle': case 'rectangle':
shapeModel = new RectangleShape(shapeData, clientID, color, injection); shapeModel = new RectangleShape(shapeData, clientID, color, injection);
break; break;
case 'polygon': case 'polygon':
shapeModel = new PolygonShape(shapeData, clientID, color, injection); shapeModel = new PolygonShape(shapeData, clientID, color, injection);
break; break;
case 'polyline': case 'polyline':
shapeModel = new PolylineShape(shapeData, clientID, color, injection); shapeModel = new PolylineShape(shapeData, clientID, color, injection);
break; break;
case 'points': case 'points':
shapeModel = new PointsShape(shapeData, clientID, color, injection); shapeModel = new PointsShape(shapeData, clientID, color, injection);
break; break;
case 'cuboid': case 'cuboid':
shapeModel = new CuboidShape(shapeData, clientID, color, injection); shapeModel = new CuboidShape(shapeData, clientID, color, injection);
break; break;
default: default:
throw new DataError(`An unexpected type of shape "${type}"`); throw new DataError(`An unexpected type of shape "${type}"`);
} }
return shapeModel; return shapeModel;
@ -63,23 +65,23 @@
let trackModel = null; let trackModel = null;
switch (type) { switch (type) {
case 'rectangle': case 'rectangle':
trackModel = new RectangleTrack(trackData, clientID, color, injection); trackModel = new RectangleTrack(trackData, clientID, color, injection);
break; break;
case 'polygon': case 'polygon':
trackModel = new PolygonTrack(trackData, clientID, color, injection); trackModel = new PolygonTrack(trackData, clientID, color, injection);
break; break;
case 'polyline': case 'polyline':
trackModel = new PolylineTrack(trackData, clientID, color, injection); trackModel = new PolylineTrack(trackData, clientID, color, injection);
break; break;
case 'points': case 'points':
trackModel = new PointsTrack(trackData, clientID, color, injection); trackModel = new PointsTrack(trackData, clientID, color, injection);
break; break;
case 'cuboid': case 'cuboid':
trackModel = new CuboidTrack(trackData, clientID, color, injection); trackModel = new CuboidTrack(trackData, clientID, color, injection);
break; break;
default: default:
throw new DataError(`An unexpected type of track "${type}"`); throw new DataError(`An unexpected type of track "${type}"`);
} }
return trackModel; return trackModel;
@ -340,20 +342,20 @@
zOrder: shape.zOrder, zOrder: shape.zOrder,
attributes: updatedAttributes attributes: updatedAttributes
? Object.keys(attributes).reduce((accumulator, attrID) => { ? Object.keys(attributes).reduce((accumulator, attrID) => {
accumulator.push({ accumulator.push({
spec_id: +attrID, spec_id: +attrID,
value: attributes[attrID], value: attributes[attrID],
}); });
return accumulator; return accumulator;
}, []) }, [])
: [], : [],
}; };
} }
} else { } else {
throw new ArgumentError( throw new ArgumentError(
`Trying to merge unknown object type: ${object.constructor.name}. ` + `Trying to merge unknown object type: ${object.constructor.name}. `
'Only shapes and tracks are expected.', + 'Only shapes and tracks are expected.',
); );
} }
} }

@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation // Copyright (C) 2019-2020 Intel Corporation
// //
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT

@ -1,11 +1,13 @@
// Copyright (C) 2020 Intel Corporation // Copyright (C) 2019-2020 Intel Corporation
// //
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
(() => { (() => {
const ObjectState = require('./object-state'); const ObjectState = require('./object-state');
const { checkObjectType } = require('./common'); const { checkObjectType } = require('./common');
const { colors, Source, ObjectShape, ObjectType, AttributeType, HistoryActions } = require('./enums'); const {
colors, Source, ObjectShape, ObjectType, AttributeType, HistoryActions,
} = require('./enums');
const { DataError, ArgumentError, ScriptingError } = require('./exceptions'); const { DataError, ArgumentError, ScriptingError } = require('./exceptions');
@ -383,17 +385,16 @@
} }
updateTimestamp(updated) { updateTimestamp(updated) {
const anyChanges = const anyChanges = updated.label
updated.label || || updated.attributes
updated.attributes || || updated.points
updated.points || || updated.outside
updated.outside || || updated.occluded
updated.occluded || || updated.keyframe
updated.keyframe || || updated.zOrder
updated.zOrder || || updated.hidden
updated.hidden || || updated.lock
updated.lock || || updated.pinned;
updated.pinned;
if (anyChanges) { if (anyChanges) {
this.updated = Date.now(); this.updated = Date.now();
@ -735,7 +736,9 @@
// Method is used to construct ObjectState objects // Method is used to construct ObjectState objects
get(frame) { get(frame) {
const { prev, next, first, last } = this.boundedKeyframes(frame); const {
prev, next, first, last,
} = this.boundedKeyframes(frame);
return { return {
...this.getPosition(frame, prev, next), ...this.getPosition(frame, prev, next),
@ -890,14 +893,13 @@
if (!labelAttributes[attrID].mutable) { if (!labelAttributes[attrID].mutable) {
redoAttributes[attrID] = attributes[attrID]; redoAttributes[attrID] = attributes[attrID];
} else if (attributes[attrID] !== current.attributes[attrID]) { } else if (attributes[attrID] !== current.attributes[attrID]) {
mutableAttributesUpdated = mutableAttributesUpdated = mutableAttributesUpdated
mutableAttributesUpdated ||
// not keyframe yet // not keyframe yet
!(frame in this.shapes) || || !(frame in this.shapes)
// keyframe, but without this attrID // keyframe, but without this attrID
!(attrID in this.shapes[frame].attributes) || || !(attrID in this.shapes[frame].attributes)
// keyframe with attrID, but with another value // keyframe with attrID, but with another value
this.shapes[frame].attributes[attrID] !== attributes[attrID]; || this.shapes[frame].attributes[attrID] !== attributes[attrID];
} }
} }
let redoShape; let redoShape;
@ -990,13 +992,13 @@
const redoShape = wasKeyframe const redoShape = wasKeyframe
? { ...this.shapes[frame], points } ? { ...this.shapes[frame], points }
: { : {
frame, frame,
points, points,
zOrder: current.zOrder, zOrder: current.zOrder,
outside: current.outside, outside: current.outside,
occluded: current.occluded, occluded: current.occluded,
attributes: {}, attributes: {},
}; };
this.shapes[frame] = redoShape; this.shapes[frame] = redoShape;
this.source = Source.MANUAL; this.source = Source.MANUAL;
@ -1019,13 +1021,13 @@
const redoShape = wasKeyframe const redoShape = wasKeyframe
? { ...this.shapes[frame], outside } ? { ...this.shapes[frame], outside }
: { : {
frame, frame,
outside, outside,
zOrder: current.zOrder, zOrder: current.zOrder,
points: current.points, points: current.points,
occluded: current.occluded, occluded: current.occluded,
attributes: {}, attributes: {},
}; };
this.shapes[frame] = redoShape; this.shapes[frame] = redoShape;
this.source = Source.MANUAL; this.source = Source.MANUAL;
@ -1048,13 +1050,13 @@
const redoShape = wasKeyframe const redoShape = wasKeyframe
? { ...this.shapes[frame], occluded } ? { ...this.shapes[frame], occluded }
: { : {
frame, frame,
occluded, occluded,
zOrder: current.zOrder, zOrder: current.zOrder,
points: current.points, points: current.points,
outside: current.outside, outside: current.outside,
attributes: {}, attributes: {},
}; };
this.shapes[frame] = redoShape; this.shapes[frame] = redoShape;
this.source = Source.MANUAL; this.source = Source.MANUAL;
@ -1077,13 +1079,13 @@
const redoShape = wasKeyframe const redoShape = wasKeyframe
? { ...this.shapes[frame], zOrder } ? { ...this.shapes[frame], zOrder }
: { : {
frame, frame,
zOrder, zOrder,
occluded: current.occluded, occluded: current.occluded,
points: current.points, points: current.points,
outside: current.outside, outside: current.outside,
attributes: {}, attributes: {},
}; };
this.shapes[frame] = redoShape; this.shapes[frame] = redoShape;
this.source = Source.MANUAL; this.source = Source.MANUAL;
@ -1110,14 +1112,14 @@
const undoShape = wasKeyframe ? this.shapes[frame] : undefined; const undoShape = wasKeyframe ? this.shapes[frame] : undefined;
const redoShape = keyframe const redoShape = keyframe
? { ? {
frame, frame,
zOrder: current.zOrder, zOrder: current.zOrder,
points: current.points, points: current.points,
outside: current.outside, outside: current.outside,
occluded: current.occluded, occluded: current.occluded,
attributes: {}, attributes: {},
source: current.source, source: current.source,
} }
: undefined; : undefined;
this.source = Source.MANUAL; this.source = Source.MANUAL;
@ -1232,8 +1234,8 @@
} }
throw new DataError( throw new DataError(
'No one left position or right position was found. ' + 'No one left position or right position was found. '
`Interpolation impossible. Client ID: ${this.clientID}`, + `Interpolation impossible. Client ID: ${this.clientID}`,
); );
} }
} }
@ -1441,8 +1443,8 @@
// Find the length of a perpendicular // Find the length of a perpendicular
// https://en.wikipedia.org/wiki/Distance_from_a_point_to_a_line // https://en.wikipedia.org/wiki/Distance_from_a_point_to_a_line
distances.push( distances.push(
Math.abs((y2 - y1) * x - (x2 - x1) * y + x2 * y1 - y2 * x1) / Math.abs((y2 - y1) * x - (x2 - x1) * y + x2 * y1 - y2 * x1)
Math.sqrt(Math.pow(y2 - y1, 2) + Math.pow(x2 - x1, 2)), / Math.sqrt(Math.pow(y2 - y1, 2) + Math.pow(x2 - x1, 2)),
); );
} else { } else {
// The link below works for lines (which have infinit length) // The link below works for lines (which have infinit length)
@ -1526,12 +1528,11 @@
lowerHull.pop(); lowerHull.pop();
if ( if (
upperHull.length === 1 && upperHull.length === 1
lowerHull.length === 1 && && lowerHull.length === 1
upperHull[0].x === lowerHull[0].x && && upperHull[0].x === lowerHull[0].x
upperHull[0].y === lowerHull[0].y && upperHull[0].y === lowerHull[0].y
) ) return upperHull;
return upperHull;
return upperHull.concat(lowerHull); return upperHull.concat(lowerHull);
} }
@ -1589,9 +1590,8 @@
const p2 = points[i + 1] || points[0]; const p2 = points[i + 1] || points[0];
// perpendicular from point to straight length // perpendicular from point to straight length
const distance = const distance = Math.abs((p2.y - p1.y) * x - (p2.x - p1.x) * y + p2.x * p1.y - p2.y * p1.x)
Math.abs((p2.y - p1.y) * x - (p2.x - p1.x) * y + p2.x * p1.y - p2.y * p1.x) / / Math.sqrt(Math.pow(p2.y - p1.y, 2) + Math.pow(p2.x - p1.x, 2));
Math.sqrt(Math.pow(p2.y - p1.y, 2) + Math.pow(p2.x - p1.x, 2));
// check if perpendicular belongs to the straight segment // check if perpendicular belongs to the straight segment
const a = Math.pow(p1.x - x, 2) + Math.pow(p1.y - y, 2); const a = Math.pow(p1.x - x, 2) + Math.pow(p1.y - y, 2);

@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation // Copyright (C) 2019-2020 Intel Corporation
// //
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT

@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation // Copyright (C) 2019-2020 Intel Corporation
// //
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT

@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation // Copyright (C) 2019-2020 Intel Corporation
// //
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
@ -6,7 +6,9 @@
const PluginRegistry = require('./plugins'); const PluginRegistry = require('./plugins');
const serverProxy = require('./server-proxy'); const serverProxy = require('./server-proxy');
const lambdaManager = require('./lambda-manager'); const lambdaManager = require('./lambda-manager');
const { isBoolean, isInteger, isEnum, isString, checkFilter } = require('./common'); const {
isBoolean, isInteger, isEnum, isString, checkFilter,
} = require('./common');
const { TaskStatus, TaskMode } = require('./enums'); const { TaskStatus, TaskMode } = require('./enums');

@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation // Copyright (C) 2019-2020 Intel Corporation
// //
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
@ -31,7 +31,9 @@ function build() {
Source, Source,
} = require('./enums'); } = require('./enums');
const { Exception, ArgumentError, DataError, ScriptingError, PluginError, ServerError } = require('./exceptions'); const {
Exception, ArgumentError, DataError, ScriptingError, PluginError, ServerError,
} = require('./exceptions');
const User = require('./user'); const User = require('./user');
const pjson = require('../package.json'); const pjson = require('../package.json');

@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation // Copyright (C) 2019-2020 Intel Corporation
// //
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
@ -56,8 +56,8 @@
if (!(value instanceof instance)) { if (!(value instanceof instance)) {
if (value !== undefined) { if (value !== undefined) {
throw new ArgumentError( throw new ArgumentError(
`"${name}" is expected to be ${instance.name}, but ` + `"${name}" is expected to be ${instance.name}, but `
`"${value.constructor.name}" has been got`, + `"${value.constructor.name}" has been got`,
); );
} }

@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation // Copyright (C) 2019-2020 Intel Corporation
// //
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT

@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation // Copyright (C) 2019-2020 Intel Corporation
// //
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT

@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation // Copyright (C) 2019-2020 Intel Corporation
// //
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT

@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation // Copyright (C) 2019-2020 Intel Corporation
// //
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT

@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation // Copyright (C) 2019-2020 Intel Corporation
// //
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
@ -18,7 +18,9 @@
* @hideconstructor * @hideconstructor
*/ */
class FrameData { class FrameData {
constructor({ width, height, name, taskID, frameNumber, startFrame, stopFrame, decodeForward }) { constructor({
width, height, name, taskID, frameNumber, startFrame, stopFrame, decodeForward,
}) {
Object.defineProperties( Object.defineProperties(
this, this,
Object.freeze({ Object.freeze({
@ -128,8 +130,8 @@
const onDecodeAll = async (frameNumber) => { const onDecodeAll = async (frameNumber) => {
if ( if (
frameDataCache[this.tid].activeChunkRequest && frameDataCache[this.tid].activeChunkRequest
chunkNumber === frameDataCache[this.tid].activeChunkRequest.chunkNumber && chunkNumber === frameDataCache[this.tid].activeChunkRequest.chunkNumber
) { ) {
const callbackArray = frameDataCache[this.tid].activeChunkRequest.callbacks; const callbackArray = frameDataCache[this.tid].activeChunkRequest.callbacks;
for (let i = callbackArray.length - 1; i >= 0; --i) { for (let i = callbackArray.length - 1; i >= 0; --i) {
@ -147,8 +149,8 @@
const rejectRequestAll = () => { const rejectRequestAll = () => {
if ( if (
frameDataCache[this.tid].activeChunkRequest && frameDataCache[this.tid].activeChunkRequest
chunkNumber === frameDataCache[this.tid].activeChunkRequest.chunkNumber && chunkNumber === frameDataCache[this.tid].activeChunkRequest.chunkNumber
) { ) {
for (const r of frameDataCache[this.tid].activeChunkRequest.callbacks) { for (const r of frameDataCache[this.tid].activeChunkRequest.callbacks) {
r.reject(r.frameNumber); r.reject(r.frameNumber);
@ -206,10 +208,10 @@
const activeRequest = frameDataCache[this.tid].activeChunkRequest; const activeRequest = frameDataCache[this.tid].activeChunkRequest;
if (!provider.isChunkCached(start, stop)) { if (!provider.isChunkCached(start, stop)) {
if ( if (
!activeRequest || !activeRequest
(activeRequest && || (activeRequest
activeRequest.completed && && activeRequest.completed
activeRequest.chunkNumber !== chunkNumber) && activeRequest.chunkNumber !== chunkNumber)
) { ) {
if (activeRequest && activeRequest.rejectRequestAll) { if (activeRequest && activeRequest.rejectRequestAll) {
activeRequest.rejectRequestAll(); activeRequest.rejectRequestAll();
@ -275,10 +277,10 @@
} }
} else { } else {
if ( if (
this.number % chunkSize > chunkSize / 4 && this.number % chunkSize > chunkSize / 4
provider.decodedBlocksCacheSize > 1 && && provider.decodedBlocksCacheSize > 1
this.decodeForward && && this.decodeForward
!provider.isNextChunkExists(this.number) && !provider.isNextChunkExists(this.number)
) { ) {
const nextChunkNumber = Math.floor(this.number / chunkSize) + 1; const nextChunkNumber = Math.floor(this.number / chunkSize) + 1;
if (nextChunkNumber * chunkSize < this.stopFrame) { if (nextChunkNumber * chunkSize < this.stopFrame) {
@ -378,8 +380,8 @@
.data() .data()
.then(() => { .then(() => {
if ( if (
!(chunkIdx in this._requestedChunks) || !(chunkIdx in this._requestedChunks)
!this._requestedChunks[chunkIdx].requestedFrames.has(requestedFrame) || !this._requestedChunks[chunkIdx].requestedFrames.has(requestedFrame)
) { ) {
reject(chunkIdx); reject(chunkIdx);
} else { } else {
@ -488,10 +490,10 @@
delete this._buffer[frameNumber]; delete this._buffer[frameNumber];
const cachedFrames = this.cachedFrames(); const cachedFrames = this.cachedFrames();
if ( if (
fillBuffer && fillBuffer
!this._activeFillBufferRequest && && !this._activeFillBufferRequest
this._size > this._chunkSize && && this._size > this._chunkSize
cachedFrames.length < (this._size * 3) / 4 && cachedFrames.length < (this._size * 3) / 4
) { ) {
const maxFrame = cachedFrames ? Math.max(...cachedFrames) : frameNumber; const maxFrame = cachedFrames ? Math.max(...cachedFrames) : frameNumber;
if (maxFrame < this._stopFrame) { if (maxFrame < this._stopFrame) {
@ -517,8 +519,8 @@
clear() { clear() {
for (const chunkIdx in this._requestedChunks) { for (const chunkIdx in this._requestedChunks) {
if ( if (
Object.prototype.hasOwnProperty.call(this._requestedChunks, chunkIdx) && Object.prototype.hasOwnProperty.call(this._requestedChunks, chunkIdx)
this._requestedChunks[chunkIdx].reject && this._requestedChunks[chunkIdx].reject
) { ) {
this._requestedChunks[chunkIdx].reject('not needed'); this._requestedChunks[chunkIdx].reject('not needed');
} }
@ -563,8 +565,8 @@
const meta = await serverProxy.frames.getMeta(taskID); const meta = await serverProxy.frames.getMeta(taskID);
const mean = meta.frames.reduce((a, b) => a + b.width * b.height, 0) / meta.frames.length; const mean = meta.frames.reduce((a, b) => a + b.width * b.height, 0) / meta.frames.length;
const stdDev = Math.sqrt( const stdDev = Math.sqrt(
meta.frames.map((x) => Math.pow(x.width * x.height - mean, 2)).reduce((a, b) => a + b) / meta.frames.map((x) => Math.pow(x.width * x.height - mean, 2)).reduce((a, b) => a + b)
meta.frames.length, / meta.frames.length,
); );
// limit of decoded frames cache by 2GB // limit of decoded frames cache by 2GB

@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation // Copyright (C) 2019-2020 Intel Corporation
// //
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
@ -146,8 +146,8 @@
data.attributes = []; data.attributes = [];
if ( if (
Object.prototype.hasOwnProperty.call(initialData, 'attributes') && Object.prototype.hasOwnProperty.call(initialData, 'attributes')
Array.isArray(initialData.attributes) && Array.isArray(initialData.attributes)
) { ) {
for (const attrData of initialData.attributes) { for (const attrData of initialData.attributes) {
data.attributes.push(new Attribute(attrData)); data.attributes.push(new Attribute(attrData));

@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation // Copyright (C) 2019-2020 Intel Corporation
// //
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT

@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation // Copyright (C) 2019-2020 Intel Corporation
// //
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
@ -143,9 +143,9 @@ class LogWithWorkingTime extends Log {
Log.prototype.validatePayload.call(this); Log.prototype.validatePayload.call(this);
if ( if (
!('working_time' in this.payload) || !('working_time' in this.payload)
!typeof this.payload.working_time === 'number' || || !typeof this.payload.working_time === 'number'
this.payload.working_time < 0 || this.payload.working_time < 0
) { ) {
const message = ` const message = `
The field "working_time" is required for ${this.type} log. It must be a number not less than 0 The field "working_time" is required for ${this.type} log. It must be a number not less than 0

@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation // Copyright (C) 2019-2020 Intel Corporation
// //
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
@ -38,8 +38,8 @@ class LoggerStorage {
lastLog: null, lastLog: null,
ignore(previousLog, currentPayload) { ignore(previousLog, currentPayload) {
return ( return (
currentPayload.object_id === previousLog.payload.object_id && currentPayload.object_id === previousLog.payload.object_id
currentPayload.id === previousLog.payload.id && currentPayload.id === previousLog.payload.id
); );
}, },
}; };

@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation // Copyright (C) 2019-2020 Intel Corporation
// //
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT

@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation // Copyright (C) 2019-2020 Intel Corporation
// //
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
@ -193,8 +193,8 @@ const { Source } = require('./enums');
data.points = [...points]; data.points = [...points];
} else { } else {
throw new ArgumentError( throw new ArgumentError(
'Points are expected to be an array ' + 'Points are expected to be an array '
`but got ${ + `but got ${
typeof points === 'object' ? points.constructor.name : typeof points typeof points === 'object' ? points.constructor.name : typeof points
}`, }`,
); );
@ -338,8 +338,8 @@ const { Source } = require('./enums');
set: (attributes) => { set: (attributes) => {
if (typeof attributes !== 'object') { if (typeof attributes !== 'object') {
throw new ArgumentError( throw new ArgumentError(
'Attributes are expected to be an object ' + 'Attributes are expected to be an object '
`but got ${ + `but got ${
typeof attributes === 'object' typeof attributes === 'object'
? attributes.constructor.name ? attributes.constructor.name
: typeof attributes : typeof attributes

@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation // Copyright (C) 2019-2020 Intel Corporation
// //
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
@ -65,7 +65,7 @@
throw new PluginError('Plugin must not contain a "functions" field'); throw new PluginError('Plugin must not contain a "functions" field');
} }
(function traverse(plugin, api) { function traverse(plugin, api) {
const decorator = {}; const decorator = {};
for (const key in plugin) { for (const key in plugin) {
if (Object.prototype.hasOwnProperty.call(plugin, key)) { if (Object.prototype.hasOwnProperty.call(plugin, key)) {
@ -74,9 +74,9 @@
traverse(plugin[key], api[key]); traverse(plugin[key], api[key]);
} }
} else if ( } else if (
['enter', 'leave'].includes(key) && ['enter', 'leave'].includes(key)
typeof api === 'function' && && typeof api === 'function'
typeof (plugin[key] === 'function') && typeof (plugin[key] === 'function')
) { ) {
decorator.callback = api; decorator.callback = api;
decorator[key] = plugin[key]; decorator[key] = plugin[key];
@ -87,9 +87,9 @@
if (Object.keys(decorator).length) { if (Object.keys(decorator).length) {
functions.push(decorator); functions.push(decorator);
} }
})(plug, { }
cvat: this,
}); traverse(plug, { cvat: this });
Object.defineProperty(plug, 'functions', { Object.defineProperty(plug, 'functions', {
value: functions, value: functions,

@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation // Copyright (C) 2019-2020 Intel Corporation
// //
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT

@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation // Copyright (C) 2019-2020 Intel Corporation
// //
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
@ -6,7 +6,9 @@
const PluginRegistry = require('./plugins'); const PluginRegistry = require('./plugins');
const loggerStorage = require('./logger-storage'); const loggerStorage = require('./logger-storage');
const serverProxy = require('./server-proxy'); const serverProxy = require('./server-proxy');
const { getFrame, getRanges, getPreview, clear: clearFrames } = require('./frames'); const {
getFrame, getRanges, getPreview, clear: clearFrames,
} = require('./frames');
const { ArgumentError } = require('./exceptions'); const { ArgumentError } = require('./exceptions');
const { TaskStatus } = require('./enums'); const { TaskStatus } = require('./enums');
const { Label } = require('./labels'); const { Label } = require('./labels');

@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation // Copyright (C) 2019-2020 Intel Corporation
// //
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT

@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation // Copyright (C) 2019-2020 Intel Corporation
// //
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT

@ -3,13 +3,6 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
module.exports = { module.exports = {
env: {
node: false,
browser: true,
es6: true,
jquery: true,
qunit: true,
},
parserOptions: { parserOptions: {
parser: 'babel-eslint', parser: 'babel-eslint',
sourceType: 'module', sourceType: 'module',

@ -5,8 +5,6 @@
module.exports = { module.exports = {
env: { env: {
node: true, node: true,
browser: true,
es6: true,
}, },
parserOptions: { parserOptions: {
parser: '@typescript-eslint/parser', parser: '@typescript-eslint/parser',

File diff suppressed because it is too large Load Diff

@ -42,8 +42,8 @@
"tsconfig-paths-webpack-plugin": "^3.2.0", "tsconfig-paths-webpack-plugin": "^3.2.0",
"typescript": "^3.7.3", "typescript": "^3.7.3",
"webpack": "^4.44.2", "webpack": "^4.44.2",
"webpack-cli": "^3.3.8", "webpack-cli": "^3.3.12",
"webpack-dev-server": "^3.8.0", "webpack-dev-server": "^3.11.0",
"worker-loader": "^2.0.0" "worker-loader": "^2.0.0"
}, },
"dependencies": { "dependencies": {

@ -15,4 +15,6 @@ import {
export type InteractionData = InteractionDataType; export type InteractionData = InteractionDataType;
export type InteractionResult = InteractionResultType; export type InteractionResult = InteractionResultType;
export { Canvas, CanvasMode, CanvasVersion, RectDrawingMethod, CuboidDrawingMethod }; export {
Canvas, CanvasMode, CanvasVersion, RectDrawingMethod, CuboidDrawingMethod,
};

@ -0,0 +1,43 @@
// lint-staged.config.js
const micromatch = require('micromatch');
function containsInPath(pattern, list) {
return list.filter((item) => micromatch.contains(item, pattern));
}
function makePattern(extension) {
return `**/*.${extension}`;
}
module.exports = (stagedFiles) => {
const eslintExtensions = ['ts', 'tsx', 'js'].map(makePattern);
const prettierExtensions = ['html', 'css', 'scss', 'json', 'yaml', 'yml', 'md']
.map(makePattern)
.concat(eslintExtensions);
const prettierFiles = micromatch(stagedFiles, prettierExtensions);
const eslintFiles = micromatch(stagedFiles, eslintExtensions);
const cvatData = containsInPath('/cvat-data/', eslintFiles);
const cvatCore = containsInPath('/cvat-core/', eslintFiles);
const cvatCanvas = containsInPath('/cvat-canvas/', eslintFiles);
const cvatUI = containsInPath('/cvat-ui/', eslintFiles);
const mapping = {};
const commands = [];
mapping['prettier --write '] = prettierFiles.join(' ');
mapping['npm run precommit:cvat-ui -- '] = cvatUI.join(' ');
mapping['npm run precommit:cvat-data -- '] = cvatData.join(' ');
mapping['npm run precommit:cvat-core -- '] = cvatCore.join(' ');
mapping['npm run precommit:cvat-canvas -- '] = cvatCanvas.join(' ');
for (const command of Object.keys(mapping)) {
const files = mapping[command];
if (files.length) {
commands.push(`${command} ${files}`);
}
}
return commands;
};

23
package-lock.json generated

@ -1424,12 +1424,6 @@
"safe-buffer": "~5.1.1" "safe-buffer": "~5.1.1"
} }
}, },
"core-js": {
"version": "3.6.5",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-3.6.5.tgz",
"integrity": "sha512-vZVEEwZoIsI+vPEuoF9Iqf5H7/M3eeQqWlQnYa8FSKKePuYTf5MWnxb5SDAzCa60b3JBRS5g9b+Dq7b1y/RCrA==",
"dev": true
},
"core-util-is": { "core-util-is": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
@ -1936,23 +1930,6 @@
"prettier-linter-helpers": "^1.0.0" "prettier-linter-helpers": "^1.0.0"
} }
}, },
"eslint-plugin-requirejs": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-requirejs/-/eslint-plugin-requirejs-4.0.0.tgz",
"integrity": "sha512-0RUXMrQ7elTtTZT6dwP6HozoAUzUBnMawBmdOKyQAWqulrLnKg8WGKJIpo7cDisjAr91SXDUIhCOrIqgbz9ETQ==",
"dev": true,
"requires": {
"ignore": "5.0.5"
},
"dependencies": {
"ignore": {
"version": "5.0.5",
"resolved": "https://registry.npmjs.org/ignore/-/ignore-5.0.5.tgz",
"integrity": "sha512-kOC8IUb8HSDMVcYrDVezCxpJkzSQWTAzf3olpKM6o9rM5zpojx23O0Fl8Wr4+qJ6ZbPEHqf1fdwev/DS7v7pmA==",
"dev": true
}
}
},
"eslint-scope": { "eslint-scope": {
"version": "5.1.1", "version": "5.1.1",
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz",

@ -11,7 +11,6 @@
"@istanbuljs/nyc-config-babel": "^1.0.1", "@istanbuljs/nyc-config-babel": "^1.0.1",
"babel-plugin-istanbul": "^6.0.0", "babel-plugin-istanbul": "^6.0.0",
"babel-register": "^6.26.0", "babel-register": "^6.26.0",
"core-js": "^3.6.5",
"coveralls": "^3.1.0", "coveralls": "^3.1.0",
"eslint": "^7.11.0", "eslint": "^7.11.0",
"eslint-config-airbnb": "^18.0.1", "eslint-config-airbnb": "^18.0.1",
@ -20,9 +19,9 @@
"eslint-plugin-header": "^3.1.0", "eslint-plugin-header": "^3.1.0",
"eslint-plugin-jest": "^24.1.0", "eslint-plugin-jest": "^24.1.0",
"eslint-plugin-prettier": "^3.1.4", "eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-requirejs": "^4.0.0",
"husky": "^4.3.0", "husky": "^4.3.0",
"lint-staged": "^10.4.2", "lint-staged": "^10.4.2",
"micromatch": "^4.0.2",
"nyc": "^15.1.0", "nyc": "^15.1.0",
"prettier": "2.1.2", "prettier": "2.1.2",
"remark-lint-emphasis-marker": "^2.0.0", "remark-lint-emphasis-marker": "^2.0.0",
@ -46,7 +45,11 @@
"coverage": "npm run instrument && npm run cp && npm run rm", "coverage": "npm run instrument && npm run cp && npm run rm",
"instrument": "nyc instrument cvat-ui cvat-ui_cov && nyc instrument cvat-canvas cvat-canvas_cov && nyc instrument cvat-data cvat-data_cov && nyc instrument cvat-core cvat-core_cov", "instrument": "nyc instrument cvat-ui cvat-ui_cov && nyc instrument cvat-canvas cvat-canvas_cov && nyc instrument cvat-data cvat-data_cov && nyc instrument cvat-core cvat-core_cov",
"cp": "cp -r cvat-ui_cov/* cvat-ui && cp -r cvat-canvas_cov/* cvat-canvas && cp -r cvat-data_cov/* cvat-data && cp -r cvat-core_cov/* cvat-core", "cp": "cp -r cvat-ui_cov/* cvat-ui && cp -r cvat-canvas_cov/* cvat-canvas && cp -r cvat-data_cov/* cvat-data && cp -r cvat-core_cov/* cvat-core",
"rm": "rm -rf cvat-ui_cov cvat-canvas_cov cvat-data_cov cvat-core_cov" "rm": "rm -rf cvat-ui_cov cvat-canvas_cov cvat-data_cov cvat-core_cov",
"precommit:cvat-data": "cd cvat-ui && eslint --fix",
"precommit:cvat-core": "cd cvat-ui && eslint --fix",
"precommit:cvat-canvas": "cd cvat-ui && eslint --fix",
"precommit:cvat-ui": "cd cvat-ui && eslint --fix"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -62,12 +65,5 @@
"hooks": { "hooks": {
"pre-commit": "lint-staged" "pre-commit": "lint-staged"
} }
},
"lint-staged": {
"*.{html,css,scss,json,yaml,yml,md}": "prettier --write",
"*.{js,ts,tsx}": [
"eslint --fix",
"prettier --write"
]
} }
} }

Loading…
Cancel
Save