Skip to content
Permalink
Browse files
refactor: eslint setup (#221)
  • Loading branch information
erisu committed Nov 27, 2019
1 parent 6d1a3cb commit 17ed8ef404a1efc5cfc6c14e5df031f7d84e23f8
Showing 13 changed files with 58 additions and 60 deletions.
@@ -1,7 +1,35 @@
# 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
extends: '@cordova/eslint-config/node'

overrides:
- files: [test/**/*.js]
extends: '@cordova/eslint-config/browser-tests'

- files: [test/test-platform-modules/**/*.js]
extends: '@cordova/eslint-config/browser'

- files: [src/**/*.js]
extends:
- '@cordova/eslint-config/browser'
- plugin:es5/no-es2015
- plugin:es5/no-es2016
globals:
define: false
PLATFORM_VERSION_BUILD_LABEL: false
@@ -24,12 +24,12 @@ module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
compile: {
'android': {},
'ios': {},
'osx': {},
'windows': { useWindowsLineEndings: true },
'browser': {},
'electron': {}
android: {},
ios: {},
osx: {},
windows: { useWindowsLineEndings: true },
browser: {},
electron: {}
},
clean: ['pkg']
});
@@ -31,7 +31,7 @@ module.exports = function build (userConfig) {
modules(config),
getCommitId()
])
.then(([ scripts, modules, commitId ]) => {
.then(([scripts, modules, commitId]) => {
Object.assign(config, { commitId });
return bundle(scripts, modules, config);
});
@@ -15,9 +15,9 @@
"url": "https://issues.apache.org/jira/browse/CB"
},
"scripts": {
"eslint": "eslint --ignore-path .gitignore .",
"lint": "eslint --ignore-path .gitignore .",
"pretest": "npm run build:test",
"test": "npm run eslint && karma start",
"test": "npm run lint && karma start",
"build": "grunt compile",
"build:test": "node build-tools/test-build pkg/cordova.test.js"
},
@@ -74,16 +74,10 @@
"globby": "^9.2.0"
},
"devDependencies": {
"@cordova/eslint-config": "^2.0.0",
"cordova-android": "^8.0.0",
"cordova-ios": "^5.0.0",
"eslint": "^5.16.0",
"eslint-config-semistandard": "^13.0.0",
"eslint-config-standard": "^12.0.0",
"eslint-plugin-es5": "^1.4.1",
"eslint-plugin-import": "^2.16.0",
"eslint-plugin-node": "^8.0.1",
"eslint-plugin-promise": "^4.1.1",
"eslint-plugin-standard": "^4.0.0",
"grunt": "^1.0.4",
"grunt-contrib-clean": "^2.0.0",
"jasmine-core": "^3.3.0",

This file was deleted.

@@ -24,12 +24,12 @@ var utils = require('cordova/utils');
var moduleExports = module.exports;

var typeMap = {
'A': 'Array',
'D': 'Date',
'N': 'Number',
'S': 'String',
'F': 'Function',
'O': 'Object'
A: 'Array',
D: 'Date',
N: 'Number',
S: 'String',
F: 'Function',
O: 'Object'
};

function extractParamName (callee, argIndex) {
@@ -23,7 +23,7 @@ var utils = require('cordova/utils');

function each (objects, func, context) {
for (var prop in objects) {
if (objects.hasOwnProperty(prop)) {
if (Object.prototype.hasOwnProperty.call(objects, prop)) {
func.apply(context, [objects[prop], prop]);
}
}
@@ -103,7 +103,7 @@ function include (parent, objects, clobber, merge) {
*/
function recursiveMerge (target, src) {
for (var prop in src) {
if (src.hasOwnProperty(prop)) {
if (Object.prototype.hasOwnProperty.call(src, prop)) {
if (target.prototype && target.prototype.constructor === target) {
// If the target object is a constructor override off prototype.
clobber(target.prototype, prop, src[prop]);
@@ -86,7 +86,7 @@ function createEvent (type, data) {
event.initEvent(type, false, false);
if (data) {
for (var i in data) {
if (data.hasOwnProperty(i)) {
if (Object.prototype.hasOwnProperty.call(data, i)) {
event[i] = data[i];
}
}
@@ -234,7 +234,7 @@ var cordova = {
}
} catch (err) {
var msg = 'Error in ' + (isSuccess ? 'Success' : 'Error') + ' callbackId: ' + callbackId + ' : ' + err;
cordova.fireWindowEvent('cordovacallbackerror', { 'message': msg, 'error': err });
cordova.fireWindowEvent('cordovacallbackerror', { message: msg, error: err });
throw err;
}
},

This file was deleted.

This file was deleted.

@@ -19,5 +19,4 @@
*
*/

/* eslint-env jasmine */
module.exports = jasmine.createSpy();
@@ -184,7 +184,7 @@ describe('channel', function () {

testChannel.subscribe(handler);
testChannel.fire(1, 2, 3);
expect(handler.calls.argsFor(0)).toEqual([ 1, 2, 3 ]);
expect(handler.calls.argsFor(0)).toEqual([1, 2, 3]);
});
it('Test#013 : should not fire a handler that was unsubscribed', function () {
var testChannel = multi ? multiChannel : stickyChannel;
@@ -247,7 +247,7 @@ describe('channel', function () {

expectCallCount(before, 1);
expectCallCount(after, 1);
expect(after.calls.argsFor(0)).toEqual([ 1, 2, 3 ]);
expect(after.calls.argsFor(0)).toEqual([1, 2, 3]);
});
it('Test#018 : should instantly trigger the callback if the event is currently being fired.', function () {
var handler1 = jasmine.createSpy().and.callFake(function () { stickyChannel.subscribe(handler2); });
@@ -73,7 +73,7 @@ describe('pluginloader', function () {
it('Test#003 : should inject plugin scripts when they are not already there', function (done) {
define('cordova/plugin_list', function (require, exports, module) {
module.exports = [
{ 'file': 'some/path.js', 'id': 'some.id' }
{ file: 'some/path.js', id: 'some.id' }
];
});
injectScript.and.callFake(function (url, onload, onerror) {
@@ -94,7 +94,7 @@ describe('pluginloader', function () {
it('Test#004 : should not inject plugin scripts when they are already there', function (done) {
define('cordova/plugin_list', function (require, exports, module) {
module.exports = [
{ 'file': 'some/path.js', 'id': 'some.id' }
{ file: 'some/path.js', id: 'some.id' }
];
});
define('some.id', function (require, exports, module) {

0 comments on commit 17ed8ef

Please sign in to comment.