chore: reformat code with EditorConfig + Prettier

- Add `.editorconfig` format file with props matching current code format
- Reformat code with Prettier
pull/3/head
David Ordás 2022-09-10 11:36:31 +02:00
parent 5eaf00bfd8
commit 732592cde1
No known key found for this signature in database
GPG Key ID: 6FD751229911593E
5 changed files with 262 additions and 195 deletions

50
.editorconfig Normal file
View File

@ -0,0 +1,50 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org
; top-most EditorConfig file
root = true
; define basic and global for any file
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
max_line_length = off
trim_trailing_whitespace = true
curly_bracket_next_line = false
spaces_around_operators = true
; DOS/Windows batch scripts -
[*.{bat,cmd}]
end_of_line = crlf
; JavaScript files -
[*.{js,ts}]
curly_bracket_next_line = true
indent_size = 2
quote_type = double
; JSON files (normal and commented version) -
[*.{json,jsonc}]
indent_size = 2
quote_type = double
; Make - match it own default syntax
[Makefile]
indent_style = tab
; Markdown files - preserve trail spaces that means break line
[*.{md,markdown}]
trim_trailing_whitespace = false
; PowerShell - match defaults for New-ModuleManifest and PSScriptAnalyzer Invoke-Formatter
[*.{ps1,psd1,psm1}]
charset = utf-8-bom
end_of_line = crlf
; YML config files - match it own default syntax
[*.{yaml,yml}]
indent_size = 2

View File

@ -7,11 +7,20 @@ const languages = require("./languages");
const commandLineArgs = require("command-line-args"); const commandLineArgs = require("command-line-args");
const optionDefinitions = [ const optionDefinitions = [
{ name: "input", multiple: true, defaultValue: ["./fpb/books", "./fpb/casts", "./fpb/courses", "./fpb/more"] }, {
name: "input",
multiple: true,
defaultValue: ["./fpb/books", "./fpb/casts", "./fpb/courses", "./fpb/more"],
},
{ name: "output", defaultValue: "./parser/fpb.json" }, { name: "output", defaultValue: "./parser/fpb.json" },
]; ];
const excludes = ["README.md", "CONTRIBUTING.md", "CODE_OF_CONDUCT.md", "SUMMARY.md"]; const excludes = [
"README.md",
"CONTRIBUTING.md",
"CODE_OF_CONDUCT.md",
"SUMMARY.md",
];
/** /**
* Parses a list item generated from remark-parse into a readable format. * Parses a list item generated from remark-parse into a readable format.
@ -51,7 +60,11 @@ function parseListItem(listItem) {
entry.author = i.value.slice(3, parenIndex).trim(); // go from " - " until the first "(" entry.author = i.value.slice(3, parenIndex).trim(); // go from " - " until the first "("
} }
} }
if (i.type === "emphasis" && i.children[0].value.slice(0, 1) === "(" && i.children[0].value.slice(-1) === ")") { if (
i.type === "emphasis" &&
i.children[0].value.slice(0, 1) === "(" &&
i.children[0].value.slice(-1) === ")"
) {
// access notes found (currently assumes exactly one child, so far this is always the case) // access notes found (currently assumes exactly one child, so far this is always the case)
entry.accessNotes = i.children[0].value.slice(1, -1); entry.accessNotes = i.children[0].value.slice(1, -1);
} }
@ -149,7 +162,9 @@ function getLangFromFilename(filename) {
function getFilesFromDir(dir) { function getFilesFromDir(dir) {
return fs return fs
.readdirSync(dir) .readdirSync(dir)
.filter((file) => path.extname(file) === ".md" && excludes.indexOf(file) === -1) .filter(
(file) => path.extname(file) === ".md" && excludes.indexOf(file) === -1
)
.map((file) => path.join(dir, file)); .map((file) => path.join(dir, file));
} }
@ -221,7 +236,9 @@ function parseMarkdown(doc) {
let lastSection = sections.length - 1; let lastSection = sections.length - 1;
let lastSubSec = sections[lastSection].subsections.length - 1; let lastSubSec = sections[lastSection].subsections.length - 1;
let contentJson = parseListItem(content); let contentJson = parseListItem(content);
sections[lastSection].subsections[lastSubSec].entries.push(contentJson); // add entry to most recent h4 sections[lastSection].subsections[lastSubSec].entries.push(
contentJson
); // add entry to most recent h4
} }
}); });
} }

View File

@ -1,191 +1,191 @@
const languages = { const languages = {
'ab': 'Abkhazian', ab: "Abkhazian",
'aa': 'Afar', aa: "Afar",
'af': 'Afrikaans', af: "Afrikaans",
'ak': 'Akan', ak: "Akan",
'sq': 'Albanian', sq: "Albanian",
'am': 'Amharic', am: "Amharic",
'ar': 'Arabic', ar: "Arabic",
'an': 'Aragonese', an: "Aragonese",
'hy': 'Armenian', hy: "Armenian",
'as': 'Assamese', as: "Assamese",
'av': 'Avaric', av: "Avaric",
'ae': 'Avestan', ae: "Avestan",
'ay': 'Aymara', ay: "Aymara",
'az': 'Azerbaijani', az: "Azerbaijani",
'bm': 'Bambara', bm: "Bambara",
'ba': 'Bashkir', ba: "Bashkir",
'eu': 'Basque', eu: "Basque",
'be': 'Belarusian', be: "Belarusian",
'bn': 'Bengali', bn: "Bengali",
'bh': 'Bihari languages', bh: "Bihari languages",
'bi': 'Bislama', bi: "Bislama",
'bs': 'Bosnian', bs: "Bosnian",
'br': 'Breton', br: "Breton",
'bg': 'Bulgarian', bg: "Bulgarian",
'my': 'Burmese', my: "Burmese",
'ca': 'Catalan, Valencian', ca: "Catalan, Valencian",
'km': 'Central Khmer', km: "Central Khmer",
'ch': 'Chamorro', ch: "Chamorro",
'ce': 'Chechen', ce: "Chechen",
'ny': 'Chichewa, Chewa, Nyanja', ny: "Chichewa, Chewa, Nyanja",
'zh': 'Chinese', zh: "Chinese",
'cu': 'Church Slavonic, Old Bulgarian, Old Church Slavonic', cu: "Church Slavonic, Old Bulgarian, Old Church Slavonic",
'cv': 'Chuvash', cv: "Chuvash",
'kw': 'Cornish', kw: "Cornish",
'co': 'Corsican', co: "Corsican",
'cr': 'Cree', cr: "Cree",
'hr': 'Croatian', hr: "Croatian",
'cs': 'Czech', cs: "Czech",
'da': 'Danish', da: "Danish",
'dv': 'Divehi, Dhivehi, Maldivian', dv: "Divehi, Dhivehi, Maldivian",
'nl': 'Dutch, Flemish', nl: "Dutch, Flemish",
'dz': 'Dzongkha', dz: "Dzongkha",
'en': 'English', en: "English",
'en-US': 'English', "en-US": "English",
'eo': 'Esperanto', eo: "Esperanto",
'et': 'Estonian', et: "Estonian",
'ee': 'Ewe', ee: "Ewe",
'fo': 'Faroese', fo: "Faroese",
'fj': 'Fijian', fj: "Fijian",
'fi': 'Finnish', fi: "Finnish",
'fr': 'French', fr: "French",
'ff': 'Fulah', ff: "Fulah",
'gd': 'Gaelic, Scottish Gaelic', gd: "Gaelic, Scottish Gaelic",
'gl': 'Galician', gl: "Galician",
'lg': 'Ganda', lg: "Ganda",
'ka': 'Georgian', ka: "Georgian",
'de': 'German', de: "German",
'ki': 'Gikuyu, Kikuyu', ki: "Gikuyu, Kikuyu",
'el': 'Greek (Modern)', el: "Greek (Modern)",
'kl': 'Greenlandic, Kalaallisut', kl: "Greenlandic, Kalaallisut",
'gn': 'Guarani', gn: "Guarani",
'gu': 'Gujarati', gu: "Gujarati",
'ht': 'Haitian, Haitian Creole', ht: "Haitian, Haitian Creole",
'ha': 'Hausa', ha: "Hausa",
'he': 'Hebrew', he: "Hebrew",
'hz': 'Herero', hz: "Herero",
'hi': 'Hindi', hi: "Hindi",
'ho': 'Hiri Motu', ho: "Hiri Motu",
'hu': 'Hungarian', hu: "Hungarian",
'is': 'Icelandic', is: "Icelandic",
'io': 'Ido', io: "Ido",
'ig': 'Igbo', ig: "Igbo",
'id': 'Indonesian', id: "Indonesian",
'ia': 'Interlingua (International Auxiliary Language Association)', ia: "Interlingua (International Auxiliary Language Association)",
'ie': 'Interlingue', ie: "Interlingue",
'iu': 'Inuktitut', iu: "Inuktitut",
'ik': 'Inupiaq', ik: "Inupiaq",
'ga': 'Irish', ga: "Irish",
'it': 'Italian', it: "Italian",
'ja': 'Japanese', ja: "Japanese",
'jv': 'Javanese', jv: "Javanese",
'kn': 'Kannada', kn: "Kannada",
'kr': 'Kanuri', kr: "Kanuri",
'ks': 'Kashmiri', ks: "Kashmiri",
'kk': 'Kazakh', kk: "Kazakh",
'rw': 'Kinyarwanda', rw: "Kinyarwanda",
'kv': 'Komi', kv: "Komi",
'kg': 'Kongo', kg: "Kongo",
'ko': 'Korean', ko: "Korean",
'kj': 'Kwanyama, Kuanyama', kj: "Kwanyama, Kuanyama",
'ku': 'Kurdish', ku: "Kurdish",
'ky': 'Kyrgyz', ky: "Kyrgyz",
'lo': 'Lao', lo: "Lao",
'la': 'Latin', la: "Latin",
'lv': 'Latvian', lv: "Latvian",
'lb': 'Letzeburgesch, Luxembourgish', lb: "Letzeburgesch, Luxembourgish",
'li': 'Limburgish, Limburgan, Limburger', li: "Limburgish, Limburgan, Limburger",
'ln': 'Lingala', ln: "Lingala",
'lt': 'Lithuanian', lt: "Lithuanian",
'lu': 'Luba-Katanga', lu: "Luba-Katanga",
'mk': 'Macedonian', mk: "Macedonian",
'mg': 'Malagasy', mg: "Malagasy",
'ms': 'Malay', ms: "Malay",
'ml': 'Malayalam', ml: "Malayalam",
'mt': 'Maltese', mt: "Maltese",
'gv': 'Manx', gv: "Manx",
'mi': 'Maori', mi: "Maori",
'mr': 'Marathi', mr: "Marathi",
'mh': 'Marshallese', mh: "Marshallese",
'ro': 'Moldovan, Moldavian, Romanian', ro: "Moldovan, Moldavian, Romanian",
'mn': 'Mongolian', mn: "Mongolian",
'na': 'Nauru', na: "Nauru",
'nv': 'Navajo, Navaho', nv: "Navajo, Navaho",
'nd': 'Northern Ndebele', nd: "Northern Ndebele",
'ng': 'Ndonga', ng: "Ndonga",
'ne': 'Nepali', ne: "Nepali",
'se': 'Northern Sami', se: "Northern Sami",
'no': 'Norwegian', no: "Norwegian",
'nb': 'Norwegian Bokmål', nb: "Norwegian Bokmål",
'nn': 'Norwegian Nynorsk', nn: "Norwegian Nynorsk",
'ii': 'Nuosu, Sichuan Yi', ii: "Nuosu, Sichuan Yi",
'oc': 'Occitan (post 1500)', oc: "Occitan (post 1500)",
'oj': 'Ojibwa', oj: "Ojibwa",
'or': 'Oriya', or: "Oriya",
'om': 'Oromo', om: "Oromo",
'os': 'Ossetian, Ossetic', os: "Ossetian, Ossetic",
'pi': 'Pali', pi: "Pali",
'pa': 'Panjabi, Punjabi', pa: "Panjabi, Punjabi",
'ps': 'Pashto, Pushto', ps: "Pashto, Pushto",
'fa': 'Persian', fa: "Persian",
'fa-IR': 'Persian (Iran)', "fa-IR": "Persian (Iran)",
'pl': 'Polish', pl: "Polish",
'pt-BR': 'Portuguese (Brazil)', "pt-BR": "Portuguese (Brazil)",
'pt-PT': 'Portuguese (Portugal)', "pt-PT": "Portuguese (Portugal)",
'qu': 'Quechua', qu: "Quechua",
'rm': 'Romansh', rm: "Romansh",
'rn': 'Rundi', rn: "Rundi",
'ru': 'Russian', ru: "Russian",
'sm': 'Samoan', sm: "Samoan",
'sg': 'Sango', sg: "Sango",
'sa': 'Sanskrit', sa: "Sanskrit",
'sc': 'Sardinian', sc: "Sardinian",
'sr': 'Serbian', sr: "Serbian",
'sn': 'Shona', sn: "Shona",
'sd': 'Sindhi', sd: "Sindhi",
'si': 'Sinhala, Sinhalese', si: "Sinhala, Sinhalese",
'sk': 'Slovak', sk: "Slovak",
'sl': 'Slovenian', sl: "Slovenian",
'so': 'Somali', so: "Somali",
'st': 'Sotho, Southern', st: "Sotho, Southern",
'nr': 'South Ndebele', nr: "South Ndebele",
'es': 'Spanish, Castilian', es: "Spanish, Castilian",
'su': 'Sundanese', su: "Sundanese",
'sw': 'Swahili', sw: "Swahili",
'ss': 'Swati', ss: "Swati",
'sv': 'Swedish', sv: "Swedish",
'tl': 'Tagalog', tl: "Tagalog",
'ty': 'Tahitian', ty: "Tahitian",
'tg': 'Tajik', tg: "Tajik",
'ta': 'Tamil', ta: "Tamil",
'tt': 'Tatar', tt: "Tatar",
'te': 'Telugu', te: "Telugu",
'th': 'Thai', th: "Thai",
'bo': 'Tibetan', bo: "Tibetan",
'ti': 'Tigrinya', ti: "Tigrinya",
'to': 'Tonga (Tonga Islands)', to: "Tonga (Tonga Islands)",
'ts': 'Tsonga', ts: "Tsonga",
'tn': 'Tswana', tn: "Tswana",
'tr': 'Turkish', tr: "Turkish",
'tk': 'Turkmen', tk: "Turkmen",
'tw': 'Twi', tw: "Twi",
'ug': 'Uighur, Uyghur', ug: "Uighur, Uyghur",
'uk': 'Ukrainian', uk: "Ukrainian",
'ur': 'Urdu', ur: "Urdu",
'uz': 'Uzbek', uz: "Uzbek",
've': 'Venda', ve: "Venda",
'vi': 'Vietnamese', vi: "Vietnamese",
'vo': 'Volap_k', vo: "Volap_k",
'wa': 'Walloon', wa: "Walloon",
'cy': 'Welsh', cy: "Welsh",
'fy': 'Western Frisian', fy: "Western Frisian",
'wo': 'Wolof', wo: "Wolof",
'xh': 'Xhosa', xh: "Xhosa",
'yi': 'Yiddish', yi: "Yiddish",
'yo': 'Yoruba', yo: "Yoruba",
'za': 'Zhuang, Chuang', za: "Zhuang, Chuang",
'zu': 'Zulu', zu: "Zulu",
}; };
module.exports = languages; module.exports = languages;