Skip to content

Commit

Permalink
Merge pull request #862 from 18F/develop
Browse files Browse the repository at this point in the history
[Security] NPM Audit fixes -- Staging
  • Loading branch information
levinmr authored Jul 16, 2024
2 parents 9aa15cb + 6c1a019 commit 97bd682
Show file tree
Hide file tree
Showing 28 changed files with 368 additions and 159 deletions.
3 changes: 0 additions & 3 deletions .mocharc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@ package: './package.json'
slow: '75'
spec:
- 'test/**/*.js'
- 'ua/test/**/*.js'
timeout: '2000'
ui: 'bdd'
watch-files:
- 'src/**/*.js'
- 'test/**/*.js'
- 'ua/src/**/*.js'
- 'ua/test/**/*.js'
41 changes: 37 additions & 4 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { configs: eslintConfigs } = require("@eslint/js");
const eslintPluginPrettierRecommended = require("eslint-plugin-prettier/recommended");
const globals = require("globals");
const jsdoc = require("eslint-plugin-jsdoc");

module.exports = [
{
Expand All @@ -11,10 +12,42 @@ module.exports = [
},
},
},
eslintConfigs.recommended,
eslintPluginPrettierRecommended,
{
// UA code is deprecated, so don't bother with static analysis rules.
ignores: ["ua/**/*.js"],
...eslintConfigs.recommended,
plugins: {
jsdoc,
},
files: ["src/**/*.js", "index.js"],
rules: {
...jsdoc.configs.recommended.rules,
"jsdoc/check-indentation": "error",
"jsdoc/check-line-alignment": "error",
"jsdoc/check-syntax": "error",
"jsdoc/convert-to-jsdoc-comments": "error",
"jsdoc/no-bad-blocks": "error",
"jsdoc/no-blank-block-descriptions": "error",
"jsdoc/no-blank-blocks": "error",
"jsdoc/require-asterisk-prefix": "error",
"jsdoc/require-jsdoc": [
"error",
{
checkGetters: false,
checkSetters: false,
publicOnly: true,
require: {
ArrowFunctionExpression: true,
ClassDeclaration: true,
ClassExpression: true,
FunctionDeclaration: true,
FunctionExpression: true,
MethodDefinition: true,
},
},
],
"jsdoc/require-throws": "error",
"jsdoc/sort-tags": "error",
"jsdoc/tag-lines": "off",
},
},
eslintPluginPrettierRecommended,
];
33 changes: 17 additions & 16 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,24 @@ const WriteAnalyticsDataToDatabase = require("./src/actions/write_analytics_data
* a sequential chain of actions on each report object in the array. Some of the
* actions performed are optional based on the options passed to this function.
*
* @param {Object} options an object with options to be used when processing
* @param {object} options an object with options to be used when processing
* all reports.
* @param {String} options.format the format of the analytics data produced.
* @param {string} options.format the format of the analytics data produced.
* Accepted formats are "csv" or "json"
* @param {String} options.output a string filepath where the analytics data
* @param {string} options.output a string filepath where the analytics data
* will be written to disk after processing.
* @param {Boolean} options.publish if true, the analytics data will be written
* @param {boolean} options.publish if true, the analytics data will be written
* to AWS S3 after processing.
* @param {Boolean} options.realtime if true, the application will use the
* @param {boolean} options.realtime if true, the application will use the
* google analytics realtime data reporting API when requesting data. Otherwise
* the application uses the non-realtime data reporting API.
* @param {Boolean} options.slim if true, the application will create a smaller
* @param {boolean} options.slim if true, the application will create a smaller
* data object when formatting the processed data.
* @param {Boolean} options['write-to-database'] if true, the application will
* @param {boolean} options.'write-to-database' if true, the application will
* write the processed analytics data to the postgres database.
* @param {String} options.only if set, runs only the report with name
* @param {string} options.only if set, runs only the report with name
* matching the passed string.
* @param {String} options.frequency if set, runs only the reports with
* @param {string} options.frequency if set, runs only the reports with
* frequency matching the passed string.
*/
async function run(options = {}) {
Expand All @@ -60,11 +60,12 @@ async function run(options = {}) {
* throw so that subsequent reports will run if an error occurs in a previous
* report.
*
* @param {AppConfig} appConfig the application config
* @param {ReportProcessingContext} context
* @param {Object} reportConfig the configuration object for the analytics
* @param {import('./src/app_config')} appConfig the application config
* @param {import('./src/report_processing_context')} context the
* report-specific context for processing.
* @param {object} reportConfig the configuration object for the analytics
* report to process.
* @returns {Promise<void>} resolves when processing completes or has an error.
* @returns {Promise} resolves when processing completes or has an error.
*/
async function _processReport(appConfig, context, reportConfig) {
return context.run(async () => {
Expand All @@ -90,9 +91,9 @@ async function _processReport(appConfig, context, reportConfig) {
* in the order provided to the processor here. The classes referenced here are
* an implementation of the Chain of Responsibility design pattern.
*
* @param {AppConfig} appConfig an application config instance.
* @param {winston.Logger} logger an application logger instance.
* @returns {Processor} an initialized processor instance.
* @param {import('./src/app_config')} appConfig an application config instance.
* @param {import('winston').Logger} logger an application logger instance.
* @returns {import('./src/processor')} an initialized processor instance.
*/
function _buildProcessor(appConfig, logger) {
return new Processor([
Expand Down
Loading

0 comments on commit 97bd682

Please sign in to comment.