The project is in a healthy, maintained state
Immosquare-cleaner streamlines Rails applications by running tools like RuboCop, ERBLint, Stylelint and more. It ensures code quality, readability, and consistency across the application.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 0, >= 0.1.26
~> 1, >= 1.62.1
~> 0, >= 0.1.18
 Project Readme

ImmosquareCleaner

A meticulously crafted Ruby gem to enhance the cleanliness and structure of your project's files. This tool ensures consistency and uniformity across various formats, including Ruby, ERB, YAML, Markdown, JSON, JS, CSS, SASS, LESS, and other formats supported by Prettier.

Supported Formats

The cleaner recognizes and caters to various file formats:

File Type File Extension Processor
ERB .html.erb htmlbeautifier && erb-lint
Ruby .rb, .rake, Gemfile, Rakefile, .axlsx, .gemspec, .ru, .podspec, .jbuilder, .rabl, .thor, config.ru, Berksfile, Capfile, Guardfile, Podfile, Thorfile, Vagrantfile rubocop
YAML .yml (only files in locales folder) ImmosquareYaml
JS .js eslint
JSON .json ImmosquareExtensions
Markdown .md, .md.erb ImmosquareCleaner
Others Any other format prettier

Linter Configurations

You can view the specific configurations for all supported linters in the linters folder of the repository.

Installation

Prerequisite: Please be sure to have bun installed. This is necessary to launch eslint & prettier commands.

For the Ruby gem:

gem "immosquare-cleaner"

Then execute:

$ bundle install

For the npm module:

Add immosquare-cleaner to your development dependencies. For instance, using bun:

$ bun add immosquare-cleaner

Usage

To clean a specific file:

ImmosquareCleaner.clean("path/to/your/file.rb")

Configuration

Tailor the behavior of the gem/module with the provided configuration options:

ImmosquareCleaner.config do |config|
  # Set custom rubocop options
  config.rubocop_options = "--your-rubocop-options-here"
  # Set custom htmlbeautifier options
  config.htmlbeautifier_options = "--your-htmlbeautifier-options-here"
  # Set custom erblint options
  config.erblint_options = "--your-erblint-options-here"
end

Integration with Visual Studio Code

Automate the cleaning process for all files upon saving in VS Code:

  1. Install the Run on Save extension from the VS Code marketplace.
  2. Add the following configuration to your settings.json in VS Code:
"emeraldwalk.runonsave": {
  "commands": [
    {
      "match": ".*",
      "cmd": "if bundle info immosquare-cleaner &>/dev/null; then bundle exec immosquare-cleaner '${file}'; else echo 'please install the gem immosquare-cleaner'; fi"
    }
  ]
}

With the above, every time you save a file in VS Code, it will automatically be cleaned using immosquare-cleaner.

Contributing

Contributions are welcome! Please open an issue or submit a pull request on our GitHub repository.

License

This gem is available under the terms of the MIT License.