Skip to content
This repository has been archived by the owner on Jan 28, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1485 from Fdawgs/chore/try
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdawgs committed Oct 8, 2023
2 parents cc334b9 + cf6aebe commit c94f8d4
Show file tree
Hide file tree
Showing 22 changed files with 46 additions and 28 deletions.
5 changes: 5 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports = {
},
extends: [
"airbnb-base",
"plugin:@eslint-community/eslint-comments/recommended",
"plugin:jsdoc/recommended",
"plugin:promise/recommended",
"plugin:regexp/recommended",
Expand Down Expand Up @@ -49,13 +50,17 @@ module.exports = {
],
root: true,
rules: {
"@eslint-community/eslint-comments/disable-enable-pair": "off",
"@eslint-community/eslint-comments/no-unused-disable": "error",
"@eslint-community/eslint-comments/require-description": "error",
"import/no-extraneous-dependencies": "error",
"jsdoc/check-syntax": "error",
"jsdoc/require-hyphen-before-param-description": "error",
"no-multiple-empty-lines": ["error", { max: 1 }],
"prefer-destructuring": ["error", { object: true, array: false }],
"promise/prefer-await-to-callbacks": "warn",
"promise/prefer-await-to-then": "warn",
"security/detect-object-injection": "off",
strict: ["error", "global"],
},
};
1 change: 1 addition & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ updates:
- "@commitlint*"
eslint:
patterns:
- "@eslint-community*"
- "eslint*"
fastify-core:
patterns:
Expand Down
1 change: 1 addition & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// for the documentation about the extensions.json format
"recommendations": [
"dbaeumer.vscode-eslint",
"eamodio.gitlens",
"esbenp.prettier-vscode",
"ms-azuretools.vscode-docker",
"redhat.vscode-xml",
Expand Down
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"files.eol": "\n",
"gitlens.telemetry.enabled": false,
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
Expand Down
2 changes: 1 addition & 1 deletion jsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Uncomment as and when needed
// "checkJs": true,
// "strict": true,
"lib": ["ES2023"],
"lib": ["ES2022"],
"module": "NodeNext",
"moduleResolution": "NodeNext",
"resolveJsonModule": true,
Expand Down
2 changes: 1 addition & 1 deletion migrations/mssql/004.do.create_tables.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";

// eslint-disable-next-line func-names
// eslint-disable-next-line func-names -- Style required by Postgrator
module.exports.generateSql = function () {
return `IF OBJECT_ID('access.tokens', 'U') IS NULL CREATE TABLE access.tokens
(
Expand Down
2 changes: 1 addition & 1 deletion migrations/mssql/005.do.create_records.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";

// eslint-disable-next-line func-names
// eslint-disable-next-line func-names -- Style required by Postgrator
module.exports.generateSql = function () {
return `INSERT INTO ${process.env.DB_PATIENT_PREFERENCES_TYPE_TABLE}
(preference_type)
Expand Down
2 changes: 1 addition & 1 deletion migrations/postgres/001.do.create_tables.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";

// eslint-disable-next-line func-names
// eslint-disable-next-line func-names -- Style required by Postgrator
module.exports.generateSql = function () {
return `CREATE SCHEMA IF NOT EXISTS access;
Expand Down
2 changes: 1 addition & 1 deletion migrations/postgres/002.do.create_records.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";

// eslint-disable-next-line func-names
// eslint-disable-next-line func-names -- Style required by Postgrator
module.exports.generateSql = function () {
return `INSERT INTO ${
process.env.DB_PATIENT_PREFERENCES_TYPE_TABLE ||
Expand Down
17 changes: 17 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,8 @@
},
"nodemonConfig": {
"env": {
"NODE_ENV": "development",
"SUPPRESS_SUPPORT": 1
"NODE_ENV": "development"
},
"verbose": true,
"watch": [
".env",
"src/**/!(*.test).*"
Expand All @@ -79,6 +77,7 @@
"devDependencies": {
"@commitlint/cli": "^17.7.2",
"@commitlint/config-conventional": "^17.7.0",
"@eslint-community/eslint-plugin-eslint-comments": "^4.1.0",
"@types/jest": "^29.5.5",
"autocannon": "^7.12.0",
"esbuild": "^0.19.4",
Expand Down
3 changes: 0 additions & 3 deletions scripts/license-checker.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/* eslint-disable security/detect-object-injection */
/* eslint-disable security-node/detect-crlf */

"use strict";

const { promisify } = require("node:util");
Expand Down
2 changes: 1 addition & 1 deletion src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const migrate = require("./migrate");
*/
async function main() {
process.on("unhandledRejection", (err) => {
// eslint-disable-next-line no-console
// eslint-disable-next-line no-console -- Pino logger may not be initialised
console.error(err);
process.exit(1);
});
Expand Down
3 changes: 2 additions & 1 deletion src/config/config.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable security/detect-non-literal-fs-filename -- Test filenames are not user-provided */

"use strict";

const { unlink } = require("node:fs/promises");
Expand All @@ -17,7 +19,6 @@ describe("Configuration", () => {
dot: true,
});

// eslint-disable-next-line security/detect-non-literal-fs-filename
await Promise.all(files.map((file) => unlink(file)));
});

Expand Down
6 changes: 3 additions & 3 deletions src/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,9 @@ async function getConfig() {
if (env.HTTPS_SSL_CERT_PATH && env.HTTPS_SSL_KEY_PATH) {
try {
config.fastifyInit.https = {
// eslint-disable-next-line security/detect-non-literal-fs-filename
// eslint-disable-next-line security/detect-non-literal-fs-filename -- Filename not user-provided
cert: await readFile(normalizeTrim(env.HTTPS_SSL_CERT_PATH)),
// eslint-disable-next-line security/detect-non-literal-fs-filename
// eslint-disable-next-line security/detect-non-literal-fs-filename -- Filename not user-provided
key: await readFile(normalizeTrim(env.HTTPS_SSL_KEY_PATH)),
};
} catch (err) {
Expand All @@ -338,7 +338,7 @@ async function getConfig() {
try {
config.fastifyInit.https = {
passphrase: env.HTTPS_PFX_PASSPHRASE,
// eslint-disable-next-line security/detect-non-literal-fs-filename
// eslint-disable-next-line security/detect-non-literal-fs-filename -- Filename not user-provided
pfx: await readFile(normalizeTrim(env.HTTPS_PFX_FILE_PATH)),
};
} catch (err) {
Expand Down
2 changes: 1 addition & 1 deletion src/migrate.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-console */
/* eslint-disable no-console -- CLI script */

"use strict";

Expand Down
2 changes: 0 additions & 2 deletions src/plugins/clean-object/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable security/detect-object-injection */

"use strict";

const fp = require("fastify-plugin");
Expand Down
1 change: 0 additions & 1 deletion src/plugins/convert-date-param-operator/plugin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ describe("Convert-Date-Param-Operator plugin", () => {
body: `${key}`,
})
.then((response) => {
// eslint-disable-next-line security/detect-object-injection
expect(response.body).toStrictEqual(values[key]);
expect(response.statusCode).toBe(200);

Expand Down
6 changes: 3 additions & 3 deletions src/routes/admin/access/bearer-token/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ const tags = ["System administration"];
* converts this from a RegExp to a String
*/
const dateTimeSearchPattern =
// eslint-disable-next-line security/detect-unsafe-regex
/^(?:ap|eb|eq|ge|gt|le|lt|ne|sa)?\d{4}-[01]\d-[0-3]\d(?:T(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:Z|[+-]\d{2}(?::?\d{2})?))?$/u;
// eslint-disable-next-line security/detect-unsafe-regex -- False positive
/^(?:ap|e[bq]|g[et]|l[et]|ne|sa)?\d{4}-[01]\d-[0-3]\d(?:T(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:Z|[+-]\d{2}(?::?\d{2})?))?$/u;

const dateTimeSearchPatternExamples = [
"2022-01-13",
Expand Down Expand Up @@ -403,7 +403,7 @@ const accessPostSchema = {
"2022-01-13T00:00:01.001Z",
])
.pattern(
// eslint-disable-next-line security/detect-unsafe-regex
// eslint-disable-next-line security/detect-unsafe-regex -- False positive
/^\d{4}-\d{2}-\d{2}(?:t\d{2}:\d{2}:\d{2})?(?:.\d{3})?z?$/imu
)
)
Expand Down
4 changes: 2 additions & 2 deletions src/routes/documents/register/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ const tags = ["Documents"];
* converts this from a RegExp to a String
*/
const dateTimeSearchPattern =
// eslint-disable-next-line security/detect-unsafe-regex
/^(?:ap|eb|eq|ge|gt|le|lt|ne|sa)?\d{4}-[01]\d-[0-3]\d(?:T(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:Z|[+-]\d{2}(?::?\d{2})?))?$/u;
// eslint-disable-next-line security/detect-unsafe-regex -- False positive
/^(?:ap|e[bq]|g[et]|l[et]|ne|sa)?\d{4}-[01]\d-[0-3]\d(?:T(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:Z|[+-]\d{2}(?::?\d{2})?))?$/u;

const dateTimeSearchPatternExamples = [
"2022-01-13",
Expand Down
2 changes: 1 addition & 1 deletion src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ async function plugin(server, config) {
)

// Errors thrown by routes and plugins are caught here
// eslint-disable-next-line promise/prefer-await-to-callbacks
// eslint-disable-next-line promise/prefer-await-to-callbacks -- False positive
.setErrorHandler(async (err, _req, res) => {
/**
* Catch 5xx errors, log them, and return a generic 500
Expand Down
3 changes: 1 addition & 2 deletions src/utils/escape-single-quotes/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* eslint-disable jsdoc/require-param-description */
/* eslint-disable security/detect-object-injection */
/* eslint-disable jsdoc/require-param-description -- Params are self-explanatory */

"use strict";

Expand Down

0 comments on commit c94f8d4

Please sign in to comment.