Skip to content

Commit

Permalink
Merge pull request #79 from BonnierNews/feature/eslint-config-exp
Browse files Browse the repository at this point in the history
Use eslint-config-exp instead of local eslint config
  • Loading branch information
varney authored Jul 27, 2023
2 parents eb52853 + 1471a15 commit 6006679
Show file tree
Hide file tree
Showing 52 changed files with 1,444 additions and 2,298 deletions.
81 changes: 2 additions & 79 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,81 +1,4 @@
{
"parserOptions": {
"ecmaVersion": 2020
},
"env": {
"node": true,
"es6": true
},
"extends": ["eslint:recommended", "plugin:json/recommended"],
"plugins": ["prettier", "json"],
"rules": {
"prettier/prettier": "error",
"arrow-parens": 2,
"arrow-spacing": 2,
"brace-style": [2, "1tbs", {"allowSingleLine": false}],
"callback-return": 2,
"camelcase": 1,
"comma-spacing": 1,
"curly": [2, "multi-line"],
"dot-notation": [2, {"allowKeywords": true}],
"eol-last": 2,
"eqeqeq": 2,
"handle-callback-err": 2,
"key-spacing": [1, {"beforeColon": false, "afterColon": true}],
"keyword-spacing": 1,
"new-cap": 2,
"new-parens": 1,
"no-alert": 2,
"no-array-constructor": 2,
"no-caller": 2,
"no-catch-shadow": 2,
"no-console": 2,
"no-duplicate-imports": 1,
"no-eval": 2,
"no-extend-native": 2,
"no-extra-bind": 2,
"no-extra-parens": [1, "functions"],
"no-implied-eval": 2,
"no-iterator": 2,
"no-label-var": 2,
"no-labels": 2,
"no-lone-blocks": 2,
"no-loop-func": 2,
"no-multi-spaces": 1,
"no-multi-str": 2,
"no-multiple-empty-lines": 1,
"no-native-reassign": 2,
"no-new": 2,
"no-new-func": 2,
"no-new-object": 2,
"no-new-symbol": 2,
"no-new-wrappers": 2,
"no-octal-escape": 2,
"no-path-concat": 2,
"no-process-exit": 2,
"no-proto": 2,
"no-return-assign": 2,
"no-script-url": 2,
"no-sequences": 2,
"no-shadow": 2,
"no-shadow-restricted-names": 2,
"no-spaced-func": 2,
"no-trailing-spaces": 1,
"no-underscore-dangle": 0,
"no-unused-expressions": 2,
"no-use-before-define": [2, "nofunc"],
"no-var": 2,
"no-with": 2,
"object-curly-spacing": 0,
"prefer-arrow-callback": 2,
"prefer-const": ["error", {"destructuring": "all"}],
"prefer-template": 1,
"semi-spacing": [1, {"before": false, "after": true}],
"space-before-blocks": 1,
"space-infix-ops": 1,
"space-unary-ops": [1, {"words": true, "nonwords": false}],
"strict": [2, "global"],
"require-await": ["error"],
"yoda": [1, "never"]
}
"root": true,
"extends": [ "exp" ]
}
5 changes: 3 additions & 2 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"bracketSpacing": false,
"bracketSpacing": true,
"printWidth": 120,
"arrowParens": "always",
"trailingComma": "none"
"trailingComma": "es5",
"semi": true
}
11 changes: 0 additions & 11 deletions eslint-config/hook-formatter.js

This file was deleted.

92 changes: 0 additions & 92 deletions eslint-config/index.js

This file was deleted.

36 changes: 0 additions & 36 deletions eslint-config/test-config.js

This file was deleted.

2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,5 @@ module.exports = {
sftp,
streams,
stripSchemaTag,
clone
clone,
};
10 changes: 3 additions & 7 deletions lib/helpers/case-body-helper.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
"use strict";

const ownerMapper = {
dn: "DNBO"
};
const ownerMapper = { dn: "DNBO" };

const sourceQueueMapper = {
dn: "DNBO"
};
const sourceQueueMapper = { dn: "DNBO" };

function createBackOfficeCaseBody(subject, description, namespace) {
return {
Expand All @@ -16,7 +12,7 @@ function createBackOfficeCaseBody(subject, description, namespace) {
origin: "Greenfield",
owner: ownerMapper[namespace],
sourceQueue: sourceQueueMapper[namespace],
subject
subject,
};
}

Expand Down
6 changes: 3 additions & 3 deletions lib/helpers/code-helper.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"use strict";

const config = require("exp-config");
const {livesInGcp} = config;
const { livesInGcp } = config;

const enumerate = (arr) => arr.map((value, index) => [index, value]);
const enumerate = (arr) => arr.map((value, index) => [ index, value ]);

const getUrl = (params) => {
const application = params.path.split("/").find(Boolean);
Expand All @@ -13,4 +13,4 @@ const getUrl = (params) => {
return `${params.baseUrl || config.proxyUrl}${params.path}`;
};

module.exports = {enumerate, getUrl};
module.exports = { enumerate, getUrl };
6 changes: 3 additions & 3 deletions lib/namespaces.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"use strict";

const postalDeliveryOnlyNamespaces = ["paf"];
const postalDeliveryOnlyNamespaces = [ "paf" ];

const commonNamespaces = ["dn", "expressen", "bnlo"];
const commonNamespaces = [ "dn", "expressen", "bnlo" ];

function postalDeliveryOnly(namespace) {
return postalDeliveryOnlyNamespaces.includes(namespace);
Expand All @@ -19,5 +19,5 @@ function getCommonNamespaces() {
module.exports = {
getCommonNamespaces,
isCommonNamespace,
postalDeliveryOnly
postalDeliveryOnly,
};
6 changes: 2 additions & 4 deletions lib/titles.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
"use strict";

const postalDeliveryAllowedTitles = ["dn", "paf", "plg"];
const postalDeliveryAllowedTitles = [ "dn", "paf", "plg" ];

function postalDeliveryAllowed(title) {
return postalDeliveryAllowedTitles.includes(title);
}

module.exports = {
postalDeliveryAllowed
};
module.exports = { postalDeliveryAllowed };
24 changes: 11 additions & 13 deletions lib/utils/email.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const config = require("exp-config");
const moment = require("moment");

async function sendEmailWithS3File(namespace, s3Path, emailParameters, context) {
const {rejectUnless, http, rejectIf} = context;
const { rejectUnless, http, rejectIf } = context;
rejectUnless(await s3.existsV2(s3Path), `need ${s3Path} to proceed`);

rejectUnless(namespace, "Missing namespace");
Expand All @@ -19,7 +19,7 @@ async function sendEmailWithS3File(namespace, s3Path, emailParameters, context)
const fileName = emailParameters.fileName || s3Path.split("/").pop();

const cache = [];
await streams.read({path: s3Path}, context, (o) => {
await streams.read({ path: s3Path }, context, (o) => {
cache.push(o);
});

Expand All @@ -44,29 +44,27 @@ async function sendEmailWithS3File(namespace, s3Path, emailParameters, context)
"\n",
`${buffer.toString("base64").replace(/([^\0]{76})/g, "$1\n")}`,
"\n",
`--${messageBoundary}--`
`--${messageBoundary}--`,
].join("\n");

const emailParams = {
RawMessage: {Data: mailContent.toString()}
};
const emailParams = { RawMessage: { Data: mailContent.toString() } };

let emailRes;
try {
emailRes = await ses.sendRawEmail(namespace, emailParams);
} catch (error) {
const fields = [
{title: "Filename", value: fileName, short: false},
{title: "s3Path", value: s3Path, short: false},
{title: "Time", value: moment(), short: false}
{ title: "Filename", value: fileName, short: false },
{ title: "s3Path", value: s3Path, short: false },
{ title: "Time", value: moment(), short: false },
];
slackIt(http, fields);
rejectIf(error, error.message);
}

const {MessageId: messageId} = emailRes;
const { MessageId: messageId } = emailRes;

return {type: "aws-ses__email", id: messageId};
return { type: "aws-ses__email", id: messageId };
}

async function slackIt(http, fields = []) {
Expand All @@ -82,8 +80,8 @@ async function slackIt(http, fields = []) {
fallback,
pretext: "AWS email sender",
color: "danger",
fields
}
fields,
},
});
}

Expand Down
Loading

0 comments on commit 6006679

Please sign in to comment.