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

Eslint prefer-const #17864

Merged
merged 2 commits into from
Nov 9, 2022
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions ui/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module.exports = {
},
rules: {
'no-console': 'error',
'prefer-const': ['error', { destructuring: 'all' }],
'ember/no-mixins': 'warn',
'ember/no-new-mixins': 'off', // should be warn but then every line of the mixin is green
// need to be fully glimmerized before these rules can be turned on
Expand Down
17 changes: 9 additions & 8 deletions ui/app/adapters/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,16 @@ export default RESTAdapter.extend({
},

addHeaders(url, options) {
let token = options.clientToken || this.auth.currentToken;
let headers = {};
const token = options.clientToken || this.auth.currentToken;
const headers = {};
if (token && !options.unauthenticated) {
headers['X-Vault-Token'] = token;
}
if (options.wrapTTL) {
headers['X-Vault-Wrap-TTL'] = options.wrapTTL;
}
let namespace = typeof options.namespace === 'undefined' ? this.namespaceService.path : options.namespace;
const namespace =
typeof options.namespace === 'undefined' ? this.namespaceService.path : options.namespace;
if (namespace && !NAMESPACE_ROOT_URLS.some((str) => url.includes(str))) {
headers['X-Vault-Namespace'] = namespace;
}
Expand All @@ -61,8 +62,8 @@ export default RESTAdapter.extend({
let url = intendedUrl;
let type = method;
let options = passedOptions;
let controlGroup = this.controlGroup;
let controlGroupToken = controlGroup.tokenForUrl(url);
const controlGroup = this.controlGroup;
const controlGroupToken = controlGroup.tokenForUrl(url);
// if we have a Control Group token that matches the intendedUrl,
// then we want to unwrap it and return the unwrapped response as
// if it were the initial request
Expand All @@ -77,15 +78,15 @@ export default RESTAdapter.extend({
},
};
}
let opts = this._preRequest(url, options);
const opts = this._preRequest(url, options);

return this._super(url, type, opts).then((...args) => {
if (controlGroupToken) {
controlGroup.deleteControlGroupToken(controlGroupToken.accessor);
}
const [resp] = args;
if (resp && resp.warnings) {
let flash = this.flashMessages;
const flash = this.flashMessages;
resp.warnings.forEach((message) => {
flash.info(message);
});
Expand All @@ -96,7 +97,7 @@ export default RESTAdapter.extend({

// for use on endpoints that don't return JSON responses
rawRequest(url, type, options = {}) {
let opts = this._preRequest(url, options);
const opts = this._preRequest(url, options);
return fetch(url, {
method: type || 'GET',
headers: opts.headers || {},
Expand Down
4 changes: 2 additions & 2 deletions ui/app/adapters/auth-method.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ export default ApplicationAdapter.extend({
},

findAll(store, type, sinceToken, snapshotRecordArray) {
let isUnauthenticated = snapshotRecordArray?.adapterOptions?.unauthenticated;
const isUnauthenticated = snapshotRecordArray?.adapterOptions?.unauthenticated;
if (isUnauthenticated) {
let url = `/${this.urlPrefix()}/internal/ui/mounts`;
const url = `/${this.urlPrefix()}/internal/ui/mounts`;
return this.ajax(url, 'GET', {
unauthenticated: true,
})
Expand Down
12 changes: 6 additions & 6 deletions ui/app/adapters/aws-credential.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import ApplicationAdapter from './application';

export default ApplicationAdapter.extend({
createRecord(store, type, snapshot) {
let ttl = snapshot.attr('ttl');
let roleArn = snapshot.attr('roleArn');
let roleType = snapshot.attr('credentialType');
const ttl = snapshot.attr('ttl');
const roleArn = snapshot.attr('roleArn');
const roleType = snapshot.attr('credentialType');
let method = 'POST';
let options;
let data = {};
const data = {};
if (roleType === 'iam_user') {
method = 'GET';
} else {
Expand All @@ -19,8 +19,8 @@ export default ApplicationAdapter.extend({
}
options = data.ttl || data.role_arn ? { data } : {};
}
let role = snapshot.attr('role');
let url = `/v1/${role.backend}/creds/${role.name}`;
const role = snapshot.attr('role');
const url = `/v1/${role.backend}/creds/${role.name}`;

return this.ajax(url, method, options).then((response) => {
response.id = snapshot.id;
Expand Down
14 changes: 7 additions & 7 deletions ui/app/adapters/clients/activity.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ export default Application.extend({
let { start_time, end_time } = query;
// check if it's an array, if it is, it's coming from an action like selecting a new startTime or new EndTime
if (Array.isArray(start_time)) {
let startYear = Number(start_time[0]);
let startMonth = Number(start_time[1]);
const startYear = Number(start_time[0]);
const startMonth = Number(start_time[1]);
start_time = formatRFC3339(new Date(startYear, startMonth, 10));
}
if (end_time) {
if (Array.isArray(end_time)) {
let endYear = Number(end_time[0]);
let endMonth = Number(end_time[1]);
const endYear = Number(end_time[0]);
const endMonth = Number(end_time[1]);
end_time = formatRFC3339(new Date(endYear, endMonth, 20));
}

Expand All @@ -30,12 +30,12 @@ export default Application.extend({
// end_time: (2) ['2022', 0]
// start_time: (2) ['2021', 2]
queryRecord(store, type, query) {
let url = `${this.buildURL()}/internal/counters/activity`;
const url = `${this.buildURL()}/internal/counters/activity`;
// check if start and/or end times are in RFC3395 format, if not convert with timezone UTC/zulu.
let queryParams = this.formatTimeParams(query);
const queryParams = this.formatTimeParams(query);
if (queryParams) {
return this.ajax(url, 'GET', { data: queryParams }).then((resp) => {
let response = resp || {};
const response = resp || {};
response.id = response.request_id || 'no-data';
return response;
});
Expand Down
4 changes: 2 additions & 2 deletions ui/app/adapters/clients/monthly.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import ApplicationAdapter from '../application';

export default class MonthlyAdapter extends ApplicationAdapter {
queryRecord() {
let url = `${this.buildURL()}/internal/counters/activity/monthly`;
const url = `${this.buildURL()}/internal/counters/activity/monthly`;
// Query has startTime defined. The API will return the endTime if none is provided.
return this.ajax(url, 'GET').then((resp) => {
let response = resp || {};
const response = resp || {};
response.id = response.request_id || 'no-data';
return response;
});
Expand Down
4 changes: 2 additions & 2 deletions ui/app/adapters/cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default ApplicationAdapter.extend({
},

findRecord(store, type, id, snapshot) {
let fetches = {
const fetches = {
health: this.health(),
sealStatus: this.sealStatus().catch((e) => e),
};
Expand Down Expand Up @@ -110,7 +110,7 @@ export default ApplicationAdapter.extend({
const { role, jwt, token, password, username, path, nonce } = data;
const url = this.urlForAuth(backend, username, path);
const verb = backend === 'token' ? 'GET' : 'POST';
let options = {
const options = {
unauthenticated: true,
};
if (backend === 'token') {
Expand Down
4 changes: 2 additions & 2 deletions ui/app/adapters/control-group.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default ApplicationAdapter.extend({
},

findRecord(store, type, id) {
let baseUrl = this.buildURL(type.modelName);
const baseUrl = this.buildURL(type.modelName);
return this.ajax(`${baseUrl}/request`, 'POST', {
data: {
accessor: id,
Expand All @@ -18,7 +18,7 @@ export default ApplicationAdapter.extend({
},

urlForUpdateRecord(id, modelName) {
let base = this.buildURL(modelName);
const base = this.buildURL(modelName);
return `${base}/authorize`;
},
});
2 changes: 1 addition & 1 deletion ui/app/adapters/database/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default ApplicationAdapter.extend({
return url;
},
optionsForQuery(id) {
let data = {};
const data = {};
if (!id) {
data['list'] = true;
}
Expand Down
12 changes: 6 additions & 6 deletions ui/app/adapters/database/role.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default ApplicationAdapter.extend({
},

optionsForQuery(id) {
let data = {};
const data = {};
if (!id) {
data['list'] = true;
}
Expand Down Expand Up @@ -83,9 +83,9 @@ export default ApplicationAdapter.extend({
}
// Names are distinct across both types of role,
// so only one request should ever come back with value
let type = staticResp.value ? 'static' : 'dynamic';
let successful = staticResp.value || dynamicResp.value;
let resp = {
const type = staticResp.value ? 'static' : 'dynamic';
const successful = staticResp.value || dynamicResp.value;
const resp = {
data: {},
backend,
id,
Expand All @@ -105,7 +105,7 @@ export default ApplicationAdapter.extend({
const dynamicReq = this.dynamicRoles(backend);

return allSettled([staticReq, dynamicReq]).then(([staticResp, dynamicResp]) => {
let resp = {
const resp = {
backend,
data: { keys: [] },
};
Expand Down Expand Up @@ -139,7 +139,7 @@ export default ApplicationAdapter.extend({

async _updateAllowedRoles(store, { role, backend, db, type = 'add' }) {
const connection = await store.queryRecord('database/connection', { backend, id: db });
let roles = [...connection.allowed_roles];
const roles = [...connection.allowed_roles];
const allowedRoles = type === 'add' ? addToArray([roles, role]) : removeFromArray([roles, role]);
connection.allowed_roles = allowedRoles;
return connection.save();
Expand Down
4 changes: 2 additions & 2 deletions ui/app/adapters/generated-item-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ export default ApplicationAdapter.extend({

getDynamicApiPath: task(function* (id) {
// TODO: remove yield at some point.
let result = yield this.store.peekRecord('auth-method', id);
const result = yield this.store.peekRecord('auth-method', id);
this.dynamicApiPath = result.apiPath;
return;
}),

fetchByQuery: task(function* (store, query, isList) {
const { id } = query;
let data = {};
const data = {};
if (isList) {
data.list = true;
yield this.getDynamicApiPath.perform(id);
Expand Down
2 changes: 1 addition & 1 deletion ui/app/adapters/identity/entity-merge.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import IdentityAdapter from './base';
export default IdentityAdapter.extend({
buildURL() {
// first arg is modelName which we're hardcoding in the call to _super.
let [, ...args] = arguments;
const [, ...args] = arguments;
return this._super('identity/entity/merge', ...args);
},

Expand Down
4 changes: 2 additions & 2 deletions ui/app/adapters/identity/entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import IdentityAdapter from './base';

export default IdentityAdapter.extend({
lookup(store, data) {
let url = `/${this.urlPrefix()}/identity/lookup/entity`;
const url = `/${this.urlPrefix()}/identity/lookup/entity`;
return this.ajax(url, 'POST', { data }).then((response) => {
// unsuccessful lookup is a 204
if (!response) return;
let modelName = 'identity/entity';
const modelName = 'identity/entity';
store.push(
store
.serializerFor(modelName)
Expand Down
4 changes: 2 additions & 2 deletions ui/app/adapters/identity/group.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import IdentityAdapter from './base';

export default IdentityAdapter.extend({
lookup(store, data) {
let url = `/${this.urlPrefix()}/identity/lookup/group`;
const url = `/${this.urlPrefix()}/identity/lookup/group`;
return this.ajax(url, 'POST', { data }).then((response) => {
// unsuccessful lookup is a 204
if (!response) return;
let modelName = 'identity/group';
const modelName = 'identity/group';
store.push(
store
.serializerFor(modelName)
Expand Down
6 changes: 3 additions & 3 deletions ui/app/adapters/keymgmt/key.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ export default class KeymgmtKeyAdapter extends ApplicationAdapter {

_updateKey(backend, name, serialized) {
// Only these two attributes are allowed to be updated
let data = pickKeys(serialized, ['deletion_allowed', 'min_enabled_version']);
const data = pickKeys(serialized, ['deletion_allowed', 'min_enabled_version']);
return this.ajax(this.url(backend, name), 'PUT', { data });
}

_createKey(backend, name, serialized) {
// Only type is allowed on create
let data = pickKeys(serialized, ['type']);
const data = pickKeys(serialized, ['type']);
return this.ajax(this.url(backend, name), 'POST', { data });
}

Expand Down Expand Up @@ -159,7 +159,7 @@ export default class KeymgmtKeyAdapter extends ApplicationAdapter {
}

async rotateKey(backend, id) {
let keyModel = this.store.peekRecord('keymgmt/key', id);
const keyModel = this.store.peekRecord('keymgmt/key', id);
const result = await this.ajax(this.url(backend, id, 'ROTATE'), 'PUT');
await keyModel.reload();
return result;
Expand Down
8 changes: 4 additions & 4 deletions ui/app/adapters/kmip/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export default ApplicationAdapter.extend({
},

_url(modelType, meta = {}, id) {
let { backend, scope, role } = meta;
let type = this.pathForType(modelType);
const { backend, scope, role } = meta;
const type = this.pathForType(modelType);
let base;
switch (type) {
case 'scope':
Expand All @@ -33,7 +33,7 @@ export default ApplicationAdapter.extend({
},

urlForQuery(query, modelType) {
let base = this._url(modelType, query);
const base = this._url(modelType, query);
return base + '?list=true';
},

Expand All @@ -47,7 +47,7 @@ export default ApplicationAdapter.extend({
},

queryRecord(store, type, query) {
let id = query.id;
const id = query.id;
delete query.id;
return this.ajax(this._url(type.modelName, query, id), 'GET').then((resp) => {
resp.id = id;
Expand Down
2 changes: 1 addition & 1 deletion ui/app/adapters/kmip/ca.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import BaseAdapter from './base';

export default BaseAdapter.extend({
urlForFindRecord(id, modelName, snapshot) {
let name = this.pathForType(modelName);
const name = this.pathForType(modelName);
return this.buildURL(id, name, snapshot);
},
});
2 changes: 1 addition & 1 deletion ui/app/adapters/kmip/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import BaseAdapter from './base';

export default BaseAdapter.extend({
_url(id, modelName, snapshot) {
let name = this.pathForType(modelName);
const name = this.pathForType(modelName);
// id here will be the mount path,
// modelName will be config so we want to transpose the first two call args
return this.buildURL(id, name, snapshot);
Expand Down
Loading