diff --git a/deno_dist/browser.ts b/deno_dist/browser.ts index bd9425a..efb2e48 100644 --- a/deno_dist/browser.ts +++ b/deno_dist/browser.ts @@ -6,6 +6,6 @@ export { templates } from "./containers.ts"; export { config, config as defaultConfig, - getConfig, configure, + getConfig, } from "./config.ts"; diff --git a/deno_dist/config.ts b/deno_dist/config.ts index 3ac6092..21a8296 100644 --- a/deno_dist/config.ts +++ b/deno_dist/config.ts @@ -170,8 +170,8 @@ function getConfig(override: PartialConfig, baseConfig?: EtaConfig): EtaConfig { /** Update Eta's base config */ -function configure(options: PartialConfig) { +function configure(options: PartialConfig): Partial { return copyProps(config, options); } -export { config, getConfig, configure }; +export { config, configure, getConfig }; diff --git a/deno_dist/err.ts b/deno_dist/err.ts index 2be82af..377228e 100644 --- a/deno_dist/err.ts +++ b/deno_dist/err.ts @@ -36,7 +36,7 @@ EtaErr.prototype = Object.create(Error.prototype, { * Throws an EtaErr with a nicely formatted error and message showing where in the template the error occurred. */ -export function ParseErr(message: string, str: string, indx: number) { +export function ParseErr(message: string, str: string, indx: number): void { var whitespace = str.slice(0, indx).split(/\n/); var lineNo = whitespace.length; diff --git a/deno_dist/file-handlers.ts b/deno_dist/file-handlers.ts index bd70c9a..6659c80 100644 --- a/deno_dist/file-handlers.ts +++ b/deno_dist/file-handlers.ts @@ -11,8 +11,8 @@ import { promiseImpl } from "./polyfills.ts"; import type { EtaConfig, - PartialConfig, EtaConfigWithFilename, + PartialConfig, } from "./config.ts"; import type { TemplateFunction } from "./compile.ts"; @@ -193,16 +193,20 @@ function renderFile( data: DataObj, config?: PartialConfig, cb?: CallbackFn, -): any; +): (Promise | void); -function renderFile(filename: string, data: DataObj, cb?: CallbackFn): any; +function renderFile( + filename: string, + data: DataObj, + cb?: CallbackFn, +): (Promise | void); function renderFile( filename: string, data: DataObj, config?: PartialConfig, cb?: CallbackFn, -) { +): (Promise | void) { /* Here we have some function overloading. Essentially, the first 2 arguments to renderFile should always be the filename and data diff --git a/deno_dist/file-utils.ts b/deno_dist/file-utils.ts index 2059a1c..eca8080 100644 --- a/deno_dist/file-utils.ts +++ b/deno_dist/file-utils.ts @@ -57,7 +57,7 @@ function getWholeFilePath( * @return absolute path to template */ -function getPath(path: string, options: EtaConfig) { +function getPath(path: string, options: EtaConfig): string { var includePath: string | false = false; var views = options.views; var searchedPaths: Array = []; @@ -192,7 +192,7 @@ function getPath(path: string, options: EtaConfig) { * Reads a file synchronously */ -function readFile(filePath: string) { +function readFile(filePath: string): string { try { return readFileSync(filePath).toString().replace(_BOM, ""); // TODO: is replacing BOM's necessary? } catch { diff --git a/deno_dist/mod.ts b/deno_dist/mod.ts index fde552f..4f41a05 100644 --- a/deno_dist/mod.ts +++ b/deno_dist/mod.ts @@ -21,6 +21,6 @@ export { templates } from "./containers.ts"; export { config, config as defaultConfig, - getConfig, configure, + getConfig, } from "./config.ts"; diff --git a/deno_dist/storage.ts b/deno_dist/storage.ts index 669436f..118298a 100644 --- a/deno_dist/storage.ts +++ b/deno_dist/storage.ts @@ -8,7 +8,7 @@ import { copyProps } from "./utils.ts"; */ class Cacher { constructor(private cache: Record) {} - define(key: string, val: T) { + define(key: string, val: T): void { this.cache[key] = val; } get(key: string): T { @@ -17,13 +17,13 @@ class Cacher { // TODO: create plugin to allow referencing helpers, filters with dot notation return this.cache[key]; } - remove(key: string) { + remove(key: string): void { delete this.cache[key]; } - reset() { + reset(): void { this.cache = {}; } - load(cacheObj: Record) { + load(cacheObj: Record): void { copyProps(this.cache, cacheObj); } } diff --git a/deno_dist/utils.ts b/deno_dist/utils.ts index 42e8e4d..a773363 100644 --- a/deno_dist/utils.ts +++ b/deno_dist/utils.ts @@ -18,11 +18,11 @@ interface EscapeMap { /* END TYPES */ -export function hasOwnProp(obj: object, prop: string) { +export function hasOwnProp(obj: object, prop: string): boolean { return Object.prototype.hasOwnProperty.call(obj, prop); } -export function copyProps(toObj: T, fromObj: T) { +export function copyProps(toObj: T, fromObj: T): T { for (var key in fromObj) { if (hasOwnProp((fromObj as unknown) as object, key)) { toObj[key] = fromObj[key]; @@ -113,7 +113,7 @@ function replaceChar(s: string): string { * @returns XML-escaped string */ -function XMLEscape(str: any) { +function XMLEscape(str: any): string { // eslint-disable-line @typescript-eslint/no-explicit-any // To deal with XSS. Based on Escape implementations of Mustache.JS and Marko, then customized. var newStr = String(str);