Skip to content

Commit

Permalink
convert to esmodules
Browse files Browse the repository at this point in the history
  • Loading branch information
spencermountain committed Mar 31, 2022
1 parent faf92b1 commit c53bca4
Show file tree
Hide file tree
Showing 135 changed files with 463 additions and 425 deletions.
33 changes: 26 additions & 7 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,23 @@
"sourceType": "module",
"ecmaFeatures": {}
},
"extends": ["plugin:compat/recommended", "plugin:regexp/recommended"],
"extends": [
"plugin:compat/recommended",
"plugin:regexp/recommended"
],
"rules": {
"semi": ["warn", "never"],
"indent": ["error", 2],
"spaced-comment": [0, "never"],
"semi": [
"warn",
"never"
],
"indent": [
"error",
2
],
"spaced-comment": [
0,
"never"
],
"no-cond-assign": 2,
"no-var": 1,
"prefer-const": 0,
Expand All @@ -27,7 +39,11 @@
"no-native-reassign": 2,
"no-redeclare": 2,
"radix": 1,
"quotes": [0, "single", "avoid-escape"],
"quotes": [
0,
"single",
"avoid-escape"
],
"no-shadow": 2,
"no-unused-vars": 1,
"no-lonely-if": 1,
Expand All @@ -39,7 +55,10 @@
"no-octal-escape": 2,
"no-constant-condition": 1,
"no-unused-expressions": 2,
"comma-dangle": [1, "only-multiline"],
"comma-dangle": [
1,
"only-multiline"
],
"space-before-function-paren": [
"error",
{
Expand All @@ -62,4 +81,4 @@
"regexp/prefer-w": 0,
"regexp/no-unused-capturing-group": 0
}
}
}
2 changes: 1 addition & 1 deletion plugins/classify/tests/misc.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import fs from 'fs'
import path from 'path'
let dir = new URL('./', import.meta.url).pathname

test('classify-test', async function (t) {
test('classify-test', function (t) {
let arr = [
['2008-British-motorcycle-Grand-Prix', 'Event'],
['Allen-R.-Morris', 'Person'],
Expand Down
2 changes: 1 addition & 1 deletion plugins/disambig/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,4 @@ const addMethod = function (models) {
// alias
models.Doc.prototype.disambig = models.Doc.prototype.disambiguation
}
module.exports = addMethod
export default addMethod
2 changes: 1 addition & 1 deletion plugins/html/src/01-doc.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ const toHtml = function (options) {
}
return html
}
module.exports = toHtml
export default toHtml
2 changes: 1 addition & 1 deletion plugins/html/src/02-section.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ const doSection = function (options) {
return '<div class="section">\n' + html + '</div>\n'
}

module.exports = doSection
export default doSection
2 changes: 1 addition & 1 deletion plugins/html/src/03-paragraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ const toHtml = function (options) {
}
return html
}
module.exports = toHtml
export default toHtml
4 changes: 2 additions & 2 deletions plugins/html/src/04-sentence.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const smartReplace = require('./_lib/smartReplace')
import smartReplace from './_lib/smartReplace.js'

const defaults = {
links: true,
Expand Down Expand Up @@ -30,4 +30,4 @@ const doSentence = function (options) {
}
return '<span class="sentence">' + text + '</span>'
}
module.exports = doSentence
export default doSentence
2 changes: 1 addition & 1 deletion plugins/html/src/05-link.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ const toHtml = function () {
let str = this.text() || this.page()
return `<a class="${classNames}" href="${href}">${str}</a>`
}
module.exports = toHtml
export default toHtml
2 changes: 1 addition & 1 deletion plugins/html/src/_lib/smartReplace.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ const smartReplace = function (all, text, result) {
return all
}

module.exports = smartReplace
export default smartReplace
2 changes: 1 addition & 1 deletion plugins/html/src/image.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const makeImage = function () {
return ' <img src="' + this.thumbnail() + '" alt="' + this.alt() + '"/>'
}
module.exports = makeImage
export default makeImage
22 changes: 11 additions & 11 deletions plugins/html/src/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const doc = require('./01-doc')
const section = require('./02-section')
const paragraph = require('./03-paragraph')
const sentence = require('./04-sentence')
const link = require('./05-link')
const infobox = require('./infobox')
const image = require('./image')
const list = require('./list')
const reference = require('./reference')
const table = require('./table')
import doc from './01-doc.js'
import section from './02-section.js'
import paragraph from './03-paragraph.js'
import sentence from './04-sentence.js'
import link from './05-link.js'
import infobox from './infobox.js'
import image from './image.js'
import list from './list.js'
import reference from './reference.js'
import table from './table.js'

const plugin = function (models) {
models.Doc.prototype.html = doc
Expand All @@ -32,4 +32,4 @@ const plugin = function (models) {

// models.Template.html = function(opts) {}
}
module.exports = plugin
export default plugin
2 changes: 1 addition & 1 deletion plugins/html/src/infobox.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ const infobox = function (options) {
html += '</table>\n'
return html
}
module.exports = infobox
export default infobox
2 changes: 1 addition & 1 deletion plugins/html/src/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ const toHtml = function (options) {
html += ' </ul>\n'
return html
}
module.exports = toHtml
export default toHtml
2 changes: 1 addition & 1 deletion plugins/html/src/reference.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ const toHtml = function (options) {
}
return ''
}
module.exports = toHtml
export default toHtml
2 changes: 1 addition & 1 deletion plugins/html/src/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ const toHtml = function (options) {
html += '</table>\n'
return html
}
module.exports = toHtml
export default toHtml
5 changes: 3 additions & 2 deletions plugins/html/tests/stress.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import wtf from './_lib.js'
import fs from 'fs'
import path from 'path'

let dir = new URL('./', import.meta.url).pathname

function from_file(page) {
let file = '../../../tests/cache/' + page + '.txt'
file = path.join(__dirname, file)
file = path.join(dir, file)
const str = fs.readFileSync(file, 'utf-8')
return wtf(str)
}
module.exports = from_file

const pages = [
'2008-British-motorcycle-Grand-Prix',
Expand Down
2 changes: 1 addition & 1 deletion plugins/i18n/src/data/birth_date_and_age.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = [
export default [
'ålder',
'ani',
'b',
Expand Down
2 changes: 1 addition & 1 deletion plugins/i18n/src/data/citation.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = [
export default [
'atsauce',
'chú thích',
'cit',
Expand Down
2 changes: 1 addition & 1 deletion plugins/i18n/src/data/cite_book.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = [
export default [
'bókaheimild',
'book reference',
'chú thích sách',
Expand Down
2 changes: 1 addition & 1 deletion plugins/i18n/src/data/cite_journal.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = [
export default [
'article',
'chú thích tạp chí',
'cita pubblicazione',
Expand Down
2 changes: 1 addition & 1 deletion plugins/i18n/src/data/cite_web.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = [
export default [
'chú thích web',
'cita web',
'ċita web',
Expand Down
2 changes: 1 addition & 1 deletion plugins/i18n/src/data/commons_cat.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = [
export default [
'catcómhaoin',
'categorìa ëd commons',
'comincat',
Expand Down
2 changes: 1 addition & 1 deletion plugins/i18n/src/data/coord.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = [
export default [
// 'coor',
'coor dd',
// 'coor dm',
Expand Down
2 changes: 1 addition & 1 deletion plugins/i18n/src/data/flag.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = [
export default [
'al2',
'bandeira',
// 'bandera',
Expand Down
2 changes: 1 addition & 1 deletion plugins/i18n/src/data/flagicon.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = [
export default [
// 'Al',
'bandera',
'bandera4',
Expand Down
2 changes: 1 addition & 1 deletion plugins/i18n/src/data/formatnum.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = [
export default [
// 'formatnum',
'formattal',
'puntudecimal',
Expand Down
2 changes: 1 addition & 1 deletion plugins/i18n/src/data/ipa.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = [
export default [
'afa',
// 'afi',
// 'api',
Expand Down
2 changes: 1 addition & 1 deletion plugins/i18n/src/data/isbn.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = [
export default [
// 'isbn',
'isbn2',
'آئی ایس بی این',
Expand Down
2 changes: 1 addition & 1 deletion plugins/i18n/src/data/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = [
export default [
'aðalgrein',
'ana madde',
'antsipirihany',
Expand Down
2 changes: 1 addition & 1 deletion plugins/i18n/src/data/persondata.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = [
export default [
'persoondata', //af
'ব্যক্তিতথ্য', //as
'personendaten', //de
Expand Down
2 changes: 1 addition & 1 deletion plugins/i18n/src/data/portal.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = [
export default [
// 'atari',
'awwur',
'chủ đề',
Expand Down
2 changes: 1 addition & 1 deletion plugins/i18n/src/data/reflist.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = [
export default [
'atsauces',
'çavkanî',
'çeşmeler',
Expand Down
2 changes: 1 addition & 1 deletion plugins/i18n/src/data/sfn.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = [
export default [
'harvnp',
'harvref',
'kdş',
Expand Down
2 changes: 1 addition & 1 deletion plugins/i18n/src/data/small.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = [
export default [
'biçûk',
'küçük',
'litaskrift',
Expand Down
2 changes: 1 addition & 1 deletion plugins/i18n/src/data/start_date.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = [
export default [
'algusaeg',
'aloituspäivämäärä',
'başlangıç tarihi',
Expand Down
2 changes: 1 addition & 1 deletion plugins/i18n/src/data/taxobox.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = [
export default [
'bảng phân loại',
'biotakso infokaste',
'blwch tacson',
Expand Down
63 changes: 42 additions & 21 deletions plugins/i18n/src/index.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,45 @@
import citation from './data/citation.js'
import coord from './data/coord.js'
import flag from './data/flag.js'
import flagicon from './data/flagicon.js'
import formatnum from './data/formatnum.js'
import ipa from './data/ipa.js'
import isbn from './data/isbn.js'
import main from './data/main.js'
import portal from './data/portal.js'
import reflist from './data/reflist.js'
import sfn from './data/sfn.js'
import small from './data/small.js'
import persondata from './data/persondata.js'
import taxobox from './data/taxobox.js'
import birthDateAge from './data/birth_date_and_age.js'
import citeBook from './data/cite_book.js'
import citeJournal from './data/cite_journal.js'
import citeWeb from './data/cite_web.js'
import commonsCat from './data/commons_cat.js'
import startDate from './data/start_date.js'

let mapping = {
'birth date and age': require('./data/birth_date_and_age'),
citation: require('./data/citation'),
'cite book': require('./data/cite_book'),
'cite journal': require('./data/cite_journal'),
'cite web': require('./data/cite_web'),
'commons cat': require('./data/commons_cat'),
coord: require('./data/coord'),
flag: require('./data/flag'),
flagicon: require('./data/flagicon'),
formatnum: require('./data/formatnum'),
ipa: require('./data/ipa'),
isbn: require('./data/isbn'),
main: require('./data/main'),
portal: require('./data/portal'),
reflist: require('./data/reflist'),
sfn: require('./data/sfn'),
small: require('./data/small'),
'start date': require('./data/start_date'),
persondata: require('./data/persondata'),
taxobox: require('./data/taxobox')
citation,
coord,
flag,
flagicon,
formatnum,
ipa,
isbn,
main,
portal,
reflist,
sfn,
small,
persondata,
taxobox,
'birth date and age': birthDateAge,
'cite book': citeBook,
'cite journal': citeJournal,
'cite web': citeWeb,
'commons cat': commonsCat,
'start date': startDate,
}

const plugin = function (models, templates) {
Expand All @@ -31,4 +52,4 @@ const plugin = function (models, templates) {
})
})
}
module.exports = plugin
export default plugin
Loading

0 comments on commit c53bca4

Please sign in to comment.