Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Strengthen frontend Biome linting rules to enforce import and Tailwind sorting, naming conventions, etc. #703

Conversation

tjementum
Copy link
Member

@tjementum tjementum commented Mar 8, 2025

Summary & Motivation

Updated the Biome configuration to enforce sorted imports in TypeScript and .tsx files and sorted Tailwind class names. A full solution-wide cleanup has been performed to align with these changes.

Biome's linting rules have been expanded to:

  • Enforce naming conventions while allowing PascalCased OpenAPI .NET parameters
  • Require explicit block statements ({}) where necessary
  • Strengthen formatting enforcement by removing format scripts from package.json, as formatting is now handled via lint

Also, a generic cleanup in the frontend, including fixing most Sonar warnings. Including:

  • Import React wherever React.ReactNode is used to avoid warnings
  • Mark variables as readonly and non-nullable where applicable
  • Remove obsolete avatar.png
  • Update location of module federation types from mf-typesto module-federation-types
  • Remove leftover configuration from React Canary usage
  • Remove workspace-biome workaround to make Biome work in VS Code

Downstream projects

  1. Update package.json scripts

Update the application/[your-self-contained system]/WebApp/package.json to apply the new strict linting rules, and remove the format script which is now fully covered by the lint script:

  "scripts": {
-   "check": "biome check",
-   "lint": "biome lint --write",
-   "format": "biome format --write",
+   "check": "biome check --error-on-warnings",
+   "lint": "biome check --write --unsafe"
  }
  1. Ignore Biome warning in bootstrap.tsx

Update application/[your-self-contained system]/WebApp/bootstrap.tsx to ignore incorrect casing of ReactDOM:

+  // biome-ignore lint/style/useNamingConvention: ReactDOM is a standard library name with consecutive uppercase letters
   import ReactDOM from "react-dom/client";
  1. Update rsbuild.config.ts

Rename the MFPlugin to ModuleFederationPlugin in application/[your-self-contained system]/WebApp/rsbuild.config.ts:

+import { ModuleFederationPlugin } from "@repo/build/plugin/ModuleFederationPlugin";
-import { MFPlugin } from "@repo/build/plugin/MFPlugin";

+ ModuleFederationPlugin({
- MFPlugin({
  1. Update react-env.d.ts

Update application/[your-self-contained system]/WebApp/react-env.d.ts to use the new module-federation-types folder:

+/// <reference types="@repo/build/module-federation-types/account-management.d.ts" />
-/// <reference types="@repo/build/mf-types/account-management.d.ts" />
  1. IMPORTANT: Restart CLI command before continuing

Since npm run format has been removed, the build CLI command will fail if you continue. After making the above changes, please restart the process by running: pp pull-platform-platform-changes --resume (where pp is your CLI alias).

Checklist

  • I have added tests, or done manual regression tests
  • I have updated the documentation, if necessary

@tjementum tjementum added the Enhancement New feature or request label Mar 8, 2025
@tjementum tjementum self-assigned this Mar 8, 2025
Copy link

linear bot commented Mar 8, 2025

@tjementum tjementum changed the title Enforce import and Tailwind class sorting with Biome, and improve linting rules Improve Biome configuration for consistent imports, Tailwind class sorting, and stricter linting Mar 8, 2025
Copy link

sonarqubecloud bot commented Mar 8, 2025

@tjementum tjementum force-pushed the pp-329-enable-biome-to-sort-tailwind-classes-and-typescript-imports branch 2 times, most recently from e3cb214 to 9be0cc7 Compare March 8, 2025 12:49
@tjementum tjementum changed the title Improve Biome configuration for consistent imports, Tailwind class sorting, and stricter linting Strengthen Biome linting, enforce import and Tailwind sorting, and improve naming conventions Mar 8, 2025
@tjementum tjementum force-pushed the pp-329-enable-biome-to-sort-tailwind-classes-and-typescript-imports branch from 435ae44 to 57c1563 Compare March 8, 2025 14:39
@tjementum tjementum force-pushed the pp-329-enable-biome-to-sort-tailwind-classes-and-typescript-imports branch from 57c1563 to a48c118 Compare March 8, 2025 14:51
@tjementum tjementum force-pushed the pp-329-enable-biome-to-sort-tailwind-classes-and-typescript-imports branch from a48c118 to 9a4af22 Compare March 8, 2025 14:53
Copy link

sonarqubecloud bot commented Mar 8, 2025

Please retry analysis of this Pull-Request directly on SonarQube Cloud

@tjementum tjementum changed the title Strengthen Biome linting, enforce import and Tailwind sorting, and improve naming conventions Strengthen frontend Biome linting rules to enforce import and Tailwind sorting, naming conventions, etc. Mar 8, 2025
@tjementum tjementum force-pushed the pp-329-enable-biome-to-sort-tailwind-classes-and-typescript-imports branch from 9a4af22 to 2dec5d0 Compare March 8, 2025 15:11
@tjementum tjementum force-pushed the pp-329-enable-biome-to-sort-tailwind-classes-and-typescript-imports branch from 2dec5d0 to a1694b1 Compare March 8, 2025 15:24
Copy link

sonarqubecloud bot commented Mar 8, 2025

Please retry analysis of this Pull-Request directly on SonarQube Cloud

@tjementum tjementum merged commit 1c6b807 into main Mar 8, 2025
15 of 16 checks passed
@tjementum tjementum deleted the pp-329-enable-biome-to-sort-tailwind-classes-and-typescript-imports branch March 8, 2025 15:30
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Enhancement New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant