Quick Start
Follow these steps to add Flint to your project.
INFO
Flint is currently in alpha and is available exclusively on npm.
Prerequisites
- Ensure you have Node.js installed (version 18 or higher recommended).
- A Git repository for your project.
1 - Installation
Install Flint using your preferred package manager.
npm install --save-dev @capsulescodes/flintpnpm add --save-dev @capsulescodes/flintyarn add --dev @capsulescodes/flint2 - Initialization
Initialize Flint in your project by running the following command:
node_modules/.bin/flint initnpx flint initThis command will:
- Create a
.flintdirectory in your project's root (if not already present). - Generate a
flint.config.jsonfile in your project's root for configuration.
3 - Configuration
Configure the flint.config.json file to specify your local and remote base commands. Here's an example configuration for formatting JavaScript files using the most popular Javascript Linter ESLint :
{
"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"
}
}
]
}For the purpose of this, here are two Eslint config file examples
eslint.local.config.js
export default [ {
rules : {
'yoda' : [ 'error', "always" ]
}
} ];eslint.remote.config.js
export default [ {
rules : {
'yoda' : [ 'error', "never" ]
}
} ];4 - Start
You're all set and ready!
But before actually run Flint, add a JS file and write some code first.
foo.js
if( "red" === color )
{
// ...
}Now run flint like you run git.
# Add foo.js file
node_modules/.bin/flint add foo.js
# Commit with message
node_modules/.bin/flint commit -m "Added foo.js file"
# Push to remote
node_modules/.bin/flint push origin main# Add foo.js file
npx flint add foo.js
# Commit with message
npx flint commit -m "Added foo.js file"
# Push to remote
npx flint push origin mainWrap git
If you'd like to keep typing git as usual instead of flint. See the Git section.
Your local and remote code will have their respective config files style from now on.
if( "red" === color )
{
// ...
}if( "red" === color )
if( color === "red" )
{
// ...
}Flint will automatically format your code during pull and push operations, ensuring a consistent codebase while allowing you to use your preferred coding style locally.
Remove Flint
To remove Flint from your project, first uninstall it using your package manager. Additionally, you should manually remove the following files and directories that Flint may have created :
- The
.flintdirectory at the root of your project. - The
flint.config.jsonfile at the root of your project. - The git wrapper function from your shell configuration file.
