Skip to content

Commit 369f070

Browse files
committed
Use JSHint to lint JS code during build, truncate verbose output of YUICompressor
1 parent d020b6c commit 369f070

File tree

2 files changed

+40
-22
lines changed

2 files changed

+40
-22
lines changed

share-oauth/pom.xml

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,35 @@
7272
<artifactId>yuicompressor-maven-plugin</artifactId>
7373
<executions>
7474
<execution>
75-
<id>compressyui</id>
76-
<phase>process-resources</phase>
75+
<id>yui-compress</id>
7776
<goals>
7877
<goal>compress</goal>
7978
</goals>
79+
<configuration>
80+
<excludes>
81+
<exclude>**/*.css</exclude>
82+
<exclude>**/*.get.js</exclude>
83+
</excludes>
84+
<jswarn>false</jswarn>
85+
<failOnWarning>false</failOnWarning>
86+
</configuration>
87+
</execution>
88+
</executions>
89+
</plugin>
90+
<plugin>
91+
<groupId>com.cj.jshintmojo</groupId>
92+
<artifactId>jshint-maven-plugin</artifactId>
93+
<executions>
94+
<execution>
95+
<goals>
96+
<goal>lint</goal>
97+
</goals>
8098
</execution>
8199
</executions>
82100
<configuration>
83-
<excludes>
84-
<exclude>**/*.css</exclude>
85-
<exclude>**/*.get.js</exclude>
86-
</excludes>
101+
<directories>
102+
<directory>src/main/resources/META-INF</directory>
103+
</directories>
87104
</configuration>
88105
</plugin>
89106
</plugins>

share-oauth/src/main/resources/META-INF/extras/modules/oauth.js

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ if (typeof Extras == "undefined" || !Extras)
193193
hasToken: function OAuth_hasToken()
194194
{
195195
// TODO check that the token is valid as well as that it just exists?
196-
return this.authData.oauth_token != null && this.authData.oauth_token != "" &&
197-
this.authData.oauth_token_secret != null && this.authData.oauth_token_secret != "";
196+
return this.authData.oauth_token !== null && this.authData.oauth_token !== "" &&
197+
this.authData.oauth_token_secret !== null && this.authData.oauth_token_secret !== "";
198198
},
199199

200200
/**
@@ -206,9 +206,9 @@ if (typeof Extras == "undefined" || !Extras)
206206
isAuthorized: function OAuth_isAuthorized()
207207
{
208208
// TODO check that the token is valid as well as that it just exists?
209-
return this.authData.oauth_token != null && this.authData.oauth_token != "" &&
210-
this.authData.oauth_token_secret != null && this.authData.oauth_token_secret != ""
211-
&& !this.authData.oauth_callback_confirmed;
209+
return this.authData.oauth_token !== null && this.authData.oauth_token !== "" &&
210+
this.authData.oauth_token_secret !== null && this.authData.oauth_token_secret !== "" &&
211+
!this.authData.oauth_callback_confirmed;
212212
},
213213

214214
/**
@@ -224,15 +224,15 @@ if (typeof Extras == "undefined" || !Extras)
224224
authParams = {};
225225

226226
// Add a callback if needed
227-
if (this.options.connectorId != null && this.options.connectorId != "")
227+
if (this.options.connectorId !== null && this.options.connectorId !== "")
228228
{
229229
authParams.oauth_callback = window.location.protocol + "//" + window.location.host +
230230
Alfresco.constants.URL_SERVICECONTEXT + "extras/oauth/auth-return" + "?rp=" +
231231
window.location.pathname.replace(Alfresco.constants.URL_CONTEXT, "") +
232232
"&pid=" + this.options.providerId + "&eid=" + this.options.endpointId + "&cid=" +
233233
this.options.connectorId;
234234
}
235-
else if (this.options.requestTokenCallbackUri != null && !authParams.oauth_callback)
235+
else if (this.options.requestTokenCallbackUri !== null && !authParams.oauth_callback)
236236
{
237237
authParams.oauth_callback = this.options.requestTokenCallbackUri;
238238
}
@@ -472,10 +472,10 @@ if (typeof Extras == "undefined" || !Extras)
472472
var successCallback = {
473473
fn: function (p_resp) {
474474
var json = p_resp.json;
475-
if (json != null && json.org != null)
475+
if (json !== null && json.org)
476476
{
477477
var credentials = json.org.alfresco.share.oauth[this.options.providerId].data;
478-
if (credentials != null && credentials.length > 0)
478+
if (credentials !== null && credentials.length > 0)
479479
{
480480
var authData = this._unpackAuthData(credentials);
481481
// Ensure both required tokens have been found
@@ -634,7 +634,7 @@ if (typeof Extras == "undefined" || !Extras)
634634
}
635635
}
636636
return params;
637-
}
637+
};
638638

639639
if (YAHOO.lang.isObject(obj.dataObj))
640640
{
@@ -647,11 +647,11 @@ if (typeof Extras == "undefined" || !Extras)
647647
var reqType = obj.requestContentType || Alfresco.util.Ajax.FORM;
648648
if (!YAHOO.lang.isValue(obj.dataStr))
649649
{
650-
if ((new RegExp("^\s*" + Alfresco.util.Ajax.FORM)).test(reqType))
650+
if ((new RegExp("^\\s*" + Alfresco.util.Ajax.FORM)).test(reqType))
651651
{
652652
obj.dataStr = objToParamString(obj.dataObj, "+");
653653
}
654-
else if ((new RegExp("^\s*" + Alfresco.util.Ajax.JSON)).test(reqType))
654+
else if ((new RegExp("^\\s*" + Alfresco.util.Ajax.JSON)).test(reqType))
655655
{
656656
obj.dataStr = YAHOO.lang.JSON.stringify(obj.dataObj || {});
657657
}
@@ -667,7 +667,7 @@ if (typeof Extras == "undefined" || !Extras)
667667
o.getResponseHeader["content-type"];
668668
// User provided a custom successCallback
669669
var json = null;
670-
if ((new RegExp("^\s*" + Alfresco.util.Ajax.JSON)).test(contentType))
670+
if ((new RegExp("^\\s*" + Alfresco.util.Ajax.JSON)).test(contentType))
671671
{
672672
cbObj.json = Alfresco.util.parseJSON(o.responseText);
673673
}
@@ -706,7 +706,8 @@ if (typeof Extras == "undefined" || !Extras)
706706
*/
707707
_packAuthData: function OAuth__packAuthData(data, delimiter, quote)
708708
{
709-
var items = [], d, quote = quote || "";
709+
var items = [], d, k;
710+
quote = quote || "";
710711
for (k in data)
711712
{
712713
items.push("" + k + "=" + quote + data[k] + quote);
@@ -773,11 +774,11 @@ if (typeof Extras == "undefined" || !Extras)
773774
data.oauth_timestamp = Math.floor(Date.now()/1000);
774775
}
775776
// Access token, if we have one and another token was not specified
776-
if (typeof data.oauth_token == "undefined" && this.authData != null && this.authData.oauth_token != null)
777+
if (typeof data.oauth_token === "undefined" && this.authData !== null && this.authData.oauth_token !== null)
777778
{
778779
data.oauth_token = this.authData.oauth_token;
779780
}
780-
if (typeof data.oauth_token_secret == "undefined" && this.authData != null && this.authData.oauth_token_secret != null)
781+
if (typeof data.oauth_token_secret === "undefined" && this.authData !== null && this.authData.oauth_token_secret !== null)
781782
{
782783
data.oauth_token_secret = this.authData.oauth_token_secret;
783784
}

0 commit comments

Comments
 (0)