Skip to content

fix: add a playground sample to the config schema - #3

Merged
dsherret merged 1 commit into
mainfrom
schema-examples
Nov 6, 2026
Merged

dsherret merged 1 commit into
mainfrom
schema-examples

Conversation

@dsherret

@dsherret dsherret commented Nov 5, 2026

Copy link
Copy Markdown
Member

Adds an x-playground sample to the config schema, which the dprint.dev playground puts in the editor when it opens this plugin, like dprint/dprint-plugin-typescript#899. The only option is newLineKind, so there are no code examples.

The sample is a .bzl file that isn't formatted, and formats to:

load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")

DEFAULT_COPTS = ["-Wall", "-Werror"]

def project_library(name, srcs, deps = [], testonly = False, **kwargs):
    """Defines a library and a test target for it."""
    cc_library(
        name = name,
        srcs = srcs,
        copts = DEFAULT_COPTS + kwargs.pop("copts", []),
        deps = deps,
        testonly = testonly,
        visibility = ["//visibility:public"],
        **kwargs
    )
    if len(srcs) > 0:
        cc_test(name = name + "_test", srcs = [s.replace(".cc", "_test.cc") for s in srcs], deps = [":" + name, "@googletest//:gtest_main"])

def _version_impl(ctx):
    out = ctx.actions.declare_file(ctx.label.name + ".txt")
    ctx.actions.write(output = out, content = ctx.attr.version)
    return [DefaultInfo(files = depset([out]))]

version_file = rule(implementation = _version_impl, attrs = {"version": attr.string(mandatory = True)})

The new "Generate config schema" CI step runs the publish-schema task from dprint/automation on the built wasm plugin, before the schema is uploaded to a release. It fails when the plugin has a diagnostic for a property's default, or the playground sample doesn't format or is already formatted, and sets the sample's extension to bzl.

@dsherret
dsherret merged commit bd31a44 into main Nov 6, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant