Skip to content

Commit

Permalink
Use ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Jul 18, 2021
1 parent eb6ac18 commit f15fb81
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 82 deletions.
18 changes: 7 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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

Expand Down Expand Up @@ -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.
Expand Down
63 changes: 0 additions & 63 deletions index.json

This file was deleted.

63 changes: 63 additions & 0 deletions list.js
Original file line number Diff line number Diff line change
@@ -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"
}
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
"Sylvan Swierkosz <sswierkosz@gmail.com>"
],
"sideEffects": false,
"type": "module",
"main": "index.js",
"files": [
"index.js",
"index.json"
"list.js"
],
"dependencies": {
"nlcst-is-literal": "^1.0.0",
Expand All @@ -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",
Expand All @@ -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"
}
Expand Down
8 changes: 3 additions & 5 deletions test.js
Original file line number Diff line number Diff line change
@@ -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(
Expand Down

0 comments on commit f15fb81

Please sign in to comment.