diff --git a/.eslintrc.yml b/.eslintrc.yml index 0cccb8c..6a02457 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -1,10 +1,23 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + root: true -extends: semistandard -rules: - indent: - - error - - 4 - camelcase: off - padded-blocks: off - operator-linebreak: off - no-throw-literal: off \ No newline at end of file +extends: "@cordova/eslint-config/browser" + +overrides: + - files: [tests/**/*.js] + extends: "@cordova/eslint-config/node-tests" diff --git a/package.json b/package.json index b8e098f..e787459 100644 --- a/package.json +++ b/package.json @@ -17,10 +17,10 @@ "ecosystem:cordova" ], "scripts": { - "test": "npm run eslint && npm run objc-tests", + "test": "npm run lint && npm run objc-tests", "objc-tests": "cd tests/ios && npm test", "preobjc-tests": "cd tests/ios && npm install", - "eslint": "node_modules/.bin/eslint src" + "lint": "eslint ." }, "author": "Apache Software Foundation", "license": "Apache-2.0", @@ -33,12 +33,6 @@ } }, "devDependencies": { - "eslint": "^3.19.0", - "eslint-config-semistandard": "^11.0.0", - "eslint-config-standard": "^10.2.1", - "eslint-plugin-import": "^2.3.0", - "eslint-plugin-node": "^5.0.0", - "eslint-plugin-promise": "^3.5.0", - "eslint-plugin-standard": "^3.0.1" + "@cordova/eslint-config": "^3.0.0" } } diff --git a/src/www/ios/ios-wkwebview-exec.js b/src/www/ios/ios-wkwebview-exec.js index 331fe93..fe37d6a 100644 --- a/src/www/ios/ios-wkwebview-exec.js +++ b/src/www/ios/ios-wkwebview-exec.js @@ -17,7 +17,7 @@ * specific language governing permissions and limitations * under the License. * -*/ + */ /** * Creates the exec bridge used to notify the native code of @@ -35,8 +35,8 @@ function massageArgsJsToNative (args) { args.forEach(function (arg, i) { if (utils.typeName(arg) === 'ArrayBuffer') { ret.push({ - 'CDVType': 'ArrayBuffer', - 'data': base64.fromArrayBuffer(arg) + CDVType: 'ArrayBuffer', + data: base64.fromArrayBuffer(arg) }); } else { ret.push(arg); @@ -64,7 +64,7 @@ function massageMessageNativeToJs (message) { function convertMessageToArgsNativeToJs (message) { var args = []; - if (!message || !message.hasOwnProperty('CDVType')) { + if (!message || !Object.prototype.hasOwnProperty.call(message, 'CDVType')) { args.push(message); } else if (message.CDVType === 'MultiPart') { message.messages.forEach(function (e) { @@ -99,8 +99,10 @@ var iOSExec = function () { // an invalid callbackId and passes it even if no callbacks were given. callbackId = 'INVALID'; } else { - throw new Error('The old format of this exec call has been removed (deprecated since 2.1). Change to: ' + // eslint-disable-line - 'cordova.exec(null, null, \'Service\', \'action\', [ arg1, arg2 ]);'); + throw new Error( + 'The old format of this exec call has been removed (deprecated since 2.1). Change to: ' + // eslint-disable-line + "cordova.exec(null, null, 'Service', 'action', [ arg1, arg2 ]);" + ); } // If actionArgs is not provided, default to an empty array @@ -110,8 +112,7 @@ var iOSExec = function () { // arguments if given. if (successCallback || failCallback) { callbackId = service + cordova.callbackId++; - cordova.callbacks[callbackId] = - {success: successCallback, fail: failCallback}; + cordova.callbacks[callbackId] = { success: successCallback, fail: failCallback }; } actionArgs = massageArgsJsToNative(actionArgs); @@ -142,8 +143,11 @@ iOSExec.nativeEvalAndFetch = function (func) { function cordovaExec () { var cexec = require('cordova/exec'); - var cexec_valid = (typeof cexec.nativeFetchMessages === 'function') && (typeof cexec.nativeEvalAndFetch === 'function') && (typeof cexec.nativeCallback === 'function'); - return (cexec_valid && execProxy !== cexec) ? cexec : iOSExec; + var cexec_valid = + typeof cexec.nativeFetchMessages === 'function' && + typeof cexec.nativeEvalAndFetch === 'function' && + typeof cexec.nativeCallback === 'function'; + return cexec_valid && execProxy !== cexec ? cexec : iOSExec; } function execProxy () { @@ -164,7 +168,12 @@ execProxy.nativeCallback = function () { module.exports = execProxy; -if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.cordova && window.webkit.messageHandlers.cordova.postMessage) { +if ( + window.webkit && + window.webkit.messageHandlers && + window.webkit.messageHandlers.cordova && + window.webkit.messageHandlers.cordova.postMessage +) { // unregister the old bridge cordova.define.remove('cordova/exec'); // redefine bridge to our new bridge diff --git a/src/www/ios/ios-wkwebview.js b/src/www/ios/ios-wkwebview.js index 71e503c..c22d410 100644 --- a/src/www/ios/ios-wkwebview.js +++ b/src/www/ios/ios-wkwebview.js @@ -17,7 +17,7 @@ * specific language governing permissions and limitations * under the License. * -*/ + */ var exec = require('cordova/exec'); diff --git a/tests/tests.js b/tests/tests.js index 879b6a0..28bafc2 100644 --- a/tests/tests.js +++ b/tests/tests.js @@ -17,28 +17,32 @@ * specific language governing permissions and limitations * under the License. * -*/ - -/* jshint jasmine: true */ + */ exports.defineAutoTests = function () { describe('cordova-plugin-wkwebview-engine (cordova)', function () { - it("cordova-plugin-wkwebview-engine.spec.1 should exist", function () { - //expect(window).toBeDefined(); + it('cordova-plugin-wkwebview-engine.spec.1 should exist', function () { + expect(window).toBeDefined(); }); }); }; exports.defineManualTests = function (contentEl, createActionButton) { - contentEl.innerHTML = 'Your HTML instructions here'; - createActionButton('Do something 1', function () { - // do something 1; - }, 'do-something-1'); - - createActionButton('Do something 2', function () { - // do something 2; - }, 'do-something-2'); + createActionButton( + 'Do something 1', + function () { + // do something 1; + }, + 'do-something-1' + ); + createActionButton( + 'Do something 2', + function () { + // do something 2; + }, + 'do-something-2' + ); };