diff --git a/enterprise/web-frontend/modules/baserow_enterprise/module.js b/enterprise/web-frontend/modules/baserow_enterprise/module.js index b278ecc851..5e90e236db 100644 --- a/enterprise/web-frontend/modules/baserow_enterprise/module.js +++ b/enterprise/web-frontend/modules/baserow_enterprise/module.js @@ -48,10 +48,14 @@ export default defineNuxtModule({ }) // Add login pages as children of login-pages (inherit login layout) - const loginPagesRoute = pages.find((route) => route.name === 'login-pages') + const loginPagesRoute = pages.find( + (route) => route.name === 'login-pages' + ) if (loginPagesRoute) { routes.forEach((route) => { - if (!loginPagesRoute.children.find(({ name }) => name === route.name)) { + if ( + !loginPagesRoute.children.find(({ name }) => name === route.name) + ) { loginPagesRoute.children.push(route) } }) diff --git a/enterprise/web-frontend/modules/baserow_enterprise/pages/login/loginWithSAML.vue b/enterprise/web-frontend/modules/baserow_enterprise/pages/login/loginWithSAML.vue index bf34b223bd..7fdac76d7d 100644 --- a/enterprise/web-frontend/modules/baserow_enterprise/pages/login/loginWithSAML.vue +++ b/enterprise/web-frontend/modules/baserow_enterprise/pages/login/loginWithSAML.vue @@ -156,65 +156,61 @@ const login = async () => { } // Async data fetching -const { data: asyncData } = await useAsyncData( - 'saml-login', - async () => { - // the SuperUser must create the account using username and password - if (store.getters['settings/get'].show_admin_signup_page === true) { - await navigateTo({ name: 'signup' }) - return {} - } +const { data: asyncData } = await useAsyncData('saml-login', async () => { + // the SuperUser must create the account using username and password + if (store.getters['settings/get'].show_admin_signup_page === true) { + await navigateTo({ name: 'signup' }) + return {} + } - // if this page is accessed directly, load the login options to - // populate the page with all the authentication providers - if (!store.getters['authProvider/getLoginOptionsLoaded']) { - await store.dispatch('authProvider/fetchLoginOptions') - } + // if this page is accessed directly, load the login options to + // populate the page with all the authentication providers + if (!store.getters['authProvider/getLoginOptionsLoaded']) { + await store.dispatch('authProvider/fetchLoginOptions') + } - const samlLoginOptions = - store.getters['authProvider/getLoginOptionsForType']( - new SamlAuthProviderType().getType() - ) + const samlLoginOptions = store.getters['authProvider/getLoginOptionsForType']( + new SamlAuthProviderType().getType() + ) - if (!samlLoginOptions) { - await navigateTo({ name: 'login', query: route.query }) // no SAML provider enabled - return {} - } + if (!samlLoginOptions) { + await navigateTo({ name: 'login', query: route.query }) // no SAML provider enabled + return {} + } - // Fetch workspace invitation if token exists - let invitation = null - const invitationToken = route.query.workspaceInvitationToken - if (invitationToken) { - try { - const { data } = - await WorkspaceService($client).fetchInvitationByToken(invitationToken) - invitation = data - } catch {} - } + // Fetch workspace invitation if token exists + let invitation = null + const invitationToken = route.query.workspaceInvitationToken + if (invitationToken) { + try { + const { data } = + await WorkspaceService($client).fetchInvitationByToken(invitationToken) + invitation = data + } catch {} + } - // in case the email is not necessary or provided via workspace invitation, - // redirect the user directly to the SAML provider - if (!samlLoginOptions.domainRequired || invitation?.email) { - try { - const { data } = await samlAuthProviderService($client).getSamlLoginUrl({ - email: invitation?.email, - original: route.query.original, - }) - return { - redirectImmediately: true, - redirectUrl: data.redirect_url, - } - } catch (error) { - return { - email: invitation?.email, - loginRequestError: true, - } + // in case the email is not necessary or provided via workspace invitation, + // redirect the user directly to the SAML provider + if (!samlLoginOptions.domainRequired || invitation?.email) { + try { + const { data } = await samlAuthProviderService($client).getSamlLoginUrl({ + email: invitation?.email, + original: route.query.original, + }) + return { + redirectImmediately: true, + redirectUrl: data.redirect_url, + } + } catch (error) { + return { + email: invitation?.email, + loginRequestError: true, } } - - return { redirectUrl: samlLoginOptions.redirect_url } } -) + + return { redirectUrl: samlLoginOptions.redirect_url } +}) // Apply async data results if (asyncData.value?.redirectImmediately) { diff --git a/web-frontend/.prettierignore b/web-frontend/.prettierignore index 6b9224f42e..a471456fd2 100644 --- a/web-frontend/.prettierignore +++ b/web-frontend/.prettierignore @@ -1,3 +1,35 @@ -modules/core/templates -**/locales/*.json +# Nuxt build outputs +.nuxt/ +.output/ +.nitro/ +dist/ + +# Dependencies +node_modules/ + +# Cache +.cache/ + +# Coverage +coverage/ + +# Logs +*.log + +# Lock files +yarn.lock +package-lock.json +pnpm-lock.yaml + +# Generated files +**/generated/** + +# Project-specific +modules/core/templates/ modules/core/formula/parser/ +modules/core/assets/scss/vendor/ +**/locales/*.json + +# Storybook +.nuxt-storybook/ +storybook-static/ diff --git a/web-frontend/eslint.config.common.mjs b/web-frontend/eslint.config.common.mjs index 92d8d3a635..6b0daaf249 100644 --- a/web-frontend/eslint.config.common.mjs +++ b/web-frontend/eslint.config.common.mjs @@ -3,7 +3,7 @@ import withNuxt from './.nuxt/eslint.config.mjs' import globals from 'globals' import vitest from 'eslint-plugin-vitest' -import prettier from 'eslint-config-prettier' +import eslintConfigPrettier from 'eslint-config-prettier' export default [ { @@ -15,7 +15,7 @@ export default [ '.nuxt-storybook/**', ], }, - prettier, + eslintConfigPrettier, // deactivate eslint rules that conflict with prettier { languageOptions: { globals: { diff --git a/web-frontend/justfile b/web-frontend/justfile index 13a009bf35..b5c6a20926 100644 --- a/web-frontend/justfile +++ b/web-frontend/justfile @@ -78,22 +78,25 @@ install: # Code Quality & Linting # ============================================================================= -# Run all linters (eslint + stylelint) +# Run all linters (eslint + stylelint + prettier) [group('4 - code-quality')] lint: - yarn run eslint - yarn run stylelint - yarn run prettier --check 'modules/**/*.scss' + yarn run lint # Fix code style issues [group('4 - code-quality')] fix: yarn run fix -# Format SCSS files with Prettier +# Check formatting with Prettier [group('4 - code-quality')] -format-scss: - yarn run prettier --write 'modules/**/*.scss' +prettier-check: + yarn run prettier:check + +# Format all files with Prettier +[group('4 - code-quality')] +format: + yarn run format # ============================================================================= # Testing diff --git a/web-frontend/modules/core/components/auth/PasswordLogin.vue b/web-frontend/modules/core/components/auth/PasswordLogin.vue index 031a1e188f..c3d327890e 100644 --- a/web-frontend/modules/core/components/auth/PasswordLogin.vue +++ b/web-frontend/modules/core/components/auth/PasswordLogin.vue @@ -113,7 +113,12 @@ export default { default: true, }, }, - emits: ['email-not-verified', 'success', 'two-factor-auth', 'invitation-accepted'], + emits: [ + 'email-not-verified', + 'success', + 'two-factor-auth', + 'invitation-accepted', + ], setup() { const values = reactive({ values: { diff --git a/web-frontend/modules/core/pages/signup.vue b/web-frontend/modules/core/pages/signup.vue index 546b1f9b19..45670e2708 100644 --- a/web-frontend/modules/core/pages/signup.vue +++ b/web-frontend/modules/core/pages/signup.vue @@ -105,7 +105,9 @@ const { data: invitation } = await useAsyncData( if (invitationToken) { try { const { data } = - await WorkspaceService($client).fetchInvitationByToken(invitationToken) + await WorkspaceService($client).fetchInvitationByToken( + invitationToken + ) return data } catch { return null diff --git a/web-frontend/modules/core/pages/workspaceInvitation.vue b/web-frontend/modules/core/pages/workspaceInvitation.vue index b79b6e4e94..a32db653ed 100644 --- a/web-frontend/modules/core/pages/workspaceInvitation.vue +++ b/web-frontend/modules/core/pages/workspaceInvitation.vue @@ -43,8 +43,9 @@ if (invitation.value) { ) { try { // Accept the invitation - returns the workspace data - const { data: workspace } = - await WorkspaceService($client).acceptInvitation(inv.id) + const { data: workspace } = await WorkspaceService( + $client + ).acceptInvitation(inv.id) // Clear workspace loaded state so it gets refetched on next page store.commit('workspace/SET_LOADED', false) diff --git a/web-frontend/modules/core/store/auth.js b/web-frontend/modules/core/store/auth.js index b1ae0f7861..53ed45012e 100644 --- a/web-frontend/modules/core/store/auth.js +++ b/web-frontend/modules/core/store/auth.js @@ -140,10 +140,7 @@ export const actions = { * Authenticate a user by his email and password. */ async login({ getters, dispatch }, { email, password }) { - const { data } = await AuthService(this.$client).login( - email, - password - ) + const { data } = await AuthService(this.$client).login(email, password) return dispatch('loginWithData', { data }) }, /** diff --git a/web-frontend/package.json b/web-frontend/package.json index d55e68ad1c..d389b94df3 100644 --- a/web-frontend/package.json +++ b/web-frontend/package.json @@ -19,7 +19,8 @@ "test:enterprise": "TZ=UTC NODE_OPTIONS=\"--max-old-space-size=8192\" vitest $EXTRA_VITEST_PARAMS --config ../enterprise/web-frontend/vitest.config.ts", "test:enterprise:coverage": "TZ=UTC NODE_OPTIONS=\"--max-old-space-size=8192\" vitest $EXTRA_VITEST_PARAMS --config ../enterprise/web-frontend/vitest.config.ts --coverage", "postinstall": "nuxt prepare", - "lint": "yarn eslint && yarn stylelint", + "lint": "yarn eslint && yarn stylelint && yarn prettier:check", + "prettier:check": "prettier --check . ../premium/web-frontend ../enterprise/web-frontend", "eslint": "yarn postinstall && yarn eslint:core && yarn eslint:premium && yarn eslint:enterprise", "stylelint": "stylelint --cache --cache-location=.cache/stylelint **/*.scss ../premium/web-frontend/modules/**/*.scss ../enterprise/web-frontend/modules/**/*.scss", "eslint:fix": "yarn eslint:core --fix && yarn eslint:premium --fix && yarn eslint:enterprise --fix", diff --git a/web-frontend/yarn.lock b/web-frontend/yarn.lock index 2ef2cea919..66079dd311 100644 --- a/web-frontend/yarn.lock +++ b/web-frontend/yarn.lock @@ -9744,16 +9744,7 @@ string-argv@~0.3.1: resolved "https://registry.yarnpkg.com/string-argv/-/string-argv-0.3.2.tgz#2b6d0ef24b656274d957d54e0a4bbf6153dc02b6" integrity sha512-aqD2Q0144Z+/RqG52NeHEkZauTAUWJO8c6yTftGJKO3Tja5tUgIfmIl6kExvhtxSDP7fXB6DvzkfMpCd/F3G+Q== -"string-width-cjs@npm:string-width@^4.2.0": - version "4.2.3" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" - integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== - dependencies: - emoji-regex "^8.0.0" - is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.1" - -string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: +"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: version "4.2.3" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== @@ -9785,14 +9776,7 @@ string_decoder@~1.1.1: dependencies: safe-buffer "~5.1.0" -"strip-ansi-cjs@npm:strip-ansi@^6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" - integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== - dependencies: - ansi-regex "^5.0.1" - -strip-ansi@^6.0.0, strip-ansi@^6.0.1: +"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== @@ -10986,16 +10970,7 @@ word-wrap@^1.2.5: resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.5.tgz#d2c45c6dd4fbce621a66f136cbe328afd0410b34" integrity sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA== -"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" - integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== - dependencies: - ansi-styles "^4.0.0" - string-width "^4.1.0" - strip-ansi "^6.0.0" - -wrap-ansi@^7.0.0: +"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==