1
0
Fork 0
mirror of synced 2024-09-20 19:33:10 +12:00

Merge branch 'master' of github.com:Budibase/budibase into feature-flag-sqs

This commit is contained in:
Sam Rose 2024-08-15 16:27:57 +01:00
commit 008ef58bf8
No known key found for this signature in database
5 changed files with 57 additions and 6 deletions

View file

@ -43,6 +43,7 @@
}, },
"rules": { "rules": {
"no-unused-vars": "off", "no-unused-vars": "off",
"local-rules/no-barrel-imports": "error",
"local-rules/no-budibase-imports": "error", "local-rules/no-budibase-imports": "error",
"local-rules/no-console-error": "error", "local-rules/no-console-error": "error",
"@typescript-eslint/no-unused-vars": [ "@typescript-eslint/no-unused-vars": [

View file

@ -1,3 +1,14 @@
const path = require("path")
const makeBarrelPath = finalPath => {
return path.resolve(__dirname, "..", finalPath)
}
const backendCoreBarrelPaths = [
makeBarrelPath(path.join("packages", "backend-core", "src", "index.ts")),
makeBarrelPath(path.join("packages", "backend-core", "src")),
makeBarrelPath(path.join("packages", "backend-core")),
]
module.exports = { module.exports = {
"no-console-error": { "no-console-error": {
create: function (context) { create: function (context) {
@ -13,11 +24,12 @@ module.exports = {
) { ) {
context.report({ context.report({
node, node,
message: 'Using console.error(err) on its own is not allowed. Either provide context to the error (console.error(msg, err)) or throw it.', message:
"Using console.error(err) on its own is not allowed. Either provide context to the error (console.error(msg, err)) or throw it.",
}) })
} }
}, },
}; }
}, },
}, },
"no-budibase-imports": { "no-budibase-imports": {
@ -106,4 +118,42 @@ module.exports = {
} }
}, },
}, },
"no-barrel-imports": {
meta: {
type: "problem",
docs: {
description:
"Disallow imports from the top-level backend-core barrel file",
category: "Best Practices",
recommended: false,
},
schema: [], // no options
messages: {
noBarrelImport:
"Avoid importing from the top-level barrel file 'backend-core/src/index.ts'. Import directly from the specific module instead.",
},
},
create(context) {
return {
ImportDeclaration(node) {
const importPath = node.source.value
const importFullPath = path.resolve(
context.getFilename(),
"..",
importPath
)
if (backendCoreBarrelPaths.includes(importFullPath)) {
context.report({
node,
messageId: "noBarrelImport",
data: {
importFullPath,
},
})
}
},
}
},
},
} }

View file

@ -2,7 +2,7 @@ import { testEnv } from "../../../tests/extra"
import * as context from "../" import * as context from "../"
import { DEFAULT_TENANT_ID } from "../../constants" import { DEFAULT_TENANT_ID } from "../../constants"
import { structures } from "../../../tests" import { structures } from "../../../tests"
import { db } from "../.." import * as db from "../../db"
import Context from "../Context" import Context from "../Context"
import { ContextMap } from "../types" import { ContextMap } from "../types"
import { IdentityType } from "@budibase/types" import { IdentityType } from "@budibase/types"

View file

@ -1,6 +1,6 @@
import { IdentityContext, IdentityType, UserCtx } from "@budibase/types" import { IdentityContext, IdentityType, UserCtx } from "@budibase/types"
import { Flag, FlagSet, FlagValues, init, shutdown } from "../" import { Flag, FlagSet, FlagValues, init, shutdown } from "../"
import { context } from "../.." import * as context from "../../context"
import environment, { withEnv } from "../../environment" import environment, { withEnv } from "../../environment"
import nodeFetch from "node-fetch" import nodeFetch from "node-fetch"
import nock from "nock" import nock from "nock"

View file

@ -1,7 +1,7 @@
import { GenericContainer, StartedTestContainer } from "testcontainers" import { GenericContainer, StartedTestContainer } from "testcontainers"
import { generator, structures } from "../../../tests" import { generator, structures } from "../../../tests"
import RedisWrapper, { closeAll } from "../redis" import RedisWrapper, { closeAll } from "../redis"
import { env } from "../.." import env from "../../environment"
import { randomUUID } from "crypto" import { randomUUID } from "crypto"
jest.setTimeout(30000) jest.setTimeout(30000)