Skip to content

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.

bash
npm install --save-dev @capsulescodes/flint
bash
pnpm add --save-dev @capsulescodes/flint
bash
yarn add --dev @capsulescodes/flint

2 - Initialization


Initialize Flint in your project by running the following command:

bash
node_modules/.bin/flint init
bash
npx flint init

This command will:

  • Create a .flint directory in your project's root (if not already present).
  • Generate a flint.config.json file 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 :

json
{
  "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
js
export default [ {
 	rules : {
 		'yoda' : [ 'error', "always" ]
 	}
} ];
eslint.remote.config.js
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

js
if( "red" === color )
{
    // ...
}

Now run flint like you run git.

bash
# 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
bash
# 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 main

Wrap 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.

js
if( "red" === color )
{
    // ...
}
js
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 .flint directory at the root of your project.
  • The flint.config.json file at the root of your project.
  • The git wrapper function from your shell configuration file.