Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add E-Prime support #71

Merged
merged 6 commits into from
Mar 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ Or exclude checks like this:
write-good *.md --no-passive
```

Or include checks like this:

```shell
# E-Prime is disabled by default.
write-good *.md --yes-eprime
```

You can run just with text without supplying files:

```shell
Expand Down Expand Up @@ -133,6 +140,9 @@ Checks for wordy phrases and unnecessary words.
### `cliches`
Checks for common cliches.

### `eprime`
Checks for ["to-be"](https://en.wikipedia.org/wiki/E-Prime) verbs. _Disabled by default_

## See also

I came across these resources while doing research to make this module.
Expand Down
5 changes: 4 additions & 1 deletion bin/write-good.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ var opts = {
passive : null,
adverb : null,
tooWordy : null,
cliches : null
cliches : null,
eprime : false // User must opt-in
};

var include = true;
Expand All @@ -40,6 +41,8 @@ args.filter(function (arg) {
textInputSupplied = inputSupplied = true;
} else if (arg.substr(0, 3) === 'no-') {
opts[arg.substr(3)] = false;
} else if (arg.substr(0, 4) === 'yes-') {
opts[arg.substr(4)] = true;
} else if (arg == 'parse') {
//overload the lint option logic above, to include
//an operational flag: --parse, which means parse-happy output
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@
"jasmine-node": "2.0.0"
},
"dependencies": {
"object.assign": "^4.0.4",
"passive-voice": "~0.0.0",
"weasel-words": "~0.1.0",
"adverb-where": "~0.0.0",
"too-wordy": "~0.1.0",
"no-cliches": "~0.1.0"
"no-cliches": "~0.1.0",
"e-prime": "~0.10.0"
},
"coordinates": [
45.522199,
Expand Down
20 changes: 20 additions & 0 deletions test/basic.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,26 @@ describe('writeGood', function () {
{ index: 2, offset: 8, reason: '"there is" is unnecessary verbiage' }
]);
});

it('should detect simple "to be" verb', function () {
expect(writeGood('NodeJs is awesome ;)', { eprime: true })).toEqual([
{ index: 7, offset: 2, reason: '"is" is a form of \'to be\'' }
]);
});

it('should ignore "to be" verb with check disabled', function () {
expect(writeGood('NodeJs is awesome ;)', { eprime: false })).toEqual([]);
});

it('should detect "to be" verb contraction', function () {
expect(writeGood('There\'s no place like localhost', { eprime: true })).toEqual([
{ index: 0, offset: 7, reason: '"There\'s" is a form of \'to be\'' }
]);
});

it('shouldn\'t flag words starting with "is" as an error', function () {
expect(writeGood('Isle of Man', { eprime: true })).toEqual([]);
});
});

describe('annotate', function () {
Expand Down
10 changes: 9 additions & 1 deletion write-good.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
var assign = Object.assign || require('object.assign');

var checks = {
weasel : { fn: require('weasel-words'), explanation: 'is a weasel word' },
illusion : { fn: require('./lib/lexical-illusions'), explanation: 'is repeated' },
Expand All @@ -7,10 +9,16 @@ var checks = {
adverb : { fn: require('adverb-where'), explanation: 'can weaken meaning'},
tooWordy : { fn: require('too-wordy'), explanation: 'is wordy or unneeded'},
cliches : { fn: require('no-cliches'), explanation: 'is a cliche'},
eprime : { fn: require('e-prime'), explanation: 'is a form of \'to be\''}
};

// User must explicitly opt-in
var disabledChecks = {
eprime: false
};

module.exports = function (text, opts) {
opts = opts || {};
opts = assign({}, disabledChecks, opts);
var suggestions = [];
Object.keys(checks).forEach(function (checkName) {
if (opts[checkName] !== false) {
Expand Down