Skip to content

200ok-ch/oklint

Repository files navigation

oklint

A rather generic, easily extendable linter for everything™.

./oklint_logo.png

Introduction

oklint is not just another linter.

lint, or a linter, is a tool that analyzes source code to flag programming errors, bugs, stylistic errors, and suspicious constructs. (Wikipedia)

oklint doesn’t lint source code, at least not first and foremost. oklint is an extendable linting system that aims for linting everything. Sounds presumptuous? It totally is! But listen…

The thing is, we wanted to ensure that in a Git repo on commit

  • files are named according to a schema
  • csv files are well formed and fit for automatic processing
  • certain keywords are present in every line of a file
  • etc (you get the picture)

As you can see, we took linting to another level. We wanted to lint all-the-things!

Usage

oklint comes with a couple of plugins. If you don’t find what you need it is relatively straight forward to develop you own plugins for oklint. It currently provides plugins for

  • filenaming
  • csv
  • timesheet_tagging

The rules are stored in YAML files called .oklint and applied on a per-directory basis. You can lint a single file against these rules by calling oklint with the path as an argument.

% find
.
./.oklint
./some-file.txt
./other-file.TXT

% oklint some-file.txt
Applying rules from .oklint...
Applying plugin filenaming...

Or you can just call without arguments to have it scan for all .oklint files and run the rules found again just the changed files in the repository. (This lowers the barrier to introduce new rules as they will only be applied to newly created or changed files.)

% oklint
Finding changed files via git...

Applying rules from .oklint...
Applying plugin filenaming...

If the command returns with the return value 0 everything is ok, which means every defined rule is satisfied. Otherwise a non-zero exit code will be returned.

We recommend using oklint in a Git repo with Git’s pre-commit hook, which will prevent commit which do not fully satisfy the defined rules.

As a matter of fact oklint currently assumes that it is used in a Git repo, because when called without arguments it uses Git to look for changed files.

We recommend husky to easily setup the git hook. This in your package.json should do:

"husky": {
  "hooks": {
    "pre-commit": "oklint"
  }
},

License

see ./LICENSE.md

About

A rather generic, easily extendable linter for everything:tm:

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published