Skip to content

Commit

Permalink
Removed Unused Variables (#301)
Browse files Browse the repository at this point in the history
* Removed Unused Variables
- Removed `"no-unused-vars": "off"` in eslintrc.
- Disabled eslint's `no-unused-vars` check where the unused vars actually serve a purpose, and removed the unused vars otherwise.

Signed-off-by: Theo Truong <[email protected]>

* - eslint's `no-unused-vars` rule now ignores variables with leading underscore.

Signed-off-by: Theo Truong <[email protected]>

Signed-off-by: Theo Truong <[email protected]>
  • Loading branch information
nhtruong authored Sep 29, 2022
1 parent 0889f59 commit b18ab79
Show file tree
Hide file tree
Showing 32 changed files with 272 additions and 267 deletions.
13 changes: 9 additions & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Up @@ -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);
});
}
Expand Down
4 changes: 3 additions & 1 deletion lib/Connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

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

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

return {
Expand Down
14 changes: 6 additions & 8 deletions lib/Helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -199,7 +197,7 @@ class Helpers {
let timeoutRef = null;
const operationsStream = new Readable({
objectMode: true,
read(size) {},
read() {},
});

const p = iterate();
Expand Down Expand Up @@ -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 {
Expand All @@ -346,7 +344,7 @@ class Helpers {
running += 1;
return pImmediate(send);
} else {
return new Promise((resolve, reject) => {
return new Promise((resolve) => {
resolveSemaphore = resolve;
});
}
Expand Down Expand Up @@ -648,7 +646,7 @@ class Helpers {
running += 1;
return pImmediate(send);
} else {
return new Promise((resolve, reject) => {
return new Promise((resolve) => {
resolveSemaphore = resolve;
});
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Transport.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
}
Expand Down
4 changes: 2 additions & 2 deletions scripts/release-canary.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions scripts/utils/generateApis.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
Expand Down
Loading

0 comments on commit b18ab79

Please sign in to comment.