diff --git a/.eslintrc b/.eslintrc index dabc4560..e17e3453 100644 --- a/.eslintrc +++ b/.eslintrc @@ -14,7 +14,7 @@ "no-console": 0, "arrow-parens": [2, "always"], - "comma-dangle": [2, "always-multiline"], + "comma-dangle": [2, "never"], "eqeqeq": 2, "linebreak-style": [2, "unix"], "prefer-arrow-callback": 2, diff --git a/Gruntfile.js b/Gruntfile.js index f86d5b66..b929087a 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -6,21 +6,21 @@ module.exports = function (grunt) { pkg: grunt.file.readJSON('package.json'), clean: { - test262: ['tmp/test262**', 'data/test262**', 'tests/test262/'], + test262: ['tmp/test262**', 'data/test262**', 'tests/test262/'] }, curl: { test262: { src : 'https://github.com/tc39/test262/archive/master.zip', - dest: 'tmp/test262.zip', - }, + dest: 'tmp/test262.zip' + } }, unzip: { test262: { src : 'tmp/test262.zip', - dest: 'tmp/', - }, + dest: 'tmp/' + } }, copy: { @@ -31,10 +31,10 @@ module.exports = function (grunt) { src : [ 'LICENSE', 'test/intl402/**/*.js', - 'harness/*.js', - ], - }, - }, + 'harness/*.js' + ] + } + } }); @@ -49,7 +49,7 @@ module.exports = function (grunt) { 'curl:test262', 'unzip:test262', 'copy:test262', - 'update-tests', + 'update-tests' ]); }; diff --git a/scripts/build-dist.js b/scripts/build-dist.js index cb39bbe1..42f63048 100644 --- a/scripts/build-dist.js +++ b/scripts/build-dist.js @@ -17,7 +17,7 @@ const bundleConfig = { format: 'umd', moduleName: 'IntlPolyfill', sourceMap: true, - external: ['Intl'], + external: ['Intl'] }; let babelConfig = JSON.parse(fs.readFileSync('src/.babelrc', 'utf8')); @@ -29,14 +29,14 @@ babelConfig.presets = babelConfig.presets.map((preset) => { let plugins = [ babel(babelConfig), commonjs({ - sourceMap: true, - }), + sourceMap: true + }) ]; if (isProduction) { plugins.push( uglify({ - warnings: false, + warnings: false }) ); } diff --git a/scripts/build-lib.js b/scripts/build-lib.js index 63abf9a5..6b19d6b6 100644 --- a/scripts/build-lib.js +++ b/scripts/build-lib.js @@ -14,8 +14,8 @@ babelConfig.presets = babelConfig.presets.map((preset) => { let bundle = rollup({ entry: p.resolve('src/core.js'), plugins: [ - babel(babelConfig), - ], + babel(babelConfig) + ] }); // Cast to native Promise. @@ -23,7 +23,7 @@ bundle = Promise.resolve(bundle); bundle.then(({write}) => write({ dest: p.resolve('lib/core.js'), - format: 'cjs', + format: 'cjs' })); process.on('unhandledRejection', (reason) => {throw reason;}); diff --git a/scripts/utils/extract-calendars.js b/scripts/utils/extract-calendars.js index 09fe312e..d0adb165 100644 --- a/scripts/utils/extract-calendars.js +++ b/scripts/utils/extract-calendars.js @@ -4,7 +4,7 @@ import * as path from 'path'; import { getParentLocale, hasCalendars, - normalizeLocale, + normalizeLocale } from './locales'; export default function extractCalendars(locales) { @@ -53,7 +53,7 @@ export default function extractCalendars(locales) { // locale doesn't have relative fields, then we fallback to the "root" // locale's fields. calendars[locale] = { - calendars: getCalendars(resolvedLocale), + calendars: getCalendars(resolvedLocale) }; return calendars; @@ -74,14 +74,14 @@ function loadCalendars(locale) { "cldr-cal-islamic-full", "cldr-cal-japanese-full", "cldr-cal-persian-full", - "cldr-cal-roc-full", + "cldr-cal-roc-full" ]; // walking all packages, selecting calendar files, then // reading the content of each calendar, and concatenating the set return pkgs.reduce((calendars, pkgName) => { let dir = path.resolve(path.dirname(require.resolve(pkgName + '/package.json')), 'main', locale); let filenames = glob.sync("ca-*.json", { - cwd: dir, + cwd: dir }); return filenames.reduce((calendars, filename) => { return Object.assign(calendars, require(path.join(dir, filename)).main[locale].dates.calendars); diff --git a/scripts/utils/extract-numbers.js b/scripts/utils/extract-numbers.js index 8ab99bf9..8e309d1a 100644 --- a/scripts/utils/extract-numbers.js +++ b/scripts/utils/extract-numbers.js @@ -47,7 +47,7 @@ module.exports = function extractNumbersFields(locales) { // locale doesn't have relative fields, then we fallback to the "root" // locale's fields. numbers[locale] = { - numbers: getNumbers(resolvedLocale), + numbers: getNumbers(resolvedLocale) }; return numbers; diff --git a/scripts/utils/locales.js b/scripts/utils/locales.js index 7cefeaf5..37da3de6 100644 --- a/scripts/utils/locales.js +++ b/scripts/utils/locales.js @@ -10,21 +10,21 @@ let PARENT_LOCALES_HASH = require('cldr-core/supplemental/parentLocales.json') .supplemental.parentLocales.parentLocale; let CALENDARS_LOCALES_HASH = glob.sync('*/ca-*.json', { - cwd: path.resolve(CLDR_DATES_DIR, 'main'), + cwd: path.resolve(CLDR_DATES_DIR, 'main') }).reduce((hash, filename) => { hash[path.dirname(filename)] = true; return hash; }, {}); let NUMBERS_LOCALES_HASH = glob.sync('*/numbers.json', { - cwd: path.resolve(CLDR_NUMBERS_DIR, 'main'), + cwd: path.resolve(CLDR_NUMBERS_DIR, 'main') }).reduce((hash, filename) => { hash[path.dirname(filename)] = true; return hash; }, {}); let CURRENCIES_LOCALES_HASH = glob.sync('*/currencies.json', { - cwd: path.resolve(CLDR_NUMBERS_DIR, 'main'), + cwd: path.resolve(CLDR_NUMBERS_DIR, 'main') }).reduce((hash, filename) => { hash[path.dirname(filename)] = true; return hash; diff --git a/scripts/utils/reduce.js b/scripts/utils/reduce.js index 719ef8cc..e955c1b9 100644 --- a/scripts/utils/reduce.js +++ b/scripts/utils/reduce.js @@ -18,7 +18,7 @@ function createNumberFormats (ptn) { let patterns = ptn.split(';'), ret = { - positivePattern: replaceSpecialChars(patterns[0]), + positivePattern: replaceSpecialChars(patterns[0]) }; // Negative patterns aren't always specified, in those cases use '-' + positivePattern @@ -52,7 +52,7 @@ export default function (locale, data) { let caMap = { 'gregorian': 'gregory', 'ethiopic-amete-alem': 'ethioaa', - 'islamic-civil': 'islamicc', + 'islamic-civil': 'islamicc' }; // Default calendar is always gregorian, apparently @@ -88,7 +88,7 @@ export default function (locale, data) { hour12: !/H|k/.test(defaultTimeFormat), formats: [], - calendars: {}, + calendars: {} }, number: { // Numbering systems, with the default first @@ -100,8 +100,8 @@ export default function (locale, data) { // Symbols symbols: {}, - currencies: {}, - }, + currencies: {} + } }; let ptn; @@ -117,7 +117,7 @@ export default function (locale, data) { plusSign: sym.plusSign, minusSign: sym.minusSign, percentSign: sym.percentSign, - infinity: sym.infinity, + infinity: sym.infinity }; }); @@ -165,27 +165,27 @@ export default function (locale, data) { obj.months = { narrow: gopv(frmt.narrow), short: gopv(frmt.abbreviated), - long: gopv(frmt.wide), + long: gopv(frmt.wide) }; } if ((frmt = data.calendars[cal].days) && (frmt = frmt.format)) { obj.days = { narrow: gopv(frmt.narrow), short: gopv(frmt.abbreviated), - long: gopv(frmt.wide), + long: gopv(frmt.wide) }; } if ((frmt = data.calendars[cal].eras)) { obj.eras = { narrow: gopv(frmt.eraNarrow), short: gopv(frmt.eraAbbr), - long: gopv(frmt.eraNames), + long: gopv(frmt.eraNames) }; } if ((frmt = data.calendars[cal].dayPeriods) && (frmt = frmt.format)) { obj.dayPeriods = { am: (frmt.wide || frmt.abbreviated).am, - pm: (frmt.wide || frmt.abbreviated).pm, + pm: (frmt.wide || frmt.abbreviated).pm }; } @@ -195,7 +195,7 @@ export default function (locale, data) { yMMMMEEEEd: defCa.dateFormats.full, yMMMMd: defCa.dateFormats.long, yMMMd: defCa.dateFormats.medium, - yMd: defCa.dateFormats.short, + yMd: defCa.dateFormats.short }; // Basic Time Formats @@ -204,7 +204,7 @@ export default function (locale, data) { hmmsszzzz: defCa.timeFormats.full, hmsz: defCa.timeFormats.long, hms: defCa.timeFormats.medium, - hm: defCa.timeFormats.short, + hm: defCa.timeFormats.short }; ret.date.formats = { @@ -214,7 +214,7 @@ export default function (locale, data) { long: defCa.dateTimeFormats.long, availableFormats: defCa.dateTimeFormats.availableFormats, dateFormats: basicDateFormats, - timeFormats: basicTimeFormats, + timeFormats: basicTimeFormats }; }); diff --git a/src/11.numberformat.js b/src/11.numberformat.js index abcf1430..39afe086 100644 --- a/src/11.numberformat.js +++ b/src/11.numberformat.js @@ -2,11 +2,11 @@ // ====================================== import { - IsWellFormedCurrencyCode, + IsWellFormedCurrencyCode } from "./6.locales-currencies-tz.js"; import { - Intl, + Intl } from "./8.intl.js"; import { @@ -14,7 +14,7 @@ import { SupportedLocales, ResolveLocale, GetNumberOption, - GetOption, + GetOption } from "./9.negotiation.js"; import { @@ -33,14 +33,14 @@ import { getInternalProperties, createRegExpRestore, secret, - objCreate, + objCreate } from "./util.js"; // Currency minor units output from get-4217 grunt task, formatted const currencyMinorUnits = { BHD: 3, BYR: 0, XOF: 0, BIF: 0, XAF: 0, CLF: 4, CLP: 0, KMF: 0, DJF: 0, XPF: 0, GNF: 0, ISK: 0, IQD: 3, JPY: 0, JOD: 3, KRW: 0, KWD: 3, LYD: 3, - OMR: 3, PYG: 0, RWF: 0, TND: 3, UGX: 0, UYI: 0, VUV: 0, VND: 0, + OMR: 3, PYG: 0, RWF: 0, TND: 3, UGX: 0, UYI: 0, VUV: 0, VND: 0 }; // Define the NumberFormat constructor internally so it cannot be tainted @@ -58,12 +58,12 @@ export function NumberFormatConstructor () { defineProperty(Intl, 'NumberFormat', { configurable: true, writable: true, - value: NumberFormatConstructor, + value: NumberFormatConstructor }); // Must explicitly set prototypes as unwritable defineProperty(Intl.NumberFormat, 'prototype', { - writable: false, + writable: false }); /** @@ -89,7 +89,7 @@ export function /*11.1.1.1 */InitializeNumberFormat (numberFormat, locales, opti // NOTE: Non-standard, for internal use only if (arguments[0] === secret) return internal; - }, + } }); // 2. Set the [[initializedIntlObject]] internal property of numberFormat to true. @@ -321,7 +321,7 @@ function CurrencyDigits(currency) { /* 11.2.3 */internals.NumberFormat = { '[[availableLocales]]': [], '[[relevantExtensionKeys]]': ['nu'], - '[[localeData]]': {}, + '[[localeData]]': {} }; /** @@ -361,7 +361,7 @@ defineProperty(Intl.NumberFormat, 'supportedLocalesOf', { // (defined in 9.2.8) with arguments availableLocales, requestedLocales, // and options. return SupportedLocales(availableLocales, requestedLocales, options); - }, internals.NumberFormat), + }, internals.NumberFormat) }); /** @@ -371,7 +371,7 @@ defineProperty(Intl.NumberFormat, 'supportedLocalesOf', { */ /* 11.3.2 */defineProperty(Intl.NumberFormat.prototype, 'format', { configurable: true, - get: GetFormatNumber, + get: GetFormatNumber }); function GetFormatNumber() { @@ -891,7 +891,7 @@ let numSys = { tamldec: ['\u0BE6', '\u0BE7', '\u0BE8', '\u0BE9', '\u0BEA', '\u0BEB', '\u0BEC', '\u0BED', '\u0BEE', '\u0BEF'], telu: ['\u0C66', '\u0C67', '\u0C68', '\u0C69', '\u0C6A', '\u0C6B', '\u0C6C', '\u0C6D', '\u0C6E', '\u0C6F'], thai: ['\u0E50', '\u0E51', '\u0E52', '\u0E53', '\u0E54', '\u0E55', '\u0E56', '\u0E57', '\u0E58', '\u0E59'], - tibt: ['\u0F20', '\u0F21', '\u0F22', '\u0F23', '\u0F24', '\u0F25', '\u0F26', '\u0F27', '\u0F28', '\u0F29'], + tibt: ['\u0F20', '\u0F21', '\u0F22', '\u0F23', '\u0F24', '\u0F25', '\u0F26', '\u0F27', '\u0F28', '\u0F29'] }; /** @@ -916,7 +916,7 @@ let numSys = { props = [ 'locale', 'numberingSystem', 'style', 'currency', 'currencyDisplay', 'minimumIntegerDigits', 'minimumFractionDigits', 'maximumFractionDigits', - 'minimumSignificantDigits', 'maximumSignificantDigits', 'useGrouping', + 'minimumSignificantDigits', 'maximumSignificantDigits', 'useGrouping' ], internal = this !== null && typeof this === 'object' && getInternalProperties(this); @@ -930,5 +930,5 @@ let numSys = { } return objCreate({}, descs); - }, + } }); diff --git a/src/12.datetimeformat.js b/src/12.datetimeformat.js index cd1dbba3..4ca8666b 100644 --- a/src/12.datetimeformat.js +++ b/src/12.datetimeformat.js @@ -2,26 +2,26 @@ // ================================== import { - toLatinUpperCase, + toLatinUpperCase } from './6.locales-currencies-tz.js'; import { - Intl, + Intl } from "./8.intl.js"; import { CanonicalizeLocaleList, ResolveLocale, GetOption, - SupportedLocales, + SupportedLocales } from "./9.negotiation.js"; import { - FormatNumber, + FormatNumber } from "./11.numberformat.js"; import { - createDateTimeFormats, + createDateTimeFormats } from "./cldr"; import { @@ -38,7 +38,7 @@ import { hop, objCreate, arrPush, - arrIndexOf, + arrIndexOf } from './util.js'; // An object map of date component keys, saves using a regex later @@ -60,7 +60,7 @@ function resolveDateString(data, ca, component, width, key) { alts = { narrow: ['short', 'long'], short: ['long', 'narrow'], - long: ['short', 'narrow'], + long: ['short', 'narrow'] }, // @@ -88,12 +88,12 @@ export function DateTimeFormatConstructor () { defineProperty(Intl, 'DateTimeFormat', { configurable: true, writable: true, - value: DateTimeFormatConstructor, + value: DateTimeFormatConstructor }); // Must explicitly set prototypes as unwritable defineProperty(DateTimeFormatConstructor, 'prototype', { - writable: false, + writable: false }); /** @@ -119,7 +119,7 @@ export function/* 12.1.1.1 */InitializeDateTimeFormat (dateTimeFormat, locales, // NOTE: Non-standard, for internal use only if (arguments[0] === secret) return internal; - }, + } }); // 2. Set the [[initializedIntlObject]] internal property of numberFormat to true. @@ -356,7 +356,7 @@ let dateTimeComponents = { hour: [ "2-digit", "numeric" ], minute: [ "2-digit", "numeric" ], second: [ "2-digit", "numeric" ], - timeZoneName: [ "short", "long" ], + timeZoneName: [ "short", "long" ] }; /** @@ -736,7 +736,7 @@ function BestFitFormatMatcher (options, formats) { /* 12.2.3 */internals.DateTimeFormat = { '[[availableLocales]]': [], '[[relevantExtensionKeys]]': ['ca', 'nu'], - '[[localeData]]': {}, + '[[localeData]]': {} }; /** @@ -776,7 +776,7 @@ defineProperty(Intl.DateTimeFormat, 'supportedLocalesOf', { // (defined in 9.2.8) with arguments availableLocales, requestedLocales, // and options. return SupportedLocales(availableLocales, requestedLocales, options); - }, internals.NumberFormat), + }, internals.NumberFormat) }); /** @@ -786,12 +786,12 @@ defineProperty(Intl.DateTimeFormat, 'supportedLocalesOf', { */ /* 12.3.2 */defineProperty(Intl.DateTimeFormat.prototype, 'format', { configurable: true, - get: GetFormatDateTime, + get: GetFormatDateTime }); defineProperty(Intl.DateTimeFormat.prototype, 'formatToParts', { configurable: true, - get: GetFormatToPartsDateTime, + get: GetFormatToPartsDateTime }); function GetFormatDateTime() { @@ -917,7 +917,7 @@ function CreateDateTimeParts(dateTimeFormat, x) { if (beginIndex > index) { arrPush.call(result, { type: 'literal', - value: pattern.substring(index, beginIndex), + value: pattern.substring(index, beginIndex) }); } // d. @@ -1006,7 +1006,7 @@ function CreateDateTimeParts(dateTimeFormat, x) { // ix arrPush.call(result, { type: p, - value: fv, + value: fv }); // f. } else if (p === 'ampm') { @@ -1017,13 +1017,13 @@ function CreateDateTimeParts(dateTimeFormat, x) { // iv. arrPush.call(result, { type: 'dayPeriod', - value: fv, + value: fv }); // g. } else { arrPush.call(result, { type: 'literal', - value: pattern.substring(beginIndex, endIndex + 1), + value: pattern.substring(beginIndex, endIndex + 1) }); } // h. @@ -1035,7 +1035,7 @@ function CreateDateTimeParts(dateTimeFormat, x) { if (endIndex < pattern.length - 1) { arrPush.call(result, { type: 'literal', - value: pattern.substr(endIndex + 1), + value: pattern.substr(endIndex + 1) }); } // 13. @@ -1067,7 +1067,7 @@ function FormatToPartsDateTime(dateTimeFormat, x) { let part = parts[i]; result.push({ type: part.type, - value: part.value, + value: part.value }); } return result; @@ -1103,7 +1103,7 @@ function ToLocalTime(date, calendar, timeZone) { '[[hour]]' : d[m + 'Hours'](), '[[minute]]' : d[m + 'Minutes'](), '[[second]]' : d[m + 'Seconds'](), - '[[inDST]]' : false, // ###TODO### + '[[inDST]]' : false // ###TODO### }); } @@ -1123,7 +1123,7 @@ function ToLocalTime(date, calendar, timeZone) { descs = new Record(), props = [ 'locale', 'calendar', 'numberingSystem', 'timeZone', 'hour12', 'weekday', - 'era', 'year', 'month', 'day', 'hour', 'minute', 'second', 'timeZoneName', + 'era', 'year', 'month', 'day', 'hour', 'minute', 'second', 'timeZoneName' ], internal = this !== null && typeof this === 'object' && getInternalProperties(this); @@ -1137,5 +1137,5 @@ function ToLocalTime(date, calendar, timeZone) { } return objCreate({}, descs); - }, + } }); diff --git a/src/13.locale-sensitive-functions.js b/src/13.locale-sensitive-functions.js index 4251b630..9d9825ef 100644 --- a/src/13.locale-sensitive-functions.js +++ b/src/13.locale-sensitive-functions.js @@ -2,23 +2,23 @@ // =========================================================================== import { - Intl, + Intl } from "./8.intl.js"; import { FormatNumber, - NumberFormatConstructor, + NumberFormatConstructor } from "./11.numberformat.js"; import { ToDateTimeOptions, DateTimeFormatConstructor, - FormatDateTime, + FormatDateTime } from "./12.datetimeformat.js"; let ls = Intl.__localeSensitiveProtos = { Number: {}, - Date: {}, + Date: {} }; /** diff --git a/src/6.locales-currencies-tz.js b/src/6.locales-currencies-tz.js index 99cca994..2283ca51 100644 --- a/src/6.locales-currencies-tz.js +++ b/src/6.locales-currencies-tz.js @@ -5,13 +5,13 @@ import { expBCP47Syntax, expExtSequences, expVariantDupes, - expSingletonDupes, + expSingletonDupes } from './exp'; import { hop, arrJoin, - arrSlice, + arrSlice } from "./util.js"; // Default locale is the first-added locale data for us @@ -67,7 +67,7 @@ const redundantTags = { "zh-cmn-Hant": "cmn-Hant", "zh-gan": "gan", "zh-wuu": "wuu", - "zh-yue": "yue", + "zh-yue": "yue" }, subtags: { BU: "MM", @@ -103,7 +103,7 @@ const redundantTags = { tlw: "weo", tnf: "prs", ybd: "rki", - yma: "lrr", + yma: "lrr" }, extLang: { aao: ["aao", "ar"], @@ -332,8 +332,8 @@ const redundantTags = { zlm: ["zlm", "ms"], zmi: ["zmi", "ms"], zsl: ["zsl", "sgn"], - zsm: ["zsm", "ms"], - }, + zsm: ["zsm", "ms"] + } }; /** diff --git a/src/8.intl.js b/src/8.intl.js index c72d59a7..059b00c1 100644 --- a/src/8.intl.js +++ b/src/8.intl.js @@ -1,5 +1,5 @@ import { - CanonicalizeLocaleList, + CanonicalizeLocaleList } from "./9.negotiation.js"; // 8 The Intl Object diff --git a/src/9.negotiation.js b/src/9.negotiation.js index 113cf9c2..e424a464 100644 --- a/src/9.negotiation.js +++ b/src/9.negotiation.js @@ -9,13 +9,13 @@ import { arrSlice, Record, hop, - defineProperty, + defineProperty } from "./util.js"; import { IsStructurallyValidLanguageTag, CanonicalizeLanguageTag, - DefaultLocale, + DefaultLocale } from "./6.locales-currencies-tz.js"; const expUnicodeExSeq = /-u(?:-[0-9a-z]{2,8})+/gi; // See `extension` below @@ -530,7 +530,7 @@ export function /*9.2.8 */SupportedLocales (availableLocales, requestedLocales, // d. Call the [[DefineOwnProperty]] internal method of subset with P, desc, // and true as arguments. defineProperty(subset, P, { - writable: false, configurable: false, value: subset[P], + writable: false, configurable: false, value: subset[P] }); } // "Freeze" the array so no new elements can be added diff --git a/src/cldr.js b/src/cldr.js index e4c46b93..7d378d7b 100644 --- a/src/cldr.js +++ b/src/cldr.js @@ -187,7 +187,7 @@ export function createDateTimeFormat(skeleton, pattern) { let formatObj = { originalPattern: pattern, - _: {}, + _: {} }; // Replace the pattern string with the one required by the specification, whilst diff --git a/src/core.js b/src/core.js index f116b152..50ac12b0 100644 --- a/src/core.js +++ b/src/core.js @@ -14,17 +14,17 @@ import { hop, arrPush, arrShift, - internals, + internals } from "./util.js"; import { IsStructurallyValidLanguageTag, defaultLocale, - setDefaultLocale, + setDefaultLocale } from "./6.locales-currencies-tz.js"; import { - Intl, + Intl } from "./8.intl.js"; import "./11.numberformat.js"; @@ -45,7 +45,7 @@ defineProperty(Intl, '__applyLocaleSensitivePrototypes', { if (hop.call(ls.Date, k)) defineProperty(Date.prototype, k, { writable: true, configurable: true, value: ls.Date[k] }); } - }, + } }); /** @@ -59,7 +59,7 @@ defineProperty(Intl, '__addLocaleData', { throw new Error("Object passed doesn't identify itself with a valid language tag"); addLocaleData(data, data.locale); - }, + } }); function addLocaleData (data, tag) {