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 2020/07/24 16:55:40 UTC
[cordova-browser] branch master updated: breaking:
@cordova/eslint-config w/ applied fix (#96)
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-browser.git
The following commit(s) were added to refs/heads/master by this push:
new 756c1d8 breaking: @cordova/eslint-config w/ applied fix (#96)
756c1d8 is described below
commit 756c1d8a1b0232af13661d2220cee51deedb60ae
Author: エリス <er...@users.noreply.github.com>
AuthorDate: Sat Jul 25 01:55:30 2020 +0900
breaking: @cordova/eslint-config w/ applied fix (#96)
---
.eslintrc.yml | 35 +++++++++++++++------
bin/create | 10 +++---
bin/lib/create.js | 2 +-
bin/template/cordova/Api.js | 55 +++++++++++++++------------------
bin/template/cordova/browser_handler.js | 2 +-
bin/template/cordova/lib/clean.js | 1 -
bin/template/cordova/lib/run.js | 2 +-
bin/template/cordova/run | 2 +-
cordova-js-src/.eslintrc.yml | 4 ---
cordova-js-src/exec.js | 5 ---
cordova-js-src/platform.js | 1 -
package.json | 12 ++-----
spec/.eslintrc.yml | 2 --
spec/browser_handler.spec.js | 19 +++++++-----
spec/create.spec.js | 3 --
spec/manifest.spec.js | 2 --
spec/projectApi.spec.js | 3 --
17 files changed, 74 insertions(+), 86 deletions(-)
diff --git a/.eslintrc.yml b/.eslintrc.yml
index 0cccb8c..3c5d4d0 100644
--- a/.eslintrc.yml
+++ b/.eslintrc.yml
@@ -1,10 +1,25 @@
-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
+# 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.
+
+extends: '@cordova/eslint-config/node'
+
+overrides:
+ - files: [spec/**/*.js]
+ extends: '@cordova/eslint-config/node-tests'
+
+ - files: [cordova-js-src/**/*.js]
+ extends: '@cordova/eslint-config/browser'
diff --git a/bin/create b/bin/create
index 3961c70..5cefef1 100755
--- a/bin/create
+++ b/bin/create
@@ -49,11 +49,11 @@ var ConfigParser = require('cordova-common').ConfigParser;
var Api = require('./template/cordova/Api');
var argv = require('nopt')({
- 'help': Boolean,
- 'cli': Boolean,
- 'shared': Boolean, // alias for --link
- 'link': Boolean
-}, { 'd': '--verbose' });
+ help: Boolean,
+ cli: Boolean,
+ shared: Boolean, // alias for --link
+ link: Boolean
+}, { d: '--verbose' });
var projectPath = argv.argv.remain[0];
diff --git a/bin/lib/create.js b/bin/lib/create.js
index 997913a..5e327f7 100644
--- a/bin/lib/create.js
+++ b/bin/lib/create.js
@@ -58,7 +58,7 @@ module.exports.createProject = function (project_path, package_name, project_nam
shell.cp('-r', path.join(ROOT, 'bin/template/www'), project_path);
// recreate our node_modules structure in the new project
- let nodeModulesDir = path.join(ROOT, 'node_modules');
+ const nodeModulesDir = path.join(ROOT, 'node_modules');
if (fs.existsSync(nodeModulesDir)) shell.cp('-r', nodeModulesDir, path.join(project_path, 'cordova'));
// copy check_reqs file
diff --git a/bin/template/cordova/Api.js b/bin/template/cordova/Api.js
index e8b9bf8..44466a7 100644
--- a/bin/template/cordova/Api.js
+++ b/bin/template/cordova/Api.js
@@ -53,7 +53,6 @@ function setupEvents (externalEventEmitter) {
}
function Api (platform, platformRootDir, events) {
-
this.platform = platform || PLATFORM_NAME;
// MyApp/platforms/browser
@@ -82,7 +81,6 @@ function Api (platform, platformRootDir, events) {
}
Api.createPlatform = function (dest, config, options, events) {
-
var creator = require('../../lib/create');
events = setupEvents(events);
@@ -121,16 +119,15 @@ Api.prototype.getPlatformInfo = function () {
// console.log("browser-platform:Api:getPlatformInfo");
// return PlatformInfo object
return {
- 'locations': this.locations,
- 'root': this.root,
- 'name': this.platform,
- 'version': { 'version': '1.0.0' }, // um, todo!
- 'projectConfig': this.config
+ locations: this.locations,
+ root: this.root,
+ name: this.platform,
+ version: { version: '1.0.0' }, // um, todo!
+ projectConfig: this.config
};
};
Api.prototype.prepare = function (cordovaProject, options) {
-
// First cleanup current config and merge project's one into own
var defaultConfigPath = path.join(this.locations.platformRootDir, 'cordova',
'defaults.xml');
@@ -173,8 +170,8 @@ Api.prototype.prepare = function (cordovaProject, options) {
shell.cp('-f', srcManifestPath, manifestPath);
} else {
var manifestJson = {
- 'background_color': '#FFF',
- 'display': 'standalone'
+ background_color: '#FFF',
+ display: 'standalone'
};
if (this.config) {
if (this.config.name()) {
@@ -211,9 +208,11 @@ Api.prototype.prepare = function (cordovaProject, options) {
"sizes": "128x128"
} ******/
// ?Is it worth looking at file extentions?
- return { 'src': icon.src,
- 'type': 'image/png',
- 'sizes': (icon.width + 'x' + icon.height) };
+ return {
+ src: icon.src,
+ type: 'image/png',
+ sizes: (icon.width + 'x' + icon.height)
+ };
});
manifestJson.icons = manifestIcons;
@@ -230,7 +229,7 @@ Api.prototype.prepare = function (cordovaProject, options) {
}
// get start_url
- var contentNode = this.config.doc.find('content') || { 'attrib': { 'src': 'index.html' } }; // sensible default
+ var contentNode = this.config.doc.find('content') || { attrib: { src: 'index.html' } }; // sensible default
manifestJson.start_url = contentNode.attrib.src;
// now we get some values from start_url page ...
@@ -260,7 +259,6 @@ Api.prototype.prepare = function (cordovaProject, options) {
};
Api.prototype.addPlugin = function (pluginInfo, installOptions) {
-
// console.log(new Error().stack);
if (!pluginInfo) {
return Promise.reject(new Error('The parameter is incorrect. The first parameter ' +
@@ -307,9 +305,9 @@ Api.prototype.addPlugin = function (pluginInfo, installOptions) {
.add_plugin_changes(pluginInfo, installOptions.variables, /* is_top_level= */true, /* should_increment= */true)
.save_all();
- var targetDir = installOptions.usePlatformWww ?
- self.getPlatformInfo().locations.platformWww :
- self.getPlatformInfo().locations.www;
+ var targetDir = installOptions.usePlatformWww
+ ? self.getPlatformInfo().locations.platformWww
+ : self.getPlatformInfo().locations.www;
self._addModulesInfo(pluginInfo, targetDir);
});
@@ -350,9 +348,9 @@ Api.prototype.removePlugin = function (plugin, uninstallOptions) {
.remove_plugin_changes(plugin, /* is_top_level= */true)
.save_all();
- var targetDir = uninstallOptions.usePlatformWww ?
- self.getPlatformInfo().locations.platformWww :
- self.getPlatformInfo().locations.www;
+ var targetDir = uninstallOptions.usePlatformWww
+ ? self.getPlatformInfo().locations.platformWww
+ : self.getPlatformInfo().locations.www;
self._removeModulesInfo(plugin, targetDir);
// Remove stale plugin directory
@@ -368,11 +366,10 @@ Api.prototype._getInstaller = function (type) {
if (!installer) {
console.log('unrecognized type ' + type);
-
} else {
- var wwwDest = options.usePlatformWww ?
- self.getPlatformInfo().locations.platformWww :
- self._handler.www_dir(self.root);
+ var wwwDest = options.usePlatformWww
+ ? self.getPlatformInfo().locations.platformWww
+ : self._handler.www_dir(self.root);
if (type === 'asset') {
installer.install(item, plugin_dir, wwwDest);
@@ -392,18 +389,16 @@ Api.prototype._getUninstaller = function (type) {
if (!installer) {
console.log('browser plugin uninstall: unrecognized type, skipping : ' + type);
-
} else {
- var wwwDest = options.usePlatformWww ?
- self.getPlatformInfo().locations.platformWww :
- self._handler.www_dir(self.root);
+ var wwwDest = options.usePlatformWww
+ ? self.getPlatformInfo().locations.platformWww
+ : self._handler.www_dir(self.root);
if (['asset', 'js-module'].indexOf(type) > -1) {
return installer.uninstall(item, wwwDest, plugin_id);
} else {
return installer.uninstall(item, self.root, plugin_id, options, project);
}
-
}
};
};
diff --git a/bin/template/cordova/browser_handler.js b/bin/template/cordova/browser_handler.js
index bccddb4..cc6e796 100644
--- a/bin/template/cordova/browser_handler.js
+++ b/bin/template/cordova/browser_handler.js
@@ -96,7 +96,7 @@ module.exports = {
events.emit('verbose', 'resource-file.uninstall is not supported for browser');
}
},
- 'framework': {
+ framework: {
install: function (obj, plugin_dir, project_dir, plugin_id, options) {
events.emit('verbose', 'framework.install is not supported for browser');
},
diff --git a/bin/template/cordova/lib/clean.js b/bin/template/cordova/lib/clean.js
index 6ee7675..ee7908c 100644
--- a/bin/template/cordova/lib/clean.js
+++ b/bin/template/cordova/lib/clean.js
@@ -26,7 +26,6 @@ var check_reqs = require('./check_reqs');
var platformBuildDir = path.join('platforms', 'browser', 'www');
var run = function () {
-
// TODO: everything calls check_reqs ... why?
// Check that requirements are (still) met
if (!check_reqs.run()) {
diff --git a/bin/template/cordova/lib/run.js b/bin/template/cordova/lib/run.js
index 0846231..ff24425 100644
--- a/bin/template/cordova/lib/run.js
+++ b/bin/template/cordova/lib/run.js
@@ -57,7 +57,7 @@ module.exports.run = function (args) {
console.log('startPage = ' + startPage);
console.log('Static file server running @ ' + projectUrl + '\nCTRL + C to shut down');
- return server.launchBrowser({ 'target': args.target, 'url': projectUrl });
+ return server.launchBrowser({ target: args.target, url: projectUrl });
})
.catch(function (error) {
console.log(error.message || error.toString());
diff --git a/bin/template/cordova/run b/bin/template/cordova/run
index 30661b8..b26b1a3 100755
--- a/bin/template/cordova/run
+++ b/bin/template/cordova/run
@@ -27,7 +27,7 @@ var args = process.argv;
start(args);
function start (argv) {
- var args = nopt({ 'help': Boolean, 'target': String, 'port': Number }, { 'help': ['/?', '-h', 'help', '-help', '/help'] }, argv);
+ var args = nopt({ help: Boolean, target: String, port: Number }, { help: ['/?', '-h', 'help', '-help', '/help'] }, argv);
if (args.help) {
help();
} else {
diff --git a/cordova-js-src/.eslintrc.yml b/cordova-js-src/.eslintrc.yml
deleted file mode 100644
index e3d49d8..0000000
--- a/cordova-js-src/.eslintrc.yml
+++ /dev/null
@@ -1,4 +0,0 @@
-env:
- node: false
- commonjs: true
- browser: true
diff --git a/cordova-js-src/exec.js b/cordova-js-src/exec.js
index f5f62f1..645ffb5 100644
--- a/cordova-js-src/exec.js
+++ b/cordova-js-src/exec.js
@@ -40,20 +40,17 @@ var execProxy = require('cordova/exec/proxy');
* @param {String[]} [args] Zero or more arguments to pass to the method
*/
module.exports = function (success, fail, service, action, args) {
-
var proxy = execProxy.get(service, action);
args = args || [];
if (proxy) {
-
var callbackId = service + cordova.callbackId++;
if (typeof success === 'function' || typeof fail === 'function') {
cordova.callbacks[callbackId] = { success: success, fail: fail };
}
try {
-
// callbackOptions param represents additional optional parameters command could pass back, like keepCallback or
// custom callbackId, for example {callbackId: id, keepCallback: true, status: cordova.callbackStatus.JSON_EXCEPTION }
var onSuccess = function (result, callbackOptions) {
@@ -95,12 +92,10 @@ module.exports = function (success, fail, service, action, args) {
});
};
proxy(onSuccess, onError, args);
-
} catch (e) {
console.log('Exception calling native with command :: ' + service + ' :: ' + action + ' ::exception=' + e);
}
} else {
-
console.log('Error: exec proxy not found for :: ' + service + ' :: ' + action);
if (typeof fail === 'function') {
diff --git a/cordova-js-src/platform.js b/cordova-js-src/platform.js
index 18e43a6..85cd6b7 100644
--- a/cordova-js-src/platform.js
+++ b/cordova-js-src/platform.js
@@ -24,7 +24,6 @@ module.exports = {
cordovaVersion: '4.2.0', // cordova-js
bootstrap: function () {
-
var modulemapper = require('cordova/modulemapper');
var channel = require('cordova/channel');
diff --git a/package.json b/package.json
index 8bd1e1e..d4dd24f 100644
--- a/package.json
+++ b/package.json
@@ -18,9 +18,9 @@
],
"scripts": {
"cover": "nyc jasmine",
- "eslint": "eslint . \"bin/**/!(*.*)\"",
+ "lint": "eslint . \"bin/**/!(*.*|gitignore)\"",
"jasmine": "jasmine",
- "test": "npm run eslint && npm run cover"
+ "test": "npm run lint && npm run cover"
},
"dependencies": {
"cordova-common": "^4.0.0",
@@ -29,13 +29,7 @@
"shelljs": "^0.5.3"
},
"devDependencies": {
- "eslint": "^5.12.0",
- "eslint-config-semistandard": "^13.0.0",
- "eslint-config-standard": "^12.0.0",
- "eslint-plugin-import": "^2.14.0",
- "eslint-plugin-node": "^8.0.1",
- "eslint-plugin-promise": "^4.0.1",
- "eslint-plugin-standard": "^4.0.0",
+ "@cordova/eslint-config": "^3.0.0",
"jasmine": "^3.3.1",
"nyc": "^14.1.1",
"tmp": "0.0.33"
diff --git a/spec/.eslintrc.yml b/spec/.eslintrc.yml
deleted file mode 100644
index 6afba65..0000000
--- a/spec/.eslintrc.yml
+++ /dev/null
@@ -1,2 +0,0 @@
-env:
- jasmine: true
\ No newline at end of file
diff --git a/spec/browser_handler.spec.js b/spec/browser_handler.spec.js
index ad73be0..e9e3313 100644
--- a/spec/browser_handler.spec.js
+++ b/spec/browser_handler.spec.js
@@ -24,15 +24,21 @@ var path = require('path');
describe('Asset install tests', function () {
var fsstatMock;
- var asset = { itemType: 'asset',
+ var asset = {
+ itemType: 'asset',
src: path.join('someSrc', 'ServiceWorker.js'),
- target: 'ServiceWorker.js' };
- var assetWithPath = { itemType: 'asset',
+ target: 'ServiceWorker.js'
+ };
+ var assetWithPath = {
+ itemType: 'asset',
src: path.join('someSrc', 'reformat.js'),
- target: path.join('js', 'deepdown', 'reformat.js') };
- var assetWithPath2 = { itemType: 'asset',
+ target: path.join('js', 'deepdown', 'reformat.js')
+ };
+ var assetWithPath2 = {
+ itemType: 'asset',
src: path.join('someSrc', 'reformat.js'),
- target: path.join('js', 'deepdown', 'reformat2.js') };
+ target: path.join('js', 'deepdown', 'reformat2.js')
+ };
var plugin_dir = 'pluginDir';
var wwwDest = 'dest';
@@ -85,6 +91,5 @@ describe('Asset install tests', function () {
spyOn(fs, 'existsSync').and.returnValue(true);
browser_handler.asset.install(assetWithPath2, plugin_dir, wwwDest);
expect(mkdir.calls.count()).toBe(1); // not called again
-
});
});
diff --git a/spec/create.spec.js b/spec/create.spec.js
index ed92a11..5d7b72d 100644
--- a/spec/create.spec.js
+++ b/spec/create.spec.js
@@ -27,7 +27,6 @@ var tmpDir = path.join(__dirname, '../temp');
var createScriptPath = path.join(cordova_bin, 'create');
function createAndBuild (projectname, projectid) {
-
var return_code = 0;
var command;
@@ -64,7 +63,6 @@ function createAndBuild (projectname, projectid) {
}
describe('create', function () {
-
it('has a create script in bin/cordova', function () {
expect(fs.existsSync(createScriptPath)).toBe(true);
});
@@ -110,5 +108,4 @@ describe('create', function () {
createAndBuild(projectname, projectid);
});
-
});
diff --git a/spec/manifest.spec.js b/spec/manifest.spec.js
index 8bc144f..13b8be9 100644
--- a/spec/manifest.spec.js
+++ b/spec/manifest.spec.js
@@ -27,7 +27,6 @@ var tmpDir = path.join(__dirname, '../temp');
var createScriptPath = path.join(cordova_bin, 'create');
function createAndBuild (projectname, projectid) {
-
var return_code = 0;
var command;
@@ -75,7 +74,6 @@ function createAndBuild (projectname, projectid) {
}
describe('create', function () {
-
it('create project with manifest.json', function () {
var projectname = 'testcreate';
var projectid = 'com.test.app1';
diff --git a/spec/projectApi.spec.js b/spec/projectApi.spec.js
index 21d6988..41f640f 100644
--- a/spec/projectApi.spec.js
+++ b/spec/projectApi.spec.js
@@ -24,7 +24,6 @@ const Api = require('../bin/template/cordova/Api');
const create = require('../bin/lib/create');
describe('can get the Api', function () {
-
it('should be defined', function () {
expect(Api).toBeDefined();
});
@@ -57,7 +56,6 @@ describe('can get the Api', function () {
});
describe('project level Api', function () {
-
var testApi = new Api();
it('can be created', function () {
@@ -103,7 +101,6 @@ describe('project level Api', function () {
expect(testApi.getPlatformInfo).toBeDefined();
expect(typeof testApi.getPlatformInfo).toBe('function');
});
-
});
// Static methods
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org