From 2bc19e3b9bfba9121dd3adf67e44978dba176f62 Mon Sep 17 00:00:00 2001 From: Chris Araman Date: Mon, 3 May 2021 13:42:10 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=96=8A=20Lint=20markdown?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/ISSUE_TEMPLATE/bug_report.md | 17 +++------------- .markdownlint.json | 4 ++++ Brewfile | 1 + CODE_OF_CONDUCT.md | 4 ++-- CONTRIBUTING.md | 29 +++++++++++++++------------- README.md | 14 ++++++++++---- docs/style.md | 15 ++++++++------ script/format | 6 +++++- script/lint | 6 +++++- 9 files changed, 55 insertions(+), 41 deletions(-) create mode 100644 .markdownlint.json diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 777686a..2cafffd 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -19,15 +19,13 @@ assignees: '' - [] [mas-cli/tap](https://github.com/mas-cli/homebrew-tap) - [] `.pkg` installer from [releases](https://github.com/mas-cli/mas/releases) - [] Built from source - - Fork/branch: ? (e.g. mas-cli/master) - - Xcode version: 10.? + - Fork/branch: ? (e.g. mas-cli/master) + - Xcode version: 10.? ## Describe the Bug > A clear and concise description of what the bug is. - - ## To Reproduce Steps to reproduce the behavior: @@ -41,29 +39,20 @@ Steps to reproduce the behavior: > A clear and concise description of what you expected to happen. - - ## Actual Behavior > A clear and concise description of what actually happened. - - ## Screenshots, Terminal Output > If applicable, add screenshots to help explain your problem. - - -``` +```bash $ mas command ... ``` - ## Additional Context > Add any other context about the problem here. > Did it work in a previous version? - - diff --git a/.markdownlint.json b/.markdownlint.json new file mode 100644 index 0000000..f2d608c --- /dev/null +++ b/.markdownlint.json @@ -0,0 +1,4 @@ +{ + "MD013": { "line_length": 120 }, + "MD033": { "allowed_elements": ["h1", "img"] } +} diff --git a/Brewfile b/Brewfile index 0afd05f..4bea1f5 100644 --- a/Brewfile +++ b/Brewfile @@ -1,3 +1,4 @@ +brew "markdownlint-cli" brew "shfmt" brew "swift-format" brew "swiftformat" diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 6f43dcb..e443d1d 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -68,9 +68,9 @@ members of the project's leadership. ## Attribution This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, -available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html +available at [homepage]: https://www.contributor-covenant.org For answers to common questions about this code of conduct, see -https://www.contributor-covenant.org/faq + diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 367d941..01ba479 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,34 +6,36 @@ We love pull requests from everyone. By participating in this project, you agree - Make sure you have a [GitHub account](https://github.com/join). - [Open an issue](https://github.com/mas-cli/mas/issues/new) to simply ask a question or request a new feature. -- Search for similar issues with the [ERROR MESSAGE](https://github.com/mas-cli/mas/issues?utf8=%E2%9C%93&q=is%3Aopen+ERROR+MESSAGE) you are exeriencing. +- Search for similar issues with the +[ERROR MESSAGE](https://github.com/mas-cli/mas/issues?utf8=%E2%9C%93&q=is%3Aopen+ERROR+MESSAGE) +you are exeriencing. - If one doesn't exist, [open a new issue](https://github.com/mas-cli/mas/issues/new) - - Clearly describe the issue including steps to reproduce when it is a bug. - - Include the earliest version of `mas` that you know has the issue. - - Include your macOS version. + - Clearly describe the issue including steps to reproduce when it is a bug. + - Include the earliest version of `mas` that you know has the issue. + - Include your macOS version. ## Making Changes - [Fork the repository](https://github.com/mas-cli/mas#fork-destination-box) on GitHub. -- Cone your fork +- Cone your fork `git clone git@github.com:your-username/mas.git` - Create a topic branch from where you want to base your work. - - This is usually the `master` branch. - - To quickly create a topic branch based on `master`, run + - This is usually the `master` branch. + - To quickly create a topic branch based on `master`, run `git checkout -b awesome-feature master` - - Please avoid working [directly on the master branch](https://softwareengineering.stackexchange.com/questions/223400/when-should-i-stop-committing-to-master-on-new-projects). - - Make commits of logical units. + - Please avoid working [directly on the master branch](https://softwareengineering.stackexchange.com/questions/223400/when-should-i-stop-committing-to-master-on-new-projects). + - Make commits of logical units. - Run script/format before committing your changes. Fix anything that isn't automatically fixed by the linters. - Push your topic branch to your fork and [submit a pull request](https://github.com/mas-cli/mas/compare/master...your-username:topic-branch). Some things that will increase the chance that your pull request is accepted: - Write tests. (Tests target is still [in progress](https://github.com/mas-cli/mas/issues/123)) - - If you need help with tests, feel free to open a PR in the meantime and just ask for some help. - - Add "[WIP]" to the title of your PR to indicate that it's not ready to be merged. + - If you need help with tests, feel free to open a PR in the meantime and just ask for some help. + - Add "[WIP]" to the title of your PR to indicate that it's not ready to be merged. - Follow our [style guide](docs/style.md). - Write a [good commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html). - - Including [appropriate emoji](https://gitmoji.carloscuesta.me/) in the first line of commit messages is fun :wink:. + - Including [appropriate emoji](https://gitmoji.carloscuesta.me/) in the first line of commit messages is fun :wink:. ## Becoming a Contributor @@ -50,7 +52,8 @@ to this project, but must remain an owner. By becoming a contributor, you agree - This project follows [trunk-based development](https://trunkbaseddevelopment.com/), where `master` is our trunk. - Release commits will be tagged in the format: `v1.2.3`. -- Once releases are tagged, high-level release notes are published on the [releases](https://github.com/mas-cli/mas/releases) page. +- Once releases are tagged, high-level release notes are published on the +[releases](https://github.com/mas-cli/mas/releases) page. See GitHub's post on creating [Contributing Guidelines](https://github.com/blog/1184-contributing-guidelines) if you would like to set up something like this for your projects. diff --git a/README.md b/README.md index 85eedb3..9ed4f82 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[

mas-cli

][mas-cli] +

mas-cli

# mas-cli @@ -109,7 +109,8 @@ $ mas purchase 768053424 ``` > Please note that you may have to re-authenticate yourself in the App Store to complete the purchase. -This is the case if the application is not free or if you configured your account not to remember the credentials for free purchases. +This is the case if the application is not free or if you configured your account not to remember the +credentials for free purchases. Use `mas outdated` to list all applications with pending updates. @@ -183,9 +184,14 @@ docs for more details. ## 💥 When something doesn't work -If you see the error "This redownload is not available for this Apple ID either because it was bought by a different user of the item was refunded or cancelled.", it's probably because you haven't installed the app through the App Store yet. See [#46](https://github.com/mas-cli/mas/issues/46#issuecomment-248581233). +If you see this error, it's probably because you haven't installed the app through the App Store yet. +See [#46](https://github.com/mas-cli/mas/issues/46#issuecomment-248581233). +> This redownload is not available for this Apple ID either because it was bought by a different user of the +> item was refunded or cancelled. -If `mas` doesn't work for you as expected (e.g. you can't update/download apps), run `mas reset` and try again. If the issue persists, please [file a bug](https://github.com/mas-cli/mas/issues/new)! All your feedback is much appreciated ✨ +If `mas` doesn't work for you as expected (e.g. you can't update/download apps), run `mas reset` and try again. +If the issue persists, please [file a bug](https://github.com/mas-cli/mas/issues/new). +All your feedback is much appreciated! ✨ ## 📺 Using `tmux` diff --git a/docs/style.md b/docs/style.md index 6de3332..3e24c3d 100644 --- a/docs/style.md +++ b/docs/style.md @@ -2,18 +2,21 @@ - Use `script/format` to automatically fix a number of style violations. - Remove unnecessary whitespace from the end of lines. - - Use `script/lint` to look for these before committing. - - Note that [two trailing spaces](https://gist.github.com/shaunlebron/746476e6e7a4d698b373) + - Use `script/lint` to look for these before committing. + - Note that [two trailing spaces](https://gist.github.com/shaunlebron/746476e6e7a4d698b373) is intentional in markdown documents to create a line break like `
`, so these should _not_ be removed. - End each file with a [newline character](https://unix.stackexchange.com/questions/18743/whats-the-point-in-adding-a-new-line-to-the-end-of-a-file#18789). -# Swift +## Swift [Sample](sample.swift) -- Avoid [force unwrapping optionals](https://blog.timac.org/2017/0628-swift-banning-force-unwrapping-optionals/) with `!` in production code - - Production code is what gets shipped with the app. Basically, everything under the [`mas-cli/`](https://github.com/mas-cli/mas/tree/master/mas-cli) folder. - - However, force unwrapping is **encouraged** in tests for less code and tests _should_ break when any expected conditions aren't met. +- Avoid [force unwrapping optionals](https://blog.timac.org/2017/0628-swift-banning-force-unwrapping-optionals/) +with `!` in production code + - Production code is what gets shipped with the app. Basically, everything under the + [`mas-cli/`](https://github.com/mas-cli/mas/tree/master/mas-cli) folder. + - However, force unwrapping is **encouraged** in tests for less code and tests + _should_ break when any expected conditions aren't met. - Prefer `struct`s over `class`es wherever possible - Default to marking classes as `final` - Prefer protocol conformance to class inheritance diff --git a/script/format b/script/format index a14c364..b888429 100755 --- a/script/format +++ b/script/format @@ -13,13 +13,17 @@ echo "==> 🚨 Formatting mas" -for LINTER in shfmt swift-format swiftformat swiftlint; do +for LINTER in markdownlint shfmt swift-format swiftformat swiftlint; do if [[ ! -x "$(command -v ${LINTER})" ]]; then echo "error: ${LINTER} is not installed. Run 'script/bootstrap' or 'brew install ${LINTER}'." exit 1 fi done +echo +echo "--> 🖊 Markdown" +markdownlint --config .markdownlint.json --fix .github . + echo echo "--> 🕊️ Swift" for SOURCE in Package.swift Sources Tests; do diff --git a/script/lint b/script/lint index 93503ab..d4e5b0b 100755 --- a/script/lint +++ b/script/lint @@ -12,7 +12,7 @@ echo "==> 🚨 Linting mas" -for LINTER in git swift-format swiftformat swiftlint; do +for LINTER in git markdownlint shfmt swift-format swiftformat swiftlint; do if [[ ! -x "$(command -v ${LINTER})" ]]; then echo "error: ${LINTER} is not installed. Run 'script/bootstrap' or 'brew install ${LINTER}'." exit 1 @@ -22,6 +22,10 @@ done echo "--> 🌳 Git" git diff --check +echo +echo "--> 🖊 Markdown" +markdownlint --config .markdownlint.json .github . + echo echo "--> 🕊️ Swift" for SOURCE in Package.swift Sources Tests; do