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": {
"no-unused-vars": "off",
"local-rules/no-barrel-imports": "error",
"local-rules/no-budibase-imports": "error",
"local-rules/no-console-error": "error",
"@typescript-eslint/no-unused-vars": [

View File

@ -1,6 +1,17 @@
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 = {
"no-console-error": {
create: function(context) {
create: function (context) {
return {
CallExpression(node) {
if (
@ -13,11 +24,12 @@ module.exports = {
) {
context.report({
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": {
@ -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 { DEFAULT_TENANT_ID } from "../../constants"
import { structures } from "../../../tests"
import { db } from "../.."
import * as db from "../../db"
import Context from "../Context"
import { ContextMap } from "../types"
import { IdentityType } from "@budibase/types"

View File

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

View File

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