From: Justin Wind Date: Sat, 4 May 2024 22:35:30 +0000 (-0700) Subject: update dependencies and devDependencies, fix lint issues X-Git-Tag: v1.6.1~1 X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=587ed2e5d32416056e2a4b98f4ceef466d3547ed;p=squeep-html-template-helper update dependencies and devDependencies, fix lint issues --- 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