Skip to content

Commit

Permalink
Tools: Bump up grunt-jscs to 1.8.0
Browse files Browse the repository at this point in the history
Fixes #421
  • Loading branch information
rxaviers committed Jul 16, 2015
1 parent 2caa094 commit 76c340c
Show file tree
Hide file tree
Showing 18 changed files with 61 additions and 13 deletions.
6 changes: 5 additions & 1 deletion .jscsrc
Original file line number Original file line Diff line number Diff line change
@@ -1,3 +1,7 @@
{ {
"preset": "jquery" "preset": "jquery",
"requireSpacesInsideParentheses": {
"all": true,
"except": [ "{", "}", "[", "]", "function", "(", ")" ]
}
} }
7 changes: 4 additions & 3 deletions Gruntfile.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ module.exports = function( grunt ) {
var name = camelCase( id.replace( /util\/|common\//, "" ) ); var name = camelCase( id.replace( /util\/|common\//, "" ) );


// MakePlural // MakePlural
if ( (/make-plural/).test( id ) ) { if ( ( /make-plural/ ).test( id ) ) {
return contents return contents


// Remove browserify wrappers. // Remove browserify wrappers.
Expand All @@ -149,7 +149,7 @@ module.exports = function( grunt ) {
.replace( "module.exports = exports['default'];", "" ) .replace( "module.exports = exports['default'];", "" )


// Remove self-tests. // Remove self-tests.
.replace( /var Tests =[\s\S]*?\n}\)\(\);/, "") .replace( /var Tests =[\s\S]*?\n}\)\(\);/, "" )
.replace( "this.tests = new Tests(this);", "" ) .replace( "this.tests = new Tests(this);", "" )
.replace( /this.fn.test =[\s\S]*?bind\(this\);/, "" ) .replace( /this.fn.test =[\s\S]*?bind\(this\);/, "" )
.replace( "this.tests.add(type, cat, examples);", "" ) .replace( "this.tests.add(type, cat, examples);", "" )
Expand All @@ -168,6 +168,7 @@ module.exports = function( grunt ) {
"}());", "}());",
"/* jshint ignore:end */" "/* jshint ignore:end */"
].join( "\n" ) ) ].join( "\n" ) )

// Wrap everything into a var assignment. // Wrap everything into a var assignment.
.replace( /^/, [ .replace( /^/, [
"var MakePlural;", "var MakePlural;",
Expand All @@ -181,7 +182,7 @@ module.exports = function( grunt ) {
].join( "\n" ) ); ].join( "\n" ) );


// messageformat // messageformat
} else if ( (/messageformat/).test( id ) ) { } else if ( ( /messageformat/ ).test( id ) ) {
return contents return contents


// Remove browserify wrappers. // Remove browserify wrappers.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"grunt-contrib-requirejs": "0.4.4", "grunt-contrib-requirejs": "0.4.4",
"grunt-contrib-uglify": "0.6.0", "grunt-contrib-uglify": "0.6.0",
"grunt-contrib-watch": "0.6.1", "grunt-contrib-watch": "0.6.1",
"grunt-jscs": "0.7.1", "grunt-jscs": "1.8.0",
"gzip-js": "0.3.2", "gzip-js": "0.3.2",
"matchdep": "0.3.0" "matchdep": "0.3.0"
}, },
Expand Down
1 change: 1 addition & 0 deletions src/core.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ function Globalize( locale ) {
* Somewhat equivalent to previous Globalize.addCultureInfo(...). * Somewhat equivalent to previous Globalize.addCultureInfo(...).
*/ */
Globalize.load = function() { Globalize.load = function() {

// validations are delegated to Cldr.load(). // validations are delegated to Cldr.load().
Cldr.load.apply( Cldr, arguments ); Cldr.load.apply( Cldr, arguments );
}; };
Expand Down
5 changes: 5 additions & 0 deletions src/date/format-properties.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ return function( pattern, cldr ) {
length = current.length; length = current.length;


if ( chr === "j" ) { if ( chr === "j" ) {

// Locale preferred hHKk. // Locale preferred hHKk.
// http://www.unicode.org/reports/tr35/tr35-dates.html#Time_Data // http://www.unicode.org/reports/tr35/tr35-dates.html#Time_Data
properties.preferredTime = chr = cldr.supplemental.timeData.preferred(); properties.preferredTime = chr = cldr.supplemental.timeData.preferred();
Expand All @@ -62,11 +63,13 @@ return function( pattern, cldr ) {


// Year // Year
case "y": case "y":

// Plain year. // Plain year.
formatNumber = true; formatNumber = true;
break; break;


case "Y": case "Y":

// Year in "Week of Year" // Year in "Week of Year"
properties.firstDay = dateFirstDayOfWeek( cldr ); properties.firstDay = dateFirstDayOfWeek( cldr );
properties.minDays = cldr.supplemental.weekData.minDays(); properties.minDays = cldr.supplemental.weekData.minDays();
Expand Down Expand Up @@ -135,6 +138,7 @@ return function( pattern, cldr ) {
break; break;


case "g": case "g":

// Modified Julian day. Need to be implemented. // Modified Julian day. Need to be implemented.
throw createErrorUnsupportedFeature({ throw createErrorUnsupportedFeature({
feature: "Julian day pattern `g`" feature: "Julian day pattern `g`"
Expand Down Expand Up @@ -207,6 +211,7 @@ return function( pattern, cldr ) {
// Zone // Zone
case "z": case "z":
case "O": case "O":

// O: "{gmtFormat}+H;{gmtFormat}-H" or "{gmtZeroFormat}", eg. "GMT-8" or "GMT". // O: "{gmtFormat}+H;{gmtFormat}-H" or "{gmtZeroFormat}", eg. "GMT-8" or "GMT".
// OOOO: "{gmtFormat}{hourFormat}" or "{gmtZeroFormat}", eg. "GMT-08:00" or "GMT". // OOOO: "{gmtFormat}{hourFormat}" or "{gmtZeroFormat}", eg. "GMT-08:00" or "GMT".
properties.gmtFormat = cldr.main( "dates/timeZoneNames/gmtFormat" ); properties.gmtFormat = cldr.main( "dates/timeZoneNames/gmtFormat" );
Expand Down
11 changes: 11 additions & 0 deletions src/date/format.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ return function( date, numberFormatters, properties ) {
length = current.length; length = current.length;


if ( chr === "j" ) { if ( chr === "j" ) {

// Locale preferred hHKk. // Locale preferred hHKk.
// http://www.unicode.org/reports/tr35/tr35-dates.html#Time_Data // http://www.unicode.org/reports/tr35/tr35-dates.html#Time_Data
chr = properties.preferredTime; chr = properties.preferredTime;
} }


if ( chr === "Z" ) { if ( chr === "Z" ) {

// Z..ZZZ: same as "xxxx". // Z..ZZZ: same as "xxxx".
if ( length < 4 ) { if ( length < 4 ) {
chr = "x"; chr = "x";
Expand All @@ -62,6 +64,7 @@ return function( date, numberFormatters, properties ) {


// Year // Year
case "y": case "y":

// Plain year. // Plain year.
// The length specifies the padding, but for two letters it also specifies the // The length specifies the padding, but for two letters it also specifies the
// maximum length. // maximum length.
Expand All @@ -73,6 +76,7 @@ return function( date, numberFormatters, properties ) {
break; break;


case "Y": case "Y":

// Year in "Week of Year" // Year in "Week of Year"
// The length specifies the padding, but for two letters it also specifies the // The length specifies the padding, but for two letters it also specifies the
// maximum length. // maximum length.
Expand Down Expand Up @@ -111,6 +115,7 @@ return function( date, numberFormatters, properties ) {


// Week // Week
case "w": case "w":

// Week of Year. // Week of Year.
// woy = ceil( ( doy + dow of 1/1 ) / 7 ) - minDaysStuff ? 1 : 0. // woy = ceil( ( doy + dow of 1/1 ) / 7 ) - minDaysStuff ? 1 : 0.
// TODO should pad on ww? Not documented, but I guess so. // TODO should pad on ww? Not documented, but I guess so.
Expand All @@ -120,6 +125,7 @@ return function( date, numberFormatters, properties ) {
break; break;


case "W": case "W":

// Week of Month. // Week of Month.
// wom = ceil( ( dom + dow of `1/month` ) / 7 ) - minDaysStuff ? 1 : 0. // wom = ceil( ( dom + dow of `1/month` ) / 7 ) - minDaysStuff ? 1 : 0.
ret = dateDayOfWeek( dateStartOf( date, "month" ), properties.firstDay ); ret = dateDayOfWeek( dateStartOf( date, "month" ), properties.firstDay );
Expand All @@ -137,6 +143,7 @@ return function( date, numberFormatters, properties ) {
break; break;


case "F": case "F":

// Day of Week in month. eg. 2nd Wed in July. // Day of Week in month. eg. 2nd Wed in July.
ret = Math.floor( date.getDate() / 7 ) + 1; ret = Math.floor( date.getDate() / 7 ) + 1;
break; break;
Expand All @@ -145,6 +152,7 @@ return function( date, numberFormatters, properties ) {
case "e": case "e":
case "c": case "c":
if ( length <= 2 ) { if ( length <= 2 ) {

// Range is [1-7] (deduced by example provided on documentation) // Range is [1-7] (deduced by example provided on documentation)
// TODO Should pad with zeros (not specified in the docs)? // TODO Should pad with zeros (not specified in the docs)?
ret = dateDayOfWeek( date, properties.firstDay ) + 1; ret = dateDayOfWeek( date, properties.firstDay ) + 1;
Expand Down Expand Up @@ -200,6 +208,7 @@ return function( date, numberFormatters, properties ) {
// Zone // Zone
case "z": case "z":
case "O": case "O":

// O: "{gmtFormat}+H;{gmtFormat}-H" or "{gmtZeroFormat}", eg. "GMT-8" or "GMT". // O: "{gmtFormat}+H;{gmtFormat}-H" or "{gmtZeroFormat}", eg. "GMT-8" or "GMT".
// OOOO: "{gmtFormat}{hourFormat}" or "{gmtZeroFormat}", eg. "GMT-08:00" or "GMT". // OOOO: "{gmtFormat}{hourFormat}" or "{gmtZeroFormat}", eg. "GMT-08:00" or "GMT".
if ( date.getTimezoneOffset() === 0 ) { if ( date.getTimezoneOffset() === 0 ) {
Expand All @@ -216,6 +225,7 @@ return function( date, numberFormatters, properties ) {
break; break;


case "X": case "X":

// Same as x*, except it uses "Z" for zero offset. // Same as x*, except it uses "Z" for zero offset.
if ( date.getTimezoneOffset() === 0 ) { if ( date.getTimezoneOffset() === 0 ) {
ret = "Z"; ret = "Z";
Expand All @@ -224,6 +234,7 @@ return function( date, numberFormatters, properties ) {


/* falls through */ /* falls through */
case "x": case "x":

// x: hourFormat("+HH;-HH") // x: hourFormat("+HH;-HH")
// xx or xxxx: hourFormat("+HHmm;-HHmm") // xx or xxxx: hourFormat("+HHmm;-HHmm")
// xxx or xxxxx: hourFormat("+HH:mm;-HH:mm") // xxx or xxxxx: hourFormat("+HH:mm;-HH:mm")
Expand Down
2 changes: 1 addition & 1 deletion src/date/is-leap-year.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ define(function() {
* Returns an indication whether the specified year is a leap year. * Returns an indication whether the specified year is a leap year.
*/ */
return function( year ) { return function( year ) {
return new Date(year, 1, 29).getMonth() === 1; return new Date( year, 1, 29 ).getMonth() === 1;
}; };


}); });
2 changes: 1 addition & 1 deletion src/date/last-day-of-month.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ define(function() {
* Return the last day of the given date's month * Return the last day of the given date's month
*/ */
return function( date ) { return function( date ) {
return new Date( date.getFullYear(), date.getMonth() + 1, 0).getDate(); return new Date( date.getFullYear(), date.getMonth() + 1, 0 ).getDate();
}; };


}); });
1 change: 1 addition & 0 deletions src/date/milliseconds-in-day.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ define([
* millisecondsInDay * millisecondsInDay
*/ */
return function( date ) { return function( date ) {

// TODO Handle daylight savings discontinuities // TODO Handle daylight savings discontinuities
return date - dateStartOf( date, "day" ); return date - dateStartOf( date, "day" );
}; };
Expand Down
8 changes: 7 additions & 1 deletion src/date/parse.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ return function( value, tokens, properties ) {
var century, chr, value, length; var century, chr, value, length;


if ( token.type === "literal" ) { if ( token.type === "literal" ) {

// continue // continue
return true; return true;
} }
Expand All @@ -49,6 +50,7 @@ return function( value, tokens, properties ) {
length = token.type.length; length = token.type.length;


if ( chr === "j" ) { if ( chr === "j" ) {

// Locale preferred hHKk. // Locale preferred hHKk.
// http://www.unicode.org/reports/tr35/tr35-dates.html#Time_Data // http://www.unicode.org/reports/tr35/tr35-dates.html#Time_Data
chr = properties.preferredTimeData; chr = properties.preferredTimeData;
Expand All @@ -69,6 +71,7 @@ return function( value, tokens, properties ) {
if ( outOfRange( value, 0, 99 ) ) { if ( outOfRange( value, 0, 99 ) ) {
return false; return false;
} }

// mimic dojo/date/locale: choose century to apply, according to a sliding // mimic dojo/date/locale: choose century to apply, according to a sliding
// window of 80 years before and 20 years after present year. // window of 80 years before and 20 years after present year.
century = Math.floor( date.getFullYear() / 100 ) * 100; century = Math.floor( date.getFullYear() / 100 ) * 100;
Expand Down Expand Up @@ -123,6 +126,7 @@ return function( value, tokens, properties ) {
break; break;


case "F": case "F":

// Day of Week in month. eg. 2nd Wed in July. // Day of Week in month. eg. 2nd Wed in July.
// Skip // Skip
break; break;
Expand All @@ -131,6 +135,7 @@ return function( value, tokens, properties ) {
case "e": case "e":
case "c": case "c":
case "E": case "E":

// Skip. // Skip.
// value = arrayIndexOf( dateWeekDays, token.value ); // value = arrayIndexOf( dateWeekDays, token.value );
break; break;
Expand Down Expand Up @@ -237,6 +242,7 @@ return function( value, tokens, properties ) {
} }


if ( era === 0 ) { if ( era === 0 ) {

// 1 BC = year 0 // 1 BC = year 0
date.setFullYear( date.getFullYear() * -1 + 1 ); date.setFullYear( date.getFullYear() * -1 + 1 );
} }
Expand All @@ -250,7 +256,7 @@ return function( value, tokens, properties ) {
if ( outOfRange( daysOfYear, 1, dateIsLeapYear( date.getFullYear() ) ? 366 : 365 ) ) { if ( outOfRange( daysOfYear, 1, dateIsLeapYear( date.getFullYear() ) ? 366 : 365 ) ) {
return null; return null;
} }
date.setMonth(0); date.setMonth( 0 );
date.setDate( daysOfYear ); date.setDate( daysOfYear );
} }


Expand Down
2 changes: 1 addition & 1 deletion src/date/pattern-re.js
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,5 @@
define(function() { define(function() {


return (/([a-z])\1*|'([^']|'')+'|''|./ig); return ( /([a-z])\1*|'([^']|'')+'|''|./ig );


}); });
4 changes: 4 additions & 0 deletions src/date/tokenizer-properties.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ return function( pattern, cldr ) {
// Month // Month
case "M": case "M":
case "L": case "L":

// number l=1:{1,2}, l=2:{2}. // number l=1:{1,2}, l=2:{2}.
// lookup l=3... // lookup l=3...
if ( length > 2 ) { if ( length > 2 ) {
Expand All @@ -84,6 +85,7 @@ return function( pattern, cldr ) {


// Day // Day
case "g": case "g":

// Modified Julian day. Need to be implemented. // Modified Julian day. Need to be implemented.
throw createErrorUnsupportedFeature({ throw createErrorUnsupportedFeature({
feature: "Julian day pattern `g`" feature: "Julian day pattern `g`"
Expand All @@ -92,6 +94,7 @@ return function( pattern, cldr ) {
// Week day // Week day
case "e": case "e":
case "c": case "c":

// lookup for length >=3. // lookup for length >=3.
if ( length <= 2 ) { if ( length <= 2 ) {
break; break;
Expand All @@ -100,6 +103,7 @@ return function( pattern, cldr ) {
/* falls through */ /* falls through */
case "E": case "E":
if ( length === 6 ) { if ( length === 6 ) {

// Note: if short day names are not explicitly specified, abbreviated day // Note: if short day names are not explicitly specified, abbreviated day
// names are used instead http://www.unicode.org/reports/tr35/tr35-dates.html#months_days_quarters_eras // names are used instead http://www.unicode.org/reports/tr35/tr35-dates.html#months_days_quarters_eras
cldr.main([ cldr.main([
Expand Down
Loading

0 comments on commit 76c340c

Please sign in to comment.