Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

breaking: @cordova/eslint-config w/ applied fix #96

Merged
merged 1 commit into from
Jul 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 25 additions & 10 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
root: true
extends: semistandard
rules:
indent:
- error
- 4
camelcase: off
padded-blocks: off
operator-linebreak: off
no-throw-literal: off
# 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'
10 changes: 5 additions & 5 deletions bin/create
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down
2 changes: 1 addition & 1 deletion bin/lib/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
55 changes: 25 additions & 30 deletions bin/template/cordova/Api.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ function setupEvents (externalEventEmitter) {
}

function Api (platform, platformRootDir, events) {

this.platform = platform || PLATFORM_NAME;

// MyApp/platforms/browser
Expand Down Expand Up @@ -82,7 +81,6 @@ function Api (platform, platformRootDir, events) {
}

Api.createPlatform = function (dest, config, options, events) {

var creator = require('../../lib/create');
events = setupEvents(events);

Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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;

Expand All @@ -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 ...
Expand Down Expand Up @@ -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 ' +
Expand Down Expand Up @@ -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);
});
Expand Down Expand Up @@ -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
Expand All @@ -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);
Expand All @@ -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);
}

}
};
};
Expand Down
2 changes: 1 addition & 1 deletion bin/template/cordova/browser_handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
},
Expand Down
1 change: 0 additions & 1 deletion bin/template/cordova/lib/clean.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
2 changes: 1 addition & 1 deletion bin/template/cordova/lib/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion bin/template/cordova/run
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 0 additions & 4 deletions cordova-js-src/.eslintrc.yml

This file was deleted.

5 changes: 0 additions & 5 deletions cordova-js-src/exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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') {
Expand Down
1 change: 0 additions & 1 deletion cordova-js-src/platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ module.exports = {
cordovaVersion: '4.2.0', // cordova-js

bootstrap: function () {

var modulemapper = require('cordova/modulemapper');
var channel = require('cordova/channel');

Expand Down
12 changes: 3 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
],
"scripts": {
"cover": "nyc jasmine",
"eslint": "eslint . \"bin/**/!(*.*)\"",
"lint": "eslint . \"bin/**/!(*.*|gitignore)\"",
erisu marked this conversation as resolved.
Show resolved Hide resolved
"jasmine": "jasmine",
"test": "npm run eslint && npm run cover"
"test": "npm run lint && npm run cover"
},
"dependencies": {
"cordova-common": "^3.1.0",
Expand All @@ -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"
Expand Down
2 changes: 0 additions & 2 deletions spec/.eslintrc.yml

This file was deleted.

19 changes: 12 additions & 7 deletions spec/browser_handler.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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

});
});
3 changes: 0 additions & 3 deletions spec/create.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
});
Expand Down Expand Up @@ -110,5 +108,4 @@ describe('create', function () {

createAndBuild(projectname, projectid);
});

});
2 changes: 0 additions & 2 deletions spec/manifest.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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';
Expand Down
Loading