Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added comma dangle rule #414

Merged
merged 1 commit into from
Jun 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = {
"arrow-parens": "off",
"camelcase": "off",
"class-methods-use-this": "off",
"comma-dangle": "off",
"comma-dangle": ["error", "never"],
"comma-spacing":["error", {"before": false, "after": true}],
"consistent-return": "off",
"dot-notation": "error",
Expand Down
8 changes: 4 additions & 4 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ const presets = [
[
"env",
{
targets: { node: "4" },
},
targets: { node: "4" }
}
],
"stage-0",
],
"stage-0"
]
];
const plugins = ["transform-object-rest-spread"];

Expand Down
28 changes: 14 additions & 14 deletions lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ exports.restore = function restore(public_ids, callback, options = {}) {
uri = ["resources", resource_type, type, "restore"];
return call_api("post", uri, {
public_ids: public_ids,
versions: options.versions,
versions: options.versions
}, callback, options);
};

Expand All @@ -109,7 +109,7 @@ exports.delete_resources = function delete_resources(public_ids, callback, optio
type = options.type || "upload";
uri = ["resources", resource_type, type];
return call_api("delete", uri, deleteResourcesParams(options, {
"public_ids[]": public_ids,
"public_ids[]": public_ids
}), callback, options);
};

Expand All @@ -119,7 +119,7 @@ exports.delete_resources_by_prefix = function delete_resources_by_prefix(prefix,
type = options.type || "upload";
uri = ["resources", resource_type, type];
return call_api("delete", uri, deleteResourcesParams(options, {
prefix: prefix,
prefix: prefix
}), callback, options);
};

Expand All @@ -137,30 +137,30 @@ exports.delete_all_resources = function delete_all_resources(callback, options =
type = options.type || "upload";
uri = ["resources", resource_type, type];
return call_api("delete", uri, deleteResourcesParams(options, {
all: true,
all: true
}), callback, options);
};

exports.delete_derived_resources = function delete_derived_resources(derived_resource_ids, callback, options = {}) {
let uri;
uri = ["derived_resources"];
return call_api("delete", uri, {
"derived_resource_ids[]": derived_resource_ids,
"derived_resource_ids[]": derived_resource_ids
}, callback, options);
};

exports.delete_derived_by_transformation = function delete_derived_by_transformation(
public_ids,
transformations,
callback,
options = {},
options = {}
) {
let params, resource_type, type, uri;
resource_type = options.resource_type || "image";
type = options.type || "upload";
uri = "resources/" + resource_type + "/" + type;
params = extend({
"public_ids[]": public_ids,
"public_ids[]": public_ids
}, pickOnlyExistingValues(options, "invalidate"));
params.keep_original = true;
params.transformations = utils.build_eager(transformations);
Expand Down Expand Up @@ -279,13 +279,13 @@ exports.upload_mapping = function upload_mapping(name, callback, options = {}) {
name = null;
}
return call_api("get", 'upload_mappings', {
folder: name,
folder: name
}, callback, options);
};

exports.delete_upload_mapping = function delete_upload_mapping(name, callback, options = {}) {
return call_api("delete", 'upload_mappings', {
folder: name,
folder: name
}, callback, options);
};

Expand All @@ -310,7 +310,7 @@ function publishResource(byKey, value, callback, options = {}) {
resource_type = options.resource_type || "image";
uri = ["resources", resource_type, "publish_resources"];
options = extend({
resource_type: resource_type,
resource_type: resource_type
}, options);
return call_api("post", uri, params, callback, options);
}
Expand Down Expand Up @@ -357,7 +357,7 @@ function updateResourcesAccessMode(access_mode, by_key, value, callback, options
resource_type = options.resource_type || "image";
type = options.type || "upload";
params = {
access_mode: access_mode,
access_mode: access_mode
};
params[by_key] = value;
return call_api("post", "resources/" + resource_type + "/" + type + "/update_access_mode", params, callback, options);
Expand All @@ -372,7 +372,7 @@ exports.update_resources_access_mode_by_prefix = function update_resources_acces
access_mode,
prefix,
callback,
options = {},
options = {}
) {
return updateResourcesAccessMode(access_mode, "prefix", prefix, callback, options);
};
Expand All @@ -381,7 +381,7 @@ exports.update_resources_access_mode_by_tag = function update_resources_access_m
access_mode,
tag,
callback,
options = {},
options = {}
) {
return updateResourcesAccessMode(access_mode, "tag", tag, callback, options);
};
Expand All @@ -390,7 +390,7 @@ exports.update_resources_access_mode_by_ids = function update_resources_access_m
access_mode,
ids,
callback,
options = {},
options = {}
) {
return updateResourcesAccessMode(access_mode, "public_ids[]", ids, callback, options);
};
Expand Down
2 changes: 1 addition & 1 deletion lib/api_client/call_account_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function call_account_api(method, uri, params, callback, options) {
const api_url = [cloudinary, "v1_1", "provisioning", "accounts", account_id].concat(uri).join("/");
const auth = {
key: ensureOption(options, "provisioning_api_key"),
secret: ensureOption(options, "provisioning_api_secret"),
secret: ensureOption(options, "provisioning_api_secret")
};

return execute_request(method, params, auth, api_url, callback, options);
Expand Down
2 changes: 1 addition & 1 deletion lib/api_client/call_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function call_api(method, uri, params, callback, options) {
const api_url = [cloudinary, "v1_1", cloud_name].concat(uri).join("/");
const auth = {
key: ensureOption(options, "api_key"),
secret: ensureOption(options, "api_secret"),
secret: ensureOption(options, "api_secret")
};

return execute_request(method, params, auth, api_url, callback, options);
Expand Down
18 changes: 9 additions & 9 deletions lib/api_client/execute_request.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ function execute_request(method, params, auth, api_url, callback, options = {})
method: method,
headers: {
'Content-Type': content_type,
'User-Agent': utils.getUserAgent(),
'User-Agent': utils.getUserAgent()
},
auth: key + ":" + secret,
auth: key + ":" + secret
});
if (options.agent != null) {
request_options.agent = options.agent;
Expand All @@ -63,8 +63,8 @@ function execute_request(method, params, auth, api_url, callback, options = {})
} catch (e) {
result = {
error: {
message: "Server return invalid JSON response. Status Code " + res.statusCode,
},
message: "Server return invalid JSON response. Status Code " + res.statusCode
}
};
}

Expand All @@ -79,7 +79,7 @@ function execute_request(method, params, auth, api_url, callback, options = {})
if (result.error) {
deferred.reject(Object.assign({
request_options,
query_params,
query_params
}, result));
} else {
deferred.resolve(result);
Expand All @@ -95,8 +95,8 @@ function execute_request(method, params, auth, api_url, callback, options = {})
message: e,
http_code: res.statusCode,
request_options,
query_params,
},
query_params
}
};
deferred.reject(err_obj.error);
if (typeof callback === "function") {
Expand All @@ -109,8 +109,8 @@ function execute_request(method, params, auth, api_url, callback, options = {})
message: "Server returned unexpected status code - " + res.statusCode,
http_code: res.statusCode,
request_options,
query_params,
},
query_params
}
};
deferred.reject(err_obj.error);
if (typeof callback === "function") {
Expand Down
10 changes: 5 additions & 5 deletions lib/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const Cache = {
publicId, options.type || 'upload',
options.resource_type || 'image',
transformation,
options.format,
options.format
);
},
/**
Expand All @@ -96,7 +96,7 @@ const Cache = {
options.resource_type || 'image',
transformation,
options.format,
value,
value
);
},
/**
Expand All @@ -106,15 +106,15 @@ const Cache = {
flushAll() {
if (!this.adapter) { return undefined; }
return this.adapter.flushAll();
},
}

};

// Define singleton property
Object.defineProperty(Cache, "instance", {
get() {
return global[CACHE];
},
}
});
Object.defineProperty(Cache, "adapter", {
/**
Expand All @@ -130,7 +130,7 @@ Object.defineProperty(Cache, "adapter", {
*/
set(adapter) {
global[CACHE_ADAPTER] = adapter;
},
}
});
Object.freeze(Cache);

Expand Down
4 changes: 2 additions & 2 deletions lib/cache/KeyValueCacheAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class KeyValueCacheAdapter extends CacheAdapter {
resourceType,
transformation,
format,
value,
),
value
)
);
}

Expand Down
4 changes: 2 additions & 2 deletions lib/cloudinary.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ exports.api = require("./api");
let account = require("./provisioning/account");

exports.provisioning = {
account: account,
account: account
};
exports.PreloadedFile = require("./preloaded_file");
exports.Cache = require('./cache');
Expand Down Expand Up @@ -155,7 +155,7 @@ exports.video = function video(public_id, options) {
if (multi_source_types && !has_sources) {
sources = source_types.map(source_type => ({
type: source_type,
transformations: source_transformation[source_type] || {},
transformations: source_transformation[source_type] || {}
}));
}
if (_.isArray(sources) && sources.length > 0) {
Expand Down
4 changes: 2 additions & 2 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ function parseCloudinaryConfigFromEnvURL(ENV_STR) {
api_key: uri.auth && uri.auth.split(":")[0],
api_secret: uri.auth && uri.auth.split(":")[1],
private_cdn: uri.pathname != null,
secure_distribution: uri.pathname && uri.pathname.substring(1),
secure_distribution: uri.pathname && uri.pathname.substring(1)
});
} else if (uri.protocol === 'account:') {
conf = Object.assign({}, conf, {
account_id: uri.host,
provisioning_api_key: uri.auth && uri.auth.split(":")[0],
provisioning_api_secret: uri.auth && uri.auth.split(":")[1],
provisioning_api_secret: uri.auth && uri.auth.split(":")[1]
});
}

Expand Down
2 changes: 1 addition & 1 deletion lib/preloaded_file.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class PreloadedFile {
let expected_signature;
expected_signature = utils.api_sign_request({
public_id: this.public_id,
version: this.version,
version: this.version
}, config().api_secret);
return this.signature === expected_signature;
}
Expand Down
18 changes: 9 additions & 9 deletions lib/provisioning/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function sub_accounts(enabled, ids = [], prefix, options = {}, callback) {
let params = {
enabled,
ids,
prefix,
prefix
};

let uri = ['sub_accounts'];
Expand Down Expand Up @@ -55,7 +55,7 @@ function create_sub_account(name, cloud_name, custom_attributes, enabled, base_a
name,
custom_attributes: custom_attributes,
enabled,
base_sub_account_id: base_account,
base_sub_account_id: base_account
};

options.content_type = "json";
Expand Down Expand Up @@ -93,7 +93,7 @@ function update_sub_account(sub_account_id, name, cloud_name, custom_attributes,
cloud_name: cloud_name,
name,
custom_attributes: custom_attributes,
enabled,
enabled
};

options.content_type = "json";
Expand Down Expand Up @@ -125,7 +125,7 @@ function user(user_id, options = {}, callback) {
function users(pending, user_ids, prefix, sub_account_id, options = {}, callback) {
let uri = ['users'];
let params = {
ids: user_ids,
ids: user_ids
};
return call_account_api('GET', uri, params, callback, options);
}
Expand All @@ -147,7 +147,7 @@ function create_user(name, email, role, sub_account_ids, options = {}, callback)
name,
email,
role,
sub_account_ids: sub_account_ids,
sub_account_ids: sub_account_ids
};
options.content_type = 'json';
return call_account_api('POST', uri, params, callback, options);
Expand All @@ -171,7 +171,7 @@ function update_user(user_id, name, email, role, sub_account_ids, options = {},
name,
email,
role,
sub_account_ids: sub_account_ids,
sub_account_ids: sub_account_ids
};
options.content_type = 'json';
return call_account_api('PUT', uri, params, callback, options);
Expand All @@ -198,7 +198,7 @@ function create_user_group(name, options = {}, callback) {
let uri = ['user_groups'];
options.content_type = 'json';
let params = {
name,
name
};
return call_account_api('POST', uri, params, callback, options);
}
Expand All @@ -213,7 +213,7 @@ function create_user_group(name, options = {}, callback) {
function update_user_group(group_id, name, options = {}, callback) {
let uri = ['user_groups', group_id];
let params = {
name,
name
};
return call_account_api('PUT', uri, params, callback, options);
}
Expand Down Expand Up @@ -304,5 +304,5 @@ module.exports = {
create_user,
create_user_group,
add_user_to_group,
delete_user_group,
delete_user_group
};
Loading