From 28d56d62efb6f5f85419ff31dece4a7e2c6f0303 Mon Sep 17 00:00:00 2001 From: Joseph Kato Date: Tue, 27 Aug 2019 13:12:44 -0700 Subject: [PATCH] Add tests --- .travis.yml | 25 +++++++++++++++++++ .yamllint.yml | 8 ++++++ Gemfile | 3 +++ README.md | 25 ++++++++++++++++++- features/rules.feature | 42 +++++++++++++++++++++++++++++++ features/steps.rb | 6 +++++ features/support/aruba.rb | 1 + fixtures/basic/.vale.ini | 6 +++++ fixtures/basic/test.md | 51 ++++++++++++++++++++++++++++++++++++++ proselint/AnimalLabels.yml | 2 +- 10 files changed, 167 insertions(+), 2 deletions(-) create mode 100644 .travis.yml create mode 100644 .yamllint.yml create mode 100644 Gemfile create mode 100644 features/rules.feature create mode 100644 features/steps.rb create mode 100644 features/support/aruba.rb create mode 100644 fixtures/basic/.vale.ini create mode 100644 fixtures/basic/test.md diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..a25c1ab --- /dev/null +++ b/.travis.yml @@ -0,0 +1,25 @@ +language: python +cache: bundler +python: + - "3.6" +install: + # Install the latest release of Vale: + - go get github.com/errata-ai/vale + + - bundle install --jobs=3 + + - pip install yamllint + - pip install markdata + - pip install pyyaml +before_script: + - yamllint -c '.yamllint.yml' proselint +script: + - cucumber + - zip -r proselint.zip proselint -x "*.DS_Store" +deploy: + provider: releases + api_key: $GITHUB_TOKEN + file: proselint.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/README.md b/README.md index e7b68cf..9a22d96 100644 --- a/README.md +++ b/README.md @@ -1 +1,24 @@ -# proselint \ No newline at end of file +# proselint [![Build Status](https://travis-ci.org/errata-ai/proselint.svg?branch=master)](https://travis-ci.org/errata-ai/proselint) ![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) + +> [`proselint`](https://github.com/amperser/proselint/) places the world’s greatest writers and editors by your side, where they whisper suggestions on how to improve your prose. + +This repository contains a [Vale-compatible](https://github.com/errata-ai/vale) implementation of the guidelines enforced by the `proselint` ([LICENSE](https://github.com/amperser/proselint/blob/master/LICENSE.md)) linter. + +## Getting Started + +> :exclamation: proselint requires Vale >= **1.7.0**. :exclamation: + +Download the [latest release](https://github.com/errata-ai/proselint/releases), copy the "proselint" 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 = proselint +``` + +See [Usage](https://github.com/errata-ai/vale/#usage) for more information. diff --git a/features/rules.feature b/features/rules.feature new file mode 100644 index 0000000..d53f500 --- /dev/null +++ b/features/rules.feature @@ -0,0 +1,42 @@ +Feature: Rules + + Scenario: Cliches + When I test "basic" + Then the output should contain exactly: + """ + test.md:1:19:proselint.Nonwords:Consider using 'regardless' instead of 'irregardless'. + test.md:3:18:proselint.Archaisms:'perchance' is archaic. + test.md:7:6:proselint.Cliches:'a chip off the old block' is a cliche. + test.md:9:12:proselint.Cliches:'a fate worse than death' is a cliche. + test.md:11:20:proselint.Spelling:Inconsistent spelling of 'color'. + test.md:11:61:proselint.Spelling:Inconsistent spelling of 'center'. + test.md:13:9:proselint.CorporateSpeak:'circle back around' is corporate speak. + test.md:15:5:proselint.Cursing:Consider replacing 'shit'. + test.md:17:16:proselint.DateCase:With lowercase letters, the periods are standard. + test.md:17:37:proselint.DateSpacing:It's standard to put a space before '7a.m.' + test.md:17:58:proselint.DateMidnight:Use 'midnight' or 'noon'. + test.md:17:81:proselint.DateRedundancy:'a.m.' is always morning; 'p.m.' is always night. + test.md:19:18:proselint.Uncomparables:'most correct' is not comparable + test.md:21:1:proselint.Hedging:'I would argue that' is hedging. + test.md:23:4:proselint.Hyperbole:'exaggerated!!!' is hyperbolic. + test.md:25:14:proselint.Jargon:'in the affirmative' is jargon. + test.md:27:10:proselint.Illusions:'the the' - There's a lexical illusion here. + test.md:29:14:proselint.LGBTOffensive:'fag' is offensive. Remove it or consider the context. + test.md:29:44:proselint.LGBTTerms:Consider using 'sexual orientation' instead of 'sexual preference'. + test.md:31:10:proselint.Malapropisms:'the Infinitesimal Universe' is a malapropism. + test.md:33:1:proselint.Apologizing:Excessive apologizing: 'More research is needed' + test.md:35:1:proselint.But:Do not start a paragraph with a 'but'. + test.md:37:9:proselint.Currency:Incorrect use of symbols in '$10 dollars'. + test.md:39:14:proselint.Oxymorons:'exact estimate' is an oxymoron. + test.md:41:38:proselint.GenderBias:Consider using 'lawyer' instead of 'lady lawyer'. + test.md:43:11:proselint.Skunked:'impassionate' is a bit of a skunked term — impossible to use without issue. + test.md:45:21:proselint.DenizenLabels:Did you mean 'Hong Konger'? + test.md:47:13:proselint.AnimalLabels:Consider using 'avine' instead of 'bird-like'. + test.md:49:20:proselint.Typography:Consider using the '©' symbol instead of '(C)'. + test.md:49:40:proselint.Typography:Consider using the '™' symbol instead of '(tm)'. + test.md:49:56:proselint.Typography:Consider using the '®' symbol instead of '(R)'. + test.md:49:79:proselint.Typography:Consider using the '×' symbol instead of '2 x 2'. + test.md:51:27:proselint.Diacritical:Consider using 'Beyoncé' instead of 'Beyonce'. + test.md:51:36:proselint.P-Value:You should use more decimal places, unless 'p = 0.00' is really true. + test.md:51:47:proselint.Needless:Prefer 'abolition' over 'abolishment' + """ diff --git a/features/steps.rb b/features/steps.rb new file mode 100644 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 100644 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 100644 index 0000000..2d0dbdb --- /dev/null +++ b/fixtures/basic/.vale.ini @@ -0,0 +1,6 @@ +StylesPath = ../../ + +MinAlertLevel = suggestion + +[*.md] +BasedOnStyles = proselint diff --git a/fixtures/basic/test.md b/fixtures/basic/test.md new file mode 100644 index 0000000..a80bea2 --- /dev/null +++ b/fixtures/basic/test.md @@ -0,0 +1,51 @@ +The test was good irregardless. + +I want to sleep, perchance to dream. + +It's a matter of concern. + +He's a chip off the old block. + +Worse than a fate worse than death. + +Painting colour on color. The centre of the arts is the art center. + +We will circle back around to it. + +Bad shit in this phrase. The QB is named ball licker. + +It happened at 7 am. It happened at 7a.m. It happened at 12 a.m. It happened at 7 a.m. in the morning. + +This sentence is most correct. + +I would argue that this is a good test. + +So exaggerated!!! + +I agree it's in the affirmative. + +Paris in the the springtime. + +I once met a fag. I once met a gay man. My sexual preference is for women. + +Found in the Infinitesimal Universe. + +More research is needed. + +But I never start with the word "but". + +It cost $10 dollars. + +He needed an exact estimate. + +The legal team had two lawyers and a lady lawyer. + +I gave an impassionate defence of the situation. + +He was definitely a Hong Kongite. + +It was some bird-like creature. + +Show me the money! (C) The Fresh Maker (tm) Just Do It (R) It is obvious that 2 x 2 = 4 + +He saw the performance by Beyonce (p = 0.00). abolishment is a needless variant. diff --git a/proselint/AnimalLabels.yml b/proselint/AnimalLabels.yml index ccdf4f0..0f33e0e 100644 --- a/proselint/AnimalLabels.yml +++ b/proselint/AnimalLabels.yml @@ -1,5 +1,5 @@ extends: substitution -message: Consider using '%s' instead of '%s'. +message: "Consider using '%s' instead of '%s'." level: error swap: (?:bull|ox)-like: taurine