2025-07-01 09:01:00
github.com
Write code your way while ensuring remote consistency.
Flint empowers developers to use their personal style and formatting preferences locally, while maintaining a consistent remote codebase. By integrating with Git, Flint automatically formats code during pull
and push
operations. This approach prevents commits from being cluttered with formatting changes, making code reviews cleaner and collaboration smoother.
Note
Flint is currently in alpha. Contributions are warmly welcomed.
1. Install Flint using your package manager
# npm
npm install --save-dev @capsulescodes/flint
2. Initialize Flint
# npm
node_modules/.bin/flint init
- The command creates a
.flint
directory in your project’s root [ unless already present ]. - The command creates a
flint.config.json
file in your project’s root [ unless already present ].
3. Optional – Copy the Flint git wrapper inside your local shell configuration file
# Flint git wrapper
git() {
if [[ -f "$PWD/.flint/git.sh" ]]; then
bash "$PWD/.flint/git.sh" "$@";
else
command git "$@";
fi
}
- The function calls flint around git if a
.flint/git.sh
file is present inside the current working directory. If not, it will call git as usual.
Note
Running flint init --wrap
integrates the wrapper during setup.
You can also use flint
as a git
alternative.
More options below.
Once initialized, Flint integrates with your Git workflow to streamline coding practices.
- Local Development : Format your code according to personal preferences.
- Pulling Code : Flint adapts remote code to your local style for easier readability.
- Committing and Pushing Code : Flint reformats your code to align with remote style guidelines.
This ensures :
- Maintaining Code Consistency :Ensures the repository always adheres to agreed-upon styles.
- Improving Readability : Local preferences don’t impact others’ workflows.
- Cleaner Commits : Keeps formatting changes separate from logic changes.
Flint creates a hidden temporary commit during certain git
operations, which may result in the following message to appear when running git status
:
On branch main
+ Your branch is ahead of 'origin/main' by 1 commit.
+ (use "git push" to publish your local commits)
nothing to commit, working tree clean
This message indicates that your local branch is configured to track the remote branch, and Flint’s hidden temporary commit makes your local branch appear ahead by one commit. If it bothers you, you can unset the upstream tracking for your branch by running :
git branch --unset-upstream
Flint uses a flint.config.json
file to manage formatting commands. Specify your local and remote formatting commands here.
Below is an example configuration file formatting Javascript files with ESLint. It formats locally based on eslint.local.config.js
file and remotely based on eslint.remote.config.js
:
{
"linters" :
[
{
"extensions" : [ "js" ],
"binary" : "node_modules/.bin/eslint",
"commands" : {
"local" : "--fix --config eslint.local.config.js --quiet",
"remote" : "--fix --config eslint.remote.config.js --quiet"
}
}
]
}
– Include Flint hooks during initialization
If you want to access Flint hooks, use the init
argument with the --hooks
option.
# npm
node_modules/.bin/flint init --hooks
– Include Git wrapper function during initialization
If you want to run Flint while using Git, use the init
argument with the --wrap
option.
# npm
node_modules/.bin/flint init --wrap
– Skip adding default configuration file during initialization
If you don’t want to add a configuration file template to your project, use the init
argument with the --no-config
option.
# npm
node_modules/.bin/flint init --no-config
– Run Flint command manually
If you want to run a specific command from configuration file property commands, use your command after the run
argument. Default is local
.
# npm
node_modules/.bin/flint run remote
– Use Flint as a Git alternative
Flint can act as a Git wrapper, allowing you to seamlessly use Git commands while benefiting from Flint’s formatting hooks. To enable this, simply replace git
with flint
in your commands.
# npm
node_modules/.bin/flint status
Note
Flint is written entirely in Bash, making it highly adaptable.
Adding support for new package managers primarily involves creating the appropriate configuration files.
Additional package managers are expected to be supported in future updates.
Contributions are warmly welcomed. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
# npm
npm run test
# bash
bash tests/runner.sh
Keep your files stored safely and securely with the SanDisk 2TB Extreme Portable SSD. With over 69,505 ratings and an impressive 4.6 out of 5 stars, this product has been purchased over 8K+ times in the past month. At only $129.99, this Amazon’s Choice product is a must-have for secure file storage.
Help keep private content private with the included password protection featuring 256-bit AES hardware encryption. Order now for just $129.99 on Amazon!
Help Power Techcratic’s Future – Scan To Support
If Techcratic’s content and insights have helped you, consider giving back by supporting the platform with crypto. Every contribution makes a difference, whether it’s for high-quality content, server maintenance, or future updates. Techcratic is constantly evolving, and your support helps drive that progress.
As a solo operator who wears all the hats, creating content, managing the tech, and running the site, your support allows me to stay focused on delivering valuable resources. Your support keeps everything running smoothly and enables me to continue creating the content you love. I’m deeply grateful for your support, it truly means the world to me! Thank you!
BITCOIN bc1qlszw7elx2qahjwvaryh0tkgg8y68enw30gpvge Scan the QR code with your crypto wallet app |
DOGECOIN D64GwvvYQxFXYyan3oQCrmWfidf6T3JpBA Scan the QR code with your crypto wallet app |
ETHEREUM 0xe9BC980DF3d985730dA827996B43E4A62CCBAA7a Scan the QR code with your crypto wallet app |
Please read the Privacy and Security Disclaimer on how Techcratic handles your support.
Disclaimer: As an Amazon Associate, Techcratic may earn from qualifying purchases.