This repository contains shared GitHub workflows for the Future Foundry organization, including automated code formatting with Prettier and Tailwind CSS class sorting.
Automatically runs on:
- Pull requests to
mainordevbranches - Pushes to
mainordevbranches
Purpose: Ensures all code is properly formatted before merging.
What it does:
- Checks if all files match Prettier formatting rules
- Fails the CI if formatting issues are detected
- Provides instructions on how to fix formatting issues
Can be triggered:
- By commenting
/formaton a pull request - Manually via workflow dispatch
Purpose: Automatically formats code and commits the changes.
What it does:
- Runs Prettier on all files
- Commits formatting changes automatically
- Comments on the PR to confirm formatting is complete
Usage:
- On any PR, comment
/formatto trigger auto-formatting - The bot will format your code and push a new commit
- Wait a few moments for the workflow to complete
To use these workflows across your organization:
- Enable organization workflows in your GitHub organization settings
- Repositories will automatically inherit these workflows
If you want to use these workflows in a specific repository:
-
Copy the
.githubdirectory to your repository root -
Install dependencies:
npm install
-
Add these scripts to your
package.json:{ "scripts": { "prettier:check": "prettier --check \"**/*.{js,jsx,ts,tsx,json,css,scss,md,html,yml,yaml}\"", "prettier:fix": "prettier --write \"**/*.{js,jsx,ts,tsx,json,css,scss,md,html,yml,yaml}\"" } }
Current configuration:
- Semi-colons: Yes
- Quotes: Single quotes
- Print Width: 100 characters
- Tab Width: 2 spaces
- Trailing Commas: ES5 compatible
- Plugins: Tailwind CSS class sorting
Files and directories that are excluded from formatting:
node_modules/- Build outputs (
dist/,build/,.next/, etc.) - Lock files
- Generated files
- Public assets
npm run prettier:checknpm run prettier:fixFor the best experience, install the Prettier VS Code extension and add to your .vscode/settings.json:
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}The prettier-plugin-tailwindcss plugin automatically sorts Tailwind CSS classes in the recommended order. This ensures consistency across the codebase.
Example:
Before:
<div className="text-center p-4 bg-blue-500 text-white font-bold">After:
<div className="bg-blue-500 p-4 font-bold text-center text-white">Make sure your repository has a package.json with the required dependencies:
{
"devDependencies": {
"prettier": "^3.1.0",
"prettier-plugin-tailwindcss": "^0.5.7"
}
}- Ensure the PR is open (not draft)
- Comment exactly
/format(case-sensitive) - Check that the workflow has proper permissions in repository settings
Check your .prettierignore file to ensure the files aren't being excluded.
To modify these workflows:
- Create a new branch
- Make your changes
- Test in a repository that uses these workflows
- Submit a PR with a clear description of changes
Internal use only - Future Foundry organization.