From 2d0ba72a2ea35f45c1ab1ac81fce3d0cbe7db419 Mon Sep 17 00:00:00 2001 From: Justin Wind Date: Fri, 22 Mar 2024 16:16:12 -0700 Subject: [PATCH 1/3] bump package version to 1.6.0 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4d0d799..c243f82 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@squeep/html-template-helper", - "version": "1.5.3", + "version": "1.6.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@squeep/html-template-helper", - "version": "1.5.3", + "version": "1.6.0", "license": "ISC", "dependencies": { "@squeep/lazy-property": "^1.1.2" diff --git a/package.json b/package.json index a8bdfc0..7fbd63e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@squeep/html-template-helper", - "version": "1.5.3", + "version": "1.6.0", "description": "Helper functions for generating HTML pages and boilerplate; intended for use in Squeep Framework Applications.", "main": "index.js", "scripts": { -- 2.44.1 From 587ed2e5d32416056e2a4b98f4ceef466d3547ed Mon Sep 17 00:00:00 2001 From: Justin Wind Date: Sat, 4 May 2024 15:35:30 -0700 Subject: [PATCH 2/3] update dependencies and devDependencies, fix lint issues --- eslint.config.js | 107 +- lib/template-helper.js | 216 ++- package-lock.json | 3900 +++++----------------------------------- package.json | 26 +- test/lint-html.js | 20 +- 5 files changed, 561 insertions(+), 3708 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index ebefcac..fcda56f 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,110 +1,7 @@ 'use strict'; -const globals = require('globals'); -const js = require('@eslint/js'); -const node = require('eslint-plugin-n'); -const security = require('eslint-plugin-security'); -const sonarjs = require('eslint-plugin-sonarjs'); -const { FlatCompat } = require('@eslint/eslintrc'); -const compat = new FlatCompat(); +const squeepConfig = require('@squeep/eslint-config'); module.exports = [ - js.configs.recommended, - ...compat.config(node.configs.recommended), - security.configs.recommended, - ...compat.config(sonarjs.configs.recommended), - { - files: [ '**/*.js' ], - plugins: { - node, - security, - sonarjs, - }, - languageOptions: { - ecmaVersion: 2023, - sourceType: 'script', - }, - rules: { - 'array-element-newline': [ - 'error', - 'consistent', - ], - 'arrow-parens': [ - 'error', - 'always', - ], - 'arrow-spacing': [ - 'error', - { - 'after': true, - 'before': true, - }, - ], - 'block-scoped-var': 'error', - 'block-spacing': 'error', - 'brace-style': 'error', - 'callback-return': 'error', - 'camelcase': 'error', - 'class-methods-use-this': 'error', - 'comma-dangle': [ - 'error', - 'always-multiline', - ], - 'comma-spacing': [ - 'error', - { - 'after': true, - 'before': false, - }, - ], - 'comma-style': [ - 'error', - 'last', - ], - 'indent': [ - 'warn', - 2, - { - 'SwitchCase': 1, - }, - ], - 'sonarjs/cognitive-complexity': 'warn', - 'keyword-spacing': 'error', - 'linebreak-style': [ - 'error', - 'unix', - ], - 'no-unused-vars': [ - 'error', { - 'varsIgnorePattern': '^_', - }, - ], - 'object-curly-spacing': [ - 'error', - 'always', - ], - 'prefer-const': 'error', - 'quotes': [ - 'error', - 'single', - ], - 'semi': [ - 'error', - 'always', - ], - 'strict': 'error', - 'vars-on-top': 'error', - }, - }, - { - files: ['test/**'], - languageOptions: { - globals: { - ...globals.mocha, - }, - }, - rules: { - "n/no-unpublished-require": "off", - }, - }, + ...squeepConfig, ]; diff --git a/lib/template-helper.js b/lib/template-helper.js index e8163ab..f2f4efe 100644 --- a/lib/template-helper.js +++ b/lib/template-helper.js @@ -10,7 +10,7 @@ const { lazy } = require('@squeep/lazy-property'); /** * Set up expected fields for how we handle error reporting * and whatnot. - * @param {Object} ctx + * @param {object} ctx context */ const initContext = (ctx) => { ctx.errors = []; @@ -19,8 +19,9 @@ const initContext = (ctx) => { /** * Some fields may have values outside normal dates, handle them here. - * @param {Date|Number} date - * @param {String} otherwise + * @param {Date|number} date potential Date or epoch milliseconds + * @param {string} otherwise returned if date is not a date + * @returns {string} date or otherwise */ const dateOrNot = (date, otherwise) => { if (!date) { @@ -42,10 +43,11 @@ const dateOrNot = (date, otherwise) => { * Why is rendering a Date as a string this complicated? * We handle the infinities because pg-promise might provide those in * lieu of a Date object from timestamp fields. - * @param {Date|Number|String} date - * @param {String=} pInf - * @param {String=} nInf - * @param {String=} otherwise + * @param {Date|number|string} date Date, epoch milliseconds, or date string + * @param {string=} pInf returned if date is +Infinity + * @param {string=} nInf returned if date is -Infinity + * @param {string=} otherwise returned if date is something else + * @returns {string} rendered date */ const dateFormat = (date, pInf = 'Never', nInf = 'Forever', otherwise = '') => { const isDatableType = ['number', 'string'].includes(typeof date); @@ -77,10 +79,11 @@ lazy(dateFormat, '_dtf', () => { /** - * Wrap a Date in a