Skip to content

[WTF-2641]: Format generated types#182

Open
weirdwater wants to merge 5 commits into
masterfrom
wtf-2641-release-style-error
Open

[WTF-2641]: Format generated types#182
weirdwater wants to merge 5 commits into
masterfrom
wtf-2641-release-style-error

Conversation

@weirdwater

@weirdwater weirdwater commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

Checklist

  • Contains unit tests ❌
  • Contains breaking changes ❌
  • Did you update version and changelog? ✅
  • PR title properly formatted ([XX-000]: description)? ✅

This PR contains

  • Bug fix
  • Feature
  • Refactor
  • Documentation
  • Other (describe)

What is the purpose of this PR?

Avoid linting errors when running the release command. As a side-effect, the generated types will now respect the widget's prettier config.

Relevant changes

Before writing the generated types to the definition file, the type generator now runs prettier to format the source.

What should be covered while testing?

Widget with many client types

Prerequisites

  • A widget (new or existing)

Steps

  1. Modify the widget xml to include properties of these types:
  • Expression Property
  • Action Property
  • Attribute Property
  • List Datasource
  • Linked ActionProperty
  • Linked AttributeProperty
  • Association Property with ReferenceSet
  • File Property
  • Image Property
  • Icon Property
  • Selection Property (Multi and Single)
  1. Run npx @mendix/pluggable-widgets-tools build
  2. Run npx @mendix/pluggable-widgets-tools lint

Result

  • With this version of PWT: Step 3 should run without errors
  • With earlier version of PWT: Step 3 will report formatting errors on the typings file

Widget with custom prettier rules

Prerequisites

  • A widget (new or existing)

Steps

  1. Edit the widget's prettier.config.js, add the following settings:
{
    semi: false,
    singleQuote: true
}
  1. Run npx @mendix/pluggable-widgets-tools build
  2. Run npx @mendix/pluggable-widgets-tools lint

Result

  • With this version of PWT: Step 3 should run without errors
  • With earlier version of PWT: Step 3 will report formatting errors on the typings file

const fakeFilename = join(cwd(), "./src/widget.ts");
// If the widget does not have a prettier config, fall back to packaged base config
const prettierConfig =
(await resolveConfig(fakeFilename)) ?? JSON.parse(await readFile(prettierConfigBasePath, "utf-8"));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can resolveConfig here end up resolving a different prettier config than the one the release check uses on the generated code?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewing the prettier command in the mx-scripts.js, it only resolves to the prettier.config.js file in the widget and does not pick up other prettier configuration options.

@weirdwater weirdwater Jun 18, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the mx-scripts and the typings generator to use the same prettier configuration and rebased.

@weirdwater weirdwater force-pushed the wtf-2641-release-style-error branch from d38841f to 57914c7 Compare June 18, 2026 12:12
@weirdwater weirdwater force-pushed the wtf-2641-release-style-error branch from 57914c7 to 0e434aa Compare June 18, 2026 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants