Skip to content

Commit b47048a

Browse files
committed
Upgrading eslint and mocha.
1 parent 001a0b0 commit b47048a

File tree

11 files changed

+62
-36
lines changed

11 files changed

+62
-36
lines changed

.github/workflows/lint-test.yaml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ on:
55
push:
66
branches:
77
- master
8-
- github_actions
9-
- support_node16
108
pull_request:
119

1210
jobs:
@@ -16,14 +14,14 @@ jobs:
1614
strategy:
1715
fail-fast: false
1816
matrix:
19-
nodejs_version: [ 12, 14, 16, 18 ]
17+
nodejs_version: [ 18, 20, 22 ]
2018

2119
steps:
2220
- name: Checkout
23-
uses: actions/checkout@v3
21+
uses: actions/checkout@v4
2422

2523
- name: Setup Node.js
26-
uses: actions/setup-node@v3
24+
uses: actions/setup-node@v4
2725
with:
2826
node-version: ${{ matrix.nodejs_version }}
2927

eslint.config.mjs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import globals from "globals";
2+
import pluginJs from "@eslint/js";
3+
import stylistic from "@stylistic/eslint-plugin";
4+
import stylisticJs from "@stylistic/eslint-plugin-js";
5+
6+
/** @type {import('eslint').Linter.Config[]} */
7+
export default [
8+
pluginJs.configs.recommended,
9+
stylistic.configs.customize({
10+
quotes: "double",
11+
semi: true,
12+
commaDangle: "only-multiline",
13+
}),
14+
{
15+
files: ["**/*.js"],
16+
languageOptions: {
17+
globals: {
18+
...globals.node,
19+
},
20+
sourceType: "commonjs",
21+
},
22+
plugins: {
23+
"@stylistic/js": stylisticJs,
24+
},
25+
rules: {
26+
"@stylistic/brace-style": 0,
27+
"@stylistic/multiline-ternary": 0,
28+
"@stylistic/object-curly-spacing": 0,
29+
"@stylistic/operator-linebreak": 0,
30+
"@stylistic/quotes": 0,
31+
"@stylistic/space-before-function-paren": 0,
32+
},
33+
},
34+
];

example/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
var LambdaForwarder = require("aws-lambda-ses-forwarder");
32

43
exports.handler = function(event, context, callback) {

index.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ var defaultConfig = {
6969
exports.parseEvent = function(data) {
7070
// Validate characteristics of a SES event record.
7171
if (!data.event ||
72-
!data.event.hasOwnProperty('Records') ||
73-
data.event.Records.length !== 1 ||
74-
!data.event.Records[0].hasOwnProperty('eventSource') ||
75-
data.event.Records[0].eventSource !== 'aws:ses' ||
76-
data.event.Records[0].eventVersion !== '1.0') {
72+
!Object.hasOwn(data.event, 'Records') ||
73+
data.event.Records.length !== 1 ||
74+
!Object.hasOwn(data.event.Records[0], 'eventSource') ||
75+
data.event.Records[0].eventSource !== 'aws:ses' ||
76+
data.event.Records[0].eventVersion !== '1.0') {
7777
data.log({
7878
message: "parseEvent() received invalid SES message:",
7979
level: "error", event: JSON.stringify(data.event)
@@ -101,7 +101,7 @@ exports.transformRecipients = function(data) {
101101
if (data.config.allowPlusSign) {
102102
origEmailKey = origEmailKey.replace(/\+.*?@/, '@');
103103
}
104-
if (data.config.forwardMapping.hasOwnProperty(origEmailKey)) {
104+
if (Object.hasOwn(data.config.forwardMapping, origEmailKey)) {
105105
newRecipients = newRecipients.concat(
106106
data.config.forwardMapping[origEmailKey]);
107107
data.originalRecipient = origEmail;
@@ -116,16 +116,16 @@ exports.transformRecipients = function(data) {
116116
origEmailUser = origEmailKey.slice(0, pos);
117117
}
118118
if (origEmailDomain &&
119-
data.config.forwardMapping.hasOwnProperty(origEmailDomain)) {
119+
Object.hasOwn(data.config.forwardMapping, origEmailDomain)) {
120120
newRecipients = newRecipients.concat(
121121
data.config.forwardMapping[origEmailDomain]);
122122
data.originalRecipient = origEmail;
123123
} else if (origEmailUser &&
124-
data.config.forwardMapping.hasOwnProperty(origEmailUser)) {
124+
Object.hasOwn(data.config.forwardMapping, origEmailUser)) {
125125
newRecipients = newRecipients.concat(
126126
data.config.forwardMapping[origEmailUser]);
127127
data.originalRecipient = origEmail;
128-
} else if (data.config.forwardMapping.hasOwnProperty("@")) {
128+
} else if (Object.hasOwn(data.config.forwardMapping, "@")) {
129129
newRecipients = newRecipients.concat(
130130
data.config.forwardMapping["@"]);
131131
data.originalRecipient = origEmail;
@@ -337,13 +337,13 @@ exports.sendMessage = function(data) {
337337
*/
338338
exports.handler = function(event, context, callback, overrides) {
339339
var steps = overrides && overrides.steps ? overrides.steps :
340-
[
341-
exports.parseEvent,
342-
exports.transformRecipients,
343-
exports.fetchMessage,
344-
exports.processMessage,
345-
exports.sendMessage
346-
];
340+
[
341+
exports.parseEvent,
342+
exports.transformRecipients,
343+
exports.fetchMessage,
344+
exports.processMessage,
345+
exports.sendMessage
346+
];
347347
var data = {
348348
event: event,
349349
callback: callback,

package.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,23 @@
55
"main": "index.js",
66
"scripts": {
77
"check-coverage": "nyc report --reporter=lcov",
8-
"lint": "eslint *.js example/*.js test/*.js",
9-
"test": "nyc --statements 100 -- mocha -- --check-leaks --timeout 3000"
8+
"lint": "npx eslint",
9+
"test": "nyc --statements 100 -- mocha -- --check-leaks"
1010
},
1111
"dependencies": {
1212
"@aws-sdk/client-s3": "^3.188.0",
1313
"@aws-sdk/client-sesv2": "^3.188.0"
1414
},
1515
"devDependencies": {
16-
"coveralls": "^3.0.7",
17-
"eslint": "^6.8.0",
18-
"eslint-config-google": "~0.6.0",
19-
"mocha": "^6.2.2",
20-
"nyc": "^15.1.0"
16+
"@eslint/js": "^9.18.0",
17+
"@stylistic/eslint-plugin": "^2.12.1",
18+
"@stylistic/eslint-plugin-js": "^2.12.1",
19+
"globals": "^15.14.0",
20+
"mocha": "^11.1.0",
21+
"nyc": "^17.1.0"
2122
},
2223
"engines": {
23-
"node": ">=8.0"
24+
"node": ">=18.0"
2425
},
2526
"repository": {
2627
"type": "git",

test/fetchMessage.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/* global describe, it */
32

43
var assert = require("assert");

test/handler.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/* global describe, it */
32

43
var assert = require("assert");

test/parseEvent.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/* global describe, it */
32

43
var assert = require("assert");

test/processMessage.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/* global describe, it */
32

43
var assert = require("assert");

test/sendMessage.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/* global describe, it */
32

43
var assert = require("assert");

0 commit comments

Comments
 (0)