Skip to content

Commit

Permalink
chore: update linting and type-helper.d.ts (speced#4619)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoscaceres authored Dec 22, 2023
1 parent a8d8f8c commit 5305ebf
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"extends": ["eslint:recommended", "plugin:prettier/recommended"],
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 2020
"ecmaVersion": 2023
},
"rules": {
"import/extensions": ["error", "always", {
Expand Down
2 changes: 0 additions & 2 deletions src/core/base-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ export async function runAll(plugs) {
runnables.forEach(
plug => !plug.name && console.warn("Plugin lacks name:", plug)
);
respecConfig.state = {};
await executePreparePass(runnables, respecConfig);
await executeRunPass(runnables, respecConfig);
respecConfig.state = {};
pub("plugins-done", respecConfig);

await postProcess(respecConfig);
Expand Down
67 changes: 66 additions & 1 deletion src/type-helper.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ interface AxeViolation {
nodes: { failureSummary: string; element: HTMLElement }[];
}

declare var respecConfig: any;
declare var respecConfig: Conf;
interface Window {
respecVersion: string;
respecUI: {
Expand Down Expand Up @@ -110,15 +110,42 @@ interface BiblioData {
etAl?: boolean;
expires: number;
}

type ProcessFn = (config: Conf, doc: Document) => Promise<void> | void;

/** Configuration object type */
interface Conf {
authors?: Person[];
/** Object containing bibliographic data */
biblio: Record<string, BiblioData>;
editors?: Person[];
formerEditors?: Person[];
/** Set of informative references */
informativeReferences: Set<string>;
localBiblio?: Record<string, BiblioData>;
/** Set of normative references */
normativeReferences: Set<string>;
shortName: string;
preProcess?: ProcessFn[];
postProcess?: ProcessFn[];
afterEnd?: ProcessFn;
specStatus?: string;
wgId?: string;
noToc: boolean;

/** Indicates whether the document is a preview */
isPreview?: boolean;
/** The pull request number, if applicable */
prNumber?: number;
/** The URL of the pull request, if applicable */
prUrl?: string;
/** The GitHub configuration object */
github?: {
/** The URL of the GitHub repository */
repoURL: string;
};
/** The title of the document */
title?: string;
}

type LicenseInfo = {
Expand Down Expand Up @@ -159,14 +186,18 @@ type ResourceHintOption = {
dontRemove?: boolean;
};

/** Represents a request to the core/xref module */
module "core/xref" {
import { IDBPDatabase, DBSchema } from "idb";

/** Represents a single request entry */
export interface RequestEntry {
term: string;
id: string;
types: string[];
/** Spec URLs to restrict the search to */
specs?: string[][];
/** The context in which the term appears */
for?: string;
}

Expand Down Expand Up @@ -244,6 +275,40 @@ type DefinitionValidator = (
pluginName: string
) => boolean;

declare class RespecError extends Error {
constructor(
message: string,
pluginName: string,
options: {
isWarning: boolean;
elements?: HTMLElement[];
title?: string;
}
);
toJSON(): {
message: string;
name: string;
plugin: string;
hint?: string;
elements?: any[];
title?: string;
details?: any;
stack?: string;
};
}

/**
* Localization strings for different languages.
*
*/
type LocalizationStrings = {
de: Record<string, string>;
en: Record<string, string>;
ja: Record<string, string>;
nl: Record<string, string>;
zh: Record<string, string>;
};

interface LinkProps {
href: string;
title: string;
Expand Down

0 comments on commit 5305ebf

Please sign in to comment.