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

Removed Unused Variables #301

Merged
merged 2 commits into from
Sep 29, 2022
Merged
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
13 changes: 9 additions & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -18,9 +18,14 @@
"endOfLine": "auto"
}
],
/*temporarily turn off no-unused-vars, open an issue to track https://github.com/opensearch-project/opensearch-js/issues/241*/
"no-unused-vars": "off",
/*temporarily turn off no-dupe-else-if, open an issue to track https://github.com/opensearch-project/opensearch-js/issues/240*/
"no-dupe-else-if": "off"
"no-dupe-else-if": "off",
"no-unused-vars": [
"error",
{
"varsIgnorePattern": "^_.*",
"argsIgnorePattern": "^_.*"
}
]
}
}
}
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -286,7 +286,7 @@ class Client extends OpenSearchAPI {

close(callback) {
if (callback == null) {
return new Promise((resolve, reject) => {
return new Promise((resolve) => {
this.close(resolve);
});
}
4 changes: 3 additions & 1 deletion lib/Connection.js
Original file line number Diff line number Diff line change
@@ -249,7 +249,8 @@ class Connection {
// We want to hide `auth`, `agent` and `ssl` since they made
// the logs very hard to read. The user can still
// access them with `instance.agent` and `instance.ssl`.
[inspect.custom](depth, options) {
[inspect.custom]() {
// eslint-disable-next-line no-unused-vars
const { authorization, ...headers } = this.headers;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to reviewer: Even though authorization is not being used, its declaration is still necessary to remove authorization from headers


return {
@@ -265,6 +266,7 @@ class Connection {
}

toJSON() {
// eslint-disable-next-line no-unused-vars
const { authorization, ...headers } = this.headers;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to reviewer: Even though authorization is not being used, its declaration is still necessary to remove authorization from headers


return {
14 changes: 6 additions & 8 deletions lib/Helpers.js
Original file line number Diff line number Diff line change
@@ -97,7 +97,6 @@ class Helpers {
}
params.scroll = params.scroll || '1m';
appendFilterPath('_scroll_id', params, false);
const { method, body, index, ...querystring } = params;

let response = null;
for (let i = 0; i <= maxRetries; i++) {
@@ -132,9 +131,8 @@ class Helpers {
for (let i = 0; i <= maxRetries; i++) {
response = await this[kClient].scroll(
{
scroll: querystring.scroll,
rest_total_hits_as_int:
querystring.rest_total_hits_as_int || querystring.restTotalHitsAsInt,
scroll: params.scroll,
rest_total_hits_as_int: params.rest_total_hits_as_int || params.restTotalHitsAsInt,
body: { scroll_id },
},
options
@@ -199,7 +197,7 @@ class Helpers {
let timeoutRef = null;
const operationsStream = new Readable({
objectMode: true,
read(size) {},
read() {},
});

const p = iterate();
@@ -332,7 +330,7 @@ class Helpers {
return { semaphore, finish };

function finish() {
return new Promise((resolve, reject) => {
return new Promise((resolve) => {
if (running === 0) {
resolve();
} else {
@@ -346,7 +344,7 @@ class Helpers {
running += 1;
return pImmediate(send);
} else {
return new Promise((resolve, reject) => {
return new Promise((resolve) => {
resolveSemaphore = resolve;
});
}
@@ -648,7 +646,7 @@ class Helpers {
running += 1;
return pImmediate(send);
} else {
return new Promise((resolve, reject) => {
return new Promise((resolve) => {
resolveSemaphore = resolve;
});
}
2 changes: 1 addition & 1 deletion lib/Transport.js
Original file line number Diff line number Diff line change
@@ -682,7 +682,7 @@ function randomSelector(connections) {
function generateRequestId() {
const maxInt = 2147483647;
let nextReqId = 0;
return function genReqId(params, options) {
return function genReqId() {
return (nextReqId = (nextReqId + 1) & maxInt);
};
}
4 changes: 2 additions & 2 deletions scripts/release-canary.js
Original file line number Diff line number Diff line change
@@ -90,8 +90,8 @@ async function release(opts) {
await writeFile(join(__dirname, '..', '.npmignore'), originalNpmIgnore, 'utf8');
}

function confirm(question) {
return new Promise((resolve, reject) => {
function confirm() {
return new Promise((resolve) => {
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
4 changes: 2 additions & 2 deletions scripts/utils/generateApis.js
Original file line number Diff line number Diff line change
@@ -267,7 +267,7 @@ function generateSingleApi(version, spec, common) {
documentation: generateDocumentation(spec[api], api),
};

function genRequiredChecks(param) {
function genRequiredChecks() {
const code = required.map(_genRequiredCheck).concat(_noBody()).filter(Boolean);

if (code.length) {
@@ -319,7 +319,7 @@ function generateSingleApi(version, spec, common) {
: str.replace(/_([a-z])/g, (k) => k[1].toUpperCase());
};

return acceptedQuerystring.reduce((acc, val, index) => {
return acceptedQuerystring.reduce((acc, val) => {
if (toCamelCase(val) !== val) {
acc[toCamelCase(val)] = val;
}
Loading