Skip to content

Commit

Permalink
Use ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Jul 19, 2021
1 parent ea4060d commit e203822
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 70 deletions.
10 changes: 4 additions & 6 deletions ar-latn.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
'use strict'
import {factory} from './factory.js'
import {cuss} from 'cuss/ar-latn.js'

var factory = require('./factory')
const retextProfanitiesArLatn = factory({lang: 'ar-latn', cuss})

module.exports = factory({
lang: 'ar-latn',
cuss: require('cuss/ar-latn')
})
export default retextProfanitiesArLatn
14 changes: 8 additions & 6 deletions en.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
'use strict'
import {factory} from './factory.js'
import {cuss} from 'cuss'
import pluralize from 'pluralize'

var factory = require('./factory')

module.exports = factory({
const retextProfanitiesEn = factory({
lang: 'en',
cuss: require('cuss'),
pluralize: require('pluralize'),
cuss,
pluralize,
// Misclassified singulars and plurals.
ignorePluralize: [
'children',
Expand All @@ -18,3 +18,5 @@ module.exports = factory({
// List of values not to normalize.
regular: ['hell']
})

export default retextProfanitiesEn
10 changes: 4 additions & 6 deletions es.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
'use strict'
import {factory} from './factory.js'
import {cuss} from 'cuss/es.js'

var factory = require('./factory')
const retextProfanitiesEs = factory({lang: 'es', cuss})

module.exports = factory({
lang: 'es',
cuss: require('cuss/es')
})
export default retextProfanitiesEs
18 changes: 7 additions & 11 deletions factory.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
'use strict'

var keys = require('object-keys')
var difference = require('lodash.difference')
var intersection = require('lodash.intersection')
var nlcstToString = require('nlcst-to-string')
var quotation = require('quotation')
var search = require('nlcst-search')
import keys from 'object-keys'
import difference from 'lodash.difference'
import intersection from 'lodash.intersection'
import nlcstToString from 'nlcst-to-string'
import quotation from 'quotation'
import search from 'nlcst-search'

// Map of `cuss` ratings to prefixes.
var prefixes = ['Be careful with', 'Reconsider using', 'Don’t use']
Expand All @@ -24,9 +22,7 @@ var comma = ','
var word = /\W+/g
var dashLetter = /-([a-z])/g

module.exports = factory

function factory(config) {
export function factory(config) {
var lang = config.lang
var regular = config.regular
var pluralize = config.pluralize
Expand Down
10 changes: 4 additions & 6 deletions fr.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
'use strict'
import {factory} from './factory.js'
import {cuss} from 'cuss/fr.js'

var factory = require('./factory')
const retextProfanitiesFr = factory({lang: 'fr', cuss})

module.exports = factory({
lang: 'fr',
cuss: require('cuss/fr')
})
export default retextProfanitiesFr
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
'use strict'
import retextProfanitiesEn from './en.js'

module.exports = require('./en')
export default retextProfanitiesEn
10 changes: 4 additions & 6 deletions it.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
'use strict'
import {factory} from './factory.js'
import {cuss} from 'cuss/it.js'

var factory = require('./factory')
const retextProfanitiesIt = factory({lang: 'it', cuss})

module.exports = factory({
lang: 'it',
cuss: require('cuss/it')
})
export default retextProfanitiesIt
14 changes: 9 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,21 @@
"Mathieu Jolivet",
"Otacilio Saraiva Maia Neto <[email protected]>"
],
"sideEffects": false,
"type": "module",
"main": "index.js",
"files": [
"index.js",
"factory.js",
"ar-latn.js",
"en.js",
"es.js",
"factory.js",
"fr.js",
"index.js",
"it.js",
"pt-br.js"
],
"dependencies": {
"cuss": "^1.15.0",
"cuss": "^2.0.0",
"lodash.difference": "^4.5.0",
"lodash.intersection": "^4.4.0",
"nlcst-search": "^2.0.0",
Expand All @@ -57,7 +60,7 @@
"retext": "^7.0.0",
"tape": "^5.0.0",
"unist-builder": "^2.0.0",
"xo": "^0.37.0"
"xo": "^0.39.0"
},
"scripts": {
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
Expand All @@ -75,8 +78,9 @@
},
"xo": {
"prettier": true,
"esnext": false,
"rules": {
"no-var": "off",
"prefer-arrow-callback": "off",
"unicorn/no-array-callback-reference": "off",
"unicorn/prefer-includes": "off",
"guard-for-in": "off"
Expand Down
10 changes: 4 additions & 6 deletions pt-br.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
'use strict'
import {factory} from './factory.js'
import {cuss} from 'cuss/pt-br.js'

var factory = require('./factory')
const retextProfanitiesPtBr = factory({lang: 'pt-br', cuss})

module.exports = factory({
lang: 'pt-br',
cuss: require('cuss/pt-br')
})
export default retextProfanitiesPtBr
18 changes: 8 additions & 10 deletions script/build-table.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
'use strict'
import range from 'mdast-util-heading-range'
import u from 'unist-builder'
import {cuss} from 'cuss'

var range = require('mdast-util-heading-range')
var u = require('unist-builder')
var cuss = require('cuss')

module.exports = table

function table() {
export default function table() {
return transformer
}

Expand All @@ -19,14 +15,16 @@ function transformer(tree) {
])
]

Object.keys(cuss).forEach(function (phrase) {
let phrase

for (phrase in cuss) {
rows.push(
u('tableRow', [
u('tableCell', [u('inlineCode', id(phrase))]),
u('tableCell', [u('inlineCode', phrase)])
])
)
})
}

return [start].concat(u('table', rows), end)
})
Expand Down
10 changes: 4 additions & 6 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
'use strict'

var test = require('tape')
var retext = require('retext')
var french = require('./fr')
var english = require('.')
import test from 'tape'
import retext from 'retext'
import french from './fr.js'
import english from './index.js'

test('profanities', function (t) {
retext()
Expand Down

0 comments on commit e203822

Please sign in to comment.