Merge pull request #13301 from Budibase/reenable-no-undef

Reenable `no-undef`
This commit is contained in:
Sam Rose 2024-03-20 11:07:23 +00:00 committed by GitHub
commit 6d286fcca2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 47 additions and 23 deletions

View File

@ -37,9 +37,11 @@
"excludedFiles": ["qa-core/**"], "excludedFiles": ["qa-core/**"],
"parser": "@typescript-eslint/parser", "parser": "@typescript-eslint/parser",
"extends": ["eslint:recommended"], "extends": ["eslint:recommended"],
"globals": {
"NodeJS": true
},
"rules": { "rules": {
"no-unused-vars": "off", "no-unused-vars": "off",
"no-undef": "off",
"no-prototype-builtins": "off", "no-prototype-builtins": "off",
"local-rules/no-budibase-imports": "error" "local-rules/no-budibase-imports": "error"
} }
@ -53,9 +55,11 @@
"env": { "env": {
"jest/globals": true "jest/globals": true
}, },
"globals": {
"NodeJS": true
},
"rules": { "rules": {
"no-unused-vars": "off", "no-unused-vars": "off",
"no-undef": "off",
"no-prototype-builtins": "off", "no-prototype-builtins": "off",
"local-rules/no-test-com": "error", "local-rules/no-test-com": "error",
"local-rules/email-domain-example-com": "error", "local-rules/email-domain-example-com": "error",

View File

@ -34,12 +34,12 @@ export async function createUserIndex() {
} }
let idxKey = prev != null ? `${prev}.${key}` : key let idxKey = prev != null ? `${prev}.${key}` : key
if (typeof input[key] === "string") { if (typeof input[key] === "string") {
// @ts-expect-error index is available in a CouchDB map function
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
// @ts-ignore
index(idxKey, input[key].toLowerCase(), { facet: true }) index(idxKey, input[key].toLowerCase(), { facet: true })
} else if (typeof input[key] !== "object") { } else if (typeof input[key] !== "object") {
// @ts-expect-error index is available in a CouchDB map function
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
// @ts-ignore
index(idxKey, input[key], { facet: true }) index(idxKey, input[key], { facet: true })
} else { } else {
idx(input[key], idxKey) idx(input[key], idxKey)

View File

@ -39,7 +39,7 @@ class InMemoryQueue implements Partial<Queue> {
_opts?: QueueOptions _opts?: QueueOptions
_messages: JobMessage[] _messages: JobMessage[]
_queuedJobIds: Set<string> _queuedJobIds: Set<string>
_emitter: EventEmitter _emitter: NodeJS.EventEmitter
_runCount: number _runCount: number
_addCount: number _addCount: number

View File

@ -30,8 +30,8 @@ export async function createLinkView() {
if (doc.type === "link") { if (doc.type === "link") {
let doc1 = doc.doc1 let doc1 = doc.doc1
let doc2 = doc.doc2 let doc2 = doc.doc2
// @ts-expect-error emit is available in a CouchDB map function
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
// @ts-ignore
emit([doc1.tableId, doc1.rowId], { emit([doc1.tableId, doc1.rowId], {
id: doc2.rowId, id: doc2.rowId,
thisId: doc1.rowId, thisId: doc1.rowId,
@ -39,8 +39,8 @@ export async function createLinkView() {
}) })
// if linking to same table can't emit twice // if linking to same table can't emit twice
if (doc1.tableId !== doc2.tableId) { if (doc1.tableId !== doc2.tableId) {
// @ts-expect-error emit is available in a CouchDB map function
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
// @ts-ignore
emit([doc2.tableId, doc2.rowId], { emit([doc2.tableId, doc2.rowId], {
id: doc1.rowId, id: doc1.rowId,
thisId: doc2.rowId, thisId: doc2.rowId,
@ -101,8 +101,8 @@ export async function createAllSearchIndex() {
if (Array.isArray(input[key])) { if (Array.isArray(input[key])) {
for (let val of input[key]) { for (let val of input[key]) {
if (typeof val !== "object") { if (typeof val !== "object") {
// @ts-expect-error index is available in a CouchDB map function
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
// @ts-ignore
index(idxKey, val, { store: true }) index(idxKey, val, { store: true })
} }
} }
@ -110,12 +110,12 @@ export async function createAllSearchIndex() {
continue continue
} }
if (typeof input[key] === "string") { if (typeof input[key] === "string") {
// @ts-expect-error index is available in a CouchDB map function
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
// @ts-ignore
index(idxKey, input[key].toLowerCase(), { store: true }) index(idxKey, input[key].toLowerCase(), { store: true })
} else if (typeof input[key] !== "object") { } else if (typeof input[key] !== "object") {
// @ts-expect-error index is available in a CouchDB map function
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
// @ts-ignore
index(idxKey, input[key], { store: true }) index(idxKey, input[key], { store: true })
} else { } else {
idx(input[key], idxKey) idx(input[key], idxKey)
@ -123,8 +123,8 @@ export async function createAllSearchIndex() {
} }
} }
if (doc._id!.startsWith("ro_")) { if (doc._id!.startsWith("ro_")) {
// @ts-expect-error index is available in a CouchDB map function
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
// @ts-ignore
index("default", doc._id) index("default", doc._id)
idx(doc) idx(doc)
} }

View File

@ -12,12 +12,15 @@ export default new Proxy(
// See https://esbuild.github.io/content-types/#direct-eval for info on // See https://esbuild.github.io/content-types/#direct-eval for info on
// why eval is being called this way. // why eval is being called this way.
// Snippets are cached and reused once they have been evaluated. // Snippets are cached and reused once they have been evaluated.
// @ts-ignore // @ts-expect-error snippetDefinitions and snippetCache are injected to the global scope
// eslint-disable-next-line no-undef
if (!(name in snippetCache)) { if (!(name in snippetCache)) {
// @ts-ignore // @ts-expect-error snippetDefinitions and snippetCache are injected to the global scope
// eslint-disable-next-line no-undef
snippetCache[name] = [eval][0](iifeWrapper(snippetDefinitions[name])) snippetCache[name] = [eval][0](iifeWrapper(snippetDefinitions[name]))
} }
// @ts-ignore // @ts-expect-error snippetDefinitions and snippetCache are injected to the global scope
// eslint-disable-next-line no-undef
return snippetCache[name] return snippetCache[name]
}, },
} }

View File

@ -170,7 +170,8 @@ export class IsolatedVM implements VM {
} }
decode(...input: any) { decode(...input: any) {
// @ts-ignore // @ts-expect-error - this is going to run in the isolate, where this function will be available
// eslint-disable-next-line no-undef
return textDecoderCb({ return textDecoderCb({
constructorArgs: this.constructorArgs, constructorArgs: this.constructorArgs,
functionArgs: input, functionArgs: input,

View File

@ -28,7 +28,7 @@
"dependencies": { "dependencies": {
"@budibase/handlebars-helpers": "^0.13.1", "@budibase/handlebars-helpers": "^0.13.1",
"dayjs": "^1.10.8", "dayjs": "^1.10.8",
"handlebars": "^4.7.6", "handlebars": "^4.7.8",
"lodash.clonedeep": "^4.5.0" "lodash.clonedeep": "^4.5.0"
}, },
"devDependencies": { "devDependencies": {

View File

@ -1,3 +1,5 @@
import Handlebars from "handlebars"
export default class Helper { export default class Helper {
private name: any private name: any
private fn: any private fn: any

View File

@ -3,6 +3,7 @@ import helpers from "@budibase/handlebars-helpers"
import { date, duration } from "./date" import { date, duration } from "./date"
import { HelperFunctionBuiltin } from "./constants" import { HelperFunctionBuiltin } from "./constants"
import Handlebars from "handlebars"
/** /**
* full list of supported helpers can be found here: * full list of supported helpers can be found here:

View File

@ -1,5 +1,5 @@
import Helper from "./Helper" import Helper from "./Helper"
import { SafeString } from "handlebars" import Handlebars from "handlebars"
import * as externalHandlebars from "./external" import * as externalHandlebars from "./external"
import { processJS } from "./javascript" import { processJS } from "./javascript"
import { import {
@ -28,7 +28,7 @@ function isObject(value: string | any[]) {
const HELPERS = [ const HELPERS = [
// external helpers // external helpers
new Helper(HelperFunctionNames.OBJECT, (value: any) => { new Helper(HelperFunctionNames.OBJECT, (value: any) => {
return new SafeString(JSON.stringify(value)) return new Handlebars.SafeString(JSON.stringify(value))
}), }),
// javascript helper // javascript helper
new Helper(HelperFunctionNames.JS, processJS, false), new Helper(HelperFunctionNames.JS, processJS, false),
@ -38,7 +38,7 @@ const HELPERS = [
(value: string, inputs: { __opts: any }) => { (value: string, inputs: { __opts: any }) => {
const { __opts } = inputs const { __opts } = inputs
if (isObject(value)) { if (isObject(value)) {
return new SafeString(JSON.stringify(value)) return new Handlebars.SafeString(JSON.stringify(value))
} }
// null/undefined values produce bad results // null/undefined values produce bad results
if (__opts && __opts.onlyFound && value == null) { if (__opts && __opts.onlyFound && value == null) {
@ -55,7 +55,7 @@ const HELPERS = [
if (__opts && __opts.escapeNewlines) { if (__opts && __opts.escapeNewlines) {
text = value.replace(/\n/g, "\\n") text = value.replace(/\n/g, "\\n")
} }
text = new SafeString(text.replace(/&amp;/g, "&")) text = new Handlebars.SafeString(text.replace(/&amp;/g, "&"))
if (text == null || typeof text !== "string") { if (text == null || typeof text !== "string") {
return text return text
} }

View File

@ -1,5 +1,5 @@
import { Context, createContext, runInNewContext } from "vm" import { Context, createContext, runInNewContext } from "vm"
import { create } from "handlebars" import { create, TemplateDelegate } from "handlebars"
import { registerAll, registerMinimum } from "./helpers/index" import { registerAll, registerMinimum } from "./helpers/index"
import { preprocess, postprocess } from "./processors" import { preprocess, postprocess } from "./processors"
import { import {
@ -47,7 +47,7 @@ function testObject(object: any) {
/** /**
* Creates a HBS template function for a given string, and optionally caches it. * Creates a HBS template function for a given string, and optionally caches it.
*/ */
const templateCache: Record<string, HandlebarsTemplateDelegate<any>> = {} const templateCache: Record<string, TemplateDelegate<any>> = {}
function createTemplate(string: string, opts?: ProcessOptions) { function createTemplate(string: string, opts?: ProcessOptions) {
opts = { ...defaultOpts, ...opts } opts = { ...defaultOpts, ...opts }

View File

@ -7,6 +7,7 @@ import {
ViewTemplateOpts, ViewTemplateOpts,
} from "../" } from "../"
import { Writable } from "stream" import { Writable } from "stream"
import PouchDB from "pouchdb-find"
export enum SearchIndex { export enum SearchIndex {
ROWS = "rows", ROWS = "rows",

View File

@ -12046,7 +12046,7 @@ handlebars-utils@^1.0.6:
kind-of "^6.0.0" kind-of "^6.0.0"
typeof-article "^0.1.1" typeof-article "^0.1.1"
handlebars@^4.7.6, handlebars@^4.7.7: handlebars@^4.7.7:
version "4.7.7" version "4.7.7"
resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.7.7.tgz#9ce33416aad02dbd6c8fafa8240d5d98004945a1" resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.7.7.tgz#9ce33416aad02dbd6c8fafa8240d5d98004945a1"
integrity sha512-aAcXm5OAfE/8IXkcZvCepKU3VzW1/39Fb5ZuqMtgI/hT8X2YgoMvBY5dLhq/cpOvw7Lk1nK/UF71aLG/ZnVYRA== integrity sha512-aAcXm5OAfE/8IXkcZvCepKU3VzW1/39Fb5ZuqMtgI/hT8X2YgoMvBY5dLhq/cpOvw7Lk1nK/UF71aLG/ZnVYRA==
@ -12058,6 +12058,18 @@ handlebars@^4.7.6, handlebars@^4.7.7:
optionalDependencies: optionalDependencies:
uglify-js "^3.1.4" uglify-js "^3.1.4"
handlebars@^4.7.8:
version "4.7.8"
resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.7.8.tgz#41c42c18b1be2365439188c77c6afae71c0cd9e9"
integrity sha512-vafaFqs8MZkRrSX7sFVUdo3ap/eNiLnb4IakshzvP56X5Nr1iGKAIqdX6tMlm6HcNRIkr6AxO5jFEoJzzpT8aQ==
dependencies:
minimist "^1.2.5"
neo-async "^2.6.2"
source-map "^0.6.1"
wordwrap "^1.0.0"
optionalDependencies:
uglify-js "^3.1.4"
har-schema@^2.0.0: har-schema@^2.0.0:
version "2.0.0" version "2.0.0"
resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-2.0.0.tgz#a94c2224ebcac04782a0d9035521f24735b7ec92" resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-2.0.0.tgz#a94c2224ebcac04782a0d9035521f24735b7ec92"