Skip to content

Commit

Permalink
Upgrading eslint and mocha.
Browse files Browse the repository at this point in the history
  • Loading branch information
arithmetric committed Jan 11, 2025
1 parent 001a0b0 commit b47048a
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 36 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/lint-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ on:
push:
branches:
- master
- github_actions
- support_node16
pull_request:

jobs:
Expand All @@ -16,14 +14,14 @@ jobs:
strategy:
fail-fast: false
matrix:
nodejs_version: [ 12, 14, 16, 18 ]
nodejs_version: [ 18, 20, 22 ]

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.nodejs_version }}

Expand Down
34 changes: 34 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import globals from "globals";
import pluginJs from "@eslint/js";
import stylistic from "@stylistic/eslint-plugin";
import stylisticJs from "@stylistic/eslint-plugin-js";

/** @type {import('eslint').Linter.Config[]} */
export default [
pluginJs.configs.recommended,
stylistic.configs.customize({
quotes: "double",
semi: true,
commaDangle: "only-multiline",
}),
{
files: ["**/*.js"],
languageOptions: {
globals: {
...globals.node,
},
sourceType: "commonjs",
},
plugins: {
"@stylistic/js": stylisticJs,
},
rules: {
"@stylistic/brace-style": 0,
"@stylistic/multiline-ternary": 0,
"@stylistic/object-curly-spacing": 0,
"@stylistic/operator-linebreak": 0,
"@stylistic/quotes": 0,
"@stylistic/space-before-function-paren": 0,
},
},
];
1 change: 0 additions & 1 deletion example/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

var LambdaForwarder = require("aws-lambda-ses-forwarder");

exports.handler = function(event, context, callback) {
Expand Down
32 changes: 16 additions & 16 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ var defaultConfig = {
exports.parseEvent = function(data) {
// Validate characteristics of a SES event record.
if (!data.event ||
!data.event.hasOwnProperty('Records') ||
data.event.Records.length !== 1 ||
!data.event.Records[0].hasOwnProperty('eventSource') ||
data.event.Records[0].eventSource !== 'aws:ses' ||
data.event.Records[0].eventVersion !== '1.0') {
!Object.hasOwn(data.event, 'Records') ||
data.event.Records.length !== 1 ||
!Object.hasOwn(data.event.Records[0], 'eventSource') ||
data.event.Records[0].eventSource !== 'aws:ses' ||
data.event.Records[0].eventVersion !== '1.0') {
data.log({
message: "parseEvent() received invalid SES message:",
level: "error", event: JSON.stringify(data.event)
Expand Down Expand Up @@ -101,7 +101,7 @@ exports.transformRecipients = function(data) {
if (data.config.allowPlusSign) {
origEmailKey = origEmailKey.replace(/\+.*?@/, '@');
}
if (data.config.forwardMapping.hasOwnProperty(origEmailKey)) {
if (Object.hasOwn(data.config.forwardMapping, origEmailKey)) {
newRecipients = newRecipients.concat(
data.config.forwardMapping[origEmailKey]);
data.originalRecipient = origEmail;
Expand All @@ -116,16 +116,16 @@ exports.transformRecipients = function(data) {
origEmailUser = origEmailKey.slice(0, pos);
}
if (origEmailDomain &&
data.config.forwardMapping.hasOwnProperty(origEmailDomain)) {
Object.hasOwn(data.config.forwardMapping, origEmailDomain)) {
newRecipients = newRecipients.concat(
data.config.forwardMapping[origEmailDomain]);
data.originalRecipient = origEmail;
} else if (origEmailUser &&
data.config.forwardMapping.hasOwnProperty(origEmailUser)) {
Object.hasOwn(data.config.forwardMapping, origEmailUser)) {
newRecipients = newRecipients.concat(
data.config.forwardMapping[origEmailUser]);
data.originalRecipient = origEmail;
} else if (data.config.forwardMapping.hasOwnProperty("@")) {
} else if (Object.hasOwn(data.config.forwardMapping, "@")) {
newRecipients = newRecipients.concat(
data.config.forwardMapping["@"]);
data.originalRecipient = origEmail;
Expand Down Expand Up @@ -337,13 +337,13 @@ exports.sendMessage = function(data) {
*/
exports.handler = function(event, context, callback, overrides) {
var steps = overrides && overrides.steps ? overrides.steps :
[
exports.parseEvent,
exports.transformRecipients,
exports.fetchMessage,
exports.processMessage,
exports.sendMessage
];
[
exports.parseEvent,
exports.transformRecipients,
exports.fetchMessage,
exports.processMessage,
exports.sendMessage
];
var data = {
event: event,
callback: callback,
Expand Down
17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,23 @@
"main": "index.js",
"scripts": {
"check-coverage": "nyc report --reporter=lcov",
"lint": "eslint *.js example/*.js test/*.js",
"test": "nyc --statements 100 -- mocha -- --check-leaks --timeout 3000"
"lint": "npx eslint",
"test": "nyc --statements 100 -- mocha -- --check-leaks"
},
"dependencies": {
"@aws-sdk/client-s3": "^3.188.0",
"@aws-sdk/client-sesv2": "^3.188.0"
},
"devDependencies": {
"coveralls": "^3.0.7",
"eslint": "^6.8.0",
"eslint-config-google": "~0.6.0",
"mocha": "^6.2.2",
"nyc": "^15.1.0"
"@eslint/js": "^9.18.0",
"@stylistic/eslint-plugin": "^2.12.1",
"@stylistic/eslint-plugin-js": "^2.12.1",
"globals": "^15.14.0",
"mocha": "^11.1.0",
"nyc": "^17.1.0"
},
"engines": {
"node": ">=8.0"
"node": ">=18.0"
},
"repository": {
"type": "git",
Expand Down
1 change: 0 additions & 1 deletion test/fetchMessage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/* global describe, it */

var assert = require("assert");
Expand Down
1 change: 0 additions & 1 deletion test/handler.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/* global describe, it */

var assert = require("assert");
Expand Down
1 change: 0 additions & 1 deletion test/parseEvent.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/* global describe, it */

var assert = require("assert");
Expand Down
1 change: 0 additions & 1 deletion test/processMessage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/* global describe, it */

var assert = require("assert");
Expand Down
1 change: 0 additions & 1 deletion test/sendMessage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/* global describe, it */

var assert = require("assert");
Expand Down
1 change: 0 additions & 1 deletion test/transformRecipients.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/* global describe, it */

var assert = require("assert");
Expand Down

0 comments on commit b47048a

Please sign in to comment.