diff --git a/index.js b/index.js index 2350cbf..f5d5467 100644 --- a/index.js +++ b/index.js @@ -1,11 +1,7 @@ -'use strict' - -var visit = require('unist-util-visit') -var toString = require('nlcst-to-string') -var literal = require('nlcst-is-literal') -var rules = require('./index.json') - -module.exports = contractions +import visit from 'unist-util-visit' +import toString from 'nlcst-to-string' +import literal from 'nlcst-is-literal' +import {list} from './list.js' // Rules. var source = 'retext-contractions' @@ -23,7 +19,7 @@ var own = {}.hasOwnProperty var data = initialize() // Check contractions use. -function contractions(options) { +export default function retextContractions(options) { var ignore = options && options.allowLiterals var straight = options && options.straight @@ -93,8 +89,8 @@ function initialize() { var key var value - for (key in rules) { - value = rules[key] + for (key in list) { + value = list[key] result[key] = value // Add upper- and sentence case as well. diff --git a/index.json b/index.json deleted file mode 100644 index 0ad3315..0000000 --- a/index.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "aint": "ain't", - "arent": "aren't", - "couldnt": "couldn't", - "didnt": "didn't", - "doesnt": "doesn't", - "dont": "don't", - "hadnt": "hadn't", - "hasnt": "hasn't", - "havent": "haven't", - "hed": "he'd", - "hes": "he's", - "howd": "how'd", - "hows": "how's", - "howll": "how'll", - "Id": "I'd", - "Im": "I'm", - "Ive": "I've", - "isnt": "isn't", - "mightnt": "mightn't", - "mustve": "must've", - "mustnt": "mustn't", - "neednt": "needn't", - "oclock": "o'clock", - "shant": "shan't", - "shes": "she's", - "shouldve": "should've", - "shouldnt": "shouldn't", - "thatd": "that'd", - "thats": "that's", - "thered": "there'd", - "theres": "there's", - "therere": "there're", - "theyd": "they'd", - "theyll": "they'll", - "theyre": "they're", - "theyve": "they've", - "tis": "'tis", - "twas": "'twas", - "twere": "'twere", - "wasnt": "wasn't", - "weve": "we've", - "werent": "weren't", - "whatll": "what'll", - "whatre": "what're", - "whats": "what's", - "whatve": "what've", - "whens": "when's", - "wheres": "where's", - "whereve": "where've", - "whod": "who'd", - "wholl": "who'll", - "whos": "who's", - "whove": "who've", - "whys": "why's", - "wouldve": "would've", - "wouldnt": "wouldn't", - "yall": "y'all", - "youd": "you'd", - "youll": "you'll", - "youre": "you're", - "youve": "you've" -} diff --git a/list.js b/list.js new file mode 100644 index 0000000..b3a2e33 --- /dev/null +++ b/list.js @@ -0,0 +1,63 @@ +export const list = { + aint: "ain't", + arent: "aren't", + couldnt: "couldn't", + didnt: "didn't", + doesnt: "doesn't", + dont: "don't", + hadnt: "hadn't", + hasnt: "hasn't", + havent: "haven't", + hed: "he'd", + hes: "he's", + howd: "how'd", + hows: "how's", + howll: "how'll", + Id: "I'd", + Im: "I'm", + Ive: "I've", + isnt: "isn't", + mightnt: "mightn't", + mustve: "must've", + mustnt: "mustn't", + neednt: "needn't", + oclock: "o'clock", + shant: "shan't", + shes: "she's", + shouldve: "should've", + shouldnt: "shouldn't", + thatd: "that'd", + thats: "that's", + thered: "there'd", + theres: "there's", + therere: "there're", + theyd: "they'd", + theyll: "they'll", + theyre: "they're", + theyve: "they've", + tis: "'tis", + twas: "'twas", + twere: "'twere", + wasnt: "wasn't", + weve: "we've", + werent: "weren't", + whatll: "what'll", + whatre: "what're", + whats: "what's", + whatve: "what've", + whens: "when's", + wheres: "where's", + whereve: "where've", + whod: "who'd", + wholl: "who'll", + whos: "who's", + whove: "who've", + whys: "why's", + wouldve: "would've", + wouldnt: "wouldn't", + yall: "y'all", + youd: "you'd", + youll: "you'll", + youre: "you're", + youve: "you've" +} diff --git a/package.json b/package.json index eb81651..73f5023 100644 --- a/package.json +++ b/package.json @@ -23,9 +23,12 @@ "Titus Wormer (https://wooorm.com)", "Sylvan Swierkosz " ], + "sideEffects": false, + "type": "module", + "main": "index.js", "files": [ "index.js", - "index.json" + "list.js" ], "dependencies": { "nlcst-is-literal": "^1.0.0", @@ -39,7 +42,7 @@ "remark-preset-wooorm": "^8.0.0", "retext": "^7.0.0", "tape": "^5.0.0", - "xo": "^0.37.0" + "xo": "^0.39.0" }, "scripts": { "format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix", @@ -57,8 +60,9 @@ }, "xo": { "prettier": true, - "esnext": false, "rules": { + "no-var": "off", + "prefer-arrow-callback": "off", "unicorn/no-array-callback-reference": "off", "guard-for-in": "off" } diff --git a/test.js b/test.js index 64b128d..9dc2f73 100644 --- a/test.js +++ b/test.js @@ -1,8 +1,6 @@ -'use strict' - -var test = require('tape') -var retext = require('retext') -var contractions = require('.') +import test from 'tape' +import retext from 'retext' +import contractions from './index.js' test('contractions(value)', function (t) { t.deepEqual(