Enforce using example.com as a domain for emails.
This commit is contained in:
parent
7837eb4ffd
commit
686697e890
|
@ -44,7 +44,8 @@
|
|||
"no-undef": "off",
|
||||
"no-prototype-builtins": "off",
|
||||
"local-rules/no-budibase-imports": "error",
|
||||
"local-rules/no-test-com": "error"
|
||||
"local-rules/no-test-com": "error",
|
||||
"local-rules/email-domain-example-com": "error"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -51,4 +51,41 @@ module.exports = {
|
|||
}
|
||||
},
|
||||
},
|
||||
"email-domain-example-com": {
|
||||
meta: {
|
||||
type: "problem",
|
||||
docs: {
|
||||
description:
|
||||
"enforce using the example.com domain for generator.email calls",
|
||||
category: "Possible Errors",
|
||||
recommended: false,
|
||||
},
|
||||
fixable: "code",
|
||||
schema: [],
|
||||
},
|
||||
create: function (context) {
|
||||
return {
|
||||
CallExpression(node) {
|
||||
if (
|
||||
node.callee.type === "MemberExpression" &&
|
||||
node.callee.object.name === "generator" &&
|
||||
node.callee.property.name === "email" &&
|
||||
node.arguments.length === 0
|
||||
) {
|
||||
context.report({
|
||||
node,
|
||||
message:
|
||||
"Prefer using generator.email with the domain \"{ domain: 'example.com' }\".",
|
||||
fix: function (fixer) {
|
||||
return fixer.replaceText(
|
||||
node,
|
||||
'generator.email({ domain: "example.com" })'
|
||||
)
|
||||
},
|
||||
})
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ export const account = (partial: Partial<Account> = {}): Account => {
|
|||
return {
|
||||
accountId: uuid(),
|
||||
tenantId: generator.word(),
|
||||
email: generator.email(),
|
||||
email: generator.email({ domain: "example.com" }),
|
||||
tenantName: generator.word(),
|
||||
hosting: Hosting.SELF,
|
||||
createdAt: Date.now(),
|
||||
|
|
|
@ -13,7 +13,7 @@ interface CreateUserRequestFields {
|
|||
export function createUserRequest(userData?: Partial<CreateUserRequestFields>) {
|
||||
const defaultValues = {
|
||||
externalId: uuid(),
|
||||
email: generator.email(),
|
||||
email: generator.email({ domain: "example.com" }),
|
||||
firstName: generator.first(),
|
||||
lastName: generator.last(),
|
||||
username: generator.name(),
|
||||
|
|
|
@ -301,7 +301,7 @@ export default class TestConfiguration {
|
|||
lastName = generator.last(),
|
||||
builder = true,
|
||||
admin = false,
|
||||
email = generator.email(),
|
||||
email = generator.email({ domain: "example.com" }),
|
||||
roles,
|
||||
} = config
|
||||
|
||||
|
@ -357,7 +357,7 @@ export default class TestConfiguration {
|
|||
id,
|
||||
firstName = generator.first(),
|
||||
lastName = generator.last(),
|
||||
email = generator.email(),
|
||||
email = generator.email({ domain: "example.com" }),
|
||||
builder = true,
|
||||
admin,
|
||||
roles,
|
||||
|
@ -485,7 +485,7 @@ export default class TestConfiguration {
|
|||
|
||||
async basicRoleHeaders() {
|
||||
return await this.roleHeaders({
|
||||
email: generator.email(),
|
||||
email: generator.email({ domain: "example.com" }),
|
||||
builder: false,
|
||||
prodApp: true,
|
||||
roleId: roles.BUILTIN_ROLE_IDS.BASIC,
|
||||
|
@ -493,7 +493,7 @@ export default class TestConfiguration {
|
|||
}
|
||||
|
||||
async roleHeaders({
|
||||
email = generator.email(),
|
||||
email = generator.email({ domain: "example.com" }),
|
||||
roleId = roles.BUILTIN_ROLE_IDS.ADMIN,
|
||||
builder = false,
|
||||
prodApp = true,
|
||||
|
|
|
@ -147,7 +147,7 @@ describe("/api/global/groups", () => {
|
|||
|
||||
await Promise.all(
|
||||
Array.from({ length: 30 }).map(async (_, i) => {
|
||||
const email = `user${i}@${generator.domain()}`
|
||||
const email = `user${i}@example.com`
|
||||
const user = await config.api.users.saveUser({
|
||||
...structures.users.user(),
|
||||
email,
|
||||
|
|
|
@ -84,7 +84,7 @@ describe("Accounts", () => {
|
|||
})
|
||||
|
||||
it("searches by email", async () => {
|
||||
const email = generator.email()
|
||||
const email = generator.email({ domain: "example.com" })
|
||||
|
||||
// Empty result
|
||||
const [_, emptyBody] = await config.api.accounts.search(email, "email")
|
||||
|
|
|
@ -4,7 +4,7 @@ import { generator } from "../../shared"
|
|||
export const generateUser = (
|
||||
overrides: Partial<User> = {}
|
||||
): CreateUserParams => ({
|
||||
email: generator.email(),
|
||||
email: generator.email({ domain: "example.com" }),
|
||||
roles: {
|
||||
[generator.string({ length: 32, alpha: true, numeric: true })]:
|
||||
generator.word(),
|
||||
|
|
Loading…
Reference in New Issue