DEV Community

Chris Aniszczyk
Chris Aniszczyk

Posted on

Linting your Open Source Repository

Have you ever wanted to lint your open source repository for common issues at build time... such as a missing LICENSE, SECURITY.md CONTRIBUTING.md or even absent source license headers? There is a tool built by the TODO Group called repolinter that tackles this problem:

GitHub logo todogroup / repolinter

Repolinter, The Open Source Repository Linter

Repo Linter Build Status

Lint open source repositories for common issues.

Installation

Repolinter requires Node.JS >= v12 to function properly. Once Node.JS is installed, you can install Repolinter using npm:

npm install -g repolinter
Enter fullscreen mode Exit fullscreen mode

Linting a Local Repository

Once installed, run the following to lint a directory:

repolinter lint <directory>
Enter fullscreen mode Exit fullscreen mode

The above command will lint <directory> with the local repolinter.json ruleset or the default ruleset if none is found:

repolinter % repolinter lint .
Target directory: <directory>
Lint:
✔ license-file-exists: Found file (LICENSE)
✔ readme-file-exists: Found file (README.md)
✔ contributing-file-exists: Found file (CONTRIBUTING)
✔ code-of-conduct-file-exists: Found file (CODE-OF-CONDUCT)
✔ changelog-file-exists: Found file (CHANGELOG)
...
repolinter % echo $?
0
Enter fullscreen mode Exit fullscreen mode

Linting a Remote Repository

Repolinter also supports linting a git repository using the --git flag. With this flag enabled, the directory input will be interpreted as a git URL which Repolinter will automatically clone into a temporary directory.

repolinter lint -g https://github.com/todogroup/repolinter.git
Enter fullscreen mode Exit fullscreen mode

It's as simple as running 'npx repolinter' against a repository:

repolinter output

You can decide what rules to run against your repository:

repolinter rules

You can also build custom rules for your project, for example, this pull request added a rule to check for security policies (SECURITY.md):

If you have ideas for more rules, please contribute them to the project.

Anyways, happy open source linting!

Top comments (0)