Skip to content

Latest commit

 

History

History
112 lines (71 loc) · 1.44 KB

README.md

File metadata and controls

112 lines (71 loc) · 1.44 KB

difflint

Go Reference

🔍 Git-based linter tool that scans code changes for compliance with defined rules in source code.

Installation

go get -u github.com/EthanThatOneKid/difflint

Usage

difflint --help

Single file

# File: ./main.py

#LINT.IF

print("Edit me first!")

#LINT.END bar

#LINT.IF :bar

print("Edit me second!")

#LINT.END

Multiple files

# File ./foo.py

#LINT.IF

print("Edit me first!")

#LINT.END bar
# File: ./main.py

#LINT.IF ./foo.py:bar

print("Edit me second!")

#LINT.END

Exhaustive switch statement

In programming languages lacking a comprehensive match statement for enumerations, our only option is to verify whether the switch statement aligns with the enumerated type.

//LINT.IF

enum Thing {
  ONE = 1,
  TWO = 2,
}

//LINT.END :thing_enum

//LINT.IF :thing_enum

switch (thing) {
  case Thing.ONE: {
    return doThingOne();
  }

  case Thing.TWO: {
    return doThingTwo();
  }
}

//LINT.END

Custom file extensions

git diff | difflint --ext_map="difflint.json"

difflint.json

{
  "yaml": ["#LINT.?"]
}

Development

Run the tool from source with the Go toolchain:

go run cli/main.go --help

Created with 💖 by @EthanThatOneKid