Skip to content

Commit

Permalink
Prepare for first public release
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeehut committed Mar 22, 2020
1 parent a79676f commit 84177fb
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 6 deletions.
16 changes: 16 additions & 0 deletions Formula/anylint.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class Anylint < Formula
desc "Lint anything by combining the power of Swift & regular expressions"
homepage "https://github.com/Flinesoft/AnyLint"
url "https://github.com/Flinesoft/AnyLint.git", :tag => "0.1.0", :revision => "?"
head "https://github.com/Flinesoft/AnyLint.git"

depends_on :xcode => ["11.3", :build]

def install
system "make", "install", "prefix=#{prefix}"
end

test do
system bin/"anylint", "-v"
end
end
38 changes: 38 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
SHELL = /bin/bash

prefix ?= /usr/local
bindir ?= $(prefix)/bin
libdir ?= $(prefix)/lib
srcdir = Sources

REPODIR = $(shell pwd)
BUILDDIR = $(REPODIR)/.build
SOURCES = $(wildcard $(srcdir)/**/*.swift)

.DEFAULT_GOAL = all

.PHONY: all
all: anylint

anylint: $(SOURCES)
@swift build \
-c release \
--disable-sandbox \
--build-path "$(BUILDDIR)"

.PHONY: install
install: anylint
@install -d "$(bindir)" "$(libdir)"
@install "$(BUILDDIR)/release/anylint" "$(bindir)"

.PHONY: uninstall
uninstall:
@rm -rf "$(bindir)/anylint"

.PHONY: clean
distclean:
@rm -f $(BUILDDIR)/release

.PHONY: clean
clean: distclean
@rm -rf $(BUILDDIR)
33 changes: 27 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
alt="Coverage"/>
</a>
<a href="https://github.com/Flinesoft/AnyLint/releases">
<img src="https://img.shields.io/badge/Version-0.0.0-blue.svg"
alt="Version: 0.0.0">
<img src="https://img.shields.io/badge/Version-0.1.0-blue.svg"
alt="Version: 0.1.0">
</a>
<a href="https://github.com/Flinesoft/AnyLint/blob/main/LICENSE">
<img src="https://img.shields.io/badge/License-MIT-lightgrey.svg"
Expand Down Expand Up @@ -50,7 +50,28 @@ Lint anything by combining the power of Swift & regular expressions.

## Installation

TODO
### Via [Homebrew](https://brew.sh):

To **install** AnyLint the first time, run these commands:

```bash
brew tap Flinesoft/AnyLint https://github.com/Flinesoft/AnyLint.git
brew install anylint
```

To **update** it to the latest version, run this instead:

```bash
brew upgrade anylint
```

### Via [Mint](https://github.com/yonaskolb/Mint):

To **install** AnyLint or **update** to the latest version, run this command:

```bash
mint install Flinesoft/AnyLint
```

## Getting Started

Expand Down Expand Up @@ -128,8 +149,6 @@ Many parameters in the above mentioned lint check methods are of `Regex` type. A

Note that we recommend using [raw strings](https://www.hackingwithswift.com/articles/162/how-to-use-raw-strings-in-swift) (`#"foo"#` instead of `"foo"`) for all regexes to get rid of double escaping backslashes (e.g. `\\s` becomes `\s`). This also allows for testing regexes in online regex editors like [rubular](https://rubular.com/) first and then copy & pasting from them without any additional escaping.

In general, initializing a `Regex` object is enough to use AnyLint – the matching part will be handled automatically. In case you want to use the `customCheck` method and need regexes there, you can learn more about how you can match strings with a `Regex` object on [the HandySwift docs](https://github.com/Flinesoft/AnyLint/blob/main/Sources/Utility/Regex.swift) (the project, the class was taken from) or read the [code documentation comments](https://github.com/Flinesoft/AnyLint/blob/main/Sources/Utility/Regex.swift).

#### CheckInfo

A `CheckInfo` contains the basic information about a lint check. It consists of:
Expand All @@ -142,7 +161,7 @@ While there is an initializer available, we recommend using a String Literal ins

```swift
// accepted structure: <id>(@<severity>): <hint>
let checkInfo: CheckInfo = "readme_path: The README file should be named exactly `README.md`."
let checkInfo: CheckInfo = "ReadmePath: The README file should be named exactly `README.md`."
```

### Check File Contents
Expand Down Expand Up @@ -255,6 +274,8 @@ AnyLint allows you to do any kind of lint checks (thus its name) as it gives you

Note that the `Violation` type just holds some additional information on the file, matched string, location in the file and applied autocorrection and that all these fields are optional. It is a simple struct used by the AnyLint reporter for more detailed output, no logic attached. The only required field is the `CheckInfo` object which caused the violation.

If you want to use regexes in your custom code, you can learn more about how you can match strings with a `Regex` object on [the HandySwift docs](https://github.com/Flinesoft/AnyLint/blob/main/Sources/Utility/Regex.swift) (the project, the class was taken from) or read the [code documentation comments](https://github.com/Flinesoft/AnyLint/blob/main/Sources/Utility/Regex.swift).

When using the `customCheck`, you might want to also include some Swift packages for [easier file handling](https://github.com/JohnSundell/Files) or [running shell commands](https://github.com/JohnSundell/ShellOut). You can do so by adding them at the top of the file like so:

> TODO: Improve the below code example with something more useful & realistic.
Expand Down

0 comments on commit 84177fb

Please sign in to comment.