Giter Site home page Giter Site logo

rogerluan / .linters Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 34 KB

My personal dotfiles for popular Swift and Ruby linters.

License: MIT License

Ruby 9.10% Shell 90.90%
dotfiles dotfiles-macos formatter ios lint-staged linter precommit-hooks rubocop ruby swiftformat

.linters's Introduction

.linters

This repo contains my personal (and thus, opinionated) configuration files for a few linters:

Installation

  1. Install the linters you're interested in using. You can check each of their repos for specific installation instructions.
  2. Copy the config files from this repo, into your own repo.
  3. There's no step 3 :)

For RuboCop, feel free to delete the extensions you're not using that are being declared in the .rubocop.yml file. For example, if you're not using Rails, you can delete the rubocop-rails extension.

Optional: configure precommit hook

I suggest you to configure a precommit hook to run the formatters before every commit. This will ensure that your code will always be automatically formatted, effortlessly.

This Python script https://github.com/hallettj/git-format-staged helps us automatically format staged files, even if they're only partially staged (e.g. when you stage just selected lines from a file, even though more parts of the file were modified). However, to avoid copy-pasting a Python script into your iOS project, I created https://github.com/rogerluan/git_stage_formatter, a gem that wraps the Python script and makes it easier to install, using RubyGems.

To install the gem, add gem "git_stage_formatter" to your Gemfile, and run bundle install.

Installing the precommit hook script

  1. Copy the contents of the precommit.sh file to your repo
  2. Create a symlink to the precommit.sh file in your .git/hooks folder:
ln -s -f ../../path/to/your/precommit.sh .git/hooks/pre-commit

Note: it must start with ../../ because that's the relative path git will use (it's executed as if it was inside of .git/hooks, so it needs to go up 2 dirs before accessing your repo's files).

This command must be run by every developer in your team. If you want to automate this, you can add the following to your Rakefile:

task :install_git_hooks do
  puts("Setting up git hooks…")
  system("ln -s -f ../../path/to/your/precommit.sh .git/hooks/pre-commit")
end
  1. Review your precommit.sh file and update everything accordingly, e.g. the paths of the binaries, the file extensions it should be linting, etc. Common file paths differ between different projects and project types (e.g. iOS vs RoR projects).

Contact

Twitter: @rogerluan_

.linters's People

Contributors

rogerluan avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

.linters's Issues

Add script to easily run these linter configs on external directories

Use case:

  1. I fork/clone a project that isn't mine 🍴
  2. My OCD distracts me from reading the project because its code style is not consistent 🥵
  3. I run something like swiftlinters /path/to/this/new/fork 🧑‍💻
  4. Now I can work in peace, more productive, without bikeshedding on code style 😇

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.