Skip to content
Permalink
Browse files
Merge pull request #669 from raphinesse/linting-improvements
Linting improvements
  • Loading branch information
raphinesse committed Aug 28, 2018
2 parents 3994b10 + 27854f3 commit 39abbe09c1073a76c3db4d90e04b1ff79229ef9f
Showing 38 changed files with 58 additions and 147 deletions.
@@ -1,6 +1,6 @@
coverage/
src/plugman/init-defaults.js
spec/cordova/fixtures/*
spec/plugman/projects/*
spec/plugman/plugins/*
spec/cordova/temp/*

@@ -20,10 +20,10 @@
var common = require('cordova-common');

exports = module.exports = {
set binname(name) {
set binname (name) {
this.cordova.binname = name;
},
get binname() {
get binname () {
return this.cordova.binname;
},
events: common.events,
@@ -1,2 +1,4 @@
env:
jasmine: true
jasmine: true
rules:
prefer-promise-reject-errors: off
@@ -25,7 +25,6 @@ var Q = require('q');
var events = require('cordova-common').events;
var cordova = require('../src/cordova/cordova');
var rewire = require('rewire');
var prepare = require('../src/cordova/prepare'); // eslint-disable-line no-unused-vars
var plugman = require('../src/plugman/plugman');
var platform = rewire('../src/cordova/platform');
var addHelper = rewire('../src/cordova/platform/addHelper');
@@ -141,7 +140,6 @@ describe('platform end-to-end', function () {

xit('Test 003 : should call prepare after plugins were installed into platform', function () {
var order = '';
var fail = jasmine.createSpy(fail); // eslint-disable-line no-use-before-define
spyOn(plugman, 'install').and.callFake(function () { order += 'I'; });
// below line won't work since prepare is inline require in addHelper, not global
var x = addHelper.__set__('prepare', function () { order += 'P'; }); // eslint-disable-line no-unused-vars
@@ -54,20 +54,16 @@ describe('fetch', function () {
});
*/
describe('local plugins', function () {
/* eslint-disable no-unused-vars */
var rm;
var sym;
var cp;
var save_metadata;
var revertLocal;
var revertFetch;
var fetchCalls = 0;
/* eslint-enable no-unused-vars */
beforeEach(function () {
rm = spyOn(shell, 'rm');
spyOn(shell, 'rm');
sym = spyOn(fs, 'symlinkSync');
cp = spyOn(shell, 'cp').and.callThrough();
save_metadata = spyOn(metadata, 'save_fetch_metadata');
spyOn(metadata, 'save_fetch_metadata');
realrm('-rf', temp);
revertLocal = fetch.__set__('localPlugins', null);
revertFetch = fetch.__set__('fetch', function (pluginDir) {
@@ -106,16 +106,10 @@ describe('plugman uninstall start', function () {
});

describe('uninstallPlatform', function () {
/* eslint-disable no-unused-vars */
var proc;
var rm;
var fsWrite;
/* eslint-enable no-unused-vars */

beforeEach(function () {
proc = spyOn(actions.prototype, 'process').and.returnValue(Q());
fsWrite = spyOn(fs, 'writeFileSync').and.returnValue(true);
rm = spyOn(shell, 'rm').and.returnValue(true);
spyOn(actions.prototype, 'process').and.returnValue(Q());
spyOn(fs, 'writeFileSync').and.returnValue(true);
spyOn(shell, 'rm').and.returnValue(true);
spyOn(shell, 'cp').and.returnValue(true);
});
describe('success', function () {
@@ -197,16 +191,12 @@ describe('uninstallPlatform', function () {
});

describe('uninstallPlugin', function () {
/* eslint-disable no-unused-vars */
var rm;
var fsWrite;
var rmstack = [];
var emit;
/* eslint-enable no-unused-vars */

beforeEach(function () {
fsWrite = spyOn(fs, 'writeFileSync').and.returnValue(true);
rm = spyOn(shell, 'rm').and.callFake(function (f, p) { rmstack.push(p); return true; });
spyOn(fs, 'writeFileSync').and.returnValue(true);
spyOn(shell, 'rm').and.callFake(function (f, p) { rmstack.push(p); return true; });
rmstack = [];
emit = spyOn(events, 'emit');
});
@@ -266,14 +256,10 @@ describe('uninstallPlugin', function () {
});

describe('uninstall', function () {
/* eslint-disable no-unused-vars */
var fsWrite;
var rm;
/* eslint-enable no-unused-vars */

beforeEach(function () {
fsWrite = spyOn(fs, 'writeFileSync').and.returnValue(true);
rm = spyOn(shell, 'rm').and.returnValue(true);
spyOn(fs, 'writeFileSync').and.returnValue(true);
spyOn(shell, 'rm').and.returnValue(true);
});

describe('failure', function () {
@@ -59,7 +59,7 @@
},
"scripts": {
"test": "npm run eslint && npm run unit-tests && npm run e2e-tests",
"eslint": "eslint src spec integration-tests",
"eslint": "eslint .",
"unit-tests": "jasmine JASMINE_CONFIG_PATH=spec/jasmine.json",
"cover": "nyc -x spec/ -x integration-tests/ npm test",
"report-coverage": "nyc report -r text-lcov > coverage.lcov && codecov",
@@ -1,2 +1,4 @@
env:
jasmine: true
jasmine: true
rules:
prefer-promise-reject-errors: off
@@ -26,15 +26,14 @@ var supported_platforms = Object.keys(platforms);

describe('build command', function () {
var is_cordova;
var cd_project_root; // eslint-disable-line no-unused-vars
var list_platforms;
var fire;
var project_dir = '/some/path';
var prepare_spy, compile_spy;

beforeEach(function () {
is_cordova = spyOn(util, 'isCordova').and.returnValue(project_dir);
cd_project_root = spyOn(util, 'cdProjectRoot').and.returnValue(project_dir);
spyOn(util, 'cdProjectRoot').and.returnValue(project_dir);
list_platforms = spyOn(util, 'listPlatforms').and.returnValue(supported_platforms);
fire = spyOn(HooksRunner.prototype, 'fire').and.returnValue(Q());
prepare_spy = spyOn(cordova, 'prepare').and.returnValue(Q());
@@ -28,14 +28,13 @@ describe('compile command', function () {
var is_cordova;
var list_platforms;
var fire;
var cd_project_root; // eslint-disable-line no-unused-vars
var platformApi;
var getPlatformApi;
var project_dir = '/some/path';

beforeEach(function () {
is_cordova = spyOn(util, 'isCordova').and.returnValue(project_dir);
cd_project_root = spyOn(util, 'cdProjectRoot').and.returnValue(project_dir);
spyOn(util, 'cdProjectRoot').and.returnValue(project_dir);
list_platforms = spyOn(util, 'listPlatforms').and.returnValue(supported_platforms);
fire = spyOn(HooksRunner.prototype, 'fire').and.returnValue(Q());
platformApi = { build: jasmine.createSpy('build').and.returnValue(Q()) };
@@ -91,9 +91,6 @@ describe('create basic test (see more in cordova-create)', function () {
// expect(configXml.name()).toEqual('TestBase');
}

var results; // eslint-disable-line no-unused-vars
events.on('results', function (res) { results = res; });

it('Test 003 : should successfully run', function () {
return Q()
.then(function () {
@@ -26,7 +26,6 @@ var supported_platforms = Object.keys(platforms).filter(function (p) { return p

describe('emulate command', function () {
var is_cordova;
var cd_project_root; // eslint-disable-line no-unused-vars
var list_platforms;
var fire;
var fail;
@@ -35,7 +34,7 @@ describe('emulate command', function () {

beforeEach(function () {
is_cordova = spyOn(util, 'isCordova').and.returnValue(project_dir);
cd_project_root = spyOn(util, 'cdProjectRoot').and.returnValue(project_dir);
spyOn(util, 'cdProjectRoot').and.returnValue(project_dir);
list_platforms = spyOn(util, 'listPlatforms').and.returnValue(supported_platforms);
fire = spyOn(HooksRunner.prototype, 'fire').and.returnValue(Q());
prepare_spy = spyOn(cordova, 'prepare').and.returnValue(Q());
@@ -72,7 +71,7 @@ describe('emulate command', function () {
describe('success', function () {
it('Test 003 : should run inside a Cordova-based project with at least one added platform and call prepare and shell out to the emulate script', function () {
return cordova.emulate(['android', 'ios'])
.then(function (err) { // eslint-disable-line handle-callback-err
.then(function () {
expect(prepare_spy).toHaveBeenCalledWith(jasmine.objectContaining({platforms: ['android', 'ios']}));
expect(getPlatformApi).toHaveBeenCalledWith('android');
expect(getPlatformApi).toHaveBeenCalledWith('ios');
@@ -82,7 +81,7 @@ describe('emulate command', function () {
});
it('Test 004 : should pass down options', function () {
return cordova.emulate({platforms: ['ios'], options: { optionTastic: true }})
.then(function (err) { // eslint-disable-line handle-callback-err
.then(function () {
expect(prepare_spy).toHaveBeenCalledWith(jasmine.objectContaining({platforms: ['ios']}));
expect(getPlatformApi).toHaveBeenCalledWith('ios');
expect(platformApi.build).toHaveBeenCalledWith({ device: false, emulator: true, optionTastic: true });
@@ -23,11 +23,10 @@ var ParserHelper = require('../../../src/cordova/metadata/parserhelper/ParserHel

describe('base parser', function () {

var exists; // eslint-disable-line no-unused-vars
var parser;

beforeEach(function () {
exists = spyOn(fs, 'existsSync');
spyOn(fs, 'existsSync');
parser = new Parser();
});

@@ -14,7 +14,6 @@
specific language governing permissions and limitations
under the License.
*/
/* eslint-env jasmine */

var path = require('path');
var fs = require('fs');
@@ -14,7 +14,6 @@
specific language governing permissions and limitations
under the License.
*/
/* globals fail */

var rewire = require('rewire');
var platform = rewire('../../../src/cordova/platform');
@@ -14,7 +14,6 @@
specific language governing permissions and limitations
under the License.
*/
/* eslint-env jasmine */

var os = require('os');
var Q = require('q');
@@ -16,9 +16,6 @@
specific language governing permissions and limitations
under the License.
*/
// TODO: remove once eslint lands
/* eslint-env jasmine */
/* globals fail */

var Q = require('q');
var rewire = require('rewire');
@@ -45,12 +42,6 @@ describe('cordova/plugin/add', function () {
hook_mock = jasmine.createSpyObj('hooks runner mock', ['fire']);
hook_mock.fire.and.returnValue(Q());
Cfg_parser_mock.prototype = jasmine.createSpyObj('config parser prototype mock', ['getPlugin', 'removePlugin', 'addPlugin', 'write']);
/* eslint-disable */
Cfg_parser_mock.prototype.getPlugin;
Cfg_parser_mock.prototype.removePlugin;
Cfg_parser_mock.prototype.addPlugin;
Cfg_parser_mock.prototype.write;
/* eslint-enable */
cfg_parser_revert_mock = add.__set__('ConfigParser', Cfg_parser_mock);
plugin_info = jasmine.createSpyObj('pluginInfo', ['getPreferences']);
plugin_info.getPreferences.and.returnValue({});
@@ -16,9 +16,6 @@
specific language governing permissions and limitations
under the License.
*/
// TODO: remove once eslint lands
/* eslint-env jasmine */
/* globals fail */

var rewire = require('rewire');
var plugin = rewire('../../../src/cordova/plugin');
@@ -27,11 +24,10 @@ var cordova_util = require('../../../src/cordova/util');
describe('cordova/plugin', function () {
var projectRoot = '/some/path';
var hook_mock = function () {};
var hook_revert_mock; // eslint-disable-line no-unused-vars

beforeEach(function () {
spyOn(cordova_util, 'cdProjectRoot').and.returnValue(projectRoot);
hook_revert_mock = plugin.__set__('HooksRunner', hook_mock);
plugin.__set__('HooksRunner', hook_mock);
});

describe('error conditions', function () {
@@ -16,9 +16,6 @@
specific language governing permissions and limitations
under the License.
*/
// TODO: remove once eslint lands
/* eslint-env jasmine */
/* globals fail */

var Q = require('q');
var list = require('../../../src/cordova/plugin/list');
@@ -16,7 +16,6 @@
specific language governing permissions and limitations
under the License.
*/
/* eslint-env jasmine */

var pluginSpec = require('../../../src/cordova/plugin/plugin_spec_parser');

@@ -16,9 +16,6 @@
specific language governing permissions and limitations
under the License.
*/
// TODO: remove this once eslint lands
/* eslint-env jasmine */
/* globals fail */

var rewire = require('rewire');
var fs = require('fs');
@@ -16,7 +16,6 @@
specific language governing permissions and limitations
under the License.
*/
/* globals fail */

var Q = require('q');
var rewire = require('rewire');
@@ -16,7 +16,6 @@
specific language governing permissions and limitations
under the License.
*/
/* eslint-env jasmine */

var rewire = require('rewire');
var plugin_util = rewire('../../../src/cordova/plugin/util');
@@ -16,7 +16,7 @@
specific language governing permissions and limitations
under the License.
*/
/* eslint-env jasmine */

var path = require('path');
var fs = require('fs');
var Plugin_parser = require('../../src/cordova/plugin_parser');
@@ -17,9 +17,6 @@
under the License.
*/

/* eslint-env jasmine */
/* global fail */

var path = require('path');
var rewire = require('rewire');
var util = require('../../src/cordova/util');
@@ -17,8 +17,6 @@
under the License.
*/

/* global xdescribe */

var cordova = require('../../src/cordova/cordova');
var console = require('console');
var path = require('path');
@@ -271,7 +271,6 @@ describe('util module', function () {
});

it('Test 024 : should convert known options (platform-agnostic) into resultant object\'s fields', function () {
/* eslint-disable no-useless-escape */
var expectedResult = {
'debug': true,
'release': true,
@@ -281,9 +280,8 @@ describe('util module', function () {
'list': true,
'buildConfig': '/fake/path/build.json',
'target': 'foo',
'archs': '\"x86 x64\"'
'archs': '"x86 x64"'
};
/* eslint-disable no-useless-escape */

expect(util.preProcessOptions({options: validOptions}).options)
.toEqual(jasmine.objectContaining(expectedResult));

0 comments on commit 39abbe0

Please sign in to comment.