Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jdkato committed Aug 27, 2019
1 parent 90618a9 commit 28d56d6
Show file tree
Hide file tree
Showing 10 changed files with 167 additions and 2 deletions.
25 changes: 25 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source 'https://rubygems.org'

gem 'aruba', '~> 0.14.3'
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,24 @@
# proselint
# 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.
42 changes: 42 additions & 0 deletions features/rules.feature
Original file line number Diff line number Diff line change
@@ -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'
"""
6 changes: 6 additions & 0 deletions features/steps.rb
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions features/support/aruba.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require 'aruba/cucumber'
6 changes: 6 additions & 0 deletions fixtures/basic/.vale.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
StylesPath = ../../

MinAlertLevel = suggestion

[*.md]
BasedOnStyles = proselint
51 changes: 51 additions & 0 deletions fixtures/basic/test.md
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 1 addition & 1 deletion proselint/AnimalLabels.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 28d56d6

Please sign in to comment.