Skip to content

Commit b9b7c16

Browse files
committed
Update eslint config
1 parent 8a28eaf commit b9b7c16

File tree

3 files changed

+31
-36
lines changed

3 files changed

+31
-36
lines changed

.eslintrc

+2-11
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
11
{
2+
"extends": "standard",
23
"rules": {
3-
"array-bracket-spacing": [ 2, "always" ],
4-
"comma-dangle": [ 2, "never" ],
5-
"eol-last": 2,
6-
"indent": [ 2, 2, { "SwitchCase": 1 } ],
7-
"no-multiple-empty-lines": 2,
8-
"no-unused-vars": 2,
9-
"object-curly-spacing": [ 2, "always" ],
10-
"quotes": [ 2, "single", "avoid-escape" ],
11-
"semi": 2,
12-
"strict": 0,
13-
"space-before-blocks": [ 2, "always" ]
4+
"semi": [2, "always"]
145
}
156
}

package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
"xcode"
3636
],
3737
"devDependencies": {
38-
"eslint": "^2.2.0"
38+
"eslint": "^3.4.0",
39+
"eslint-config-standard": "^6.0.0",
40+
"eslint-plugin-promise": "^2.0.1",
41+
"eslint-plugin-standard": "^2.0.0"
3942
}
4043
}

src/add-swift-support.js

+25-24
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ var fs = require('fs');
1717
var path = require('path');
1818
var xcode = require('xcode');
1919

20-
module.exports = function(context) {
20+
module.exports = function (context) {
2121
var platformMetadata = context.requireCordovaModule('cordova-lib/src/cordova/platform_metadata');
2222
var projectRoot = context.opts.projectRoot;
2323
var glob = context.requireCordovaModule('glob');
2424

2525
// This script has to be executed depending on the command line arguments, not
2626
// on the hook execution cycle.
27-
if((context.hook === 'after_platform_add' && context.cmdLine.includes('platform add'))
28-
|| (context.hook === 'after_prepare' && context.cmdLine.includes('prepare'))
29-
|| (context.hook === 'after_plugin_add' && context.cmdLine.includes('plugin add'))) {
30-
platformMetadata.getPlatformVersions(projectRoot).then(function(platformVersions) {
27+
if ((context.hook === 'after_platform_add' && context.cmdLine.includes('platform add')) ||
28+
(context.hook === 'after_prepare' && context.cmdLine.includes('prepare')) ||
29+
(context.hook === 'after_plugin_add' && context.cmdLine.includes('plugin add'))) {
30+
platformMetadata.getPlatformVersions(projectRoot).then(function (platformVersions) {
3131
var IOS_MIN_DEPLOYMENT_TARGET = '7.0';
3232
var platformPath = path.join(projectRoot, 'platforms', 'ios');
3333

@@ -45,13 +45,13 @@ module.exports = function(context) {
4545
var buildConfig;
4646
var configName;
4747

48-
platformVersions.forEach(function(platformVersion) {
49-
if(platformVersion.platform === 'ios') {
48+
platformVersions.forEach(function (platformVersion) {
49+
if (platformVersion.platform === 'ios') {
5050
iosPlatformVersion = platformVersion.version;
5151
}
5252
});
5353

54-
if(!iosPlatformVersion) {
54+
if (!iosPlatformVersion) {
5555
return;
5656
}
5757

@@ -65,9 +65,9 @@ module.exports = function(context) {
6565

6666
bridgingHeaderPath = getBridgingHeaderPath(context, projectPath, iosPlatformVersion);
6767

68-
try{
68+
try {
6969
fs.statSync(bridgingHeaderPath);
70-
} catch(err) {
70+
} catch (err) {
7171
// If the bridging header doesn't exist, we create it with the minimum
7272
// Cordova/CDV.h import.
7373
bridgingHeaderContent = [ '//',
@@ -85,15 +85,15 @@ module.exports = function(context) {
8585
for (configName in buildConfigs) {
8686
if (!COMMENT_KEY.test(configName)) {
8787
buildConfig = buildConfigs[configName];
88-
if(xcodeProject.getBuildProperty('SWIFT_OBJC_BRIDGING_HEADER', buildConfig.name) !== bridgingHeaderProperty) {
88+
if (xcodeProject.getBuildProperty('SWIFT_OBJC_BRIDGING_HEADER', buildConfig.name) !== bridgingHeaderProperty) {
8989
xcodeProject.updateBuildProperty('SWIFT_OBJC_BRIDGING_HEADER', bridgingHeaderProperty, buildConfig.name);
9090
console.log('Update IOS build setting SWIFT_OBJC_BRIDGING_HEADER to:', bridgingHeaderProperty, 'for build configuration', buildConfig.name);
9191
}
9292
}
9393
}
9494

9595
// Look for any bridging header defined in the plugin
96-
glob('**/*Bridging-Header*.h', { cwd: pluginsPath }, function(error, files) {
96+
glob('**/*Bridging-Header*.h', { cwd: pluginsPath }, function (error, files) {
9797
var bridgingHeader = path.basename(bridgingHeaderPath);
9898
var headers = files.map(function (filePath) {
9999
return path.basename(filePath);
@@ -103,8 +103,10 @@ module.exports = function(context) {
103103
// one already configured in the project.
104104
var content = fs.readFileSync(bridgingHeaderPath, 'utf-8');
105105

106-
headers.forEach(function(header) {
107-
if(header !== bridgingHeader && !~content.indexOf(header)) {
106+
if (error) throw new Error(error);
107+
108+
headers.forEach(function (header) {
109+
if (header !== bridgingHeader && !~content.indexOf(header)) {
108110
if (content.charAt(content.length - 1) !== '\n') {
109111
content += '\n';
110112
}
@@ -117,7 +119,7 @@ module.exports = function(context) {
117119
for (configName in buildConfigs) {
118120
if (!COMMENT_KEY.test(configName)) {
119121
buildConfig = buildConfigs[configName];
120-
if(parseFloat(xcodeProject.getBuildProperty('IPHONEOS_DEPLOYMENT_TARGET', buildConfig.name)) < parseFloat(IOS_MIN_DEPLOYMENT_TARGET)) {
122+
if (parseFloat(xcodeProject.getBuildProperty('IPHONEOS_DEPLOYMENT_TARGET', buildConfig.name)) < parseFloat(IOS_MIN_DEPLOYMENT_TARGET)) {
121123
xcodeProject.updateBuildProperty('IPHONEOS_DEPLOYMENT_TARGET', IOS_MIN_DEPLOYMENT_TARGET, buildConfig.name);
122124
console.log('Update IOS project deployment target to:', IOS_MIN_DEPLOYMENT_TARGET, 'for build configuration', buildConfig.name);
123125
}
@@ -127,16 +129,15 @@ module.exports = function(context) {
127129
console.log('Update IOS build setting ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES to: YES', 'for build configuration', buildConfig.name);
128130
}
129131

130-
if(xcodeProject.getBuildProperty('LD_RUNPATH_SEARCH_PATHS', buildConfig.name) !== '"@executable_path/Frameworks"') {
131-
xcodeProject.updateBuildProperty('LD_RUNPATH_SEARCH_PATHS','"@executable_path/Frameworks"', buildConfig.name);
132+
if (xcodeProject.getBuildProperty('LD_RUNPATH_SEARCH_PATHS', buildConfig.name) !== '"@executable_path/Frameworks"') {
133+
xcodeProject.updateBuildProperty('LD_RUNPATH_SEARCH_PATHS', '"@executable_path/Frameworks"', buildConfig.name);
132134
console.log('Update IOS build setting LD_RUNPATH_SEARCH_PATHS to: @executable_path/Frameworks', 'for build configuration', buildConfig.name);
133135
}
134136

135-
if(typeof xcodeProject.getBuildProperty('SWIFT_VERSION', buildConfig.name) === 'undefined') {
136-
xcodeProject.updateBuildProperty('SWIFT_VERSION','3.0', buildConfig.name);
137+
if (typeof xcodeProject.getBuildProperty('SWIFT_VERSION', buildConfig.name) === 'undefined') {
138+
xcodeProject.updateBuildProperty('SWIFT_VERSION', '3.0', buildConfig.name);
137139
console.log('Update SWIFT version to', 3.0, buildConfig.name);
138140
}
139-
140141
}
141142
}
142143

@@ -146,11 +147,11 @@ module.exports = function(context) {
146147
}
147148
};
148149

149-
function getConfigParser(context, config) {
150+
function getConfigParser (context, config) {
150151
var semver = context.requireCordovaModule('semver');
151152
var ConfigParser;
152153

153-
if(semver.lt(context.opts.cordova.version, '5.4.0')) {
154+
if (semver.lt(context.opts.cordova.version, '5.4.0')) {
154155
ConfigParser = context.requireCordovaModule('cordova-lib/src/ConfigParser/ConfigParser');
155156
} else {
156157
ConfigParser = context.requireCordovaModule('cordova-common/src/ConfigParser/ConfigParser');
@@ -159,10 +160,10 @@ function getConfigParser(context, config) {
159160
return new ConfigParser(config);
160161
}
161162

162-
function getBridgingHeaderPath(context, projectPath, iosPlatformVersion) {
163+
function getBridgingHeaderPath (context, projectPath, iosPlatformVersion) {
163164
var semver = context.requireCordovaModule('semver');
164165
var bridgingHeaderPath;
165-
if(semver.lt(iosPlatformVersion, '4.0.0')) {
166+
if (semver.lt(iosPlatformVersion, '4.0.0')) {
166167
bridgingHeaderPath = path.posix.join(projectPath, 'Plugins', 'Bridging-Header.h');
167168
} else {
168169
bridgingHeaderPath = path.posix.join(projectPath, 'Bridging-Header.h');

0 commit comments

Comments
 (0)