From fa6cb55759d154b10280e7e9a9ebd06aa12cce2b Mon Sep 17 00:00:00 2001 From: Gergely Brautigam <182850+Skarlso@users.noreply.github.com> Date: Tue, 24 Dec 2024 11:07:46 +0100 Subject: [PATCH] lint fix and removed commented out code --- pkg/generate.go | 33 +-------------------------------- wasm/app.go | 12 ++++++------ wasm/index.go | 4 ++-- wasm/index.html | 10 +++++----- wasm/main.go | 2 +- wasm/share.html | 22 +++++++++++----------- wasm/web/app.wasm | Bin 32454233 -> 32453508 bytes 7 files changed, 26 insertions(+), 57 deletions(-) diff --git a/pkg/generate.go b/pkg/generate.go index 92317fa..1c41c49 100644 --- a/pkg/generate.go +++ b/pkg/generate.go @@ -139,22 +139,6 @@ func (p *Parser) ParseProperties(version string, file io.Writer, properties map[ p.indent += 2 p.inArray = true - // we need to not output a `\n` if there are no more properties to parse. - //if p.onlyRequired && !slices.Contains(requiredFields, k) { - // p.indent -= 2 - // w.write(file, " {}\n") - // p.inArray = false // no longer in an array... - // - // continue - //} - //if p.onlyRequired && p.emptyAfterTrimRequired(properties[k].Items.Schema.Properties, properties[k].Items.Schema.Required) { - // p.indent -= 2 - // w.write(file, " {}\n") - // p.inArray = false // no longer in an array... - // - // continue - //} - if err := p.ParseProperties(version, file, properties[k].Items.Schema.Properties, properties[k].Items.Schema.Required); err != nil { return err } @@ -185,22 +169,7 @@ func (p *Parser) ParseProperties(version string, file io.Writer, properties map[ w.write(file, " {}\n") } else { p.indent += 2 - //if p.onlyRequired && p.emptyAfterTrimRequired( - // properties[k].AdditionalProperties.Schema.Properties, - // properties[k].AdditionalProperties.Schema.Required) { - // p.indent -= 2 - // w.write(file, " {}\n") - // - // continue - //} - //if p.onlyRequired && !slices.Contains(requiredFields, k) { - // p.indent -= 2 - // w.write(file, " {}\n") - // - // continue - //} - - //w.write(file, "\n") + // This will eventually end up in case len(properties[k].Properties) > 0: hence, we don't need // an empty check in here. That would be redundant. if err := p.ParseProperties( diff --git a/wasm/app.go b/wasm/app.go index ed0379d..6448120 100644 --- a/wasm/app.go +++ b/wasm/app.go @@ -60,12 +60,12 @@ func (v *detailsView) Render() app.UI { // `Pre` isn't allowed to have anything other than CODE inside. return app.Div().Body( app.Div().Class("form-check").Body( - app.Label().Class("form-check-label").For(fmt.Sprintf("enable-comments-%s", v.version.Version)).Body(app.Text("Enable comments on YAML output")), - app.Input().Class("form-check-input").Type("checkbox").ID(fmt.Sprintf("enable-comments-%s", v.version.Version)).OnClick(v.OnCheckComment), + app.Label().Class("form-check-label").For("enable-comments-"+v.version.Version).Body(app.Text("Enable comments on YAML output")), + app.Input().Class("form-check-input").Type("checkbox").ID("enable-comments-"+v.version.Version).OnClick(v.OnCheckComment), ), app.Div().Class("form-check").Body( - app.Label().Class("form-check-label").For(fmt.Sprintf("enable-minimal-%s", v.version.Version)).Body(app.Text("Enable minimal required YAML output")), - app.Input().Class("form-check-input").Type("checkbox").ID(fmt.Sprintf("enable-minimal-%s", v.version.Version)).OnClick(v.OnCheckMinimal), + app.Label().Class("form-check-label").For("enable-minimal-"+v.version.Version).Body(app.Text("Enable minimal required YAML output")), + app.Input().Class("form-check-input").Type("checkbox").ID("enable-minimal-"+v.version.Version).OnClick(v.OnCheckMinimal), ), app.Pre().Body( app.Div().ID("yaml-sample-"+v.version.Version).Body(app.If(v.renderErr != nil, func() app.UI { @@ -77,7 +77,7 @@ func (v *detailsView) Render() app.UI { ) } -func (v *detailsView) OnCheckComment(ctx app.Context, _ app.Event) { +func (v *detailsView) OnCheckComment(_ app.Context, _ app.Event) { v.comment = !v.comment content, err := v.version.generateYAMLDetails(v.comment, v.minimal) if err != nil { @@ -90,7 +90,7 @@ func (v *detailsView) OnCheckComment(ctx app.Context, _ app.Event) { v.content = content } -func (v *detailsView) OnCheckMinimal(ctx app.Context, _ app.Event) { +func (v *detailsView) OnCheckMinimal(_ app.Context, _ app.Event) { v.minimal = !v.minimal content, err := v.version.generateYAMLDetails(v.comment, v.minimal) if err != nil { diff --git a/wasm/index.go b/wasm/index.go index da72925..f0256ed 100644 --- a/wasm/index.go +++ b/wasm/index.go @@ -283,8 +283,8 @@ func (i *index) Render() app.UI { // Prevent double rendering components. if i.isMounted { return app.Main().Body( - //app.Script().Src("https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-core.min.js"), - //app.Script().Src("https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/autoloader/prism-autoloader.min.js"), + // app.Script().Src("https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-core.min.js"), + // app.Script().Src("https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/autoloader/prism-autoloader.min.js"), app.Div().Class("container").Body(func() app.UI { if i.err != nil { return app.Div().Class("container").Body(&header{titleOnClick: i.NavBackOnClick, hidden: true}, i.buildError()) diff --git a/wasm/index.html b/wasm/index.html index e31f6e2..8d06a37 100644 --- a/wasm/index.html +++ b/wasm/index.html @@ -4,17 +4,17 @@ - + - +