summaryrefslogtreecommitdiff
path: root/std/encoding
diff options
context:
space:
mode:
Diffstat (limited to 'std/encoding')
-rw-r--r--std/encoding/_yaml/dumper/dumper.ts9
-rw-r--r--std/encoding/_yaml/example/sample_document.ts3
-rw-r--r--std/encoding/_yaml/loader/loader.ts2
-rw-r--r--std/encoding/_yaml/loader/loader_state.ts3
-rw-r--r--std/encoding/_yaml/stringify.ts5
-rw-r--r--std/encoding/_yaml/type.ts4
-rw-r--r--std/encoding/_yaml/utils.ts2
-rw-r--r--std/encoding/toml.ts20
-rw-r--r--std/encoding/toml_test.ts4
9 files changed, 32 insertions, 20 deletions
diff --git a/std/encoding/_yaml/dumper/dumper.ts b/std/encoding/_yaml/dumper/dumper.ts
index e1f1a142a..ec517ffb2 100644
--- a/std/encoding/_yaml/dumper/dumper.ts
+++ b/std/encoding/_yaml/dumper/dumper.ts
@@ -499,7 +499,9 @@ function writeScalar(
return `'${string.replace(/'/g, "''")}'`;
case STYLE_LITERAL:
return `|${blockHeader(string, state.indent)}${
- dropEndingNewline(indentString(string, indent))
+ dropEndingNewline(
+ indentString(string, indent),
+ )
}`;
case STYLE_FOLDED:
return `>${blockHeader(string, state.indent)}${
@@ -867,7 +869,10 @@ function inspectNode(
}
}
-function getDuplicateReferences(object: object, state: DumperState): void {
+function getDuplicateReferences(
+ object: Record<string, unknown>,
+ state: DumperState,
+): void {
const objects: Any[] = [],
duplicatesIndexes: number[] = [];
diff --git a/std/encoding/_yaml/example/sample_document.ts b/std/encoding/_yaml/example/sample_document.ts
index f66b3c417..8ef714d42 100644
--- a/std/encoding/_yaml/example/sample_document.ts
+++ b/std/encoding/_yaml/example/sample_document.ts
@@ -7,7 +7,8 @@ import { parse } from "../../yaml.ts";
const yml = Deno.readFileSync(`${Deno.cwd()}/example/sample_document.yml`);
const document = new TextDecoder().decode(yml);
- const obj = parse(document) as object;
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ const obj = parse(document) as Record<string, any>;
console.log(obj);
let i = 0;
diff --git a/std/encoding/_yaml/loader/loader.ts b/std/encoding/_yaml/loader/loader.ts
index 216e315f2..18bab93f5 100644
--- a/std/encoding/_yaml/loader/loader.ts
+++ b/std/encoding/_yaml/loader/loader.ts
@@ -813,7 +813,7 @@ function readFlowCollection(state: LoaderState, nodeIndent: number): boolean {
valueNode,
);
} else if (isPair) {
- (result as Array<{}>).push(
+ (result as ArrayObject[]).push(
storeMappingPair(
state,
null,
diff --git a/std/encoding/_yaml/loader/loader_state.ts b/std/encoding/_yaml/loader/loader_state.ts
index 60a7ccabc..81edeb28d 100644
--- a/std/encoding/_yaml/loader/loader_state.ts
+++ b/std/encoding/_yaml/loader/loader_state.ts
@@ -22,7 +22,8 @@ export interface LoaderStateOptions {
onWarning?(this: null, e?: YAMLError): void;
}
-export type ResultType = [] | {} | string;
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
+export type ResultType = any[] | Record<string, any> | string;
export class LoaderState extends State {
public documents: Any[] = [];
diff --git a/std/encoding/_yaml/stringify.ts b/std/encoding/_yaml/stringify.ts
index 9b3b5a80e..ed7b82d84 100644
--- a/std/encoding/_yaml/stringify.ts
+++ b/std/encoding/_yaml/stringify.ts
@@ -13,6 +13,9 @@ export type DumpOptions = DumperStateOptions;
*
* You can disable exceptions by setting the skipInvalid option to true.
*/
-export function stringify(obj: object, options?: DumpOptions): string {
+export function stringify(
+ obj: Record<string, unknown>,
+ options?: DumpOptions,
+): string {
return dump(obj, options);
}
diff --git a/std/encoding/_yaml/type.ts b/std/encoding/_yaml/type.ts
index 18dee338c..89a91106b 100644
--- a/std/encoding/_yaml/type.ts
+++ b/std/encoding/_yaml/type.ts
@@ -17,7 +17,7 @@ interface TypeOptions {
resolve?: (data: Any) => boolean;
construct?: (data: string) => Any;
instanceOf?: Any;
- predicate?: (data: object) => boolean;
+ predicate?: (data: Record<string, unknown>) => boolean;
represent?: RepresentFn | ArrayObject<RepresentFn>;
defaultStyle?: StyleVariant;
styleAliases?: ArrayObject;
@@ -31,7 +31,7 @@ export class Type {
public tag: string;
public kind: KindType | null = null;
public instanceOf: Any;
- public predicate?: (data: object) => boolean;
+ public predicate?: (data: Record<string, unknown>) => boolean;
public represent?: RepresentFn | ArrayObject<RepresentFn>;
public defaultStyle?: StyleVariant;
public styleAliases?: ArrayObject;
diff --git a/std/encoding/_yaml/utils.ts b/std/encoding/_yaml/utils.ts
index e009ae3cf..3d4e48771 100644
--- a/std/encoding/_yaml/utils.ts
+++ b/std/encoding/_yaml/utils.ts
@@ -38,7 +38,7 @@ export function isUndefined(value: unknown): value is undefined {
return value === undefined;
}
-export function isObject(value: unknown): value is object {
+export function isObject(value: unknown): value is Record<string, unknown> {
return value !== null && typeof value === "object";
}
diff --git a/std/encoding/toml.ts b/std/encoding/toml.ts
index 121459dbf..212c14bdc 100644
--- a/std/encoding/toml.ts
+++ b/std/encoding/toml.ts
@@ -124,10 +124,14 @@ class Parser {
}
this.tomlLines = merged;
}
- _unflat(keys: string[], values: object = {}, cObj: object = {}): object {
+ _unflat(
+ keys: string[],
+ values: Record<string, unknown> | unknown[] = {},
+ cObj: Record<string, unknown> | unknown[] = {},
+ ): Record<string, unknown> {
const out: Record<string, unknown> = {};
if (keys.length === 0) {
- return cObj;
+ return cObj as Record<string, unknown>;
} else {
if (Object.keys(cObj).length === 0) {
cObj = values;
@@ -398,7 +402,7 @@ class Parser {
const shift = pathDeclaration.shift();
if (shift) {
k = shift.replace(/"/g, "");
- v = this._unflat(pathDeclaration, v as object);
+ v = this._unflat(pathDeclaration, v as Record<string, unknown>);
}
} else {
k = k.replace(/"/g, "");
@@ -411,7 +415,7 @@ class Parser {
}
}
}
- parse(): object {
+ parse(): Record<string, unknown> {
this._sanitize();
this._parseLines();
this._cleanOutput();
@@ -433,9 +437,9 @@ function joinKeys(keys: string[]): string {
class Dumper {
maxPad = 0;
- srcObject: object;
+ srcObject: Record<string, unknown>;
output: string[] = [];
- constructor(srcObjc: object) {
+ constructor(srcObjc: Record<string, unknown>) {
this.srcObject = srcObjc;
}
dump(): string[] {
@@ -592,11 +596,11 @@ class Dumper {
}
}
-export function stringify(srcObj: object): string {
+export function stringify(srcObj: Record<string, unknown>): string {
return new Dumper(srcObj).dump().join("\n");
}
-export function parse(tomlString: string): object {
+export function parse(tomlString: string): Record<string, unknown> {
// File is potentially using EOL CRLF
tomlString = tomlString.replace(/\r\n/g, "\n").replace(/\\\n/g, "\n");
return new Parser(tomlString).parse();
diff --git a/std/encoding/toml_test.ts b/std/encoding/toml_test.ts
index 565fe1eeb..9b5e1a56b 100644
--- a/std/encoding/toml_test.ts
+++ b/std/encoding/toml_test.ts
@@ -6,7 +6,7 @@ import { parse, stringify } from "./toml.ts";
const testFilesDir = path.resolve("encoding", "testdata");
-function parseFile(filePath: string): object {
+function parseFile(filePath: string): Record<string, unknown> {
if (!existsSync(filePath)) {
throw new Error(`File not found: ${filePath}`);
}
@@ -254,7 +254,6 @@ Deno.test({
Deno.test({
name: "[TOML] Cargo",
fn(): void {
- /* eslint-disable @typescript-eslint/camelcase */
const expected = {
workspace: { members: ["./", "core"] },
bin: [{ name: "deno", path: "cli/main.rs" }],
@@ -291,7 +290,6 @@ Deno.test({
},
target: { "cfg(windows)": { dependencies: { winapi: "0.3.6" } } },
};
- /* eslint-enable @typescript-eslint/camelcase */
const actual = parseFile(path.join(testFilesDir, "cargo.toml"));
assertEquals(actual, expected);
},