Skip to content

Commit

Permalink
Merge branch 'release/0.1.1' into versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeehut committed Mar 23, 2020
2 parents 25fec7d + 6538d50 commit e80ac90
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 33 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
/*.xcodeproj
xcuserdata/
/AnyLintTempTests
.codacy-coverage
*.lcov
codacy-coverage.json
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,13 @@ If needed, pluralize to `Tasks`, `PRs` or `Authors` and list multiple entries se
### Security
- None.

## [0.1.1] - 2020-03-23
### Added
- Added two simple lint check examples in first code sample in README. (Thanks for the pointer, [Dave Verwer](https://github.com/daveverwer)!)
Author: [Cihat Gündüz](https://github.com/Jeehut)
### Changed
- Changed `CheckInfo` id casing convention from snake_case to UpperCamelCase in `blank` template.
Author: [Cihat Gündüz](https://github.com/Jeehut)

## [0.1.0] - 2020-03-22
Initial public release.
2 changes: 1 addition & 1 deletion Formula/anylint.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
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 => "?"
url "https://github.com/Flinesoft/AnyLint.git", :tag => "0.1.0", :revision => "25fec7dd29d86f0ef97fc2dddcd41d2576d9570c"
head "https://github.com/Flinesoft/AnyLint.git"

depends_on :xcode => ["11.3", :build]
Expand Down
Binary file added Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 34 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<p align="center">
<img src="https://raw.githubusercontent.com/Flinesoft/AnyLint/main/Logo.png"
width=562 height=115>
</p>

<p align="center">
<a href="https://app.bitrise.io/app/b2708c16ab236ff8">
<img src="https://app.bitrise.io/app/b2708c16ab236ff8/status.svg?token=PuELIpLj_V11GkcIztEgGQ&branch=main"
Expand All @@ -12,8 +17,8 @@
alt="Coverage"/>
</a>
<a href="https://github.com/Flinesoft/AnyLint/releases">
<img src="https://img.shields.io/badge/Version-0.1.0-blue.svg"
alt="Version: 0.1.0">
<img src="https://img.shields.io/badge/Version-0.1.1-blue.svg"
alt="Version: 0.1.1">
</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 @@ -46,7 +51,7 @@

# AnyLint

Lint anything by combining the power of Swift & regular expressions.
Lint any project in any language using Swift and regular expressions. With built-in support for matching and non-matching examples validation & autocorrect replacement. Replaces SwiftLint custom rules & works for other languages as well! 🎉

## Installation

Expand Down Expand Up @@ -81,17 +86,38 @@ To initialize AnyLint in a project, run:
anylint --init blank
```

This will create the Swift script file `lint.swift` with the following contents:
This will create the Swift script file `lint.swift` with something like following contents:

```swift
#!/usr/local/bin/swift-sh
import AnyLint // @Flinesoft ~> 0.1.0
import AnyLint // @Flinesoft ~> 0.1.1

// MARK: - Variables
// some example variables
let readmeFile: Regex = #"README\.md"#

// MARK: - Checks
// some example lint checks
// MARK: Readme
try Lint.checkFilePaths(
checkInfo: "Readme: Each project should have a README.md file explaining the project.",
regex: readmeFile,
matchingExamples: ["README.md"],
nonMatchingExamples: ["README.markdown", "Readme.md", "ReadMe.md"],
violateIfNoMatchesFound: true
)

// MARK: ReadmeTypoLicense
try Lint.checkFileContents(
checkInfo: "ReadmeTypoLicense: Misspelled word 'license'.",
regex: #"([\s#]L|l)isence([\s\.,:;])"#,
matchingExamples: [" license:", "## Lisence\n"],
nonMatchingExamples: [" license:", "## License\n"],
includeFilters: [readmeFile],
autoCorrectReplacement: "$1icense$2",
autoCorrectExamples: [
AutoCorrection(before: " license:", after: " license:"),
AutoCorrection(before: "## Lisence\n", after: "## License\n"),
]
)

// MARK: - Log Summary & Exit
Lint.logSummaryAndExit()
Expand Down Expand Up @@ -282,7 +308,7 @@ When using the `customCheck`, you might want to also include some Swift packages
```swift
#!/usr/local/bin/swift-sh
import AnyLint // @Flinesoft ~> 0.1.0
import AnyLint // @Flinesoft ~> 0.1.1
import Files // @JohnSundell ~> 4.1.1
import ShellOut // @JohnSundell ~> 2.3.0

Expand Down
16 changes: 8 additions & 8 deletions Sources/AnyLintCLI/ConfigurationTemplates/BlankTemplate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ enum BlankTemplate: ConfigurationTemplate {
let readmeFile: Regex = #"README\.md"#

// MARK: - Checks
// MARK: readme
// MARK: Readme
try Lint.checkFilePaths(
checkInfo: "readme: Each project should have a README.md file, explaining how to use or contribute to the project.",
checkInfo: "Readme: Each project should have a README.md file, explaining how to use or contribute to the project.",
regex: #"^README\.md$"#,
matchingExamples: ["README.md"],
nonMatchingExamples: ["README.markdown", "Readme.md", "ReadMe.md"],
violateIfNoMatchesFound: true
)

// MARK: readme_path
// MARK: ReadmePath
try Lint.checkFilePaths(
checkInfo: "readme_path: The README file should be named exactly `README.md`.",
checkInfo: "ReadmePath: The README file should be named exactly `README.md`.",
regex: #"^(.*/)?([Rr][Ee][Aa][Dd][Mm][Ee]\.markdown|readme\.md|Readme\.md|ReadMe\.md)$"#,
matchingExamples: ["README.markdown", "readme.md", "ReadMe.md"],
nonMatchingExamples: ["README.md", "CHANGELOG.md", "CONTRIBUTING.md", "api/help.md"],
Expand All @@ -33,9 +33,9 @@ enum BlankTemplate: ConfigurationTemplate {
]
)

// MARK: readme_top_level_title
// MARK: ReadmeTopLevelTitle
try Lint.checkFileContents(
checkInfo: "readme_top_level_title: The README.md file should only contain a single top level title.",
checkInfo: "ReadmeTopLevelTitle: The README.md file should only contain a single top level title.",
regex: #"(^|\n)#[^#](.*\n)*\n#[^#]"#,
matchingExamples: [
"""
Expand All @@ -60,9 +60,9 @@ enum BlankTemplate: ConfigurationTemplate {
includeFilters: [readmeFile]
)

// MARK: readme_typo_license
// MARK: ReadmeTypoLicense
try Lint.checkFileContents(
checkInfo: "readme_typo_license: Misspelled word 'license'.",
checkInfo: "ReadmeTypoLicense: Misspelled word 'license'.",
regex: #"([\s#]L|l)isence([\s\.,:;])"#,
matchingExamples: [" lisence:", "## Lisence\n"],
nonMatchingExamples: [" license:", "## License\n"],
Expand Down
2 changes: 1 addition & 1 deletion Sources/Utility/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public var log = Logger(outputType: .console)
/// Constants to reference across the project.
public enum Constants {
/// The current tool version string. Conforms to SemVer 2.0.
public static let currentVersion: String = "0.1.0"
public static let currentVersion: String = "0.1.1"

/// The name of this tool.
public static let toolName: String = "AnyLint"
Expand Down
2 changes: 1 addition & 1 deletion Sources/Utility/Logger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public final class Logger {
private func consoleMessage(_ message: String, level: PrintLevel) {
switch level {
case .success:
print(formattedCurrentTime(), " ", message.green)
print(formattedCurrentTime(), "", message.green)

case .info:
print(formattedCurrentTime(), "ℹ️ ", message.lightBlue)
Expand Down
14 changes: 0 additions & 14 deletions lint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -453,19 +453,5 @@ try Lint.checkFileContents(
includeFilters: [readmeFile]
)

// MARK: ReadmeTypoLicense
try Lint.checkFileContents(
checkInfo: "ReadmeTypoLicense: Misspelled word 'license'.",
regex: #"([\s#]L|l)isence([\s\.,:;])"#,
matchingExamples: [" lisence:", "## Lisence\n"],
nonMatchingExamples: [" license:", "## License\n"],
includeFilters: [readmeFile],
autoCorrectReplacement: "$1icense$2",
autoCorrectExamples: [
AutoCorrection(before: " lisence:", after: " license:"),
AutoCorrection(before: "## Lisence\n", after: "## License\n"),
]
)

// MARK: - Log Summary & Exit
Lint.logSummaryAndExit()

0 comments on commit e80ac90

Please sign in to comment.