Giter Site home page Giter Site logo

end-of-file's Introduction

End of file

End of file is formatter to ensure text files always end with one newline. Eof is able to resolve every possible situation - missing newline, more then one newline and whitespaces mixed with newlines. Simple configuration is done using parameters, no config file is needed.

Configurable options:

  • include or exclude hidden files (file or folders starting with dot)
  • blacklisted strings that are found inside traversed paths
  • whitelisted extensions
  • whitelisted files that are registered with git
  • identification of text files (mimetype or bruteforce)
  • validation only mode for ci pipelines

The code is short and dead simple so if you have more questions feel free to open an issue or take a look into src.

Installation

End_of_file is python script and thus python3.6 or newer must be present on the system. Eof is just another pip package and can be installed with pip install end-of-file.

Usage

Installation adds Eof to your environment so feel free to try

eof --help

To format project

eof ./project

If you are using git and are concerned only about files that are registered to git following flag can be used. Git must be installed for this option to work.

eof ./project --git

To format only specific extensions

eof ./project --extensions=txt,md,py,rb,cpp

To check in ci/cd if project is formatted correctly, return 0 if yes, 1 if changes are needed. Files are not changed.

eof ./project --check

In case you have for example build destination in your project and want to skip it you can use --ignore flag. Paths with substring from this option are skipped.

eof --ignore /dist -i egg-info

Circleci job example

circleci-job:
  docker:
    - image: circleci/python:3
  steps:
    - checkout
    - run: pip install end-of-file
    - run: eof --check

Strategies

Eof needs to have a way to identify files that should be checked for correct newline. There are two options to choose from.

Bruteforce (default)

Bruteforce strategy just opens the file and tries to read first line, if that does not work it assumes the file does not contain text and is skipped. This should be the most precise but may take more time.

eof --strategy='bruteforce'

Mimetype

Mimetype strategy checks extensions against lookup table.

eof --strategy='mimetype'

Testing

Code is fairly well tested, feel free to take a look.

License

BSD 3-Clause

end-of-file's People

Contributors

keeo avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

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.