diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..2c0e1af --- /dev/null +++ b/.eslintignore @@ -0,0 +1,7 @@ +# /node_modules/* and /bower_components/* ignored by default + +app/App_Resources/* +hooks/* +platforms/* +dist/* +scripts/* diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..a460462 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,233 @@ +{ + "env": { + "node": true, + "es6": true + }, + "globals": { + "global": true + }, + "extends": "eslint:recommended", + "rules": { + "accessor-pairs": "error", + "array-bracket-spacing": "error", + "arrow-body-style": "error", + "arrow-parens": "error", + "arrow-spacing": "error", + "block-spacing": "error", + "brace-style": [ + "error", + "stroustrup", + { "allowSingleLine": true } + ], + "camelcase": "error", + "comma-dangle": "error", + "comma-spacing": "error", + "comma-style": "error", + "complexity": "error", + "computed-property-spacing": "error", + "curly": "error", + "default-case": "error", + "dot-location": [ + "error", + "property" + ], + "dot-notation": "error", + "eol-last": "error", + "eqeqeq": "error", + "func-call-spacing": "error", + "generator-star-spacing": "error", + "guard-for-in": "error", + "handle-callback-err": "error", + "id-blacklist": "error", + "id-match": "error", + "keyword-spacing": "error", + "max-depth": "error", + "max-nested-callbacks": "error", + "max-statements-per-line": "error", + "new-parens": "error", + "newline-per-chained-call": "off", + "no-alert": "error", + "no-array-constructor": "error", + "no-bitwise": [ + "error", + { + "int32Hint": true + } + ], + "no-caller": "error", + "no-catch-shadow": "error", + "no-confusing-arrow": "error", + "no-console": "off", + "no-continue": "off", + "no-div-regex": "error", + "no-duplicate-imports": "error", + "no-else-return": "off", + "no-empty-function": "off", + "no-eq-null": "off", + "no-eval": "error", + "no-extend-native": "error", + "no-extra-bind": "error", + "no-extra-label": "error", + "no-extra-parens": "off", + "no-floating-decimal": "error", + "no-global-assign": "error", + "no-implicit-coercion": [ + "error", + { + "boolean": false, + "number": false, + "string": false + } + ], + "no-implicit-globals": "error", + "no-implied-eval": "error", + "no-inline-comments": "off", + "no-inner-declarations": [ + "error", + "functions" + ], + "no-invalid-this": "off", + "no-iterator": "error", + "no-label-var": "error", + "no-labels": "error", + "no-lone-blocks": "error", + "no-lonely-if": "off", + "no-loop-func": "error", + "no-magic-numbers": "off", + "no-mixed-operators": "error", + "no-mixed-requires": "error", + "no-multi-spaces": "error", + "no-multi-str": "error", + "no-multiple-empty-lines": "error", + "no-negated-condition": "off", + "no-nested-ternary": "error", + "no-new": "error", + "no-new-func": "error", + "no-new-object": "error", + "no-new-require": "error", + "no-new-wrappers": "error", + "no-octal-escape": "error", + "no-param-reassign": "off", + "no-path-concat": "error", + "no-plusplus": "off", + "no-process-env": "off", + "no-process-exit": "off", + "no-proto": "off", + "no-prototype-builtins": "off", + "no-restricted-globals": "error", + "no-restricted-imports": "error", + "no-restricted-modules": "error", + "no-restricted-syntax": "error", + "no-return-assign": [ + "error", + "except-parens" + ], + "no-script-url": "error", + "no-self-compare": "error", + "no-sequences": "error", + "no-shadow": "off", + "no-shadow-restricted-names": "error", + "no-spaced-func": "error", + "no-sync": "off", + "no-tabs": "off", + "no-template-curly-in-string": "error", + "no-ternary": "off", + "no-throw-literal": "error", + "no-trailing-spaces": "error", + "no-undef-init": "off", + "no-undefined": "off", + "no-underscore-dangle": "off", + "no-unmodified-loop-condition": "error", + "no-unneeded-ternary": "off", + "no-unsafe-negation": "error", + "no-unused-expressions": "error", + "no-unused-vars": [ + "error", + { + "vars": "all", + "args": "none", + "ignoreRestSiblings": false + } + ], + "no-use-before-define": "off", + "no-useless-call": "off", + "no-useless-computed-key": "error", + "no-useless-concat": "error", + "no-useless-constructor": "error", + "no-useless-escape": "off", + "no-useless-rename": "error", + "no-var": "error", + "no-void": "off", + "no-warning-comments": "off", + "no-whitespace-before-property": "error", + "no-with": "error", + "object-curly-newline": "off", + "object-curly-spacing": [ + "error", + "always" + ], + "object-property-newline": "error", + "object-shorthand": "off", + "one-var": [ + "error", + "never" + ], + "one-var-declaration-per-line": "off", + "operator-assignment": "off", + "operator-linebreak": [ + "error", + "after" + ], + "padded-blocks": "off", + "padding-line-between-statements": [ + "error", + { + "blankLine": "always", + "prev": "*", + "next": "return" + } + ], + "prefer-arrow-callback": "error", + "prefer-const": "error", + "prefer-spread": "error", + "prefer-template": "error", + "quotes": "error", + "radix": "error", + "rest-spread-spacing": "error", + "semi": "error", + "semi-spacing": [ + "error", + { + "after": true, + "before": false + } + ], + "sort-imports": "error", + "space-before-blocks": "error", + "space-in-parens": [ + "error", + "never" + ], + "space-infix-ops": "error", + "space-unary-ops": "error", + "strict": "error", + "template-curly-spacing": "error", + "unicode-bom": [ + "error", + "never" + ], + "wrap-iife": "error", + "wrap-regex": "error", + "yield-star-spacing": "error", + "yoda": [ + "error", + "never" + ] + }, + "parserOptions": { + "ecmaVersion": 6, + "ecmaFeatures": { + "impliedStrict": true + } + } +} diff --git a/app/application/android-broadcast-receiver/android-broadcast-receiver-page.js b/app/application/android-broadcast-receiver/android-broadcast-receiver-page.js index 24eeea9..3ba7208 100644 --- a/app/application/android-broadcast-receiver/android-broadcast-receiver-page.js +++ b/app/application/android-broadcast-receiver/android-broadcast-receiver-page.js @@ -1,10 +1,11 @@ -var applicationModule = require("tns-core-modules/application"); -var Observable = require("tns-core-modules/data/observable").Observable; -var platformModule = require("tns-core-modules/platform"); -var vm, receiver; +const applicationModule = require("tns-core-modules/application"); +const Observable = require("tns-core-modules/data/observable").Observable; +const platformModule = require("tns-core-modules/platform"); +let vm; +let receiver; function onNavigatingTo(args) { - var page = args.object; + const page = args.object; page.actionBar.title = ""; vm = new Observable(); vm.set("info", "Using Android Broadcast Receiver \nto check the battery life"); @@ -19,10 +20,10 @@ function onNavigatedTo(args) { // >> broadcast-receiver if (platformModule.isAndroid) { // use tns-platform-dclarations to acces native APIs (e.g. ndroid.content.Intent) - receiver = applicationModule.android.registerBroadcastReceiver(android.content.Intent.ACTION_BATTERY_CHANGED, function onReceiveCallback(context, intent) { - var level = intent.getIntExtra(android.os.BatteryManager.EXTRA_LEVEL, -1); - var scale = intent.getIntExtra(android.os.BatteryManager.EXTRA_SCALE, -1); - var percent = (level / scale) * 100.0; + receiver = applicationModule.android.registerBroadcastReceiver(android.content.Intent.ACTION_BATTERY_CHANGED, (context, intent) => { + const level = intent.getIntExtra(android.os.BatteryManager.EXTRA_LEVEL, -1); + const scale = intent.getIntExtra(android.os.BatteryManager.EXTRA_SCALE, -1); + const percent = (level / scale) * 100.0; vm.set("batteryLife", percent.toString()); }); } diff --git a/app/application/application-events/application-events-page.js b/app/application/application-events/application-events-page.js index 88ce89e..f07724a 100644 --- a/app/application/application-events/application-events-page.js +++ b/app/application/application-events/application-events-page.js @@ -1,18 +1,26 @@ // >> application-events-import -var applicationModule = require("tns-core-modules/application"); +const applicationModule = require("tns-core-modules/application"); // << application-events-import -var Observable = require("tns-core-modules/data/observable").Observable; -var enums = require("ui/enums"); -var vm; -var launchListener, suspendListener, resumeListener, exitListener, displayedListener, lowMemoryListener, orientationChangedListener, uncaughtErrorListener; +const Observable = require("tns-core-modules/data/observable").Observable; +const enums = require("ui/enums"); +let vm; +let launchListener; +let suspendListener; +let resumeListener; +let exitListener; +let displayedListener; +let lowMemoryListener; +let orientationChangedListener; +let uncaughtErrorListener; + function onNavigatingTo(args) { - var page = args.object; + const page = args.object; vm = new Observable(); vm.set("actionBarTitle", args.context.actionBarTitle); vm.set("info", "Refer to the code-behind files \nfor Application Events snippets"); if (applicationModule.android) { - var activity = applicationModule.android.foregroundActivity; - var orientationEnum = activity.getResources().getConfiguration().orientation; + const activity = applicationModule.android.foregroundActivity; + const orientationEnum = activity.getResources().getConfiguration().orientation; vm.set("orientation", (orientationEnum === 1 ? enums.DeviceOrientation.portrait : enums.DeviceOrientation.landscape)); } else if (applicationModule.ios) { @@ -24,36 +32,36 @@ function onNavigatingTo(args) { exports.onNavigatingTo = onNavigatingTo; function onGridLoaded(args) { // >> application-events - launchListener = applicationModule.on(applicationModule.launchEvent, function (args) { + launchListener = applicationModule.on(applicationModule.launchEvent, (args) => { // The root view for this Window on iOS or Activity for Android. // If not set a new Frame will be created as a root view in order to maintain backwards compatibility. - console.log("Root View: " + args.root); + console.log("Root View: ", args.root); console.log("The appication was launched!"); }); - suspendListener = applicationModule.on(applicationModule.suspendEvent, function (args) { + suspendListener = applicationModule.on(applicationModule.suspendEvent, (args) => { console.log("The appication was suspended!"); }); - resumeListener = applicationModule.on(applicationModule.resumeEvent, function (args) { + resumeListener = applicationModule.on(applicationModule.resumeEvent, (args) => { console.log("The appication was resumed!"); }); - exitListener = applicationModule.on(applicationModule.exitEvent, function (args) { + exitListener = applicationModule.on(applicationModule.exitEvent, (args) => { console.log("The appication was closed!"); }); - displayedListener = applicationModule.on(applicationModule.displayedEvent, function (args) { + displayedListener = applicationModule.on(applicationModule.displayedEvent, (args) => { console.log("NativeScript displayedEvent"); }); - lowMemoryListener = applicationModule.on(applicationModule.lowMemoryEvent, function (args) { + lowMemoryListener = applicationModule.on(applicationModule.lowMemoryEvent, (args) => { // the instance that has raidsed the event - console.log("Instance: " + args.object); + console.log("Instance: ", args.object); }); - orientationChangedListener = applicationModule.on(applicationModule.orientationChangedEvent, function (args) { + orientationChangedListener = applicationModule.on(applicationModule.orientationChangedEvent, (args) => { // orientationChangedEventData.newValue: "portrait" | "landscape" | "unknown" - console.log("Orientation: " + args.newValue); + console.log("Orientation: ", args.newValue); vm.set("orientation", args.newValue); }); - uncaughtErrorListener = applicationModule.on(applicationModule.uncaughtErrorEvent, function (args) { + uncaughtErrorListener = applicationModule.on(applicationModule.uncaughtErrorEvent, (args) => { // UnhandledErrorEventData.error: NativeScriptError - console.log("NativeScript Error: " + args.error); + console.log("NativeScript Error: ", args.error); }); // << application-events } diff --git a/app/application/application-page.js b/app/application/application-page.js index 5289de5..5a7563b 100644 --- a/app/application/application-page.js +++ b/app/application/application-page.js @@ -1,13 +1,16 @@ -var ListViewLinksModel = require("../links-view-model"); -var link = require("../link"); -var navigationLinks = [ +const ListViewLinksModel = require("../links-view-model"); +const link = require("../link"); +const navigationLinks = [ new link("Check Platform", "/application/check-platform/check-platform-page"), new link("Application Events", "/application/application-events/application-events-page"), new link("Android Broadcast Receiver", "/application/android-broadcast-receiver/android-broadcast-receiver-page"), new link("iOS Notification Observer", "/application/ios-notification-observer/ios-notification-observer-page") ]; function onNavigatingTo(args) { - var page = args.object; - page.bindingContext = new ListViewLinksModel({ links: navigationLinks, actionBarTitle: args.context.title }); + const page = args.object; + page.bindingContext = new ListViewLinksModel({ + links: navigationLinks, + actionBarTitle: args.context.title + }); } exports.onNavigatingTo = onNavigatingTo; diff --git a/app/application/check-platform/check-platform-page.js b/app/application/check-platform/check-platform-page.js index ccb943c..1b81a27 100644 --- a/app/application/check-platform/check-platform-page.js +++ b/app/application/check-platform/check-platform-page.js @@ -1,10 +1,10 @@ // >> application-require-js -var application = require("tns-core-modules/application"); +const application = require("tns-core-modules/application"); // << application-require-js function onGridLoaded(args) { - var grid = args.object; - var lbl = grid.getViewById("lbl"); - var iconLabel = grid.getViewById("iconLabel"); + const grid = args.object; + const lbl = grid.getViewById("lbl"); + const iconLabel = grid.getViewById("iconLabel"); iconLabel.className = "fa"; iconLabel.textAlignment = "center"; iconLabel.verticalAlignment = "middle"; @@ -31,7 +31,7 @@ function onGridLoaded(args) { } exports.onGridLoaded = onGridLoaded; function onNavigatingTo(args) { - var page = args.object; + const page = args.object; page.actionBar.title = args.context.title; } exports.onNavigatingTo = onNavigatingTo; diff --git a/app/application/ios-notification-observer/ios-notification-observer-page.js b/app/application/ios-notification-observer/ios-notification-observer-page.js index 0ca6634..0e1ee4d 100644 --- a/app/application/ios-notification-observer/ios-notification-observer-page.js +++ b/app/application/ios-notification-observer/ios-notification-observer-page.js @@ -1,10 +1,11 @@ -var application = require("tns-core-modules/application"); -var Observable = require("tns-core-modules/data/observable").Observable; -var platformModule = require("tns-core-modules/platform"); -var utilsModule = require("tns-core-modules/utils/utils"); -var vm, observer; +const application = require("tns-core-modules/application"); +const Observable = require("tns-core-modules/data/observable").Observable; +const platformModule = require("tns-core-modules/platform"); +const utilsModule = require("tns-core-modules/utils/utils"); +let vm; +let observer; function onNavigatingTo(args) { - var page = args.object; + const page = args.object; vm = new Observable(); vm.set("info", "Using iOS Notification Observer \nto check the battery life"); vm.set("batteryLife", "0"); @@ -20,7 +21,7 @@ function onNavigatedTo(args) { // import { ios as iosUtils } from "tns-core-modules/utils/utils"; utilsModule.ios.getter(UIDevice, UIDevice.currentDevice).batteryMonitoringEnabled = true; vm.set("batteryLife", +(utilsModule.ios.getter(UIDevice, UIDevice.currentDevice).batteryLevel * 100).toFixed(1)); - observer = application.ios.addNotificationObserver(UIDeviceBatteryLevelDidChangeNotification, function onReceiveCallback(notification) { + observer = application.ios.addNotificationObserver(UIDeviceBatteryLevelDidChangeNotification, (notification) => { // tslint:disable:max-line-length vm.set("batteryLife", +(utilsModule.ios.getter(UIDevice, UIDevice.currentDevice).batteryLevel * 100).toFixed(1)); }); diff --git a/app/ui/action-bar/action-bar-page.js b/app/ui/action-bar/action-bar-page.js index 06f696b..ae2557a 100644 --- a/app/ui/action-bar/action-bar-page.js +++ b/app/ui/action-bar/action-bar-page.js @@ -1,10 +1,13 @@ -var ListViewLinksModel = require("../../links-view-model"); -var link = require("../../link"); -var navigationLinks = [ - new link("Basics", "/ui/action-bar/basics/basics-page"), +const ListViewLinksModel = require("../../links-view-model"); +const link = require("../../link"); +const navigationLinks = [ + new link("Basics", "/ui/action-bar/basics/basics-page") ]; function onNavigatingTo(args) { - var page = args.object; - page.bindingContext = new ListViewLinksModel({ links: navigationLinks, actionBarTitle: args.context.title }); + const page = args.object; + page.bindingContext = new ListViewLinksModel({ + links: navigationLinks, + actionBarTitle: args.context.title + }); } exports.onNavigatingTo = onNavigatingTo; diff --git a/app/ui/action-bar/basics/basics-page.js b/app/ui/action-bar/basics/basics-page.js index 9085ad0..7f3c3e3 100644 --- a/app/ui/action-bar/basics/basics-page.js +++ b/app/ui/action-bar/basics/basics-page.js @@ -1,10 +1,10 @@ const Observable = require("tns-core-modules/data/observable").Observable; function onNavigatingTo(args) { - let page = args.object; - let vm = new Observable(); + const page = args.object; + const vm = new Observable(); vm.set("title", "Getting Started \nAction Bar Example"); vm.set("snippet", ""); page.bindingContext = vm; } -exports.onNavigatingTo = onNavigatingTo; \ No newline at end of file +exports.onNavigatingTo = onNavigatingTo; diff --git a/app/ui/activity-indicator/activity-indicator-page.js b/app/ui/activity-indicator/activity-indicator-page.js index 9876381..4791d6a 100644 --- a/app/ui/activity-indicator/activity-indicator-page.js +++ b/app/ui/activity-indicator/activity-indicator-page.js @@ -1,13 +1,15 @@ -var ListViewLinksModel = require("../../links-view-model"); -var link = require("../../link"); -var navigationLinks = [ +const ListViewLinksModel = require("../../links-view-model"); +const link = require("../../link"); +const navigationLinks = [ new link("Basics", "/ui/activity-indicator/basics/basics-page"), new link("Styling", "/ui/activity-indicator/styling/styling-page"), new link("Dynamic Creation", "/ui/activity-indicator/code-behind/code-behind-page") ]; function onNavigatingTo(args) { - var page = args.object; - page.bindingContext = new ListViewLinksModel({ links: navigationLinks, actionBarTitle: args.context.title }); + const page = args.object; + page.bindingContext = new ListViewLinksModel({ + links: navigationLinks, + actionBarTitle: args.context.title }); } exports.onNavigatingTo = onNavigatingTo; diff --git a/app/ui/activity-indicator/basics/basics-page.js b/app/ui/activity-indicator/basics/basics-page.js index 57753f6..168d7b9 100644 --- a/app/ui/activity-indicator/basics/basics-page.js +++ b/app/ui/activity-indicator/basics/basics-page.js @@ -14,4 +14,4 @@ function onNavigatingTo(args) { page.bindingContext = vm; // << activity-indicator-setting-busy-code } -exports.onNavigatingTo = onNavigatingTo; \ No newline at end of file +exports.onNavigatingTo = onNavigatingTo; diff --git a/app/ui/activity-indicator/code-behind/code-behind-page.js b/app/ui/activity-indicator/code-behind/code-behind-page.js index f8e7cb8..d54128b 100644 --- a/app/ui/activity-indicator/code-behind/code-behind-page.js +++ b/app/ui/activity-indicator/code-behind/code-behind-page.js @@ -21,7 +21,7 @@ function onNavigatingTo(args) { myStsck.addChild(indicator); // << activity-indicator-code-behind - vm.set("snippet", 'const image = new Image(); \nimage.isLoading = true; \n\nconst indicator = new ActivityIndicator(); \nindicator.bind({ \n sourceProperty: "isLoading",\n targetProperty: "busy\n}, image);"'); + vm.set("snippet", "const image = new Image(); \nimage.isLoading = true; \n\nconst indicator = new ActivityIndicator(); \nindicator.bind({ \n sourceProperty: 'isLoading',\n targetProperty: 'busy\n}, image);'"); page.bindingContext = vm; } -exports.onNavigatingTo = onNavigatingTo; \ No newline at end of file +exports.onNavigatingTo = onNavigatingTo; diff --git a/app/ui/activity-indicator/styling/styling-page.js b/app/ui/activity-indicator/styling/styling-page.js index 877ec97..99056c2 100644 --- a/app/ui/activity-indicator/styling/styling-page.js +++ b/app/ui/activity-indicator/styling/styling-page.js @@ -6,7 +6,7 @@ function onNavigatingTo(args) { const vm = new Observable(); vm.set("isLoading", true); - var snippet = ''; + const snippet = ""; vm.set("snippet", snippet); // >> large-ios-indicator @@ -20,4 +20,4 @@ function onNavigatingTo(args) { page.bindingContext = vm; } -exports.onNavigatingTo = onNavigatingTo; \ No newline at end of file +exports.onNavigatingTo = onNavigatingTo; diff --git a/app/ui/animations/animating-properties/animating-properties-page.js b/app/ui/animations/animating-properties/animating-properties-page.js index 6d6ae93..b84ae04 100644 --- a/app/ui/animations/animating-properties/animating-properties-page.js +++ b/app/ui/animations/animating-properties/animating-properties-page.js @@ -1,10 +1,9 @@ const AnimationCurve = require("tns-core-modules/ui/enums").AnimationCurve; const Animation = require("tns-core-modules/ui/animation").Animation; -const AnimationDefinitions = require("tns-core-modules/ui/animation").AnimationDefinitions; const Color = require("tns-core-modules/color").Color; -let animation, - myView; +let animation; +let myView; function onLoaded(args) { const page = args.object; @@ -22,8 +21,14 @@ function animate(args) { iterations: 3, opacity: 0.8, rotate: 360, - scale: { x: 2, y: 2 }, - translate: { x: 0, y: 200 } + scale: { + x: 2, + y: 2 + }, + translate: { + x: 0, + y: 200 + } }).then(() => { console.log("Animation finished"); }).catch((e) => { @@ -37,7 +42,7 @@ function animateTarget(args) { // >> animation-target const myView = args.object; - let animationDefinition = { + const animationDefinition = { target: myView, // provide the view to animate curve: AnimationCurve.easeOut, duration: 1000, @@ -49,13 +54,13 @@ function animateTarget(args) { animation.play() .then(() => { console.log("Animation finished"); - console.log("animation.isPlaying: " + animation.isPlaying); + console.log("animation.isPlaying: ", animation.isPlaying); }).catch((e) => { console.log(e.message); }); // << animation-target } -exports.animateTarget = animateTarget +exports.animateTarget = animateTarget; function cancelAnimation() { // >> animation-cancel @@ -64,19 +69,19 @@ function cancelAnimation() { } function demonstrateSimpleAnimations(args) { - let view = args.object; + const view = args.object; // >> animating-background-color view.backgroundColor = new Color("red"); - view.animate({ - backgroundColor: new Color("green"), - duration: 2000 + view.animate({ + backgroundColor: new Color("green"), + duration: 2000 }); // << animating-background-color // >> using-animation-curve-enum view.animate({ - translate: { x: 0, y: 100}, + translate: { x: 0, y: 100 }, duration: 1000, curve: AnimationCurve.easeIn }); @@ -84,9 +89,12 @@ function demonstrateSimpleAnimations(args) { // >> creating-cubic-bezier view.animate({ - translate: { x: 0, y: 100 }, + translate: { + x: 0, + y: 100 + }, duration: 1000, - curve: enums.AnimationCurve.cubicBezier(0.1, 0.1, 0.1, 1) + curve: AnimationCurve.cubicBezier(0.1, 0.1, 0.1, 1) }); // << creating-cubic-bezier -} \ No newline at end of file +} diff --git a/app/ui/animations/animations-page.js b/app/ui/animations/animations-page.js index 10c8afe..7f5c2ea 100644 --- a/app/ui/animations/animations-page.js +++ b/app/ui/animations/animations-page.js @@ -1,4 +1,4 @@ -let ListViewLinksModel = require("../../links-view-model"); +const ListViewLinksModel = require("../../links-view-model"); const link = require("../../link"); const navigationLinks = [ new link("Animating Multiple Properties", "/ui/animations/animating-properties/animating-properties-page"), @@ -21,7 +21,10 @@ const AnimationCurveEnum = require("tns-core-modules/ui/enums").AnimationCurve; // << animations-imports function onNavigatingTo(args) { - var page = args.object; - page.bindingContext = new ListViewLinksModel({ links: navigationLinks, actionBarTitle: args.context.title }); + const page = args.object; + page.bindingContext = new ListViewLinksModel({ + links: navigationLinks, + actionBarTitle: args.context.title + }); } exports.onNavigatingTo = onNavigatingTo; diff --git a/app/ui/animations/chaining-animations/chaining-animations-page.js b/app/ui/animations/chaining-animations/chaining-animations-page.js index 5554c45..9fe8efe 100644 --- a/app/ui/animations/chaining-animations/chaining-animations-page.js +++ b/app/ui/animations/chaining-animations/chaining-animations-page.js @@ -1,6 +1,3 @@ -const AnimationCurve = require("tns-core-modules/ui/enums").AnimationCurve; -const Animation = require("tns-core-modules/ui/animation").Animation; - let myView; function onLoaded(args) { @@ -21,7 +18,7 @@ function onLoaded(args) { }).catch((e) => { console.log(e.message); }); - // << chaining-animations + // << chaining-animations } exports.onLoaded = onLoaded; diff --git a/app/ui/animations/multiple-views/multiple-views-page.js b/app/ui/animations/multiple-views/multiple-views-page.js index 8a1a9fe..5593647 100644 --- a/app/ui/animations/multiple-views/multiple-views-page.js +++ b/app/ui/animations/multiple-views/multiple-views-page.js @@ -1,8 +1,9 @@ -const AnimationCurve = require("tns-core-modules/ui/enums").AnimationCurve; -const AnimationDefinition = require("tns-core-modules/ui/animation").AnimationDefinition; const Animation = require("tns-core-modules/ui/animation").Animation; -let view1, view2, view3, view4; +let view1; +let view2; +let view3; +let view4; function onLoaded(args) { const page = args.object; @@ -16,37 +17,37 @@ exports.onLoaded = onLoaded; function animate() { // >> animate-multiple-views - let definitions = []; + const definitions = []; - let definition1 = { + const definition1 = { target: view1, translate: { x: 200, y: 0 }, duration: 1000 }; definitions.push(definition1); - let definition2 = { + const definition2 = { target: view2, translate: { x: 0, y: 200 }, duration: 1000 }; definitions.push(definition2); - let definition3 = { + const definition3 = { target: view3, translate: { x: -200, y: 0 }, duration: 1000 }; definitions.push(definition3); - let definition4 = { + const definition4 = { target: view4, translate: { x: 0, y: -200 }, duration: 1000 }; definitions.push(definition4); - let animationSet = new Animation(definitions); + const animationSet = new Animation(definitions); animationSet.play() .then(() => { @@ -54,7 +55,7 @@ function animate() { }).catch((e) => { console.log(e.message); }); - // << animate-multiple-views + // << animate-multiple-views } exports.animate = animate; @@ -69,4 +70,4 @@ function reset() { view4.translateX = 0; view4.translateY = 0; } -exports.reset = reset; \ No newline at end of file +exports.reset = reset; diff --git a/app/ui/button/basics/basics-page.js b/app/ui/button/basics/basics-page.js index ed695fb..0624fc8 100644 --- a/app/ui/button/basics/basics-page.js +++ b/app/ui/button/basics/basics-page.js @@ -1,9 +1,8 @@ const Observable = require("tns-core-modules/data/observable").Observable; -let vm = new Observable(); +const vm = new Observable(); function onNavigatingTo(args) { - let page = args.object; - + const page = args.object; vm.set("counter", 0); page.bindingContext = vm; } @@ -11,11 +10,11 @@ exports.onNavigatingTo = onNavigatingTo; // >> button-tap-event function onTap(args) { - let button = args.object; + // const button = args.object; let count = vm.get("counter"); // initial value = 0 vm.set("counter", ++count); - alert("Tapped " + vm.get("counter") + " times!"); + console.log("Tapped ", vm.get("counter"), " times!"); } exports.onTap = onTap; -// << button-tap-event \ No newline at end of file +// << button-tap-event diff --git a/app/ui/button/button-page.js b/app/ui/button/button-page.js index 6e5a859..68b0403 100644 --- a/app/ui/button/button-page.js +++ b/app/ui/button/button-page.js @@ -1,12 +1,15 @@ -var ListViewLinksModel = require("../../links-view-model"); -var link = require("../../link"); -var navigationLinks = [ +const ListViewLinksModel = require("../../links-view-model"); +const link = require("../../link"); +const navigationLinks = [ new link("Basics", "/ui/button/basics/basics-page"), new link("Styling", "/ui/button/styling/styling-page"), - new link("Dynamic Creation", "/ui/button/dynamic-creation/dynamic-creation-page"), + new link("Dynamic Creation", "/ui/button/dynamic-creation/dynamic-creation-page") ]; function onNavigatingTo(args) { - var page = args.object; - page.bindingContext = new ListViewLinksModel({ links: navigationLinks, actionBarTitle: args.context.title }); + const page = args.object; + page.bindingContext = new ListViewLinksModel({ + links: navigationLinks, + actionBarTitle: args.context.title + }); } exports.onNavigatingTo = onNavigatingTo; diff --git a/app/ui/button/dynamic-creation/dynamic-creation-page.js b/app/ui/button/dynamic-creation/dynamic-creation-page.js index c75d7c3..be92b6f 100644 --- a/app/ui/button/dynamic-creation/dynamic-creation-page.js +++ b/app/ui/button/dynamic-creation/dynamic-creation-page.js @@ -2,11 +2,11 @@ const Button = require("tns-core-modules/ui/button").Button; // << import-button-widget function onNavigatingTo(args) { - let page = args.object; - let container = page.getViewById("container"); + const page = args.object; + const container = page.getViewById("container"); // >> button-code-create - let myButton = new Button(); + const myButton = new Button(); myButton.text = "Tap me!"; myButton.className = "btn btn-primary btn-active"; myButton.on("tap", () => { diff --git a/app/ui/button/styling/styling-page.js b/app/ui/button/styling/styling-page.js index 04a7aaf..78fc5e9 100644 --- a/app/ui/button/styling/styling-page.js +++ b/app/ui/button/styling/styling-page.js @@ -1,12 +1,5 @@ -const Observable = require("tns-core-modules/data/observable").Observable; - -function onNavigatingTo(args) { - let page = args.object; -} -exports.onNavigatingTo = onNavigatingTo; - function onTap(args) { - let button = args.object; + const button = args.object; console.log("Button tapped", button); } exports.onTap = onTap; diff --git a/app/ui/button/styling/styling-page.xml b/app/ui/button/styling/styling-page.xml index 695861a..a66def8 100644 --- a/app/ui/button/styling/styling-page.xml +++ b/app/ui/button/styling/styling-page.xml @@ -1,4 +1,4 @@ - + diff --git a/package.json b/package.json index 4fd4793..bf4e2c9 100644 --- a/package.json +++ b/package.json @@ -20,8 +20,9 @@ "babel-traverse": "6.26.0", "babel-types": "6.26.0", "babylon": "6.18.0", - "lazy": "1.0.11", + "eslint": "^4.19.0", "fs-extra": "^0.30.0", + "lazy": "1.0.11", "markdown-snippet-injector": "^0.2.0", "tar.gz": "^1.0.7" },