Skip to content
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
15 changes: 12 additions & 3 deletions config/eslint/custom-rules.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import stylistic from "@stylistic/eslint-plugin";
import jsdoc from "eslint-plugin-jsdoc";

export default {
files: ["**/*.{js,mjs,cjs,ts,tsx}"],
plugins: {
jsdoc
jsdoc,
"@stylistic": stylistic
},
rules: {
"@typescript-eslint/no-unused-vars": "warn",
Expand Down Expand Up @@ -68,14 +70,21 @@ export default {
next: "*"
}
],
"lines-around-comment": [
// The @stylistic variant understands TypeScript bodies (interfaces,
// enums, type literals, modules), so it does not fight Prettier there.
"lines-around-comment": "off",
"@stylistic/lines-around-comment": [
"warn",
{
beforeBlockComment: true,
allowBlockStart: true,
allowObjectStart: true,
allowArrayStart: true,
allowClassStart: true
allowClassStart: true,
allowInterfaceStart: true,
allowEnumStart: true,
allowTypeStart: true,
allowModuleStart: true
}
],
"max-depth": ["warn", 4],
Expand Down
10 changes: 8 additions & 2 deletions config/eslint/scripts.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
/**
* Overrides for the maintenance scripts under `scripts/`.
* Overrides for the maintenance scripts under `scripts/` and the authoring
* inputs they load from `docs/` (`docs/content/authored/*.mjs`).
*
* These are build and integration-test files rather than library sources:
* they are plain JavaScript, they run on a console, and the Apps Script ones
* reach for the library through the shared global scope.
*/
export default {
files: ["scripts/**/*.{js,mjs,cjs}"],
files: ["scripts/**/*.{js,mjs,cjs}", "docs/**/*.{js,mjs,cjs}"],
rules: {
// A build script reports its progress; that is its interface.
"no-console": "off",
Expand All @@ -17,6 +18,11 @@ export default {
// A bundler exists to read and write computed paths.
"security/detect-non-literal-fs-filename": "off",

// The patterns parse repository sources and are built from constants
// in these files, never from outside input.
"security/detect-unsafe-regex": "off",
"security/detect-non-literal-regexp": "off",

// The lookups here are into objects these files declare themselves.
"security/detect-object-injection": "off"
}
Expand Down
6 changes: 5 additions & 1 deletion config/eslint/security.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ export default {
security
},
rules: {
...security.configs.recommended.rules
...security.configs.recommended.rules,

// Flags every `obj[key]`. The keys here come from code, not from request
// input, and CodeQL already covers prototype pollution.
"security/detect-object-injection": "off"
}
};
8 changes: 6 additions & 2 deletions docs/content/authored/_entry.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/** Assembles one prose entry from a table keyed by field, then by language. */
/**
* Assembles one prose entry from a table keyed by field, then by language.
*/

const LANGUAGE_CODES = ["en", "ru", "uk", "de", "fr"];

Expand Down Expand Up @@ -28,7 +30,9 @@ export function entry({
return result;
}

/** Short-hand for a value that is only described in one sentence per language. */
/**
* Short-hand for a value that is only described in one sentence per language.
*/
export function code(body) {
return [{ body: ["```javascript", body, "```"].join("\n") }];
}
4 changes: 3 additions & 1 deletion docs/content/authored/a1.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/** Prose for the A1-notation and column-letter helpers. */
/**
* Prose for the A1-notation and column-letter helpers.
*/

import { code, entry } from "./_entry.mjs";

Expand Down
4 changes: 3 additions & 1 deletion docs/content/authored/html.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/** Prose for the HTML and XML helpers. */
/**
* Prose for the HTML and XML helpers.
*/

import { code, entry } from "./_entry.mjs";

Expand Down
4 changes: 3 additions & 1 deletion docs/content/authored/last-functions.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/** Prose for the last of the Apps Script helpers. */
/**
* Prose for the last of the Apps Script helpers.
*/

import { code, entry } from "./_entry.mjs";

Expand Down
4 changes: 3 additions & 1 deletion docs/content/authored/object.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/** Prose for the object helpers and the JSON pair. */
/**
* Prose for the object helpers and the JSON pair.
*/

import { code, entry } from "./_entry.mjs";

Expand Down
4 changes: 3 additions & 1 deletion docs/content/authored/path-misc.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/** Prose for the path helpers and the odds and ends. */
/**
* Prose for the path helpers and the odds and ends.
*/

import { code, entry } from "./_entry.mjs";

Expand Down
8 changes: 6 additions & 2 deletions docs/content/authored/rest.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
/** Prose for the remaining functions and classes. */
/**
* Prose for the remaining functions and classes.
*/

import { code, entry } from "./_entry.mjs";

const NONE = { en: "", ru: "", uk: "", de: "", fr: "" };

/** A shorter form for entries that need one paragraph and no parameters table beyond the obvious. */
/**
* A shorter form for entries that need one paragraph and no parameters table beyond the obvious.
*/
function simple({
seeAlso,
examples,
Expand Down
4 changes: 3 additions & 1 deletion docs/content/authored/sheet-conditional.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/** Prose for the conditional row and column operations, and the lookups. */
/**
* Prose for the conditional row and column operations, and the lookups.
*/

import { code, entry } from "./_entry.mjs";

Expand Down
4 changes: 3 additions & 1 deletion docs/content/authored/sheet-guards.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/** Prose for the two-argument grid-range guards, the admin family and the leftovers. */
/**
* Prose for the two-argument grid-range guards, the admin family and the leftovers.
*/

import { code, entry } from "./_entry.mjs";

Expand Down
4 changes: 3 additions & 1 deletion docs/content/authored/sheet-read.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/** Prose for reading a sheet, its schema and its formulas. */
/**
* Prose for reading a sheet, its schema and its formulas.
*/

import { code, entry } from "./_entry.mjs";

Expand Down
4 changes: 3 additions & 1 deletion docs/content/authored/sheet-write.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/** Prose for the row and column operations on a sheet. */
/**
* Prose for the row and column operations on a sheet.
*/

import { code, entry } from "./_entry.mjs";

Expand Down
4 changes: 3 additions & 1 deletion docs/content/authored/string.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/** Prose for the string helpers. Example code is shared by every language. */
/**
* Prose for the string helpers. Example code is shared by every language.
*/

export const FUNCTIONS = {
toCamelCase: {
Expand Down
4 changes: 3 additions & 1 deletion docs/content/authored/string2.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/** Prose for the remaining string helpers. */
/**
* Prose for the remaining string helpers.
*/

const CASE_OPTION = {
en: "`trim` trims the string and collapses runs of whitespace into single spaces.",
Expand Down
8 changes: 6 additions & 2 deletions docs/content/authored/string3.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
/** Prose for the remaining string helpers: escaping, templating and versions. */
/**
* Prose for the remaining string helpers: escaping, templating and versions.
*/

const L = ["en", "ru", "uk", "de", "fr"];

/** Assembles one entry from a table keyed by field, then by language. */
/**
* Assembles one entry from a table keyed by field, then by language.
*/
export function entry({
examples,
seeAlso,
Expand Down
4 changes: 3 additions & 1 deletion docs/content/authored/time-json.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/** Prose for the JSON pair, the time helpers and the path helpers. */
/**
* Prose for the JSON pair, the time helpers and the path helpers.
*/

import { code, entry } from "./_entry.mjs";

Expand Down
4 changes: 3 additions & 1 deletion docs/content/authored/types.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/** Prose for the types, interfaces and classes the package exports. */
/**
* Prose for the types, interfaces and classes the package exports.
*/

import { code, entry } from "./_entry.mjs";

Expand Down
61 changes: 61 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
"@eslint/js": "^9.39.2",
"@eslint/json": "^0.14.0",
"@eslint/markdown": "^7.5.1",
"@stylistic/eslint-plugin": "^6.0.1",
"@types/eslint-plugin-security": "^3.0.1",
"@types/google-apps-script": "^2.0.15",
"@types/node": "^25.0.9",
Expand Down
5 changes: 4 additions & 1 deletion scripts/docs/author-batch.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ for (const file of readdirSync(AUTHORED).sort()) {
const dir = join(ROOT, "docs/content", language.code, "functions");

mkdirSync(dir, { recursive: true });
writeFileSync(join(dir, `${name}.json`), `${JSON.stringify(content, null, 2)}\n`);

const json = JSON.stringify(content, null, 2);

writeFileSync(join(dir, `${name}.json`), `${json}\n`);
written += 1;
}
}
Expand Down
5 changes: 4 additions & 1 deletion scripts/docs/author-exceptions.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,10 @@ for (const [name, data] of Object.entries(CLASSES)) {
const dir = join(ROOT, "docs/content", language.code, "functions");

mkdirSync(dir, { recursive: true });
writeFileSync(join(dir, `${name}.json`), `${JSON.stringify(content, null, 2)}\n`);

const json = JSON.stringify(content, null, 2);

writeFileSync(join(dir, `${name}.json`), `${json}\n`);
written += 1;
}
}
Expand Down
Loading
Loading