Skip to content

Commit

Permalink
Merged Pull Request '#118 fix/eslint_warnings->main : Fix/eslint warn…
Browse files Browse the repository at this point in the history
…ings'

Fix/eslint warnings
  • Loading branch information
Automation51D authored May 31, 2024
2 parents 1bd7c4b + 9449764 commit 0c10147
Show file tree
Hide file tree
Showing 22 changed files with 445 additions and 442 deletions.
5 changes: 5 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
"parserOptions": {
"ecmaVersion": 2020
},
"settings": {
"jsdoc": {
"mode": "typescript"
}
},
"rules": {
"node/no-deprecated-api": "off",
"no-throw-literal": "off",
Expand Down
55 changes: 28 additions & 27 deletions fiftyone.pipeline.cloudrequestengine/cloudRequestEngine.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
/* *********************************************************************
* This Original Work is copyright of 51 Degrees Mobile Experts Limited.
* Copyright 2023 51 Degrees Mobile Experts Limited, Davidson House,
* Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
*
* This Original Work is licensed under the European Union Public Licence
* (EUPL) v.1.2 and is subject to its terms as set out below.
*
* If a copy of the EUPL was not distributed with this file, You can obtain
* one at https://opensource.org/licenses/EUPL-1.2.
*
* The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
* amended by the European Commission) shall be deemed incompatible for
* the purposes of the Work and the provisions of the compatibility
* clause in Article 5 of the EUPL shall not apply.
*
* If using the Work as, or as part of, a network application, by
* including the attribution notice(s) required under Article 5 of the EUPL
* in the end user terms of the application under an appropriate heading,
* such notice(s) shall fulfill the requirements of that article.
/* *********************************************************************
* This Original Work is copyright of 51 Degrees Mobile Experts Limited.
* Copyright 2023 51 Degrees Mobile Experts Limited, Davidson House,
* Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
*
* This Original Work is licensed under the European Union Public Licence
* (EUPL) v.1.2 and is subject to its terms as set out below.
*
* If a copy of the EUPL was not distributed with this file, You can obtain
* one at https://opensource.org/licenses/EUPL-1.2.
*
* The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
* amended by the European Commission) shall be deemed incompatible for
* the purposes of the Work and the provisions of the compatibility
* clause in Article 5 of the EUPL shall not apply.
*
* If using the Work as, or as part of, a network application, by
* including the attribution notice(s) required under Article 5 of the EUPL
* in the end user terms of the application under an appropriate heading,
* such notice(s) shall fulfill the requirements of that article.
* ********************************************************************* */

const util = require('util');
Expand Down Expand Up @@ -52,7 +52,7 @@ class CloudRequestEngine extends Engine {
* made from a origin matching those allowed by the resource key.
* For more detail, see the 'Request Headers' section in the
* <a href="https://cloud.51degrees.com/api-docs/index.html">cloud documentation</a>.
* @param options.requestClient
* @param {RequestClient} options.requestClient Set predefined RequestClient.
*/
constructor (
{
Expand Down Expand Up @@ -176,8 +176,7 @@ class CloudRequestEngine extends Engine {
* However, transport level errors or other failures can result in
* responses that are plain text. This function handles these cases.
*
* @param {string} response the response data to process
* @param responseBody
* @param {string} responseBody the response data to process
* @returns {Array} The error messages
*/
getErrorMessages (responseBody) {
Expand All @@ -196,7 +195,8 @@ class CloudRequestEngine extends Engine {
/**
* Used to handle errors from http requests
*
* @param response
* @param {http.ServerResponse} response Responce to get errors from
* @returns {Array<CloudRequestError>} Array of CloudRequestError from response
*/
getErrorsFromResponse (response) {
let content = response;
Expand Down Expand Up @@ -370,7 +370,7 @@ class CloudRequestEngine extends Engine {
* If there are evidence keys other than 'query.' that conflict then
* this is unexpected so a warning will be logged.
*
* @param {FlowData} flowData
* @param {FlowData} flowData FlowData to get evidence from
* @returns {Evidence} Evidence Dictionary
*/
getContent (flowData) {
Expand All @@ -393,7 +393,7 @@ class CloudRequestEngine extends Engine {
/**
* Add query data to the evidence.
*
* @param flowData
* @param {FlowData} flowData FlowData for logging
* @param {object} queryData The destination dictionary to add query data to.
* @param {Evidence} allEvidence All evidence in the flow data. This is used to
* report which evidence keys are conflicting.
Expand Down Expand Up @@ -449,6 +449,7 @@ class CloudRequestEngine extends Engine {
*
* @param {Evidence} evidence All evidence in the flow data.
* @param {stirng} type Required evidence key prefix
* @returns {Evidence} Selected evidence
*/
getSelectedEvidence (evidence, type) {
let selectedEvidence = {};
Expand Down Expand Up @@ -483,7 +484,7 @@ class CloudRequestEngine extends Engine {
*
* @param {string} itemKey Key to check
* @param {string} prefix The prefix to check for.
* @returns True if the key has the prefix.
* @returns {boolean} True if the key has the prefix.
*/
hasKeyPrefix (itemKey, prefix) {
return itemKey.startsWith(prefix + '.');
Expand Down
7 changes: 3 additions & 4 deletions fiftyone.pipeline.cloudrequestengine/requestClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class RequestClient {
* @param {*} data The data to send in the body of the request
* @param {*} origin The value to use for the Origin header when
* making the request
* @returns a Promise. The resolve function will be passed the content
* @returns {Promise} The resolve function will be passed the content
* from the response and the reject function will be passed
* an object with 3 properties:
* headers = HTTP headers in the response
Expand All @@ -43,9 +43,8 @@ class RequestClient {
} else {
httpModule = require('http');
}

let requestData = '';
if (data) {
var requestData = '';
const keys = Object.keys(data);
for (let i = 0; i < keys.length; i++) {
requestData += encodeURIComponent(keys[i]) + '=' + encodeURIComponent(data[keys[i]]);
Expand Down Expand Up @@ -104,7 +103,7 @@ class RequestClient {
* @param {*} url The url to send a request to
* @param {*} origin The value to use for the Origin header when
* making the request
* @returns a Promise. The resolve function will be passed the content
* @returns {Promise} The resolve function will be passed the content
* from the response and the reject function will be passed
* an object with 3 properties:
* headers = HTTP headers in the response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,10 @@ test('validate case when cloud unavailable', (done) => {
});

/**
* Check if Properties contains name
*
* @param properties
* @param name
* @param {object} properties Object of properties
* @param {string} name Name of the property
*/
function propertiesContainName (properties, name) {
expect(properties[name.toLowerCase()]).not.toBeUndefined();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
/* *********************************************************************
* This Original Work is copyright of 51 Degrees Mobile Experts Limited.
* Copyright 2023 51 Degrees Mobile Experts Limited, Davidson House,
* Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
*
* This Original Work is licensed under the European Union Public Licence
* (EUPL) v.1.2 and is subject to its terms as set out below.
*
* If a copy of the EUPL was not distributed with this file, You can obtain
* one at https://opensource.org/licenses/EUPL-1.2.
*
* The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
* amended by the European Commission) shall be deemed incompatible for
* the purposes of the Work and the provisions of the compatibility
* clause in Article 5 of the EUPL shall not apply.
*
* If using the Work as, or as part of, a network application, by
* including the attribution notice(s) required under Article 5 of the EUPL
* in the end user terms of the application under an appropriate heading,
* such notice(s) shall fulfill the requirements of that article.
/* *********************************************************************
* This Original Work is copyright of 51 Degrees Mobile Experts Limited.
* Copyright 2023 51 Degrees Mobile Experts Limited, Davidson House,
* Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
*
* This Original Work is licensed under the European Union Public Licence
* (EUPL) v.1.2 and is subject to its terms as set out below.
*
* If a copy of the EUPL was not distributed with this file, You can obtain
* one at https://opensource.org/licenses/EUPL-1.2.
*
* The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
* amended by the European Commission) shall be deemed incompatible for
* the purposes of the Work and the provisions of the compatibility
* clause in Article 5 of the EUPL shall not apply.
*
* If using the Work as, or as part of, a network application, by
* including the attribution notice(s) required under Article 5 of the EUPL
* in the end user terms of the application under an appropriate heading,
* such notice(s) shall fulfill the requirements of that article.
* ********************************************************************* */

/**
@example clientSideEvidenceFlowElement.js
This example demonstrates the creation of a custom flow element
which takes the results of a client side form collecting
date of birth, setting this as evidence on a flowData object
to calculate a person's starsign.
The flowElement also serves additional JavaScript which gets a
user's geolocation and saves the latitude as a cookie.
This latitude is also then passed in to the flowData to
calculate if a person is in the northern or southern hemispheres.
* @example clientSideEvidenceFlowElement.js
*
* This example demonstrates the creation of a custom flow element
* which takes the results of a client side form collecting
* date of birth, setting this as evidence on a flowData object
* to calculate a person's starsign.
* The flowElement also serves additional JavaScript which gets a
* user's geolocation and saves the latitude as a cookie.
* This latitude is also then passed in to the flowData to
* calculate if a person is in the northern or southern hemispheres.
*
*/

// First require the core Pipeline
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
/* *********************************************************************
* This Original Work is copyright of 51 Degrees Mobile Experts Limited.
* Copyright 2023 51 Degrees Mobile Experts Limited, Davidson House,
* Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
*
* This Original Work is licensed under the European Union Public Licence
* (EUPL) v.1.2 and is subject to its terms as set out below.
*
* If a copy of the EUPL was not distributed with this file, You can obtain
* one at https://opensource.org/licenses/EUPL-1.2.
*
* The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
* amended by the European Commission) shall be deemed incompatible for
* the purposes of the Work and the provisions of the compatibility
* clause in Article 5 of the EUPL shall not apply.
*
* If using the Work as, or as part of, a network application, by
* including the attribution notice(s) required under Article 5 of the EUPL
* in the end user terms of the application under an appropriate heading,
* such notice(s) shall fulfill the requirements of that article.
/* *********************************************************************
* This Original Work is copyright of 51 Degrees Mobile Experts Limited.
* Copyright 2023 51 Degrees Mobile Experts Limited, Davidson House,
* Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
*
* This Original Work is licensed under the European Union Public Licence
* (EUPL) v.1.2 and is subject to its terms as set out below.
*
* If a copy of the EUPL was not distributed with this file, You can obtain
* one at https://opensource.org/licenses/EUPL-1.2.
*
* The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
* amended by the European Commission) shall be deemed incompatible for
* the purposes of the Work and the provisions of the compatibility
* clause in Article 5 of the EUPL shall not apply.
*
* If using the Work as, or as part of, a network application, by
* including the attribution notice(s) required under Article 5 of the EUPL
* in the end user terms of the application under an appropriate heading,
* such notice(s) shall fulfill the requirements of that article.
* ********************************************************************* */

/**
@example simpleEvidenceFlowElement.js
This example demonstrates the creation of a custom flowElement
which takes a birth date as evidence and uses it to check a
lookup table for a starsign.
* @example simpleEvidenceFlowElement.js
*
* This example demonstrates the creation of a custom flowElement
* which takes a birth date as evidence and uses it to check a
* lookup table for a starsign.
*
*/

// First require the core Pipeline
Expand Down
50 changes: 25 additions & 25 deletions fiftyone.pipeline.core/examples/pipelines.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
/* *********************************************************************
* This Original Work is copyright of 51 Degrees Mobile Experts Limited.
* Copyright 2023 51 Degrees Mobile Experts Limited, Davidson House,
* Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
*
* This Original Work is licensed under the European Union Public Licence
* (EUPL) v.1.2 and is subject to its terms as set out below.
*
* If a copy of the EUPL was not distributed with this file, You can obtain
* one at https://opensource.org/licenses/EUPL-1.2.
*
* The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
* amended by the European Commission) shall be deemed incompatible for
* the purposes of the Work and the provisions of the compatibility
* clause in Article 5 of the EUPL shall not apply.
*
* If using the Work as, or as part of, a network application, by
* including the attribution notice(s) required under Article 5 of the EUPL
* in the end user terms of the application under an appropriate heading,
* such notice(s) shall fulfill the requirements of that article.
/* *********************************************************************
* This Original Work is copyright of 51 Degrees Mobile Experts Limited.
* Copyright 2023 51 Degrees Mobile Experts Limited, Davidson House,
* Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
*
* This Original Work is licensed under the European Union Public Licence
* (EUPL) v.1.2 and is subject to its terms as set out below.
*
* If a copy of the EUPL was not distributed with this file, You can obtain
* one at https://opensource.org/licenses/EUPL-1.2.
*
* The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
* amended by the European Commission) shall be deemed incompatible for
* the purposes of the Work and the provisions of the compatibility
* clause in Article 5 of the EUPL shall not apply.
*
* If using the Work as, or as part of, a network application, by
* including the attribution notice(s) required under Article 5 of the EUPL
* in the end user terms of the application under an appropriate heading,
* such notice(s) shall fulfill the requirements of that article.
* ********************************************************************* */

/**
@example pipelines.js
This example demonstrates syncronous and asyncronous pipelines
with multiple flowElements and other core features of the 51Degrees pipeline
* @example pipelines.js
*
* This example demonstrates syncronous and asyncronous pipelines
* with multiple flowElements and other core features of the 51Degrees pipeline
*
*/

// Note that this example is designed to be run from within the
Expand Down
42 changes: 21 additions & 21 deletions fiftyone.pipeline.core/flowElement.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
/* *********************************************************************
* This Original Work is copyright of 51 Degrees Mobile Experts Limited.
* Copyright 2023 51 Degrees Mobile Experts Limited, Davidson House,
* Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
*
* This Original Work is licensed under the European Union Public Licence
* (EUPL) v.1.2 and is subject to its terms as set out below.
*
* If a copy of the EUPL was not distributed with this file, You can obtain
* one at https://opensource.org/licenses/EUPL-1.2.
*
* The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
* amended by the European Commission) shall be deemed incompatible for
* the purposes of the Work and the provisions of the compatibility
* clause in Article 5 of the EUPL shall not apply.
*
* If using the Work as, or as part of, a network application, by
* including the attribution notice(s) required under Article 5 of the EUPL
* in the end user terms of the application under an appropriate heading,
* such notice(s) shall fulfill the requirements of that article.
/* *********************************************************************
* This Original Work is copyright of 51 Degrees Mobile Experts Limited.
* Copyright 2023 51 Degrees Mobile Experts Limited, Davidson House,
* Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
*
* This Original Work is licensed under the European Union Public Licence
* (EUPL) v.1.2 and is subject to its terms as set out below.
*
* If a copy of the EUPL was not distributed with this file, You can obtain
* one at https://opensource.org/licenses/EUPL-1.2.
*
* The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
* amended by the European Commission) shall be deemed incompatible for
* the purposes of the Work and the provisions of the compatibility
* clause in Article 5 of the EUPL shall not apply.
*
* If using the Work as, or as part of, a network application, by
* including the attribution notice(s) required under Article 5 of the EUPL
* in the end user terms of the application under an appropriate heading,
* such notice(s) shall fulfill the requirements of that article.
* ********************************************************************* */

const EvidenceKeyFilterBase = require('./evidenceKeyFilter');
Expand Down Expand Up @@ -90,7 +90,7 @@ class FlowElement {
* Function called to check if a FlowElement is ready
* Used when there are asynchronous initialisation steps
*
* @returns {Promise}
* @returns {Promise} returns Promise
* */
ready () {
return Promise.resolve(this);
Expand Down
Loading

0 comments on commit 0c10147

Please sign in to comment.