From 69223ee2f047dc6dbfd0a081a21b0686f0308b96 Mon Sep 17 00:00:00 2001 From: Chris Chinchilla Date: Mon, 12 Oct 2020 19:51:29 +0200 Subject: [PATCH] Refactor --- .gitignore | 50 +++++++++++++++++++++++ .travis.yml | 26 ++++++++++++ .yamllint.yml | 8 ++++ Gemfile | 3 ++ Gemfile.lock | 83 +++++++++++++++++++++++++++++++++++++++ README.md | 28 ++++++++++++- features/rules.feature | 15 +++++++ features/steps.rb | 6 +++ features/support/aruba.rb | 1 + fixtures/basic/.vale.ini | 6 +++ fixtures/basic/fail.md | 5 +++ fixtures/basic/pass.md | 5 +++ fixtures/basic/real.md | 5 +++ 13 files changed, 239 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100644 .travis.yml create mode 100644 .yamllint.yml create mode 100644 Gemfile create mode 100644 Gemfile.lock create mode 100755 features/rules.feature create mode 100755 features/steps.rb create mode 100755 features/support/aruba.rb create mode 100755 fixtures/basic/.vale.ini create mode 100755 fixtures/basic/fail.md create mode 100755 fixtures/basic/pass.md create mode 100755 fixtures/basic/real.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5e1422c --- /dev/null +++ b/.gitignore @@ -0,0 +1,50 @@ +*.gem +*.rbc +/.config +/coverage/ +/InstalledFiles +/pkg/ +/spec/reports/ +/spec/examples.txt +/test/tmp/ +/test/version_tmp/ +/tmp/ + +# Used by dotenv library to load environment variables. +# .env + +## Specific to RubyMotion: +.dat* +.repl_history +build/ +*.bridgesupport +build-iPhoneOS/ +build-iPhoneSimulator/ + +## Specific to RubyMotion (use of CocoaPods): +# +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control +# +# vendor/Pods/ + +## Documentation cache and generated files: +/.yardoc/ +/_yardoc/ +/doc/ +/rdoc/ + +## Environment normalization: +/.bundle/ +/vendor/bundle +/lib/bundler/man/ + +# for a library or gem, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# Gemfile.lock +# .ruby-version +# .ruby-gemset + +# unless supporting rvm < 1.11.0 or doing something fancy, ignore this: +.rvmrc diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..691ba1d --- /dev/null +++ b/.travis.yml @@ -0,0 +1,26 @@ +language: python +cache: bundler +python: + - "3.6" +install: + # Install the latest release of Vale: + - curl -sL https://install.goreleaser.com/github.com/ValeLint/vale.sh | bash + - export PATH=./bin:"$PATH" + + - bundle install --jobs=3 + + - pip install yamllint + - pip install markdata + - pip install pyyaml +before_script: + - yamllint -c '.yamllint.yml' 18F +script: + - cucumber + - zip -r 18F.zip 18F -x "*.DS_Store" +deploy: + provider: releases + api_key: $GITHUB_TOKEN + file: 18F.zip + skip_cleanup: true + on: + tags: true diff --git a/.yamllint.yml b/.yamllint.yml new file mode 100644 index 0000000..e94216a --- /dev/null +++ b/.yamllint.yml @@ -0,0 +1,8 @@ +rules: + # We only include a single document (without directives) in our rules, so + # the extra markup is unnecessary. + document-start: disable + # Many rules include a `link` key that can be relatively long. + # + # TODO: Should we change this? + line-length: disable diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..8bd8b53 --- /dev/null +++ b/Gemfile @@ -0,0 +1,3 @@ +source 'https://rubygems.org' + +gem 'aruba', '~> 0.14.3' diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..edc6330 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,83 @@ +GEM + remote: https://rubygems.org/ + specs: + activesupport (6.0.3.4) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) + zeitwerk (~> 2.2, >= 2.2.2) + aruba (0.14.14) + childprocess (>= 0.6.3, < 4.0.0) + contracts (~> 0.9) + cucumber (>= 1.3.19) + ffi (~> 1.9) + rspec-expectations (>= 2.99) + thor (>= 0.19, < 2.0) + builder (3.2.4) + childprocess (3.0.0) + concurrent-ruby (1.1.7) + contracts (0.16.0) + cucumber (5.1.3) + builder (~> 3.2, >= 3.2.4) + cucumber-core (~> 8.0, >= 8.0.1) + cucumber-create-meta (~> 2.0, >= 2.0.2) + cucumber-cucumber-expressions (~> 10.3, >= 10.3.0) + cucumber-gherkin (~> 15.0, >= 15.0.2) + cucumber-html-formatter (~> 9.0, >= 9.0.0) + cucumber-messages (~> 13.1, >= 13.1.0) + cucumber-wire (~> 4.0, >= 4.0.1) + diff-lcs (~> 1.4, >= 1.4.4) + multi_test (~> 0.1, >= 0.1.2) + sys-uname (~> 1.2, >= 1.2.1) + cucumber-core (8.0.1) + cucumber-gherkin (~> 15.0, >= 15.0.2) + cucumber-messages (~> 13.0, >= 13.0.1) + cucumber-tag-expressions (~> 2.0, >= 2.0.4) + cucumber-create-meta (2.0.2) + cucumber-messages (~> 13.0, >= 13.0.1) + sys-uname (~> 1.2, >= 1.2.1) + cucumber-cucumber-expressions (10.3.0) + cucumber-gherkin (15.0.2) + cucumber-messages (~> 13.0, >= 13.0.1) + cucumber-html-formatter (9.0.0) + cucumber-messages (~> 13.0, >= 13.0.1) + cucumber-messages (13.1.0) + protobuf-cucumber (~> 3.10, >= 3.10.8) + cucumber-tag-expressions (2.0.4) + cucumber-wire (4.0.1) + cucumber-core (~> 8.0, >= 8.0.1) + cucumber-cucumber-expressions (~> 10.3, >= 10.3.0) + cucumber-messages (~> 13.0, >= 13.0.1) + diff-lcs (1.4.4) + ffi (1.13.1) + i18n (1.8.5) + concurrent-ruby (~> 1.0) + middleware (0.1.0) + minitest (5.14.2) + multi_test (0.1.2) + protobuf-cucumber (3.10.8) + activesupport (>= 3.2) + middleware + thor + thread_safe + rspec-expectations (3.9.2) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.9.0) + rspec-support (3.9.3) + sys-uname (1.2.1) + ffi (>= 1.0.0) + thor (1.0.1) + thread_safe (0.3.6) + tzinfo (1.2.7) + thread_safe (~> 0.1) + zeitwerk (2.4.0) + +PLATFORMS + ruby + +DEPENDENCIES + aruba (~> 0.14.3) + +BUNDLED WITH + 2.1.4 diff --git a/README.md b/README.md index cfc3075..381717e 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,35 @@ # 18F -A Vale linter style that replicates the 18F style guide -Based on [18F](https://pages.18f.gov/content-guide/). +A Vale linter style that replicates the 18F [18F](https://pages.18f.gov/content-guide/). + +__Not complete, and WIP, contributions welcome__.😁 + + +[![Build Status](https://travis-ci.org/testthedocs/18F.svg?branch=master)](https://travis-ci.org/testthedocs/18F) ![Vale version](https://img.shields.io/badge/vale-%3E%3D%20v1.7.0-blue.svg) ![license](https://img.shields.io/github/license/mashape/apistatus.svg) + +This repository contains a [Vale-compatible](https://github.com/errata-ai/vale) implementation of the guidelines enforced by the [18F](https://pages.18f.gov/content-guide/). > This project is in the worldwide [public domain](LICENSE.md). > As a work of the United States government, this project is in the public domain within the United States. > Additionally, we waive copyright and related rights in the work worldwide through the CC0 1.0 Universal public domain dedication. +> +## Getting Started + +> :exclamation: Requires Vale >= **1.7.0**. :exclamation: + +Download the [latest release](https://github.com/testthedocs/18F/releases), copy the "18F" directory to your `StylesPath`, and include it in your configuration file: + +```ini +# This goes in a file named either `.vale.ini` or `_vale.ini`. +StylesPath = path/to/some/directory +MinAlertLevel = warning # suggestion, warning or error + +# Only Markdown and .txt files; change to whatever you're using. +[*.{md,txt}] +# List of styles to load. +BasedOnStyles = 18F +``` +See [Usage](https://github.com/errata-ai/vale/#usage) for more information. \ No newline at end of file diff --git a/features/rules.feature b/features/rules.feature new file mode 100755 index 0000000..0cc3b5a --- /dev/null +++ b/features/rules.feature @@ -0,0 +1,15 @@ +Feature: Rules + + Scenario: Basic test case + When I test "basic" + Then the output should contain exactly: + """ + fail.md:3:11:18F.Abbreviations:Use 'e.g.,' instead of 'eg' + fail.md:3:17:18F.Abbreviations:Use 'i.e.,' instead of 'ie' + fail.md:5:22:18F.Quotes:Punctuation should be inside the quotes. + fail.md:5:30:18F.Contractions:Use 'it's' instead of 'it is.' + fail.md:5:50:18F.Brands:Use 'bandage' instead of 'Band-Aid.' + fail.md:5:82:18F.Clarity:Avoid using 'agenda' (unless you’re talking about a meeting). + fail.md:5:90:18F.OxfordComma:Use the Oxford comma in a list of three or more items. + fail.md:5:157:18F.Terms:Prefer 'usability testing' over 'user testing.' + """ diff --git a/features/steps.rb b/features/steps.rb new file mode 100755 index 0000000..61da285 --- /dev/null +++ b/features/steps.rb @@ -0,0 +1,6 @@ +cmd = 'vale --output=line --sort --normalize --relative' + +When(/^I test "(.*)"$/) do |rule| + step %(I cd to "../../fixtures/#{rule}") + step %(I run `#{cmd} .`) +end diff --git a/features/support/aruba.rb b/features/support/aruba.rb new file mode 100755 index 0000000..fb0a661 --- /dev/null +++ b/features/support/aruba.rb @@ -0,0 +1 @@ +require 'aruba/cucumber' diff --git a/fixtures/basic/.vale.ini b/fixtures/basic/.vale.ini new file mode 100755 index 0000000..8f3ebff --- /dev/null +++ b/fixtures/basic/.vale.ini @@ -0,0 +1,6 @@ +StylesPath = ../../ + +MinAlertLevel = suggestion + +[*.md] +BasedOnStyles = 18F \ No newline at end of file diff --git a/fixtures/basic/fail.md b/fixtures/basic/fail.md new file mode 100755 index 0000000..b84ac65 --- /dev/null +++ b/fixtures/basic/fail.md @@ -0,0 +1,5 @@ +# WELCOME! + +Don't use eg or ie. And in a list of one, two, and three items don't use an oxford comma. + +If you are 1-3 don't "join", it is not much of a Band-Aid and has too much of an agenda. It's better that you do one, two and three. One space please when user testing. And use your API properly. \ No newline at end of file diff --git a/fixtures/basic/pass.md b/fixtures/basic/pass.md new file mode 100755 index 0000000..d406054 --- /dev/null +++ b/fixtures/basic/pass.md @@ -0,0 +1,5 @@ +# Welcome + +Don't use e.g., or i.e., And in a list of one, two, and three items don't use an oxford comma. + +If you are between one and three don't "join," it's not much of a fix and has too much hidden meaning. It's better that you do one, two, and three. One space please when user-testing. And use your API (application programming interface) properly. \ No newline at end of file diff --git a/fixtures/basic/real.md b/fixtures/basic/real.md new file mode 100755 index 0000000..d406054 --- /dev/null +++ b/fixtures/basic/real.md @@ -0,0 +1,5 @@ +# Welcome + +Don't use e.g., or i.e., And in a list of one, two, and three items don't use an oxford comma. + +If you are between one and three don't "join," it's not much of a fix and has too much hidden meaning. It's better that you do one, two, and three. One space please when user-testing. And use your API (application programming interface) properly. \ No newline at end of file