From 8b4291f710aaa26b24dd1536f4b78e34cec2a3cd Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 14 Sep 2023 20:36:18 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/renderer/src/stories/JSONSchemaForm.js | 46 +++++++++++----------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/src/renderer/src/stories/JSONSchemaForm.js b/src/renderer/src/stories/JSONSchemaForm.js index d1a7967ea..e1902a2a3 100644 --- a/src/renderer/src/stories/JSONSchemaForm.js +++ b/src/renderer/src/stories/JSONSchemaForm.js @@ -487,36 +487,36 @@ export class JSONSchemaForm extends LitElement { #getRenderable = (schema = {}, required, path, recursive = false) => { const entries = Object.entries(schema.properties ?? {}); - const isArrayOfArrays = (arr) => !!arr.find((v) => Array.isArray(v)) + const isArrayOfArrays = (arr) => !!arr.find((v) => Array.isArray(v)); const flattenRecursedValues = (arr) => { - const newArr = [] + const newArr = []; arr.forEach((o) => { - if (isArrayOfArrays(o)) newArr.push(...o) - else newArr.push(o) - }) + if (isArrayOfArrays(o)) newArr.push(...o); + else newArr.push(o); + }); - return newArr - } + return newArr; + }; const isRenderable = (key, value) => { - if (recursive && value.properties) return this.#getRenderable(value, required[key], [...path, key], true) - - else return [key, value] - } + if (recursive && value.properties) return this.#getRenderable(value, required[key], [...path, key], true); + else return [key, value]; + }; - const res = entries.map(([key, value]) => { - if (!value.properties && key === "definitions") return false; // Skip definitions - if (this.ignore.includes(key)) return false; - if (this.showLevelOverride >= path.length) return isRenderable(key, value); - if (required[key]) return isRenderable(key, value); - if (this.#getLink([...this.#base, ...path, key])) return isRenderable(key, value); - if (!this.onlyRequired) return isRenderable(key, value); - return false; - }).filter(o => !!o) + const res = entries + .map(([key, value]) => { + if (!value.properties && key === "definitions") return false; // Skip definitions + if (this.ignore.includes(key)) return false; + if (this.showLevelOverride >= path.length) return isRenderable(key, value); + if (required[key]) return isRenderable(key, value); + if (this.#getLink([...this.#base, ...path, key])) return isRenderable(key, value); + if (!this.onlyRequired) return isRenderable(key, value); + return false; + }) + .filter((o) => !!o); return flattenRecursedValues(res); // Flatten on the last pass - }; validateOnChange = () => {}; @@ -756,7 +756,6 @@ export class JSONSchemaForm extends LitElement { if (this.mode === "accordion" && hasMany) { const headerName = header(name); - this.#nestedForms[name] = new JSONSchemaForm({ identifier: this.identifier, schema: info, @@ -792,8 +791,7 @@ export class JSONSchemaForm extends LitElement { base: fullPath, }); - - const accordion = new Accordion({ + const accordion = new Accordion({ sections: { [headerName]: { subtitle: `${this.#getRenderable(info, required[name], fullPath, true).length} fields`,