Skip to content
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

chore: use @see jsdoc tag for inline comment links #1650

Merged
merged 4 commits into from
Sep 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,12 @@
"SUPPRESS_SUPPORT": 1
},
"ignore": [
"src/temp",
"test_resources"
"src/temp"
],
"verbose": true,
"watch": [
".env",
"src"
"src/**/!(*.test).*"
]
},
"devDependencies": {
Expand Down
4 changes: 3 additions & 1 deletion scripts/license-checker.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

const { promisify } = require("node:util");
const { init } = require("license-checker");
/** @type {string[]} */
// @ts-ignore: module is a JSON file
const copyLeftLicenses = require("spdx-copyleft");
const path = require("upath");

Expand All @@ -20,7 +22,7 @@ async function checkLicenses() {

/**
* List of deprecated copyleft license identifiers
* @see https://spdx.org/licenses/
* @see {@link https://spdx.org/licenses/ | SPDX License List}
*/
const deprecatedLicenseList = [
"AGPL-1.0",
Expand Down
25 changes: 5 additions & 20 deletions src/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ async function getConfig() {
// The maximum payload, in bytes, the server is allowed to accept
bodyLimit: env.REQ_BODY_MAX_BYTES || 10485760,
/**
* See https://fastify.io/docs/latest/Reference/Logging/
* and https://getpino.io/#/docs/api for logger options
* @see {@link https://fastify.io/docs/latest/Reference/Logging | Fastify logging}
* @see {@link https://getpino.io/#/docs/api | Pino API}
*/
logger: {
formatters: {
Expand Down Expand Up @@ -330,23 +330,6 @@ async function getConfig() {
],
},
},
htmltidy: {
/**
* Refer to http://api.html-tidy.org/tidy/tidylib_api_5.6.0/tidy_quickref.html for tidy options
*
* The following options have been turned on:
* - bare (remove Microsoft specific HTML and replace ` ` with spaces)
* - clean (replace legacy HTML tags)
* - dropProprietaryAttributes (remove proprietary attributes, such as Microsoft data binding attributes)
* - escapeCdata (convert <![CDATA[]]> sections to normal text)
* - sortAttributes (sort attributes in element in ascending alphabetic sort)
*/
bare: true,
clean: true,
dropProprietaryAttributes: true,
escapeCdata: true,
sortAttributes: "alpha",
},
poppler: {
binPath: env.POPPLER_BINARY_PATH
? path.normalizeSafe(env.POPPLER_BINARY_PATH)
Expand Down Expand Up @@ -415,7 +398,9 @@ async function getConfig() {
if (env.LOG_ROTATION_FILENAME) {
const logFile = path.normalizeTrim(env.LOG_ROTATION_FILENAME);

// Rotation options: https://github.com/rogerc/file-stream-rotator/#options
/**
* @see {@link https://github.com/rogerc/file-stream-rotator/#options | File stream rotator options}
*/
config.fastifyInit.logger.stream = getStream({
audit_file: path.joinSafe(path.dirname(logFile), ".audit.json"),
date_format: env.LOG_ROTATION_DATE_FORMAT || "YYYY-MM-DD",
Expand Down
6 changes: 4 additions & 2 deletions src/plugins/docx-to-html/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ async function plugin(server) {
const { value } = await convertToHtml(req.body);

/**
* Mammoth does not wrap the results inside <html> and <body> tags itself.
* Mammoth does not wrap the results inside <html> and <body> tags itself, so
* do that here.
*
* `fixUtf8` function replaces most common incorrectly converted
* Windows-1252 to UTF-8 results with HTML equivalents.
* Refer to https://i18nqa.com/debug/utf8-debug.html for more info
* @see {@link https://i18nqa.com/debug/utf8-debug.html | UTF-8 Encoding Debugging Chart}
*/
req.conversionResults.body = new JSDOM(
`<!DOCTYPE html>
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/pdf-to-html/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ async function plugin(server, options) {
/**
* `fixUtf8` function replaces most common incorrectly converted
* Windows-1252 to UTF-8 results with HTML equivalents.
* Refer to https://i18nqa.com/debug/utf8-debug.html for more info
* @see {@link https://i18nqa.com/debug/utf8-debug.html | UTF-8 Encoding Debugging Chart}
*/
req.conversionResults.body = fixUtf8(dom.serialize());
res.type(
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/pdf-to-txt/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ async function plugin(server, options) {
/**
* `fixUtf8` function replaces most common incorrectly converted
* Windows-1252 to UTF-8 results with HTML equivalents.
* Refer to https://i18nqa.com/debug/utf8-debug.html for more info
* @see {@link https://i18nqa.com/debug/utf8-debug.html | UTF-8 Encoding Debugging Chart}
*/
req.conversionResults.body = fixUtf8(dom.serialize());
}
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/rtf-to-html/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ async function plugin(server, options) {
/**
* `fixUtf8` function replaces most common incorrectly converted
* Windows-1252 to UTF-8 results with HTML equivalents.
* Refer to https://i18nqa.com/debug/utf8-debug.html for more info
* @see {@link https://i18nqa.com/debug/utf8-debug.html | UTF-8 Encoding Debugging Chart}
*/
req.conversionResults.body = fixUtf8(dom.serialize());
} catch (err) {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/shared-schemas/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ async function plugin(server) {
/**
* NOTE: `.definition()` definitions have been replaced with `.prop()` properties, and
* `.id()` ids removed due to definitions breaking in v4.12.1 of fastify-swagger.
* See https://github.com/fastify/fastify-swagger/issues/524
* @see {@link https://github.com/fastify/fastify-swagger/issues/524 | fastify-swagger Issue #524}
*/

// Response schemas
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/tidy-css/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ async function plugin(server) {
/**
* Font family names containing any non-alphabetical characters
* other than hyphens should be quoted.
* See https://w3.org/TR/css-fonts-4/#family-name-syntax
* @see {@link https://w3.org/TR/css-fonts-4/#family-name-syntax | Syntax of <family-name>}
*/
if (styleRule.style["font-family"]) {
const fonts = styleRule.style["font-family"].split(",");
Expand Down
9 changes: 5 additions & 4 deletions src/plugins/tidy-html/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ const tidyP = promisify(tidy);
*/
async function plugin(server) {
/**
* Refer to https://api.html-tidy.org/tidy/tidylib_api_5.8.0/tidy_quickref.html for tidy options
*
* The following options have been turned on:
* - bare (replace smart quotes and em dashes with ASCII and replace `&nbsp;` with spaces)
* - bare (remove Microsoft specific HTML and replace `&nbsp;` with spaces)
* - clean (replace legacy HTML tags)
* - dropProprietaryAttributes (remove proprietary attributes, such as Microsoft data binding attributes)
* - escapeCdata (convert <![CDATA[]]> sections to normal text)
* @see {@link https://api.html-tidy.org/tidy/tidylib_api_5.8.0/tidy_quickref.html | HTMLTidy2 options}
*/
const htmlTidyConfig = {
bare: true,
Expand All @@ -33,7 +32,9 @@ async function plugin(server) {
escapeCdata: true,
};

// Refer to https://github.com/terser/html-minifier-terser#options-quick-reference for options
/**
* @see {@link https://github.com/terser/html-minifier-terser#options-quick-reference | HTMLMinifier options}
*/
const htmlMinifyConfig = {
collapseWhitespace: true,
decodeEntities: true,
Expand Down
7 changes: 3 additions & 4 deletions src/routes/admin/healthcheck/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ const S = require("fluent-json-schema").default;
const tags = ["System administration"];

/**
* Fastify uses AJV for JSON Schema Validation,
* see https://fastify.io/docs/latest/Reference/Validation-and-Serialization/
*
* Fastify uses AJV for JSON Schema Validation.
* Input validation protects against XSS, HPP, prototype pollution,
* and most other injection attacks
* and most other injection attacks.
* @see {@link https://fastify.io/docs/latest/Reference/Validation-and-Serialization | Fastify Validation and Serialization}
*/
const healthcheckGetSchema = {
tags,
Expand Down
5 changes: 2 additions & 3 deletions src/routes/doc/txt/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ const S = require("fluent-json-schema").default;
const tags = ["DOC", "DOT"];

/**
* Fastify uses AJV for JSON Schema Validation,
* see https://fastify.io/docs/latest/Reference/Validation-and-Serialization/
*
* Fastify uses AJV for JSON Schema Validation.
* Input validation protects against XSS, HPP, prototype pollution,
* and most other injection attacks.
* @see {@link https://fastify.io/docs/latest/Reference/Validation-and-Serialization | Fastify Validation and Serialization}
*/
const docToTxtPostSchema = {
tags,
Expand Down
5 changes: 4 additions & 1 deletion src/routes/docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
</head>
<body>
<script>
// Redoc no longer supports IE, see https://github.com/Redocly/redoc/issues/1936
/**
* @description Detect IE and display message if detected.
* @see {@link https://github.com/Redocly/redoc/issues/1936 | Redoc Issue #1936}
*/
if (window.document.documentMode) {
var p = document.createElement("p");
p.innerHTML =
Expand Down
7 changes: 3 additions & 4 deletions src/routes/docs/openapi/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
const S = require("fluent-json-schema").default;

/**
* Fastify uses AJV for JSON Schema Validation,
* see https://fastify.io/docs/latest/Reference/Validation-and-Serialization/
*
* Fastify uses AJV for JSON Schema Validation.
* Input validation protects against XSS, HPP, prototype pollution,
* and most other injection attacks
* and most other injection attacks.
* @see {@link https://fastify.io/docs/latest/Reference/Validation-and-Serialization | Fastify Validation and Serialization}
*/
const docsOpenapiGetSchema = {
hide: true,
Expand Down
5 changes: 4 additions & 1 deletion src/routes/docs/route.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ exports[`Docs route GET requests Returns HTML 1`] = `
</head>
<body>
<script>
// Redoc no longer supports IE, see https://github.com/Redocly/redoc/issues/1936
/**
* @description Detect IE and display message if detected.
* @see {@link https://github.com/Redocly/redoc/issues/1936 | Redoc Issue #1936}
*/
if (window.document.documentMode) {
var p = document.createElement("p");
p.innerHTML =
Expand Down
7 changes: 3 additions & 4 deletions src/routes/docs/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
const S = require("fluent-json-schema").default;

/**
* Fastify uses AJV for JSON Schema Validation,
* see https://fastify.io/docs/latest/Reference/Validation-and-Serialization/
*
* Fastify uses AJV for JSON Schema Validation.
* Input validation protects against XSS, HPP, prototype pollution,
* and most other injection attacks
* and most other injection attacks.
* @see {@link https://fastify.io/docs/latest/Reference/Validation-and-Serialization | Fastify Validation and Serialization}
*/
const docsGetSchema = {
hide: true,
Expand Down
7 changes: 3 additions & 4 deletions src/routes/docx/html/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ const S = require("fluent-json-schema").default;
const tags = ["DOCM", "DOCX", "DOTM", "DOTX"];

/**
* Fastify uses AJV for JSON Schema Validation,
* see https://fastify.io/docs/latest/Reference/Validation-and-Serialization/
*
* Fastify uses AJV for JSON Schema Validation.
* Input validation protects against XSS, HPP, prototype pollution,
* and most other injection attacks
* and most other injection attacks.
* @see {@link https://fastify.io/docs/latest/Reference/Validation-and-Serialization | Fastify Validation and Serialization}
*/
const docxToHtmlPostSchema = {
tags,
Expand Down
5 changes: 2 additions & 3 deletions src/routes/docx/txt/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ const S = require("fluent-json-schema").default;
const tags = ["DOCM", "DOCX", "DOTM", "DOTX"];

/**
* Fastify uses AJV for JSON Schema Validation,
* see https://fastify.io/docs/latest/Reference/Validation-and-Serialization/
*
* Fastify uses AJV for JSON Schema Validation.
* Input validation protects against XSS, HPP, prototype pollution,
* and most other injection attacks.
* @see {@link https://fastify.io/docs/latest/Reference/Validation-and-Serialization | Fastify Validation and Serialization}
*/
const docxToTxtPostSchema = {
tags,
Expand Down
5 changes: 2 additions & 3 deletions src/routes/html/txt/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ const S = require("fluent-json-schema").default;
const tags = ["HTML"];

/**
* Fastify uses AJV for JSON Schema Validation,
* see https://fastify.io/docs/latest/Reference/Validation-and-Serialization/
*
* Fastify uses AJV for JSON Schema Validation.
* Input validation protects against XSS, HPP, prototype pollution,
* and most other injection attacks.
* @see {@link https://fastify.io/docs/latest/Reference/Validation-and-Serialization | Fastify Validation and Serialization}
*/
const htmlToTxtPostSchema = {
tags,
Expand Down
7 changes: 3 additions & 4 deletions src/routes/pdf/html/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ const S = require("fluent-json-schema").default;
const tags = ["PDF"];

/**
* Fastify uses AJV for JSON Schema Validation,
* see https://fastify.io/docs/latest/Reference/Validation-and-Serialization/
*
* Fastify uses AJV for JSON Schema Validation.
* Input validation protects against XSS, HPP, prototype pollution,
* and most other injection attacks
* and most other injection attacks.
* @see {@link https://fastify.io/docs/latest/Reference/Validation-and-Serialization | Fastify Validation and Serialization}
*/
const pdfToHtmlPostSchema = {
tags,
Expand Down
7 changes: 3 additions & 4 deletions src/routes/pdf/txt/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ const S = require("fluent-json-schema").default;
const tags = ["PDF"];

/**
* Fastify uses AJV for JSON Schema Validation,
* see https://fastify.io/docs/latest/Reference/Validation-and-Serialization/
*
* Fastify uses AJV for JSON Schema Validation.
* Input validation protects against XSS, HPP, prototype pollution,
* and most other injection attacks
* and most other injection attacks.
* @see {@link https://fastify.io/docs/latest/Reference/Validation-and-Serialization | Fastify Validation and Serialization}
*/
const pdfToTxtPostSchema = {
tags,
Expand Down
7 changes: 3 additions & 4 deletions src/routes/rtf/html/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ const S = require("fluent-json-schema").default;
const tags = ["RTF"];

/**
* Fastify uses AJV for JSON Schema Validation,
* see https://fastify.io/docs/latest/Reference/Validation-and-Serialization/
*
* Fastify uses AJV for JSON Schema Validation.
* Input validation protects against XSS, HPP, prototype pollution,
* and most other injection attacks
* and most other injection attacks.
* @see {@link https://fastify.io/docs/latest/Reference/Validation-and-Serialization | Fastify Validation and Serialization}
*/
const rtfToHtmlPostSchema = {
tags,
Expand Down
7 changes: 3 additions & 4 deletions src/routes/rtf/txt/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ const S = require("fluent-json-schema").default;
const tags = ["RTF"];

/**
* Fastify uses AJV for JSON Schema Validation,
* see https://fastify.io/docs/latest/Reference/Validation-and-Serialization/
*
* Fastify uses AJV for JSON Schema Validation.
* Input validation protects against XSS, HPP, prototype pollution,
* and most other injection attacks
* and most other injection attacks.
* @see {@link https://fastify.io/docs/latest/Reference/Validation-and-Serialization | Fastify Validation and Serialization}
*/
const rtfToTxtPostSchema = {
tags,
Expand Down
7 changes: 5 additions & 2 deletions src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ async function plugin(server, config) {
// Opt-out of Google's Topics advertising-surveillance API
.register(flocOff)

// Use Helmet to set response security headers: https://helmetjs.github.io/
/**
* Use Helmet to set response security headers.
* @see {@link https://helmetjs.github.io | Helmet}
*/
.register(helmet, config.helmet)

// Utility functions and error handlers
Expand Down Expand Up @@ -116,7 +119,7 @@ async function plugin(server, config) {
/**
* Encapsulate plugins and routes into a secured child context, so that admin and
* docs routes do not inherit the bearer token auth plugin.
* See https://fastify.io/docs/latest/Reference/Encapsulation/ for more info
* @see {@link https://fastify.io/docs/latest/Reference/Encapsulation | Fastify Encapsulation}
*/
.register(async (securedContext) => {
if (config.bearerTokenAuthKeys) {
Expand Down
4 changes: 2 additions & 2 deletions src/server.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1086,8 +1086,8 @@ describe("Server deployment", () => {
"Docsmith | Documentation"
);
/**
* Checks redoc has not rendered an error component:
* https://github.com/Redocly/redoc/blob/main/src/components/ErrorBoundary.tsx
* Checks redoc has not rendered an error component.
* @see {@link https://github.com/Redocly/redoc/blob/main/src/components/ErrorBoundary.tsx | Redoc ErrorBoundary component}
*/
const heading = page.locator("h1 >> nth=0");
await heading.waitFor();
Expand Down
5 changes: 4 additions & 1 deletion src/server.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ exports[`Server deployment API documentation Content /docs route Returns HTML 1`
</head>
<body>
<script>
// Redoc no longer supports IE, see https://github.com/Redocly/redoc/issues/1936
/**
* @description Detect IE and display message if detected.
* @see {@link https://github.com/Redocly/redoc/issues/1936 | Redoc Issue #1936}
*/
if (window.document.documentMode) {
var p = document.createElement("p");
p.innerHTML =
Expand Down
Loading