From 18fd079c64f217cc4dfbceefcad88c7627db1668 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Thu, 21 Jan 2021 16:44:03 +0000 Subject: [PATCH 1/6] Attempting to polyfill for browser --- packages/string-templates/package.json | 3 ++ packages/string-templates/rollup.config.js | 11 +++++- packages/string-templates/yarn.lock | 46 +++++++++++++++++++++- 3 files changed, 56 insertions(+), 4 deletions(-) diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json index d84901a2d6..31159bd87a 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -14,15 +14,18 @@ "dependencies": { "handlebars": "^4.7.6", "handlebars-helpers": "^0.10.0", + "handlebars-utils": "^1.0.6", "helper-date": "^1.0.1", "lodash": "^4.17.20" }, "devDependencies": { + "@rollup/plugin-json": "^4.1.0", "jest": "^26.6.3", "rollup": "^2.36.2", "rollup-plugin-commonjs": "^10.1.0", "rollup-plugin-node-builtins": "^2.1.2", "rollup-plugin-node-globals": "^1.4.0", + "rollup-plugin-node-polyfills": "^0.2.1", "rollup-plugin-node-resolve": "^5.2.0", "typescript": "^4.1.3" } diff --git a/packages/string-templates/rollup.config.js b/packages/string-templates/rollup.config.js index f4cf851f92..75a9c1ada9 100644 --- a/packages/string-templates/rollup.config.js +++ b/packages/string-templates/rollup.config.js @@ -1,7 +1,9 @@ import commonjs from "rollup-plugin-commonjs" -import nodeResolve from "rollup-plugin-node-resolve" import globals from "rollup-plugin-node-globals" import builtins from "rollup-plugin-node-builtins" +import polyfills from "rollup-plugin-node-polyfills" +import resolve from "rollup-plugin-node-resolve" +import json from "@rollup/plugin-json" export default { input: "src/index.js", @@ -14,11 +16,16 @@ export default { fs: "fs", }, }, + treeshake: true, external: ["fs"], plugins: [ - nodeResolve({ preferBuiltins: false }), + polyfills(), + resolve({ + preferBuiltins: false + }), commonjs(), globals(), builtins(), + json(), ], } diff --git a/packages/string-templates/yarn.lock b/packages/string-templates/yarn.lock index 73b8cb1537..a6700aaaed 100644 --- a/packages/string-templates/yarn.lock +++ b/packages/string-templates/yarn.lock @@ -465,6 +465,22 @@ "@types/yargs" "^15.0.0" chalk "^4.0.0" +"@rollup/plugin-json@^4.1.0": + version "4.1.0" + resolved "https://registry.yarnpkg.com/@rollup/plugin-json/-/plugin-json-4.1.0.tgz#54e09867ae6963c593844d8bd7a9c718294496f3" + integrity sha512-yfLbTdNS6amI/2OpmbiBoW12vngr5NW2jCJVZSBEz+H5KfUJZ2M7sDjk0U6GOOdCWFVScShte29o9NezJ53TPw== + dependencies: + "@rollup/pluginutils" "^3.0.8" + +"@rollup/pluginutils@^3.0.8": + version "3.1.0" + resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-3.1.0.tgz#706b4524ee6dc8b103b3c995533e5ad680c02b9b" + integrity sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg== + dependencies: + "@types/estree" "0.0.39" + estree-walker "^1.0.1" + picomatch "^2.2.2" + "@sinonjs/commons@^1.7.0": version "1.8.2" resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.8.2.tgz#858f5c4b48d80778fde4b9d541f27edc0d56488b" @@ -517,6 +533,11 @@ resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.46.tgz#0fb6bfbbeabd7a30880504993369c4bf1deab1fe" integrity sha512-laIjwTQaD+5DukBZaygQ79K1Z0jb1bPEMRrkXSLjtCcZm+abyp5YbrqpSLzD42FwWW6gK/aS4NYpJ804nG2brg== +"@types/estree@0.0.39": + version "0.0.39" + resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.39.tgz#e177e699ee1b8c22d23174caaa7422644389509f" + integrity sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw== + "@types/graceful-fs@^4.1.2": version "4.1.4" resolved "https://registry.yarnpkg.com/@types/graceful-fs/-/graceful-fs-4.1.4.tgz#4ff9f641a7c6d1a3508ff88bc3141b152772e753" @@ -1755,6 +1776,11 @@ estree-walker@^0.6.1: resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-0.6.1.tgz#53049143f40c6eb918b23671d1fe3219f3a1b362" integrity sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w== +estree-walker@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-1.0.1.tgz#31bc5d612c96b704106b477e6dd5d8aa138cb700" + integrity sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg== + esutils@^2.0.2: version "2.0.3" resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" @@ -3345,7 +3371,7 @@ magic-string@^0.22.5: dependencies: vlq "^0.2.2" -magic-string@^0.25.2: +magic-string@^0.25.2, magic-string@^0.25.3: version "0.25.7" resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.25.7.tgz#3f497d6fd34c669c6798dcb821f2ef31f5445051" integrity sha512-4CrMT5DOHTDk4HYDlzmwu4FVCcIYI8gauveasrdCu2IKIFOJ3f0v/8MDGJCDL9oD2ppz/Av1b0Nj345H9M+XIA== @@ -3758,7 +3784,7 @@ performance-now@^2.1.0: resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" integrity sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns= -picomatch@^2.0.4, picomatch@^2.0.5: +picomatch@^2.0.4, picomatch@^2.0.5, picomatch@^2.2.2: version "2.2.2" resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.2.tgz#21f333e9b6b8eaff02468f5146ea406d345f4dad" integrity sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg== @@ -4087,6 +4113,15 @@ rollup-plugin-commonjs@^10.1.0: resolve "^1.11.0" rollup-pluginutils "^2.8.1" +rollup-plugin-inject@^3.0.0: + version "3.0.2" + resolved "https://registry.yarnpkg.com/rollup-plugin-inject/-/rollup-plugin-inject-3.0.2.tgz#e4233855bfba6c0c12a312fd6649dff9a13ee9f4" + integrity sha512-ptg9PQwzs3orn4jkgXJ74bfs5vYz1NCZlSQMBUA0wKcGp5i5pA1AO3fOUEte8enhGUC+iapTCzEWw2jEFFUO/w== + dependencies: + estree-walker "^0.6.1" + magic-string "^0.25.3" + rollup-pluginutils "^2.8.1" + rollup-plugin-node-builtins@^2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/rollup-plugin-node-builtins/-/rollup-plugin-node-builtins-2.1.2.tgz#24a1fed4a43257b6b64371d8abc6ce1ab14597e9" @@ -4109,6 +4144,13 @@ rollup-plugin-node-globals@^1.4.0: process-es6 "^0.11.6" rollup-pluginutils "^2.3.1" +rollup-plugin-node-polyfills@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/rollup-plugin-node-polyfills/-/rollup-plugin-node-polyfills-0.2.1.tgz#53092a2744837164d5b8a28812ba5f3ff61109fd" + integrity sha512-4kCrKPTJ6sK4/gLL/U5QzVT8cxJcofO0OU74tnB19F40cmuAKSzH5/siithxlofFEjwvw1YAhPmbvGNA6jEroA== + dependencies: + rollup-plugin-inject "^3.0.0" + rollup-plugin-node-resolve@^5.2.0: version "5.2.0" resolved "https://registry.yarnpkg.com/rollup-plugin-node-resolve/-/rollup-plugin-node-resolve-5.2.0.tgz#730f93d10ed202473b1fb54a5997a7db8c6d8523" From 0e93c4b7f83b52ed6f91d6479451293b893c9427 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Thu, 21 Jan 2021 17:30:18 +0000 Subject: [PATCH 2/6] Updating build process to fix issues with polyfill. --- packages/string-templates/package.json | 1 - packages/string-templates/rollup.config.js | 29 +++++++++++----------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json index 31159bd87a..abc3efc51a 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -25,7 +25,6 @@ "rollup-plugin-commonjs": "^10.1.0", "rollup-plugin-node-builtins": "^2.1.2", "rollup-plugin-node-globals": "^1.4.0", - "rollup-plugin-node-polyfills": "^0.2.1", "rollup-plugin-node-resolve": "^5.2.0", "typescript": "^4.1.3" } diff --git a/packages/string-templates/rollup.config.js b/packages/string-templates/rollup.config.js index 75a9c1ada9..6ca34c5dfe 100644 --- a/packages/string-templates/rollup.config.js +++ b/packages/string-templates/rollup.config.js @@ -1,27 +1,26 @@ import commonjs from "rollup-plugin-commonjs" -import globals from "rollup-plugin-node-globals" -import builtins from "rollup-plugin-node-builtins" -import polyfills from "rollup-plugin-node-polyfills" import resolve from "rollup-plugin-node-resolve" +import builtins from "rollup-plugin-node-builtins" +import globals from "rollup-plugin-node-globals" import json from "@rollup/plugin-json" +const production = !process.env.ROLLUP_WATCH + export default { input: "src/index.js", - output: { - file: "dist/bundle.js", - format: "umd", - name: "string-templates", - exports: "named", - globals: { - fs: "fs", + output: [ + { + sourcemap: true, + format: "umd", + file: "./dist/bundle.js", + name: "string-templates", + exports: "named", }, - }, - treeshake: true, - external: ["fs"], + ], plugins: [ - polyfills(), resolve({ - preferBuiltins: false + preferBuiltins: true, + browser: true, }), commonjs(), globals(), From 1a87b2caafd4426fbae866cfe0c4590b6ab86962 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Thu, 21 Jan 2021 17:30:51 +0000 Subject: [PATCH 3/6] Linting. --- packages/string-templates/src/custom/preprocessor.js | 8 ++++++-- packages/string-templates/src/helpers/constants.js | 2 +- packages/string-templates/src/helpers/external.js | 10 ++++++---- packages/string-templates/src/helpers/index.js | 2 +- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/packages/string-templates/src/custom/preprocessor.js b/packages/string-templates/src/custom/preprocessor.js index 83f08cf9da..a86af5cd43 100644 --- a/packages/string-templates/src/custom/preprocessor.js +++ b/packages/string-templates/src/custom/preprocessor.js @@ -44,10 +44,14 @@ const PROCESSORS = [ // exclude helpers and brackets, regex will only find double brackets const exclusions = HelperNames() // find all the parts split by spaces - const splitBySpaces = statement.split(" ").filter(el => el !== "{{" && el !== "}}") + const splitBySpaces = statement + .split(" ") + .filter(el => el !== "{{" && el !== "}}") // remove braces if they are found and weren't spaced out splitBySpaces[0] = splitBySpaces[0].replace("{", "") - splitBySpaces[splitBySpaces.length - 1] = splitBySpaces[splitBySpaces.length - 1].replace("}", "") + splitBySpaces[splitBySpaces.length - 1] = splitBySpaces[ + splitBySpaces.length - 1 + ].replace("}", "") // remove the excluded elements const propertyParts = splitBySpaces.filter( part => exclusions.indexOf(part) === -1 diff --git a/packages/string-templates/src/helpers/constants.js b/packages/string-templates/src/helpers/constants.js index a2dccaea10..124ba6f277 100644 --- a/packages/string-templates/src/helpers/constants.js +++ b/packages/string-templates/src/helpers/constants.js @@ -12,7 +12,7 @@ module.exports.HelperFunctionBuiltin = [ "unless", "log", "lookup", - "with" + "with", ] module.exports.HelperFunctionNames = { diff --git a/packages/string-templates/src/helpers/external.js b/packages/string-templates/src/helpers/external.js index 840e40dbd7..9bad3a0eba 100644 --- a/packages/string-templates/src/helpers/external.js +++ b/packages/string-templates/src/helpers/external.js @@ -13,7 +13,7 @@ const EXTERNAL_FUNCTION_COLLECTIONS = [ "number", "url", "string", - "markdown" + "markdown", ] const DATE_NAME = "date" @@ -26,15 +26,17 @@ exports.registerAll = handlebars => { let hbsHelperInfo = helpers[collection]() for (let [name, func] of Object.entries(hbsHelperInfo)) { // skip built in functions and ones seen already - if (HelperFunctionBuiltin.indexOf(name) !== -1 || - externalNames.indexOf(name) !== -1) { + if ( + HelperFunctionBuiltin.indexOf(name) !== -1 || + externalNames.indexOf(name) !== -1 + ) { continue } externalNames.push(name) } // attach it to our handlebars instance helpers[collection]({ - handlebars + handlebars, }) } // add date external functionality diff --git a/packages/string-templates/src/helpers/index.js b/packages/string-templates/src/helpers/index.js index 0891d54c60..e5cf3c7a01 100644 --- a/packages/string-templates/src/helpers/index.js +++ b/packages/string-templates/src/helpers/index.js @@ -32,7 +32,7 @@ const HELPERS = [ module.exports.HelperNames = () => { return Object.values(HelperFunctionNames).concat( HelperFunctionBuiltin, - externalHandlebars.externalHelperNames, + externalHandlebars.externalHelperNames ) } From 5076c2f064bb14e351a253a063299304991d3edc Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Thu, 21 Jan 2021 17:56:00 +0000 Subject: [PATCH 4/6] Changing up how processors work to make it a bit easier to add to them. --- packages/string-templates/src/index.js | 6 ++-- .../string-templates/src/processors/index.js | 26 +++++++++++++++++ .../{custom => processors}/postprocessor.js | 4 +++ .../{custom => processors}/preprocessor.js | 29 +------------------ packages/string-templates/src/utilities.js | 4 +++ 5 files changed, 38 insertions(+), 31 deletions(-) create mode 100644 packages/string-templates/src/processors/index.js rename packages/string-templates/src/{custom => processors}/postprocessor.js (52%) rename packages/string-templates/src/{custom => processors}/preprocessor.js (68%) diff --git a/packages/string-templates/src/index.js b/packages/string-templates/src/index.js index c54d3b9429..2636752488 100644 --- a/packages/string-templates/src/index.js +++ b/packages/string-templates/src/index.js @@ -1,6 +1,6 @@ const handlebars = require("handlebars") const { registerAll } = require("./helpers/index") -const { preprocess } = require("./custom/preprocessor") +const processors = require("./processors") const { cloneDeep } = require("lodash/fp") const { removeNull } = require("./utilities") @@ -88,10 +88,10 @@ module.exports.processStringSync = (string, context) => { throw "Cannot process non-string types." } let template - string = preprocess(string) + string = processors.preprocess(string) // this does not throw an error when template can't be fulfilled, have to try correct beforehand template = hbsInstance.compile(string) - return template(clonedContext) + return processors.postprocess(template(clonedContext)) } /** diff --git a/packages/string-templates/src/processors/index.js b/packages/string-templates/src/processors/index.js new file mode 100644 index 0000000000..d781de53ad --- /dev/null +++ b/packages/string-templates/src/processors/index.js @@ -0,0 +1,26 @@ +const { FIND_HBS_REGEX } = require("../utilities") +const preprocessor = require("./preprocessor") +const postprocessor = require("./postprocessor") + +function process(string, processors) { + for (let processor of processors) { + // re-run search each time incase previous processor updated/removed a match + let regex = new RegExp(FIND_HBS_REGEX) + let matches = string.match(regex) + if (matches == null) { + continue + } + for (let match of matches) { + string = processor.process(string, match) + } + } + return string +} + +module.exports.preprocess = string => { + return process(string, preprocessor.processors) +} + +module.exports.postprocess = string => { + return process(string, postprocessor.processors) +} \ No newline at end of file diff --git a/packages/string-templates/src/custom/postprocessor.js b/packages/string-templates/src/processors/postprocessor.js similarity index 52% rename from packages/string-templates/src/custom/postprocessor.js rename to packages/string-templates/src/processors/postprocessor.js index 4dad27ab98..76a962c52f 100644 --- a/packages/string-templates/src/custom/postprocessor.js +++ b/packages/string-templates/src/processors/postprocessor.js @@ -1,6 +1,10 @@ +const { FIND_HBS_REGEX } = require("../utilities") + class Postprocessor { constructor(name, fn) { this.name = name this.fn = fn } } + +module.exports.processors = [] diff --git a/packages/string-templates/src/custom/preprocessor.js b/packages/string-templates/src/processors/preprocessor.js similarity index 68% rename from packages/string-templates/src/custom/preprocessor.js rename to packages/string-templates/src/processors/preprocessor.js index a86af5cd43..0d71445788 100644 --- a/packages/string-templates/src/custom/preprocessor.js +++ b/packages/string-templates/src/processors/preprocessor.js @@ -3,7 +3,6 @@ const { swapStrings, isAlphaNumeric, FIND_HBS_REGEX, - includesAny, } = require("../utilities") const PreprocessorNames = { @@ -25,7 +24,7 @@ class Preprocessor { } } -const PROCESSORS = [ +module.exports.processors = [ new Preprocessor(PreprocessorNames.SWAP_TO_DOT, statement => { let startBraceIdx = statement.indexOf("[") let lastIdx = 0 @@ -90,29 +89,3 @@ const PROCESSORS = [ return `{{ all ${insideStatement} }}` }), ] - -/** - * When running handlebars statements to execute on the context of the automation it possible user's may input handlebars - * in a few different forms, some of which are invalid but are logically valid. An example of this would be the handlebars - * statement "{{steps[0].revision}}" here it is obvious the user is attempting to access an array or object using array - * like operators. These are not supported by handlebars and therefore the statement will fail. This function pre-processes will - * the handlebars statement so it instead reads as "{{steps.0.revision}}" which is valid and will work. It may also be expanded - * to include any other handlebars statement pre-process that has been deemed necessary for the system. - * - * @param {string} string The string which *may* contain handlebars statements, it is OK if it does not contain any. - * @returns {string} The string that was input with processed up handlebars statements as required. - */ -module.exports.preprocess = string => { - for (let processor of PROCESSORS) { - // re-run search each time incase previous processor updated/removed a match - let regex = new RegExp(FIND_HBS_REGEX) - let matches = string.match(regex) - if (matches == null) { - continue - } - for (let match of matches) { - string = processor.process(string, match) - } - } - return string -} diff --git a/packages/string-templates/src/utilities.js b/packages/string-templates/src/utilities.js index 8b45820250..b973b56acd 100644 --- a/packages/string-templates/src/utilities.js +++ b/packages/string-templates/src/utilities.js @@ -21,3 +21,7 @@ module.exports.removeNull = obj => { ]) ) } + +module.exports.findHbsStatements = string => { + +} \ No newline at end of file From decc1aba5e652f71750a23534977ced23c1c7164 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Thu, 21 Jan 2021 17:56:22 +0000 Subject: [PATCH 5/6] Linting. --- packages/string-templates/src/processors/index.js | 2 +- packages/string-templates/src/processors/preprocessor.js | 6 +----- packages/string-templates/src/utilities.js | 4 +--- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/packages/string-templates/src/processors/index.js b/packages/string-templates/src/processors/index.js index d781de53ad..225a707c60 100644 --- a/packages/string-templates/src/processors/index.js +++ b/packages/string-templates/src/processors/index.js @@ -23,4 +23,4 @@ module.exports.preprocess = string => { module.exports.postprocess = string => { return process(string, postprocessor.processors) -} \ No newline at end of file +} diff --git a/packages/string-templates/src/processors/preprocessor.js b/packages/string-templates/src/processors/preprocessor.js index 0d71445788..aa1d58bd43 100644 --- a/packages/string-templates/src/processors/preprocessor.js +++ b/packages/string-templates/src/processors/preprocessor.js @@ -1,9 +1,5 @@ const { HelperNames } = require("../helpers") -const { - swapStrings, - isAlphaNumeric, - FIND_HBS_REGEX, -} = require("../utilities") +const { swapStrings, isAlphaNumeric, FIND_HBS_REGEX } = require("../utilities") const PreprocessorNames = { SWAP_TO_DOT: "swap-to-dot-notation", diff --git a/packages/string-templates/src/utilities.js b/packages/string-templates/src/utilities.js index b973b56acd..e700ea6c53 100644 --- a/packages/string-templates/src/utilities.js +++ b/packages/string-templates/src/utilities.js @@ -22,6 +22,4 @@ module.exports.removeNull = obj => { ) } -module.exports.findHbsStatements = string => { - -} \ No newline at end of file +module.exports.findHbsStatements = string => {} From 90dce862f19a988b417f46af038b07bf52498ffc Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Thu, 21 Jan 2021 18:08:04 +0000 Subject: [PATCH 6/6] Fixing some issues CI linting found. --- packages/string-templates/rollup.config.js | 2 -- packages/string-templates/src/helpers/external.js | 3 ++- packages/string-templates/src/processors/postprocessor.js | 3 +-- packages/string-templates/src/processors/preprocessor.js | 3 ++- packages/string-templates/src/utilities.js | 4 +--- 5 files changed, 6 insertions(+), 9 deletions(-) diff --git a/packages/string-templates/rollup.config.js b/packages/string-templates/rollup.config.js index 6ca34c5dfe..5a71316fb5 100644 --- a/packages/string-templates/rollup.config.js +++ b/packages/string-templates/rollup.config.js @@ -4,8 +4,6 @@ import builtins from "rollup-plugin-node-builtins" import globals from "rollup-plugin-node-globals" import json from "@rollup/plugin-json" -const production = !process.env.ROLLUP_WATCH - export default { input: "src/index.js", output: [ diff --git a/packages/string-templates/src/helpers/external.js b/packages/string-templates/src/helpers/external.js index 9bad3a0eba..7c767db5f4 100644 --- a/packages/string-templates/src/helpers/external.js +++ b/packages/string-templates/src/helpers/external.js @@ -24,7 +24,8 @@ exports.registerAll = handlebars => { for (let collection of EXTERNAL_FUNCTION_COLLECTIONS) { // collect information about helper let hbsHelperInfo = helpers[collection]() - for (let [name, func] of Object.entries(hbsHelperInfo)) { + for (let entry of Object.entries(hbsHelperInfo)) { + const name = entry[0] // skip built in functions and ones seen already if ( HelperFunctionBuiltin.indexOf(name) !== -1 || diff --git a/packages/string-templates/src/processors/postprocessor.js b/packages/string-templates/src/processors/postprocessor.js index 76a962c52f..9f2491cb17 100644 --- a/packages/string-templates/src/processors/postprocessor.js +++ b/packages/string-templates/src/processors/postprocessor.js @@ -1,5 +1,4 @@ -const { FIND_HBS_REGEX } = require("../utilities") - +/* eslint-disable no-unused-vars */ class Postprocessor { constructor(name, fn) { this.name = name diff --git a/packages/string-templates/src/processors/preprocessor.js b/packages/string-templates/src/processors/preprocessor.js index aa1d58bd43..131fb522f9 100644 --- a/packages/string-templates/src/processors/preprocessor.js +++ b/packages/string-templates/src/processors/preprocessor.js @@ -1,5 +1,5 @@ const { HelperNames } = require("../helpers") -const { swapStrings, isAlphaNumeric, FIND_HBS_REGEX } = require("../utilities") +const { swapStrings, isAlphaNumeric } = require("../utilities") const PreprocessorNames = { SWAP_TO_DOT: "swap-to-dot-notation", @@ -7,6 +7,7 @@ const PreprocessorNames = { FINALISE: "finalise", } +/* eslint-disable no-unused-vars */ class Preprocessor { constructor(name, fn) { this.name = name diff --git a/packages/string-templates/src/utilities.js b/packages/string-templates/src/utilities.js index e700ea6c53..71b5aa1875 100644 --- a/packages/string-templates/src/utilities.js +++ b/packages/string-templates/src/utilities.js @@ -14,12 +14,10 @@ module.exports.swapStrings = (string, start, length, swap) => { module.exports.removeNull = obj => { return Object.fromEntries( Object.entries(obj) - .filter(([key, value]) => value != null) + .filter(entry => entry[1] != null) .map(([key, value]) => [ key, value === Object(value) ? module.exports.removeNull(value) : value, ]) ) } - -module.exports.findHbsStatements = string => {}