From a96c7ce9974018f3302e8a1b78978d14c592ab09 Mon Sep 17 00:00:00 2001 From: Nedyalko Nikolov Date: Fri, 18 Nov 2016 16:37:04 +0200 Subject: [PATCH] Intl plugin outputs es6. --- .gitignore | 1 + compile.sh | 25 +++-- package.json | 14 ++- rollup.config.js | 31 ++++++ src/index.d.ts | 1 - src/index.ts | 13 +++ src/nativescript-intl-common.js | 184 +++++++++++++++---------------- src/nativescript-intl-common.ts | 94 +++++++++------- src/nativescript-intl.android.js | 96 +++++++--------- src/nativescript-intl.android.ts | 81 ++++++++------ src/nativescript-intl.d.ts | 37 +++++++ src/nativescript-intl.ios.js | 78 ++++++------- src/nativescript-intl.ios.ts | 67 ++++++----- src/package.json | 7 +- src/references.d.ts | 3 + src/tsconfig.json | 16 +-- src/tslint.json | 118 ++++++++++++++++++++ tests/package.json | 6 +- 18 files changed, 545 insertions(+), 327 deletions(-) create mode 100644 rollup.config.js delete mode 100644 src/index.d.ts create mode 100644 src/index.ts create mode 100644 src/nativescript-intl.d.ts create mode 100644 src/references.d.ts create mode 100644 src/tslint.json diff --git a/.gitignore b/.gitignore index 9476098..5b21769 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ tests/node_modules/ example/node_modules/ example/platforms/ dist/ +src/**/*.js diff --git a/compile.sh b/compile.sh index f583433..a258888 100755 --- a/compile.sh +++ b/compile.sh @@ -3,19 +3,30 @@ SOURCE_DIR=src; PACK_DIR=dist/package/; DIST_DIR=dist; +ANDROID=android; +IOS=ios; copy_package_files() { - cp "$SOURCE_DIR"/package.json $PACK_DIR - cp "$SOURCE_DIR"/*.md $PACK_DIR - cp "$SOURCE_DIR"/*.d.ts $PACK_DIR + cp "$SOURCE_DIR"/package.json "$PACK_DIR" + cp "$SOURCE_DIR"/*.md "$PACK_DIR" + cp "$SOURCE_DIR"/*.d.ts "$PACK_DIR" } #clean dist folder from previous compilation -rm -rf $DIST_DIR +rm -rf "$DIST_DIR" #create package folder -mkdir -p $PACK_DIR +mkdir -p "$PACK_DIR" + +# compile ts +node_modules/.bin/tsc -p "$SOURCE_DIR" --outDir "$PACK_DIR" + +node_modules/tslint/bin/tslint --project "$SOURCE_DIR"/tsconfig.json --config "$SOURCE_DIR"/tslint.json + +# make commonjs bundle for ANDROID +node_modules/rollup/bin/rollup -c --environment PLATFORM:$ANDROID + +# make commonjs bundle for IOS +node_modules/rollup/bin/rollup -c --environment PLATFORM:$IOS -#compile package and copy file required by npm -node_modules/.bin/tsc -p $SOURCE_DIR --outDir $PACK_DIR copy_package_files diff --git a/package.json b/package.json index dc91e39..7ea5e17 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,13 @@ { - "devDependencies": { - "typescript": "^1.8.9" - } + "scripts": { + "tslint": "tslint --project src/tsconfig.json --config src/tslint.json", + "tsc": "tsc -p src/tsconfig.json", + "create": "bash ./create.sh" + }, + "devDependencies": { + "rollup": "^0.36.4", + "tns-platform-declarations": "^2.4.0-2016-09-28-1", + "tslint": "^4.0.2", + "typescript": "^2.0.6" + } } diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 0000000..c93066e --- /dev/null +++ b/rollup.config.js @@ -0,0 +1,31 @@ +import * as path from "path"; +import * as fs from "fs"; + +class NsPathResolve { + constructor(options){ + this.options = options; + } + resolveId(id, from){ + //console.log(`id: ${id}, from: ${from}`); + if (from) { + var filePath = path.join(path.dirname(from), `${id}.js`); + //console.log(`filePath: ${filePath}`); + if (!fs.existsSync(filePath)) { + return path.join(path.dirname(from), `${id}.${process.env.PLATFORM}.js`); + } + } + } +} + +const nsPathResolve = (config) => new NsPathResolve(config); + +export default { + entry: "dist/package/index.js", + dest: `dist/package/bundle.${process.env.PLATFORM}.js`, + format: "cjs", + sourceMap: "inline", + treeshake: false, + plugins: [ + nsPathResolve() + ] +} diff --git a/src/index.d.ts b/src/index.d.ts deleted file mode 100644 index d5c2924..0000000 --- a/src/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./nativescript-intl-common"; diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..a5c3bf8 --- /dev/null +++ b/src/index.ts @@ -0,0 +1,13 @@ +// important since typescript compiler does not recognize DateTimeFormat and NumberFormat +import { DateTimeFormat, NumberFormat } from "./nativescript-intl"; + +export { DateTimeFormat, NumberFormat } from "./nativescript-intl"; + +declare var global: any; + +if (!global.Intl) { + global.Intl = {}; +} +global.Intl.DateTimeFormat = DateTimeFormat; +global.Intl.NumberFormat = NumberFormat; + diff --git a/src/nativescript-intl-common.js b/src/nativescript-intl-common.js index 34a3e6e..532ae80 100644 --- a/src/nativescript-intl-common.js +++ b/src/nativescript-intl-common.js @@ -1,11 +1,10 @@ -"use strict"; -exports.NUMERIC = "numeric"; -exports.LONG = "long"; -exports.SHORT = "short"; -exports.TWODIGIT = "2-digit"; -exports.FULL = "full"; -var DateTimeFormat = (function () { - function DateTimeFormat(locale, options, pattern) { +export const NUMERIC = "numeric"; +export const LONG = "long"; +export const SHORT = "short"; +export const TWODIGIT = "2-digit"; +export const FULL = "full"; +export class DateTimeFormat { + constructor(locale, options, pattern) { this.locale = locale; this.options = options; this.pattern = pattern; @@ -23,50 +22,52 @@ var DateTimeFormat = (function () { "G": "era", "a": "hour12" }; - if (options && options.minute === exports.NUMERIC) { - this.options.minute = exports.TWODIGIT; + if (options && options.minute === NUMERIC) { + this.options.minute = TWODIGIT; } - if (options && options.hour === exports.NUMERIC) { - this.options.hour = exports.TWODIGIT; + if (options && options.hour === NUMERIC) { + this.options.hour = TWODIGIT; } } - DateTimeFormat.prototype.hasTimeOptions = function (options) { + hasTimeOptions(options) { return options.hour !== undefined || options.minute !== undefined || options.second !== undefined; - }; - DateTimeFormat.prototype.hasDateOptions = function (options) { - return options.weekday !== undefined || options.year !== undefined || options.month !== undefined || options.day !== undefined; - }; - DateTimeFormat.prototype.useFullDatePattern = function (intlOptions) { - var i; - var propsArray = Object.keys(intlOptions); - var propsArrayLength = propsArray.length; - var result = false; + } + hasDateOptions(options) { + return options.weekday !== undefined || + options.year !== undefined || + options.month !== undefined || + options.day !== undefined; + } + useFullDatePattern(intlOptions) { + let i; + let propsArray = Object.keys(intlOptions); + let propsArrayLength = propsArray.length; + let result = false; for (i = 0; i < propsArrayLength; i++) { - if (intlOptions[propsArray[i]] === exports.LONG || intlOptions[propsArray[i]] === exports.SHORT) { + if (intlOptions[propsArray[i]] === LONG || intlOptions[propsArray[i]] === SHORT) { result = true; break; } } return result; - }; - DateTimeFormat.prototype.getNativePattern = function (patternDefinition, locale) { + } + getNativePattern(patternDefinition, locale) { return ""; - }; - DateTimeFormat.prototype.getCorrectPatternForLocale = function () { - var dateTimePatternOptions = {}; + } + getCorrectPatternForLocale() { + let dateTimePatternOptions = {}; if (this.hasDateOptions(this.options)) { if (this.useFullDatePattern(this.options)) { - dateTimePatternOptions.date = exports.FULL; + dateTimePatternOptions.date = FULL; } else { - dateTimePatternOptions.date = exports.SHORT; + dateTimePatternOptions.date = SHORT; } } if (this.hasTimeOptions(this.options)) { - dateTimePatternOptions.time = exports.FULL; + dateTimePatternOptions.time = FULL; } - var result = this.getNativePattern(dateTimePatternOptions, this.locale); - console.log("nativePattern: " + result); + let result = this.getNativePattern(dateTimePatternOptions, this.locale); if (this.options.hour) { if (this.options.hour12 !== undefined) { result = this.options.hour12 ? result.replace(/H/g, "h") : result.replace(/h/g, "H"); @@ -76,19 +77,19 @@ var DateTimeFormat = (function () { } } return result; - }; - DateTimeFormat.prototype.getDateElementsFromPattern = function (pattern) { - var result = []; - var patternLength = pattern.length; - var i = 0; - var stringInsidePattern = false; + } + getDateElementsFromPattern(pattern) { + let result = []; + let patternLength = pattern.length; + let i = 0; + let stringInsidePattern = false; while (i < patternLength) { if (pattern[i] === '"' || pattern[i] === "'") { - var p = i + 1; + let p = i + 1; while (p < patternLength && pattern[i] !== pattern[p]) { p++; } - for (var j = i; j < p + 1; j++) { + for (let j = i; j < p + 1; j++) { result.push({ "isDateElement": false, "patternValue": pattern[j] @@ -98,7 +99,7 @@ var DateTimeFormat = (function () { continue; } if (this.dateTimeFormatElements.hasOwnProperty(pattern[i])) { - var j = i; + let j = i; while (i < patternLength && pattern[i] === pattern[j]) { i++; } @@ -117,16 +118,16 @@ var DateTimeFormat = (function () { } } return result; - }; - DateTimeFormat.prototype.prepareDateElement = function (intlOption, dateElement) { + } + prepareDateElement(intlOption, dateElement) { switch (intlOption) { - case exports.NUMERIC: + case NUMERIC: return dateElement; - case exports.TWODIGIT: + case TWODIGIT: return dateElement.repeat(2); - case exports.SHORT: + case SHORT: return dateElement.repeat(3); - case exports.LONG: + case LONG: return dateElement.repeat(4); case true: return dateElement; @@ -135,22 +136,21 @@ var DateTimeFormat = (function () { default: return dateElement; } - }; - DateTimeFormat.prototype.preparePattern = function (pattern, options) { - console.log("preparePattern input - " + pattern); - var patternOptions = this.getDateElementsFromPattern(pattern); - var patternOptionsLength = patternOptions.length; - for (var i_1 = 0; i_1 < patternOptionsLength; i_1++) { - if (patternOptions[i_1].isDateElement) { - var formatChar = patternOptions[i_1].patternValue[0]; - var intlOptionValue = options[patternOptions[i_1].intlOption]; + } + preparePattern(pattern, options) { + let patternOptions = this.getDateElementsFromPattern(pattern); + let patternOptionsLength = patternOptions.length; + for (let i = 0; i < patternOptionsLength; i++) { + if (patternOptions[i].isDateElement) { + let formatChar = patternOptions[i].patternValue[0]; + let intlOptionValue = options[patternOptions[i].intlOption]; if (intlOptionValue !== undefined) { - var newPatternValue = this.prepareDateElement(intlOptionValue, formatChar); - patternOptions[i_1].patternValue = newPatternValue; + let newPatternValue = this.prepareDateElement(intlOptionValue, formatChar); + patternOptions[i].patternValue = newPatternValue; } else { - if (i_1 > 0) { - var j = i_1 - 1; + if (i > 0) { + let j = i - 1; while (patternOptions[j] && patternOptions[j].isDateElement === false) { if (patternOptions[j].patternValue !== " ") { if (patternOptions[j].patternValue !== '"' && patternOptions[j].patternValue !== "'") { @@ -164,58 +164,48 @@ var DateTimeFormat = (function () { j--; } } - patternOptions[i_1].patternValue = ""; + patternOptions[i].patternValue = ""; } } } - var result = []; - var i = 0; + let result = []; + let i = 0; while (patternOptions[i].patternValue === "" || patternOptions[i].isDateElement === false) { i++; } for (i; i < patternOptionsLength; i++) { result.push(patternOptions[i].patternValue); } - console.log("preparePattern output - " + result.join("")); return result.join(""); - }; - DateTimeFormat.prototype.formatNative = function (pattern, locale, date) { + } + formatNative(pattern, locale, date) { return ""; - }; - Object.defineProperty(DateTimeFormat.prototype, "preparedPattern", { - get: function () { - if (!this._preparedPattern) { - if (this.pattern) { - this._preparedPattern = this.pattern; - } - else { - this._preparedPattern = this.preparePattern(this.getCorrectPatternForLocale(), this.options); - } + } + get preparedPattern() { + if (!this._preparedPattern) { + if (this.pattern) { + this._preparedPattern = this.pattern; } - console.log("preparedPattern: " + this._preparedPattern); - return this._preparedPattern; - }, - enumerable: true, - configurable: true - }); - DateTimeFormat.prototype.format = function (date) { + else { + this._preparedPattern = this.preparePattern(this.getCorrectPatternForLocale(), this.options); + } + } + return this._preparedPattern; + } + format(date) { return this.formatNative(this.preparedPattern, this.locale, date); - }; - return DateTimeFormat; -}()); -exports.DateTimeFormat = DateTimeFormat; -var NumberFormat = (function () { - function NumberFormat(locale, options, pattern) { + } +} +export class NumberFormat { + constructor(locale, options, pattern) { this.locale = locale; this.options = options; this.pattern = pattern; } - NumberFormat.prototype.formatNative = function (value, locale, options, pattern) { + formatNative(value, locale, options, pattern) { return ""; - }; - NumberFormat.prototype.format = function (value) { + } + format(value) { return this.formatNative(value, this.locale, this.options, this.pattern); - }; - return NumberFormat; -}()); -exports.NumberFormat = NumberFormat; + } +} diff --git a/src/nativescript-intl-common.ts b/src/nativescript-intl-common.ts index a633a1a..7bf7609 100644 --- a/src/nativescript-intl-common.ts +++ b/src/nativescript-intl-common.ts @@ -1,11 +1,18 @@ -export var NUMERIC = "numeric"; -export var LONG = "long"; -export var SHORT = "short"; -export var TWODIGIT = "2-digit"; -export var FULL = "full"; - -export class DateTimeFormat { - constructor(private locale?: string, private options?: Intl.DateTimeFormatOptions, private pattern?: string) { +import { + DateTimeFormat as intlDateTimeFormat, + DateTimeFormatOptions as intlDateTimeFormatOptions, + NumberFormat as intlNumberFormat, + NumberFormatOptions as intlNumberFormatOptions +} from "nativescript-intl"; + +export const NUMERIC = "numeric"; +export const LONG = "long"; +export const SHORT = "short"; +export const TWODIGIT = "2-digit"; +export const FULL = "full"; + +export class DateTimeFormat implements intlDateTimeFormat { + constructor(private locale?: string, private options?: intlDateTimeFormatOptions, private pattern?: string) { if (options && options.minute === NUMERIC) { this.options.minute = TWODIGIT; } @@ -13,20 +20,23 @@ export class DateTimeFormat { this.options.hour = TWODIGIT; } } - - private hasTimeOptions(options: Intl.DateTimeFormatOptions): boolean { + + private hasTimeOptions(options: intlDateTimeFormatOptions): boolean { return options.hour !== undefined || options.minute !== undefined || options.second !== undefined; } - - private hasDateOptions(options: Intl.DateTimeFormatOptions): boolean { - return options.weekday !== undefined || options.year !== undefined || options.month !== undefined || options.day !== undefined; + + private hasDateOptions(options: intlDateTimeFormatOptions): boolean { + return options.weekday !== undefined || + options.year !== undefined || + options.month !== undefined || + options.day !== undefined; } - + private useFullDatePattern(intlOptions): boolean { - var i; - var propsArray = Object.keys(intlOptions); - var propsArrayLength = propsArray.length; - var result = false; + let i; + let propsArray = Object.keys(intlOptions); + let propsArrayLength = propsArray.length; + let result = false; for (i = 0; i < propsArrayLength; i++) { if (intlOptions[propsArray[i]] === LONG || intlOptions[propsArray[i]] === SHORT) { result = true; @@ -35,18 +45,17 @@ export class DateTimeFormat { } return result; } - + public getNativePattern(patternDefinition: {date?: string, time?: string}, locale?: string): string { return ""; } - + private getCorrectPatternForLocale(): string { let dateTimePatternOptions: {date?: string, time?: string} = {}; if (this.hasDateOptions(this.options)) { if (this.useFullDatePattern(this.options)) { dateTimePatternOptions.date = FULL; - } - else { + } else { dateTimePatternOptions.date = SHORT; } } @@ -56,14 +65,14 @@ export class DateTimeFormat { let result = this.getNativePattern(dateTimePatternOptions, this.locale); if (this.options.hour) { if (this.options.hour12 !== undefined) { - result = this.options.hour12 ? result.replace(/H/g, "h") : result.replace(/h/g, "H"); + result = this.options.hour12 ? result.replace(/H/g, "h") : result.replace(/h/g, "H"); } else { - this.options.hour12 = !(result.indexOf("H") > -1); + this.options.hour12 = !(result.indexOf("H") > -1); } } return result; } - + private dateTimeFormatElements = { "M": "month", "E": "weekday", @@ -78,21 +87,21 @@ export class DateTimeFormat { "G": "era", "a": "hour12" }; - + // isDateElement (boolean), patternValue - dateElement content, intlOption - corresponding Intl option name private getDateElementsFromPattern(pattern: string) { let result = []; let patternLength = pattern.length; let i = 0; let stringInsidePattern = false; - while(i < patternLength) { + while (i < patternLength) { // handle case with a string inside pattern if (pattern[i] === '"' || pattern[i] === "'") { let p = i + 1; while (p < patternLength && pattern[i] !== pattern[p]) { p++; } - for(let j = i; j < p + 1; j++) { + for (let j = i; j < p + 1; j++) { result.push({ "isDateElement": false, "patternValue": pattern[j] @@ -104,7 +113,7 @@ export class DateTimeFormat { if (this.dateTimeFormatElements.hasOwnProperty(pattern[i])) { let j = i; while (i < patternLength && pattern[i] === pattern[j]) { i++; } - result.push({ + result.push({ "isDateElement": true, "patternValue": pattern.substr(j, i - j), "intlOption": this.dateTimeFormatElements[pattern[j]] @@ -119,7 +128,7 @@ export class DateTimeFormat { } return result; } - + private prepareDateElement(intlOption, dateElement) { switch (intlOption) { case NUMERIC: @@ -140,11 +149,11 @@ export class DateTimeFormat { return dateElement; } } - + private preparePattern(pattern, options) { let patternOptions = this.getDateElementsFromPattern(pattern); let patternOptionsLength = patternOptions.length; - for(let i = 0; i < patternOptionsLength; i++) { + for (let i = 0; i < patternOptionsLength; i++) { if (patternOptions[i].isDateElement) { let formatChar = patternOptions[i].patternValue[0]; let intlOptionValue = options[patternOptions[i].intlOption]; @@ -174,17 +183,17 @@ export class DateTimeFormat { let result = []; let i = 0; // remove leading delimiters - while(patternOptions[i].patternValue === "" || patternOptions[i].isDateElement === false) {i++;} - for(i; i < patternOptionsLength; i++) { + while (patternOptions[i].patternValue === "" || patternOptions[i].isDateElement === false) { i++; } + for (i; i < patternOptionsLength; i++) { result.push(patternOptions[i].patternValue); } return result.join(""); } - + public formatNative(pattern: string, locale?: string, date?: Date): string { return ""; } - + private _preparedPattern: string; public get preparedPattern(): string { if (!this._preparedPattern) { @@ -196,20 +205,21 @@ export class DateTimeFormat { } return this._preparedPattern; } - + public format(date?: Date): string { return this.formatNative(this.preparedPattern, this.locale, date); } } -export class NumberFormat { - constructor(private locale?: string, private options?: Intl.NumberFormatOptions, private pattern?: string) { } - - public formatNative(value: number, locale?: string, options?: Intl.NumberFormatOptions, pattern?: string): string { +export class NumberFormat implements intlNumberFormat { + constructor(private locale?: string, private options?: intlNumberFormatOptions, private pattern?: string) { } + + public formatNative(value: number, locale?: string, options?: intlNumberFormatOptions, pattern?: string): string { return ""; } - + public format(value: number) { return this.formatNative(value, this.locale, this.options, this.pattern); } } + diff --git a/src/nativescript-intl.android.js b/src/nativescript-intl.android.js index 16a2b8c..1d77135 100644 --- a/src/nativescript-intl.android.js +++ b/src/nativescript-intl.android.js @@ -1,30 +1,24 @@ -"use strict"; -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; -var common = require("./nativescript-intl-common"); -var localesCache = new Map(); +import { DateTimeFormat as commonDateTimeFormat, NumberFormat as commonNumberFormat, FULL } from "./nativescript-intl-common"; +let localesCache = new Map(); function getNativeLocale(locale) { if (localesCache.has(locale)) { return localesCache.get(locale); } - var result; + let result; if (locale) { - locale = locale.replace(/_/g, '-'); - var firstHypenIndex = locale.indexOf('-'); - var lang = ''; - var country = ''; + locale = locale.replace(/_/g, "-"); + let firstHypenIndex = locale.indexOf("-"); + let lang = ""; + let country = ""; if (firstHypenIndex > -1) { lang = locale.substr(0, firstHypenIndex); - var nextHypenIndex = locale.substr(firstHypenIndex + 1).indexOf('-'); + let nextHypenIndex = locale.substr(firstHypenIndex + 1).indexOf("-"); country = locale.substr(firstHypenIndex + 1, (nextHypenIndex > -1) ? nextHypenIndex : undefined); } else { lang = locale; } - if (country !== '') { + if (country !== "") { result = new java.util.Locale(lang, country); } else { @@ -32,20 +26,16 @@ function getNativeLocale(locale) { } } else { - result = new java.util.Locale('en', 'US'); + result = new java.util.Locale("en", "US"); } localesCache.set(locale, result); return result; } -var DateTimeFormat = (function (_super) { - __extends(DateTimeFormat, _super); - function DateTimeFormat() { - _super.apply(this, arguments); - } - DateTimeFormat.prototype.getNativePattern = function (patternDefinition, locale) { - var result = ''; - var flag = 0; - var nativeLocale; +export class DateTimeFormat extends commonDateTimeFormat { + getNativePattern(patternDefinition, locale) { + let result = ""; + let flag = 0; + let nativeLocale; if (locale) { nativeLocale = getNativeLocale(locale); flag++; @@ -56,7 +46,7 @@ var DateTimeFormat = (function (_super) { if (patternDefinition.time) { flag = flag + 4; } - var dateFormat; + let dateFormat; switch (flag) { case 0: dateFormat = java.text.DateFormat.getDateTimeInstance(); @@ -65,10 +55,11 @@ var DateTimeFormat = (function (_super) { dateFormat = java.text.DateFormat.getDateTimeInstance(0, 0, nativeLocale); break; case 2: - dateFormat = java.text.DateFormat.getDateInstance(patternDefinition.date === common.FULL ? 0 : 3); + dateFormat = java.text.DateFormat.getDateInstance(patternDefinition.date === FULL ? 0 : 3); break; case 3: - dateFormat = java.text.DateFormat.getDateInstance(patternDefinition.date === common.FULL ? 0 : 3, nativeLocale); + dateFormat = + java.text.DateFormat.getDateInstance(patternDefinition.date === FULL ? 0 : 3, nativeLocale); break; case 4: dateFormat = java.text.DateFormat.getTimeInstance(1); @@ -77,44 +68,41 @@ var DateTimeFormat = (function (_super) { dateFormat = java.text.DateFormat.getTimeInstance(1, nativeLocale); break; case 6: - dateFormat = java.text.DateFormat.getDateTimeInstance(patternDefinition.date === common.FULL ? 0 : 3, 1); + dateFormat = java.text.DateFormat.getDateTimeInstance(patternDefinition.date === FULL ? 0 : 3, 1); break; case 7: - dateFormat = java.text.DateFormat.getDateTimeInstance(patternDefinition.date === common.FULL ? 0 : 3, 1, nativeLocale); + dateFormat = + java.text.DateFormat.getDateTimeInstance(patternDefinition.date === FULL ? 0 : 3, 1, nativeLocale); break; default: break; } result = dateFormat.toPattern(); return result; - }; - DateTimeFormat.prototype.formatNative = function (pattern, locale, date) { - var sdf = locale ? new java.text.SimpleDateFormat(pattern, getNativeLocale(locale)) : new java.text.SimpleDateFormat(pattern); + } + formatNative(pattern, locale, date) { + let sdf = locale ? + new java.text.SimpleDateFormat(pattern, getNativeLocale(locale)) : + new java.text.SimpleDateFormat(pattern); return sdf.format(date ? new java.util.Date(date.valueOf()) : new java.util.Date()).toString(); - }; - return DateTimeFormat; -}(common.DateTimeFormat)); -exports.DateTimeFormat = DateTimeFormat; -var NumberFormat = (function (_super) { - __extends(NumberFormat, _super); - function NumberFormat() { - _super.apply(this, arguments); } - NumberFormat.prototype.formatNative = function (value, locale, options, pattern) { - var numberFormat; +} +export class NumberFormat extends commonNumberFormat { + formatNative(value, locale, options, pattern) { + let numberFormat; if (pattern) { numberFormat = new java.text.DecimalFormat(pattern); } else { if (options) { switch (options.style.toLowerCase()) { - case 'decimal': + case "decimal": numberFormat = java.text.NumberFormat.getNumberInstance(getNativeLocale(locale)); break; - case 'percent': + case "percent": numberFormat = java.text.NumberFormat.getPercentInstance(getNativeLocale(locale)); break; - case 'currency': + case "currency": numberFormat = java.text.NumberFormat.getCurrencyInstance(getNativeLocale(locale)); if (options.currency !== void 0) { numberFormat.setCurrency(java.util.Currency.getInstance(options.currency)); @@ -141,12 +129,14 @@ var NumberFormat = (function (_super) { if (options && options.useGrouping !== void 0) { numberFormat.setGroupingUsed(options.useGrouping); } - var decimalFormatSymbols = locale ? new java.text.DecimalFormatSymbols(getNativeLocale(locale)) : new java.text.DecimalFormatSymbols(); + let decimalFormatSymbols = locale ? + new java.text.DecimalFormatSymbols(getNativeLocale(locale)) : + new java.text.DecimalFormatSymbols(); numberFormat.setDecimalFormatSymbols(decimalFormatSymbols); - if (options && (options.style.toLowerCase() === 'currency' && options.currencyDisplay === 'code')) { + if (options && (options.style.toLowerCase() === "currency" && options.currencyDisplay === "code")) { if (!pattern) { - var currrentPattern = numberFormat.toPattern(); - currrentPattern = currrentPattern.replace('¤', '¤¤'); + let currrentPattern = numberFormat.toPattern(); + currrentPattern = currrentPattern.replace("¤", "¤¤"); numberFormat = new java.text.DecimalFormat(currrentPattern); numberFormat.setDecimalFormatSymbols(decimalFormatSymbols); } @@ -155,7 +145,5 @@ var NumberFormat = (function (_super) { } } return numberFormat.format(value); - }; - return NumberFormat; -}(common.NumberFormat)); -exports.NumberFormat = NumberFormat; + } +} diff --git a/src/nativescript-intl.android.ts b/src/nativescript-intl.android.ts index 9f26bac..6800244 100644 --- a/src/nativescript-intl.android.ts +++ b/src/nativescript-intl.android.ts @@ -1,6 +1,11 @@ -import common = require("./nativescript-intl-common"); +import { + DateTimeFormat as commonDateTimeFormat, + NumberFormat as commonNumberFormat, + FULL +} from "./nativescript-intl-common"; +import { NumberFormatOptions } from "nativescript-intl"; -var localesCache: Map = new Map(); +let localesCache: Map = new Map(); function getNativeLocale(locale?: string) { if (localesCache.has(locale)) { @@ -8,43 +13,43 @@ function getNativeLocale(locale?: string) { } let result; if (locale) { - locale = locale.replace(/_/g, '-'); - let firstHypenIndex = locale.indexOf('-'); - let lang = ''; - let country = ''; + locale = locale.replace(/_/g, "-"); + let firstHypenIndex = locale.indexOf("-"); + let lang = ""; + let country = ""; if (firstHypenIndex > -1) { lang = locale.substr(0, firstHypenIndex); - let nextHypenIndex = locale.substr(firstHypenIndex + 1).indexOf('-') + let nextHypenIndex = locale.substr(firstHypenIndex + 1).indexOf("-"); country = locale.substr(firstHypenIndex + 1, (nextHypenIndex > -1) ? nextHypenIndex : undefined); } else { lang = locale; } - if (country !== '') { + if (country !== "") { result = new java.util.Locale(lang, country); } else { result = new java.util.Locale(lang); } } else { - result = new java.util.Locale('en', 'US'); + result = new java.util.Locale("en", "US"); } localesCache.set(locale, result); return result; } -export class DateTimeFormat extends common.DateTimeFormat { +export class DateTimeFormat extends commonDateTimeFormat { public getNativePattern(patternDefinition: {date?: string, time?: string}, locale?: string): string { - let result = ''; + let result = ""; let flag = 0; let nativeLocale; if (locale) { nativeLocale = getNativeLocale(locale); flag++; } - + if (patternDefinition.date) { flag = flag + 2; } - + if (patternDefinition.time) { flag = flag + 4; } @@ -60,11 +65,12 @@ export class DateTimeFormat extends common.DateTimeFormat { break; case 2: // only date 0 for full, 3 for Short date format using default locale - dateFormat = java.text.DateFormat.getDateInstance(patternDefinition.date === common.FULL ? 0 : 3); + dateFormat = java.text.DateFormat.getDateInstance(patternDefinition.date === FULL ? 0 : 3); break; case 3: // date + locale - dateFormat = java.text.DateFormat.getDateInstance(patternDefinition.date === common.FULL ? 0 : 3, nativeLocale); + dateFormat = + java.text.DateFormat.getDateInstance(patternDefinition.date === FULL ? 0 : 3, nativeLocale); break; case 4: // only time we always use long pattern using default locale @@ -76,11 +82,12 @@ export class DateTimeFormat extends common.DateTimeFormat { break; case 6: // time + date using default locale - dateFormat = java.text.DateFormat.getDateTimeInstance(patternDefinition.date === common.FULL ? 0 : 3, 1); + dateFormat = java.text.DateFormat.getDateTimeInstance(patternDefinition.date === FULL ? 0 : 3, 1); break; case 7: // locale + date + time - dateFormat = java.text.DateFormat.getDateTimeInstance(patternDefinition.date === common.FULL ? 0 : 3, 1, nativeLocale); + dateFormat = + java.text.DateFormat.getDateTimeInstance(patternDefinition.date === FULL ? 0 : 3, 1, nativeLocale); break; default: break; @@ -88,9 +95,11 @@ export class DateTimeFormat extends common.DateTimeFormat { result = dateFormat.toPattern(); return result; } - + public formatNative(pattern: string, locale?: string, date?: Date): string { - let sdf = locale ? new java.text.SimpleDateFormat(pattern, getNativeLocale(locale)) : new java.text.SimpleDateFormat(pattern); + let sdf = locale ? + new java.text.SimpleDateFormat(pattern, getNativeLocale(locale)) : + new java.text.SimpleDateFormat(pattern); return sdf.format(date ? new java.util.Date(date.valueOf()) : new java.util.Date()).toString(); } } @@ -103,21 +112,21 @@ export class DateTimeFormat extends common.DateTimeFormat { // minimumIntegerDigits?: number; // minimumFractionDigits?: number; // maximumFractionDigits?: number; -export class NumberFormat extends common.NumberFormat { - public formatNative(value: number, locale?: string, options?: Intl.NumberFormatOptions, pattern?: string) { +export class NumberFormat extends commonNumberFormat { + public formatNative(value: number, locale?: string, options?: NumberFormatOptions, pattern?: string) { let numberFormat; if (pattern) { numberFormat = new java.text.DecimalFormat(pattern); } else { if (options) { switch (options.style.toLowerCase()) { - case 'decimal': + case "decimal": numberFormat = java.text.NumberFormat.getNumberInstance(getNativeLocale(locale)); break; - case 'percent': + case "percent": numberFormat = java.text.NumberFormat.getPercentInstance(getNativeLocale(locale)); break; - case 'currency': + case "currency": numberFormat = java.text.NumberFormat.getCurrencyInstance(getNativeLocale(locale)); if (options.currency !== void 0) { numberFormat.setCurrency(java.util.Currency.getInstance(options.currency)); @@ -131,40 +140,42 @@ export class NumberFormat extends common.NumberFormat { numberFormat = java.text.NumberFormat.getNumberInstance(getNativeLocale(locale)); } } - + if (options && options.minimumIntegerDigits !== void 0) { numberFormat.setMinimumIntegerDigits(options.minimumIntegerDigits); } - + if (options && options.minimumFractionDigits !== void 0) { numberFormat.setMinimumFractionDigits(options.minimumFractionDigits); } - + if (options && options.maximumFractionDigits !== void 0) { numberFormat.setMaximumFractionDigits(options.maximumFractionDigits); } - + if (options && options.useGrouping !== void 0) { numberFormat.setGroupingUsed(options.useGrouping); } - - let decimalFormatSymbols = locale ? new java.text.DecimalFormatSymbols(getNativeLocale(locale)) : new java.text.DecimalFormatSymbols(); + + let decimalFormatSymbols = locale ? + new java.text.DecimalFormatSymbols(getNativeLocale(locale)) : + new java.text.DecimalFormatSymbols(); numberFormat.setDecimalFormatSymbols(decimalFormatSymbols); - - if (options && (options.style.toLowerCase() === 'currency' && options.currencyDisplay === 'code')) { + + if (options && (options.style.toLowerCase() === "currency" && options.currencyDisplay === "code")) { if (!pattern) { let currrentPattern = numberFormat.toPattern(); // this will display currency code instead of currency symbol - currrentPattern = currrentPattern.replace('¤', '¤¤'); + currrentPattern = currrentPattern.replace("¤", "¤¤"); numberFormat = new java.text.DecimalFormat(currrentPattern); numberFormat.setDecimalFormatSymbols(decimalFormatSymbols); } - + if (options.currency !== void 0) { decimalFormatSymbols.setCurrency(java.util.Currency.getInstance(options.currency)); } } - + return numberFormat.format(value); } } diff --git a/src/nativescript-intl.d.ts b/src/nativescript-intl.d.ts new file mode 100644 index 0000000..5aaf199 --- /dev/null +++ b/src/nativescript-intl.d.ts @@ -0,0 +1,37 @@ +export var NUMERIC: string; +export var LONG: string; +export var SHORT: string; +export var TWODIGIT: string; +export var FULL: string; +export interface DateTimeFormatOptions { + weekday?: string; + era?: string; + year?: string; + month?: string; + day?: string; + hour?: string; + minute?: string; + second?: string; + timeZoneName?: string; + hour12?: boolean; +} + +export class DateTimeFormat { + constructor(locale?: string, options?: DateTimeFormatOptions, pattern?: string); + format(date?: Date): string; +} + +export interface NumberFormatOptions { + style?: string; + currency?: string; + currencyDisplay?: string; + useGrouping?: boolean; + minimumIntegerDigits?: number; + minimumFractionDigits?: number; + maximumFractionDigits?: number; +} + +export class NumberFormat { + constructor(locale?: string, options?: NumberFormatOptions, pattern?: string); + format(value: number): string; +} diff --git a/src/nativescript-intl.ios.js b/src/nativescript-intl.ios.js index 92991da..ad0ee2e 100644 --- a/src/nativescript-intl.ios.js +++ b/src/nativescript-intl.ios.js @@ -1,70 +1,56 @@ -"use strict"; -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; -var common = require("./nativescript-intl-common"); -var DateTimeFormat = (function (_super) { - __extends(DateTimeFormat, _super); - function DateTimeFormat() { - _super.apply(this, arguments); - } - DateTimeFormat.prototype.getNativePattern = function (patternDefinition, locale) { - var dateFormatter = NSDateFormatter.new(); +import { DateTimeFormat as commonDateTimeFormat, NumberFormat as commonNumberFormat, FULL } from "./nativescript-intl-common"; +export class DateTimeFormat extends commonDateTimeFormat { + getNativePattern(patternDefinition, locale) { + let dateFormatter = NSDateFormatter.new(); if (locale) { dateFormatter.locale = NSLocale.alloc().initWithLocaleIdentifier(locale); } if (patternDefinition.date) { - dateFormatter.dateStyle = patternDefinition.date === common.FULL ? NSDateFormatterStyle.NSDateFormatterFullStyle : NSDateFormatterStyle.NSDateFormatterShortStyle; + dateFormatter.dateStyle = patternDefinition.date === FULL ? + 4 : + 1; } if (patternDefinition.time) { - dateFormatter.timeStyle = NSDateFormatterStyle.NSDateFormatterLongStyle; + dateFormatter.timeStyle = 3; } return dateFormatter.dateFormat; - }; - DateTimeFormat.prototype.formatNative = function (pattern, locale, date) { - var dateFormatter = NSDateFormatter.new(); + } + formatNative(pattern, locale, date) { + let dateFormatter = NSDateFormatter.new(); if (locale) { dateFormatter.locale = NSLocale.alloc().initWithLocaleIdentifier(locale); } dateFormatter.dateFormat = pattern; - return dateFormatter.stringFromDate(date ? NSDate.dateWithTimeIntervalSince1970(date.valueOf() / 1000) : NSDate.new()); - }; - return DateTimeFormat; -}(common.DateTimeFormat)); -exports.DateTimeFormat = DateTimeFormat; -var NumberFormat = (function (_super) { - __extends(NumberFormat, _super); - function NumberFormat() { - _super.apply(this, arguments); + return dateFormatter.stringFromDate(date ? date : new Date()); } - NumberFormat.prototype.formatNative = function (value, locale, options, pattern) { - var numberFormat = NSNumberFormatter.new(); +} +export class NumberFormat extends commonNumberFormat { + formatNative(value, locale, options, pattern) { + let numberFormat = NSNumberFormatter.new(); if (locale) { numberFormat.locale = NSLocale.alloc().initWithLocaleIdentifier(locale); } if (options) { switch (options.style.toLowerCase()) { - case 'decimal': - numberFormat.numberStyle = NSNumberFormatterStyle.NSNumberFormatterDecimalStyle; + case "decimal": + numberFormat.numberStyle = 1; break; - case 'percent': - numberFormat.numberStyle = NSNumberFormatterStyle.NSNumberFormatterPercentStyle; + case "percent": + numberFormat.numberStyle = 3; break; - case 'currency': - numberFormat.numberStyle = NSNumberFormatterStyle.NSNumberFormatterCurrencyStyle; + case "currency": + numberFormat.numberStyle = 2; if (options.currency !== void 0) { numberFormat.currencyCode = options.currency; } break; default: - numberFormat.numberStyle = NSNumberFormatterStyle.NSNumberFormatterDecimalStyle; + numberFormat.numberStyle = 1; break; } } else { - numberFormat.numberStyle = NSNumberFormatterStyle.NSNumberFormatterDecimalStyle; + numberFormat.numberStyle = 1; } if (options && options.minimumIntegerDigits !== void 0) { numberFormat.minimumIntegerDigits = options.minimumIntegerDigits; @@ -82,14 +68,12 @@ var NumberFormat = (function (_super) { numberFormat.positiveFormat = pattern; } else { - if (options && (options.style.toLowerCase() === 'currency' && options.currencyDisplay === 'code')) { - var pattern_1 = numberFormat.positiveFormat; - pattern_1 = pattern_1.replace('¤', '¤¤'); - numberFormat.positiveFormat = pattern_1; + if (options && (options.style.toLowerCase() === "currency" && options.currencyDisplay === "code")) { + let tempPattern = numberFormat.positiveFormat; + tempPattern = tempPattern.replace("¤", "¤¤"); + numberFormat.positiveFormat = tempPattern; } } - return numberFormat.stringFromNumber(NSNumber.alloc().initWithDouble(value)); - }; - return NumberFormat; -}(common.NumberFormat)); -exports.NumberFormat = NumberFormat; + return numberFormat.stringFromNumber(value); + } +} diff --git a/src/nativescript-intl.ios.ts b/src/nativescript-intl.ios.ts index 7b006ca..46cd392 100644 --- a/src/nativescript-intl.ios.ts +++ b/src/nativescript-intl.ios.ts @@ -1,27 +1,37 @@ -import common = require("./nativescript-intl-common"); +import { + DateTimeFormat as commonDateTimeFormat, + NumberFormat as commonNumberFormat, + FULL +} from "./nativescript-intl-common"; +import { NumberFormatOptions } from "nativescript-intl"; -export class DateTimeFormat extends common.DateTimeFormat { +export class DateTimeFormat extends commonDateTimeFormat { public getNativePattern(patternDefinition: {date?: string, time?: string}, locale?: string): string { let dateFormatter = NSDateFormatter.new(); if (locale) { dateFormatter.locale = NSLocale.alloc().initWithLocaleIdentifier(locale); } if (patternDefinition.date) { - dateFormatter.dateStyle = patternDefinition.date === common.FULL ? NSDateFormatterStyle.NSDateFormatterFullStyle : NSDateFormatterStyle.NSDateFormatterShortStyle; + dateFormatter.dateStyle = patternDefinition.date === FULL ? + NSDateFormatterStyle.FullStyle : + NSDateFormatterStyle.ShortStyle; } if (patternDefinition.time) { - dateFormatter.timeStyle = NSDateFormatterStyle.NSDateFormatterLongStyle; + dateFormatter.timeStyle = NSDateFormatterStyle.LongStyle; } return dateFormatter.dateFormat; } - + public formatNative(pattern: string, locale?: string, date?: Date): string { let dateFormatter = NSDateFormatter.new(); if (locale) { dateFormatter.locale = NSLocale.alloc().initWithLocaleIdentifier(locale); } dateFormatter.dateFormat = pattern; - return dateFormatter.stringFromDate(date ? NSDate.dateWithTimeIntervalSince1970(date.valueOf()/1000) : NSDate.new()); + // return dateFormatter.stringFromDate(date ? + // NSDate.dateWithTimeIntervalSince1970(date.valueOf()/1000) : + // NSDate.new()); + return dateFormatter.stringFromDate(date ? date : new Date()); } } @@ -32,61 +42,62 @@ export class DateTimeFormat extends common.DateTimeFormat { // minimumIntegerDigits?: number; // minimumFractionDigits?: number; // maximumFractionDigits?: number; -export class NumberFormat extends common.NumberFormat { - public formatNative(value: number, locale?: string, options?: Intl.NumberFormatOptions, pattern?: string) { +export class NumberFormat extends commonNumberFormat { + public formatNative(value: number, locale?: string, options?: NumberFormatOptions, pattern?: string) { let numberFormat = NSNumberFormatter.new(); if (locale) { numberFormat.locale = NSLocale.alloc().initWithLocaleIdentifier(locale); } if (options) { switch (options.style.toLowerCase()) { - case 'decimal': - numberFormat.numberStyle = NSNumberFormatterStyle.NSNumberFormatterDecimalStyle; + case "decimal": + numberFormat.numberStyle = NSNumberFormatterStyle.DecimalStyle; break; - case 'percent': - numberFormat.numberStyle = NSNumberFormatterStyle.NSNumberFormatterPercentStyle; + case "percent": + numberFormat.numberStyle = NSNumberFormatterStyle.PercentStyle; break; - case 'currency': - numberFormat.numberStyle = NSNumberFormatterStyle.NSNumberFormatterCurrencyStyle; + case "currency": + numberFormat.numberStyle = NSNumberFormatterStyle.CurrencyStyle; if (options.currency !== void 0) { numberFormat.currencyCode = options.currency; } break; default: - numberFormat.numberStyle = NSNumberFormatterStyle.NSNumberFormatterDecimalStyle; + numberFormat.numberStyle = NSNumberFormatterStyle.DecimalStyle; break; } } else { - numberFormat.numberStyle = NSNumberFormatterStyle.NSNumberFormatterDecimalStyle; + numberFormat.numberStyle = NSNumberFormatterStyle.DecimalStyle; } - + if (options && options.minimumIntegerDigits !== void 0) { numberFormat.minimumIntegerDigits = options.minimumIntegerDigits; } - + if (options && options.minimumFractionDigits !== void 0) { numberFormat.minimumFractionDigits = options.minimumFractionDigits; } - + if (options && options.maximumFractionDigits !== void 0) { numberFormat.maximumFractionDigits = options.maximumFractionDigits; } - + if (options && options.useGrouping !== void 0) { - numberFormat.usesGroupingSeparator = options.useGrouping; + numberFormat.usesGroupingSeparator = options.useGrouping; } - + if (pattern) { numberFormat.positiveFormat = pattern; } else { - if (options && (options.style.toLowerCase() === 'currency' && options.currencyDisplay === 'code')) { - let pattern = numberFormat.positiveFormat; + if (options && (options.style.toLowerCase() === "currency" && options.currencyDisplay === "code")) { + let tempPattern = numberFormat.positiveFormat; // this will display currency code instead of currency symbol - pattern = pattern.replace('¤', '¤¤'); - numberFormat.positiveFormat = pattern; + tempPattern = tempPattern.replace("¤", "¤¤"); + numberFormat.positiveFormat = tempPattern; } } - - return numberFormat.stringFromNumber(NSNumber.alloc().initWithDouble(value)); + + // return numberFormat.stringFromNumber(NSNumber.alloc().initWithDouble(value)); + return numberFormat.stringFromNumber(value); } } diff --git a/src/package.json b/src/package.json index 5e7df4f..11fdae7 100644 --- a/src/package.json +++ b/src/package.json @@ -2,11 +2,12 @@ "name": "nativescript-intl", "version": "0.0.6", "description": "Provides API for using Native date, time and number formatting with an API similar to Intl.js", - "main": "nativescript-intl", + "main": "bundle", + "module": "nativescript-intl", "nativescript": { "platforms": { - "android": "2.1.0", - "ios": "2.1.0" + "android": "2.3.0", + "ios": "2.3.0" } }, "keywords": [ diff --git a/src/references.d.ts b/src/references.d.ts new file mode 100644 index 0000000..9e497ae --- /dev/null +++ b/src/references.d.ts @@ -0,0 +1,3 @@ +/// +/// +/// \ No newline at end of file diff --git a/src/tsconfig.json b/src/tsconfig.json index df4c3b4..286f7ee 100644 --- a/src/tsconfig.json +++ b/src/tsconfig.json @@ -1,24 +1,26 @@ { "compilerOptions": { - "module": "commonjs", - "target": "es5", + "module": "es6", + "target": "es6", "noImplicitAny": false, "removeComments": true, "preserveConstEnums": true, "sourceMap": false, - "declaration": true, - "noLib": false + "declaration": false, + "lib": [ + "es2016" + ] }, "filesGlob": [ "./**/*.ts", "!./node_modules/**/*.ts" ], "files": [ - "../d.ts/references.d.ts", - "index.d.ts", + "references.d.ts", "nativescript-intl-common.ts", "nativescript-intl.android.ts", - "nativescript-intl.ios.ts" + "nativescript-intl.ios.ts", + "index.ts" ], "exclude": [] } diff --git a/src/tslint.json b/src/tslint.json new file mode 100644 index 0000000..e2b7eca --- /dev/null +++ b/src/tslint.json @@ -0,0 +1,118 @@ +{ + "rules": { + "member-access": false, + "no-any": false, + "no-inferrable-types": false, + "no-internal-module": true, + "no-var-requires": false, + "typedef": false, + "typedef-whitespace": [ + true, + { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + }, + { + "call-signature": "space", + "index-signature": "space", + "parameter": "space", + "property-declaration": "space", + "variable-declaration": "space" + } + ], + + "ban": false, + "curly": true, + "no-arg": true, + "no-bitwise": true, + "no-conditional-assignment": true, + "no-console": [ + true, + "debug", + "info", + "time", + "timeEnd", + "trace" + ], + "no-construct": true, + "no-debugger": true, + "no-duplicate-variable": true, + "no-empty": false, + "no-eval": true, + "no-null-keyword": false, + "no-shadowed-variable": true, + "no-string-literal": false, + "no-switch-case-fall-through": true, + "no-unused-expression": true, + "no-use-before-declare": true, + "no-var-keyword": true, + "radix": false, + "switch-default": true, + "triple-equals": [ + true, + "allow-null-check" + ], + "eofline": true, + "indent": [ + true, + "spaces" + ], + "max-line-length": [ + true, + 120 + ], + "no-require-imports": false, + "no-trailing-whitespace": true, + "object-literal-sort-keys": false, + "trailing-comma": [ + true, + { + "multiline": false, + "singleline": "never" + } + ], + + "align": false, + "class-name": true, + "comment-format": [ + true, + "check-space" + ], + "interface-name": false, + "jsdoc-format": true, + "no-consecutive-blank-lines": [ + true, 2 + ], + "one-line": [ + true, + "check-open-brace", + "check-catch", + "check-else", + "check-finally", + "check-whitespace" + ], + "quotemark": [ + true, + "double", + "avoid-escape" + ], + "semicolon": [true, "always"], + "variable-name": [ + true, + "check-format", + "allow-leading-underscore", + "ban-keywords" + ], + "whitespace": [ + true, + "check-branch", + "check-decl", + "check-operator", + "check-separator", + "check-type" + ] + } +} diff --git a/tests/package.json b/tests/package.json index 0211851..7858710 100644 --- a/tests/package.json +++ b/tests/package.json @@ -2,11 +2,11 @@ "nativescript": { "id": "org.nativescript.tests", "tns-android": { - "version": "2.4.0" + "version": "2.4.1" } }, "dependencies": { - "nativescript-intl": "file:..\\dist\\nativescript-intl-0.0.5.tgz", + "nativescript-intl": "file:..\\dist\\nativescript-intl-0.0.6.tgz", "nativescript-unit-test-runner": "^0.3.3", "tns-core-modules": "^2.1.0" }, @@ -23,4 +23,4 @@ "lazy": "1.0.11", "mocha": "^2.4.5" } -} \ No newline at end of file +}