-
Notifications
You must be signed in to change notification settings - Fork 38
chore: reduce Node.js threat surface — Node 24, ESLint 10 flat config, dep upgrades #307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
a0a3d76
07028ff
db171fb
3807038
07e3e43
d245c65
617f200
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| 20.19.4 | ||
| 24.15.0 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| 'use strict'; | ||
|
|
||
| const lobConfig = require('eslint-config-lob'); | ||
|
|
||
| module.exports = [ | ||
| ...lobConfig, | ||
| { | ||
| languageOptions: { | ||
| ecmaVersion: 2017, | ||
| globals: { | ||
| API_KEY: false, | ||
| expect: false, | ||
| HAS_LIVE_KEY: false, | ||
| INTEGRATION_TIMEOUT: false, | ||
| LiveLob: false, | ||
| Lob: false, | ||
| mocks: false | ||
| } | ||
| } | ||
| }, | ||
| { | ||
| files: ['examples/**/*.js'], | ||
| rules: { | ||
| 'no-console': 0 | ||
| } | ||
| }, | ||
| { | ||
| ignores: ['coverage/**'] | ||
| } | ||
| ]; | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -3,12 +3,12 @@ | |||||||||||||||||||||||||||
| const converter = require('json-2-csv'); | ||||||||||||||||||||||||||||
| const fs = require('fs'); | ||||||||||||||||||||||||||||
| const moment = require('moment'); | ||||||||||||||||||||||||||||
| const parse = require('csv-parse'); | ||||||||||||||||||||||||||||
| const { parse } = require('csv-parse'); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const LobFactory = require('../../lib/index.js'); | ||||||||||||||||||||||||||||
| const lob = new LobFactory('YOUR_API_KEY'); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const inputFile = fs.createReadStream(`${__dirname}/input.csv`); | ||||||||||||||||||||||||||||
| const inputData = fs.readFileSync(`${__dirname}/input.csv`, { encoding: 'utf-8' }); | ||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changing from |
||||||||||||||||||||||||||||
| const successFd = fs.openSync(`${__dirname}/success.csv`, 'w'); | ||||||||||||||||||||||||||||
| const errorFd = fs.openSync(`${__dirname}/error.csv`, 'w'); | ||||||||||||||||||||||||||||
| const letterTemplate = fs.readFileSync(`${__dirname}/letter_template.html`).toString(); | ||||||||||||||||||||||||||||
|
|
@@ -23,7 +23,7 @@ const companyInfo = { | |||||||||||||||||||||||||||
| address_country: 'US' | ||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const parser = parse({ columns: true }, (err, data) => { | ||||||||||||||||||||||||||||
| parse(inputData, { columns: true }, (err, data) => { | ||||||||||||||||||||||||||||
| if (err) { | ||||||||||||||||||||||||||||
| return console.log(err); | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
@@ -68,24 +68,20 @@ const parser = parse({ columns: true }, (err, data) => { | |||||||||||||||||||||||||||
| console.log(`Successfully sent a letter to ${client.name}`); | ||||||||||||||||||||||||||||
| client.letter_id = letter.id; | ||||||||||||||||||||||||||||
| client.letter_url = letter.url; | ||||||||||||||||||||||||||||
| converter.json2csv(client, (err2, csv) => { | ||||||||||||||||||||||||||||
| if (err2) { | ||||||||||||||||||||||||||||
| converter.json2csv(client, { prependHeader: false }) | ||||||||||||||||||||||||||||
| .then((csv) => fs.write(successFd, csv, () => {})) | ||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||
| .catch((err2) => { | ||||||||||||||||||||||||||||
| throw err2; | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| fs.write(successFd, csv); | ||||||||||||||||||||||||||||
| }, { PREPEND_HEADER: false }); | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using
Suggested change
|
||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||
| .catch(() => { | ||||||||||||||||||||||||||||
| console.log(`Could not send letter to ${client.name}`); | ||||||||||||||||||||||||||||
| converter.json2csv(client, (err2, csv) => { | ||||||||||||||||||||||||||||
| if (err2) { | ||||||||||||||||||||||||||||
| converter.json2csv(client, { prependHeader: false }) | ||||||||||||||||||||||||||||
| .then((csv) => fs.write(errorFd, csv, () => {})) | ||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A newline should be appended here as well to ensure the error CSV is correctly formatted. Using
Suggested change
|
||||||||||||||||||||||||||||
| .catch((err2) => { | ||||||||||||||||||||||||||||
| throw err2; | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| fs.write(errorFd, csv); | ||||||||||||||||||||||||||||
| }, { PREPEND_HEADER: false }); | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using .then((csv) => {
fs.writeSync(errorFd, csv + "\n");
})
.catch((err2) => {
console.error("Error writing to error file:", err2);
}); |
||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| inputFile.pipe(parser); | ||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
ecmaVersionis set to2017. Since the project is targeting modern Node.js versions (20+), it is recommended to update this tolatestor at least2022to support linting of modern JavaScript features (e.g., optional chaining, nullish coalescing) in tests and examples.