You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by er...@apache.org on 2019/11/27 14:27:10 UTC
[cordova-js] branch master updated: refactor: eslint setup (#221)
This is an automated email from the ASF dual-hosted git repository.
erisu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-js.git
The following commit(s) were added to refs/heads/master by this push:
new 17ed8ef refactor: eslint setup (#221)
17ed8ef is described below
commit 17ed8ef404a1efc5cfc6c14e5df031f7d84e23f8
Author: エリス <er...@users.noreply.github.com>
AuthorDate: Wed Nov 27 23:27:02 2019 +0900
refactor: eslint setup (#221)
---
.eslintrc.yml | 40 +++++++++++++++++++++++++++-----
Gruntfile.js | 12 +++++-----
build-tools/build.js | 2 +-
package.json | 12 +++-------
src/.eslintrc.yml | 12 ----------
src/common/argscheck.js | 12 +++++-----
src/common/builder.js | 4 ++--
src/cordova.js | 4 ++--
test/.eslintrc.yml | 7 ------
test/test-platform-modules/.eslintrc.yml | 4 ----
test/test-platform-modules/exec.js | 1 -
test/test.channel.js | 4 ++--
test/test.pluginloader.js | 4 ++--
13 files changed, 58 insertions(+), 60 deletions(-)
diff --git a/.eslintrc.yml b/.eslintrc.yml
index 14c1daf..0e94bb6 100644
--- a/.eslintrc.yml
+++ b/.eslintrc.yml
@@ -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
diff --git a/Gruntfile.js b/Gruntfile.js
index 4984ad4..bcfb46a 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -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']
});
diff --git a/build-tools/build.js b/build-tools/build.js
index 0b6fc87..3b55d12 100644
--- a/build-tools/build.js
+++ b/build-tools/build.js
@@ -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);
});
diff --git a/package.json b/package.json
index ea0dcf2..38e3443 100644
--- a/package.json
+++ b/package.json
@@ -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",
diff --git a/src/.eslintrc.yml b/src/.eslintrc.yml
deleted file mode 100644
index 11dfeda..0000000
--- a/src/.eslintrc.yml
+++ /dev/null
@@ -1,12 +0,0 @@
-extends:
- - plugin:es5/no-es2015
- - plugin:es5/no-es2016
-
-env:
- node: false
- commonjs: true
- browser: true
-
-globals:
- define: false
- PLATFORM_VERSION_BUILD_LABEL: false
diff --git a/src/common/argscheck.js b/src/common/argscheck.js
index c94c5ec..74ac7e3 100644
--- a/src/common/argscheck.js
+++ b/src/common/argscheck.js
@@ -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) {
diff --git a/src/common/builder.js b/src/common/builder.js
index 7b6dc40..e61ff83 100644
--- a/src/common/builder.js
+++ b/src/common/builder.js
@@ -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]);
diff --git a/src/cordova.js b/src/cordova.js
index c88e2f9..28df375 100644
--- a/src/cordova.js
+++ b/src/cordova.js
@@ -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;
}
},
diff --git a/test/.eslintrc.yml b/test/.eslintrc.yml
deleted file mode 100644
index bcbaf1e..0000000
--- a/test/.eslintrc.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-env:
- node: false
- browser: true
- jasmine: true
-
-globals:
- cordova: false
diff --git a/test/test-platform-modules/.eslintrc.yml b/test/test-platform-modules/.eslintrc.yml
deleted file mode 100644
index e3d49d8..0000000
--- a/test/test-platform-modules/.eslintrc.yml
+++ /dev/null
@@ -1,4 +0,0 @@
-env:
- node: false
- commonjs: true
- browser: true
diff --git a/test/test-platform-modules/exec.js b/test/test-platform-modules/exec.js
index 4812348..a5ea8e8 100644
--- a/test/test-platform-modules/exec.js
+++ b/test/test-platform-modules/exec.js
@@ -19,5 +19,4 @@
*
*/
-/* eslint-env jasmine */
module.exports = jasmine.createSpy();
diff --git a/test/test.channel.js b/test/test.channel.js
index 667c70b..5588e4c 100644
--- a/test/test.channel.js
+++ b/test/test.channel.js
@@ -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); });
diff --git a/test/test.pluginloader.js b/test/test.pluginloader.js
index ed5c9f9..72c3787 100644
--- a/test/test.pluginloader.js
+++ b/test/test.pluginloader.js
@@ -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) {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org