From 35ccaeba56bc723defac5a9d7430c07d67284681 Mon Sep 17 00:00:00 2001 From: Zhihe Li Date: Mon, 13 Oct 2025 10:53:21 -0400 Subject: [PATCH] =?UTF-8?q?style:=20=F0=9F=92=84=20Update=20if=20curly=20b?= =?UTF-8?q?race=20statements=20(#3023)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- addons/api/.eslintrc.js | 1 + addons/api/addon/abilities/role.js | 3 ++- addons/api/addon/serializers/account.js | 3 ++- .../api/addon/serializers/credential-store.js | 3 ++- addons/api/addon/serializers/storage-bucket.js | 3 ++- addons/api/addon/serializers/target.js | 6 ++++-- addons/api/addon/serializers/user.js | 3 ++- addons/api/mirage/config.js | 3 ++- addons/auth/.eslintrc.js | 1 + addons/core/.eslintrc.js | 1 + addons/core/addon/decorators/resource-filter.js | 3 ++- addons/rose/.eslintrc.js | 1 + e2e-tests/.eslintrc.cjs | 1 + e2e-tests/admin/pages/orgs.js | 17 ++++++++--------- e2e-tests/admin/pages/targets.js | 6 ++++-- ui/admin/.eslintrc.js | 1 + .../credential-libraries/index.js | 3 ++- .../credential-store/credentials/index.js | 3 ++- .../host-sets/host-set/create-and-add-host.js | 3 ++- .../host-catalog/host-sets/index.js | 3 ++- .../host-catalogs/host-catalog/hosts/index.js | 3 ++- ui/admin/app/routes/onboarding.js | 3 ++- .../app/routes/scopes/scope/authenticate.js | 3 ++- ui/desktop/.eslintrc.js | 1 + 24 files changed, 51 insertions(+), 27 deletions(-) diff --git a/addons/api/.eslintrc.js b/addons/api/.eslintrc.js index d55e8bca1..058a98bee 100644 --- a/addons/api/.eslintrc.js +++ b/addons/api/.eslintrc.js @@ -26,6 +26,7 @@ module.exports = { browser: true, }, rules: { + curly: ['error', 'multi-line', 'consistent'], 'ember/no-get': 'off', 'ember/no-get-with-default': 'off', 'ember/no-computed-properties-in-native-classes': 'off', diff --git a/addons/api/addon/abilities/role.js b/addons/api/addon/abilities/role.js index 4ab6abb00..ef0e1053c 100644 --- a/addons/api/addon/abilities/role.js +++ b/addons/api/addon/abilities/role.js @@ -59,10 +59,11 @@ export default class RoleAbility extends ModelAbility { const type = this.model.constructor.modelName; const typeIsValid = type === 'user' || type === 'group' || type === 'managed-group'; - if (!typeIsValid) + if (!typeIsValid) { throw new InvalidRolePrincipalTypeError( `Expected a role principal of type 'user', 'group', or 'managed-group'. Got '${type}'.`, ); + } return this.can.can(`read ${type}`, this.model); } } diff --git a/addons/api/addon/serializers/account.js b/addons/api/addon/serializers/account.js index fb2184676..76ca43f10 100644 --- a/addons/api/addon/serializers/account.js +++ b/addons/api/addon/serializers/account.js @@ -98,8 +98,9 @@ export default class AccountSerializer extends ApplicationSerializer { serialized.attributes = {}; } // New record case - if (password && snapshot?.record?.isNew) + if (password && snapshot?.record?.isNew) { serialized.attributes.password = password; + } // Set password custom method if (snapshot?.adapterOptions?.method === 'set-password') { serialized = this.serializeForSetPassword(snapshot, password); diff --git a/addons/api/addon/serializers/credential-store.js b/addons/api/addon/serializers/credential-store.js index 55acddc78..6d61c97f9 100644 --- a/addons/api/addon/serializers/credential-store.js +++ b/addons/api/addon/serializers/credential-store.js @@ -28,8 +28,9 @@ export default class CredentialStoreSerializer extends ApplicationSerializer { if ( !serialized.attributes?.client_certificate_key && serialized.attributes?.client_certificate - ) + ) { delete serialized.attributes.client_certificate_key; + } } return serialized; } diff --git a/addons/api/addon/serializers/storage-bucket.js b/addons/api/addon/serializers/storage-bucket.js index 5186f36be..ee4a22345 100644 --- a/addons/api/addon/serializers/storage-bucket.js +++ b/addons/api/addon/serializers/storage-bucket.js @@ -76,9 +76,10 @@ export default class StorageBucketSerializer extends ApplicationSerializer { // This deletes any fields that don't belong to the record's credential type if (options.isNestedAttribute && json.attributes) { // The key must be included in the fieldsByType list above - if (!fieldsByCredentialType[credentialType].includes(key)) + if (!fieldsByCredentialType[credentialType].includes(key)) { // API requires these fields to be null json.attributes[key] = null; + } } //json.secrets is only present, if there are any updates to the secret fields diff --git a/addons/api/addon/serializers/target.js b/addons/api/addon/serializers/target.js index 374d55bb0..ef24a28d4 100644 --- a/addons/api/addon/serializers/target.js +++ b/addons/api/addon/serializers/target.js @@ -33,16 +33,18 @@ export default class TargetSerializer extends ApplicationSerializer { const injectedApplicationCredentialSourceIDs = snapshot?.adapterOptions?.injectedApplicationCredentialSourceIDs; - if (brokeredCredentialSourceIDs) + if (brokeredCredentialSourceIDs) { serialized = this.serializeWithBrokeredCredentialSources( snapshot, brokeredCredentialSourceIDs, ); - if (injectedApplicationCredentialSourceIDs) + } + if (injectedApplicationCredentialSourceIDs) { serialized = this.serializeWithInjectedApplicationCredentialSources( snapshot, injectedApplicationCredentialSourceIDs, ); + } if (isNew && serialized?.with_aliases) { // API expects scope id along with every alias value diff --git a/addons/api/addon/serializers/user.js b/addons/api/addon/serializers/user.js index 5b71a9b70..7f3219acc 100644 --- a/addons/api/addon/serializers/user.js +++ b/addons/api/addon/serializers/user.js @@ -18,8 +18,9 @@ export default class UserSerializer extends ApplicationSerializer { serialize(snapshot) { let serialized = super.serialize(...arguments); const accountIDs = snapshot?.adapterOptions?.accountIDs; - if (accountIDs) + if (accountIDs) { serialized = this.serializewithAccounts(snapshot, accountIDs); + } return serialized; } diff --git a/addons/api/mirage/config.js b/addons/api/mirage/config.js index 70a97c1ce..f608d6942 100644 --- a/addons/api/mirage/config.js +++ b/addons/api/mirage/config.js @@ -542,10 +542,11 @@ function routes() { session.update({ status: pickRandomStatusString(), }); - if (session.id.split('-').pop() % 2) + if (session.id.split('-').pop() % 2) { session.update({ userId: 'authenticateduser', }); + } }); } if (recursive && scope_id === 'global') { diff --git a/addons/auth/.eslintrc.js b/addons/auth/.eslintrc.js index 326b89347..e43b699fc 100644 --- a/addons/auth/.eslintrc.js +++ b/addons/auth/.eslintrc.js @@ -26,6 +26,7 @@ module.exports = { browser: true, }, rules: { + curly: ['error', 'multi-line', 'consistent'], 'ember/no-get': 'off', 'ember/no-get-with-default': 'off', 'ember/no-computed-properties-in-native-classes': 'off', diff --git a/addons/core/.eslintrc.js b/addons/core/.eslintrc.js index 8cce37345..79d6f44ac 100644 --- a/addons/core/.eslintrc.js +++ b/addons/core/.eslintrc.js @@ -26,6 +26,7 @@ module.exports = { browser: true, }, rules: { + curly: ['error', 'multi-line', 'consistent'], 'ember/no-get': 'off', 'ember/no-get-with-default': 'off', 'ember/no-computed-properties-in-native-classes': 'off', diff --git a/addons/core/addon/decorators/resource-filter.js b/addons/core/addon/decorators/resource-filter.js index ad31c6bd0..e31437a30 100644 --- a/addons/core/addon/decorators/resource-filter.js +++ b/addons/core/addon/decorators/resource-filter.js @@ -129,8 +129,9 @@ class RouteResourceFilter extends EmberObject { const filterKey = `filter-${name}`; // If the route has no query params specified yet, declare them. - if (!Object.keys(routeClass.queryParams).length) + if (!Object.keys(routeClass.queryParams).length) { routeClass.queryParams = {}; + } // If the route has no resource filters list specified yet, create one. if (!routeClass.resourceFilterParams) routeClass.resourceFilterParams = []; diff --git a/addons/rose/.eslintrc.js b/addons/rose/.eslintrc.js index 02baaa86b..8f83723dc 100644 --- a/addons/rose/.eslintrc.js +++ b/addons/rose/.eslintrc.js @@ -26,6 +26,7 @@ module.exports = { browser: true, }, rules: { + curly: ['error', 'multi-line', 'consistent'], 'ember/no-jquery': 'error', 'ember/no-new-mixins': 0, 'ember/no-get': 'off', diff --git a/e2e-tests/.eslintrc.cjs b/e2e-tests/.eslintrc.cjs index bbc3ddc87..07fe34bc1 100644 --- a/e2e-tests/.eslintrc.cjs +++ b/e2e-tests/.eslintrc.cjs @@ -20,6 +20,7 @@ module.exports = { es2021: true, }, rules: { + curly: ['error', 'multi-line', 'consistent'], 'no-empty-pattern': ['error', { allowObjectPatternsAsParameters: true }], }, overrides: [ diff --git a/e2e-tests/admin/pages/orgs.js b/e2e-tests/admin/pages/orgs.js index 16d4780a5..dd2660d1a 100644 --- a/e2e-tests/admin/pages/orgs.js +++ b/e2e-tests/admin/pages/orgs.js @@ -60,16 +60,15 @@ export class OrgsPage extends BaseResourcePage { async chooseScopeFromDropdown(fromScope, toScope) { await this.page .getByRole('button', { name: fromScope, exact: true }) - .click() - await this.page - .getByRole('option', { name: toScope, exact: true }) - .click() + .click(); + await this.page.getByRole('option', { name: toScope, exact: true }).click(); await expect( - this.page.getByRole('button', { name: toScope, exact: true }) - ).toBeVisible() - if (toScope != 'Global') + this.page.getByRole('button', { name: toScope, exact: true }), + ).toBeVisible(); + if (toScope !== 'Global') { await expect( - this.page.getByRole('link', { name: toScope, exact: true }) - ).toBeVisible() + this.page.getByRole('link', { name: toScope, exact: true }), + ).toBeVisible(); + } } } diff --git a/e2e-tests/admin/pages/targets.js b/e2e-tests/admin/pages/targets.js index cb1e3dbdb..99ebd6b9f 100644 --- a/e2e-tests/admin/pages/targets.js +++ b/e2e-tests/admin/pages/targets.js @@ -44,12 +44,14 @@ export class TargetsPage extends BaseResourcePage { await this.page.getByLabel('Name').fill(targetName); await this.page.getByLabel('Description').fill('This is an automated test'); if (targetType) { - if (targetTypeLabel) + if (targetTypeLabel) { await this.page .getByRole('group', { name: 'Type' }) .getByLabel(targetTypeLabel) .click(); - else throw new Error(`Unsupported target type: ${targetType}`); + } else { + throw new Error(`Unsupported target type: ${targetType}`); + } } if (address) await this.page.getByLabel('Target Address').fill(address); if (port) await this.page.getByLabel('Default Port').fill(port); diff --git a/ui/admin/.eslintrc.js b/ui/admin/.eslintrc.js index 4c2a5df1b..189b48bf3 100644 --- a/ui/admin/.eslintrc.js +++ b/ui/admin/.eslintrc.js @@ -26,6 +26,7 @@ module.exports = { browser: true, }, rules: { + curly: ['error', 'multi-line', 'consistent'], 'ember/no-get': 'off', 'ember/no-get-with-default': 'off', 'ember/no-computed-properties-in-native-classes': 'off', diff --git a/ui/admin/app/controllers/scopes/scope/credential-stores/credential-store/credential-libraries/index.js b/ui/admin/app/controllers/scopes/scope/credential-stores/credential-store/credential-libraries/index.js index b63da395e..34e554bcb 100644 --- a/ui/admin/app/controllers/scopes/scope/credential-stores/credential-store/credential-libraries/index.js +++ b/ui/admin/app/controllers/scopes/scope/credential-stores/credential-store/credential-libraries/index.js @@ -56,10 +56,11 @@ export default class ScopesScopeCredentialStoresCredentialStoreCredentialLibrari async cancel(credentialLibrary) { const { isNew } = credentialLibrary; credentialLibrary.rollbackAttributes(); - if (isNew) + if (isNew) { await this.router.transitionTo( 'scopes.scope.credential-stores.credential-store.credential-libraries', ); + } } /** diff --git a/ui/admin/app/controllers/scopes/scope/credential-stores/credential-store/credentials/index.js b/ui/admin/app/controllers/scopes/scope/credential-stores/credential-store/credentials/index.js index a8092a9bb..dad3d9a10 100644 --- a/ui/admin/app/controllers/scopes/scope/credential-stores/credential-store/credentials/index.js +++ b/ui/admin/app/controllers/scopes/scope/credential-stores/credential-store/credentials/index.js @@ -56,10 +56,11 @@ export default class ScopesScopeCredentialStoresCredentialStoreCredentialsIndexC async cancel(credential) { const { isNew } = credential; credential.rollbackAttributes(); - if (isNew) + if (isNew) { await this.router.transitionTo( 'scopes.scope.credential-stores.credential-store.credentials', ); + } } /** diff --git a/ui/admin/app/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/host-set/create-and-add-host.js b/ui/admin/app/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/host-set/create-and-add-host.js index 4355b1f92..30759ed85 100644 --- a/ui/admin/app/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/host-set/create-and-add-host.js +++ b/ui/admin/app/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/host-set/create-and-add-host.js @@ -40,9 +40,10 @@ export default class ScopesScopeHostCatalogsHostCatalogHostSetsHostSetCreateAndA cancel(host) { const { isNew } = host; host.rollbackAttributes(); - if (isNew) + if (isNew) { this.router.transitionTo( 'scopes.scope.host-catalogs.host-catalog.host-sets.host-set.hosts', ); + } } } diff --git a/ui/admin/app/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/index.js b/ui/admin/app/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/index.js index 12a433e2d..1dca4d144 100644 --- a/ui/admin/app/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/index.js +++ b/ui/admin/app/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/index.js @@ -57,10 +57,11 @@ export default class ScopesScopeHostCatalogsHostCatalogHostSetsIndexController e cancel(hostSet) { const { isNew } = hostSet; hostSet.rollbackAttributes(); - if (isNew) + if (isNew) { this.router.transitionTo( 'scopes.scope.host-catalogs.host-catalog.host-sets', ); + } } /** diff --git a/ui/admin/app/controllers/scopes/scope/host-catalogs/host-catalog/hosts/index.js b/ui/admin/app/controllers/scopes/scope/host-catalogs/host-catalog/hosts/index.js index 9ad6dadb8..2b78ba840 100644 --- a/ui/admin/app/controllers/scopes/scope/host-catalogs/host-catalog/hosts/index.js +++ b/ui/admin/app/controllers/scopes/scope/host-catalogs/host-catalog/hosts/index.js @@ -56,8 +56,9 @@ export default class ScopesScopeHostCatalogsHostCatalogHostsIndexController exte cancel(host) { const { isNew } = host; host.rollbackAttributes(); - if (isNew) + if (isNew) { this.router.transitionTo('scopes.scope.host-catalogs.host-catalog.hosts'); + } } /** diff --git a/ui/admin/app/routes/onboarding.js b/ui/admin/app/routes/onboarding.js index bae7993aa..9debcfe49 100644 --- a/ui/admin/app/routes/onboarding.js +++ b/ui/admin/app/routes/onboarding.js @@ -24,8 +24,9 @@ export default class OnboardingRoute extends Route { scope_id: 'global', query: { filters: { scope_id: [{ equals: 'global' }] } }, }); - if (!this.session.isAuthenticated || orgs.length) + if (!this.session.isAuthenticated || orgs.length) { this.router.transitionTo('index'); + } } /** diff --git a/ui/admin/app/routes/scopes/scope/authenticate.js b/ui/admin/app/routes/scopes/scope/authenticate.js index 85e486616..b321fa2c3 100644 --- a/ui/admin/app/routes/scopes/scope/authenticate.js +++ b/ui/admin/app/routes/scopes/scope/authenticate.js @@ -16,8 +16,9 @@ export default class ScopesScopeAuthenticateRoute extends Route { // =methods beforeModel() { - if (this.session.isAuthenticated) + if (this.session.isAuthenticated) { this.router.transitionTo('scopes.scope.index'); + } } /** diff --git a/ui/desktop/.eslintrc.js b/ui/desktop/.eslintrc.js index b38f0e03a..70fd5efd0 100644 --- a/ui/desktop/.eslintrc.js +++ b/ui/desktop/.eslintrc.js @@ -26,6 +26,7 @@ module.exports = { browser: true, }, rules: { + curly: ['error', 'multi-line', 'consistent'], 'ember/no-get': 'off', 'ember/no-get-with-default': 'off', 'ember/no-computed-properties-in-native-classes': 'off',