chore: Fix various lint warnings (#9362)

* Fix various linting errors

This commit addresses several linting warnings reported by ESLint:

- @typescript-eslint/no-shadow:
  - I renamed variables in inner scopes to avoid conflicts with variables in outer scopes in the following files:
    - server/commands/accountProvisioner.ts
    - server/commands/documentDuplicator.ts
    - server/commands/documentMover.ts
    - server/commands/teamProvisioner.test.ts
    - server/commands/teamProvisioner.ts
    - server/commands/userInviter.ts
    - server/commands/userProvisioner.ts
    - server/emails/templates/BaseEmail.tsx
- @typescript-eslint/no-explicit-any:
  - I replaced `any` with more specific types (Record<string, unknown> or void) in the following files:
    - server/emails/templates/BaseEmail.tsx
    - server/emails/templates/InviteEmail.tsx
    - server/emails/templates/SigninEmail.tsx
    - server/logging/Logger.ts

These changes improve code clarity and type safety without altering functionality.

* Update BaseEmail.tsx

* lint

---------

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
This commit is contained in:
Tom Moor
2025-06-01 10:59:55 -04:00
committed by GitHub
parent d73d0523f4
commit 1836d2ef63
11 changed files with 25 additions and 22 deletions
+4 -4
View File
@@ -101,7 +101,7 @@ async function accountProvisioner({
// The account could not be provisioned for the provided teamId
// check to see if we can try authentication using email matching only
if (err.id === "invalid_authentication") {
const authenticationProvider = await AuthenticationProvider.findOne({
const authProvider = await AuthenticationProvider.findOne({
where: {
name: authenticationProviderParams.name,
teamId: teamParams.teamId,
@@ -116,11 +116,11 @@ async function accountProvisioner({
order: [["enabled", "DESC"]],
});
if (authenticationProvider) {
if (authProvider) {
emailMatchOnly = true;
result = {
authenticationProvider,
team: authenticationProvider.team,
authenticationProvider: authProvider,
team: authProvider.team,
isNewTeam: false,
};
}
+2 -2
View File
@@ -60,7 +60,7 @@ export default async function documentDuplicator({
async function duplicateChildDocuments(
original: Document,
duplicated: Document
duplicatedDocument: Document
) {
const childDocuments = await original.findChildDocuments(
{
@@ -77,7 +77,7 @@ export default async function documentDuplicator({
for (const childDocument of childDocuments) {
const duplicatedChildDocument = await documentCreator({
parentDocumentId: duplicated.id,
parentDocumentId: duplicatedDocument.id,
icon: childDocument.icon,
color: childDocument.color,
title: childDocument.title,
+3 -3
View File
@@ -193,11 +193,11 @@ async function documentMover({
document.collection = newCollection;
result.documents.push(
...documents.map((document) => {
...documents.map((doc) => {
if (newCollection) {
document.collection = newCollection;
doc.collection = newCollection;
}
return document;
return doc;
})
);
+3 -3
View File
@@ -110,14 +110,14 @@ describe("teamProvisioner", () => {
let error;
try {
const subdomain = faker.internet.domainWord();
const testSubdomain = faker.internet.domainWord();
await teamProvisioner({
teamId: exampleTeam.id,
name: "name",
subdomain,
subdomain: testSubdomain,
authenticationProvider: {
name: "google",
providerId: `${subdomain}.com`,
providerId: `${testSubdomain}.com`,
},
ip,
});
+4 -4
View File
@@ -83,7 +83,7 @@ async function teamProvisioner({
}
// This team + auth provider combination has not been seen before in self hosted
const team = await Team.findByPk(teamId, {
const existingTeam = await Team.findByPk(teamId, {
rejectOnEmpty: true,
});
@@ -91,14 +91,14 @@ async function teamProvisioner({
// new team is allowed then assign the authentication provider to the
// existing team
if (domain) {
if (await team.isDomainAllowed(domain)) {
authP = await team.$create<AuthenticationProvider>(
if (await existingTeam.isDomainAllowed(domain)) {
authP = await existingTeam.$create<AuthenticationProvider>(
"authenticationProvider",
authenticationProvider
);
return {
authenticationProvider: authP,
team,
team: existingTeam,
isNewTeam: false,
};
}
+3 -1
View File
@@ -46,7 +46,9 @@ export default async function userInviter({
email: emails,
},
});
const existingEmails = existingUsers.map((user) => user.email);
const existingEmails = existingUsers.map(
(existingUser) => existingUser.email
);
const filteredInvites = normalizedInvites.filter(
(invite) => !existingEmails.includes(invite.email)
);
+2 -2
View File
@@ -136,7 +136,7 @@ export default async function userProvisioner({
// that's never been active before.
const isInvite = existingUser.isInvited;
const auth = await sequelize.transaction(async (transaction) => {
const userAuth = await sequelize.transaction(async (transaction) => {
if (isInvite) {
await Event.create(
{
@@ -198,7 +198,7 @@ export default async function userProvisioner({
return {
user: existingUser,
authentication: auth,
authentication: userAuth,
isNewUser: isInvite,
};
} else if (!authentication && !team?.allowedDomains.length) {
+1 -1
View File
@@ -35,7 +35,7 @@ export interface EmailProps {
export default abstract class BaseEmail<
T extends EmailProps,
S extends Record<string, any> | void = void
S extends Record<string, unknown> | void = void
> {
private props: T;
private metadata?: NotificationMetadata;
+1 -1
View File
@@ -21,7 +21,7 @@ type Props = EmailProps & {
/**
* Email sent to an external user when an admin sends them an invite.
*/
export default class InviteEmail extends BaseEmail<Props, Record<string, any>> {
export default class InviteEmail extends BaseEmail<Props, void> {
protected get category() {
return EmailMessageCategory.Invitation;
}
+1 -1
View File
@@ -20,7 +20,7 @@ type Props = EmailProps & {
/**
* Email sent to a user when they request a magic sign-in link.
*/
export default class SigninEmail extends BaseEmail<Props, Record<string, any>> {
export default class SigninEmail extends BaseEmail<Props, void> {
protected get category() {
return EmailMessageCategory.Authentication;
}
+1
View File
@@ -26,6 +26,7 @@ type LogCategory =
| "database"
| "utils"
| "plugins";
type Extra = Record<string, any>;
class Logger {