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

Open Source Repository Linter

Repo Linter Build Status

Lint open source repositories for common issues.

Usage

To run against a directory, add it to the command line npx repolinter /my/code/dir.

To run against a git repository, use the --git option: npx repolinter --git https://my.git.code/awesome.

Note, if you are running a version of npm < 5.2.0, run npm install npx first.

You can also run Repo Linter locally by cloning this repository and running bin/repolinter.js with either a directory of a git repository the same as above. This is useful during development.

Examples

To quickly get started, checkout this repository and run npx repolinter against itself.

git clone https://github.com/todogroup/repolinter
npx repolinter
✔ license-file-exists: found (LICENSE)
✔ readme-file-exists: found (README.md)
✔ contributing-file-exists: found (CONTRIBUTING)
✔ code-of-conduct-file-exists: found (CODE-OF-CONDUCT)
✔ changelog-file-exists: found (CHANGELOG)
✔ readme-references-license: File README.md contains license
✔ binaries-not-present: Excluded file type doesn't exist (**/*.exe,**/*.dll)
✔ license-detectable-by-licensee: Licensee identified the license for project: Apache License 2.0
✔

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)