Skip to content

Commit 15b1178

Browse files
committed
lint issues
1 parent 8651a90 commit 15b1178

23 files changed

+59
-60
lines changed

.eslintrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
"no-use-before-define": 0,
2626
"key-spacing": 0,
2727
"consistent-return": 0,
28+
"no-shadow": 0,
29+
"no-sequences": 0,
2830
"no-return-assign": 0
2931
}
3032
}

docs/components/pages/i18n.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ var Calendar = React.createClass({
4747
<pre>
4848
<code className='js'>
4949
{`var {
50-
GlobalizeNumberLocalizer
51-
, GlobalizeDateLocalizer } = require('react-widgets/lib/globalize-localizer')
50+
globalizeNumberLocalizer
51+
, globalizeDateLocalizer } = require('react-widgets/lib/globalize-localizers')
5252
53-
configure.setNumberLocalizer(GlobalizeNumberLocalizer(globalize))
54-
configure.setDateLocalizer(GlobalizeDateLocalizer(globalize))
53+
configure.setNumberLocalizer(globalizeNumberLocalizer(globalize))
54+
configure.setDateLocalizer(globalizeDateLocalizer(globalize))
5555
`}
5656
</code>
5757
</pre>

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@
2424
"react-component"
2525
],
2626
"scripts": {
27-
"test": "mocha -R spec ./test/server.js && node _test-versions.js",
27+
"test": "npm run lint && mocha -R spec ./test/server.js && node _test-versions.js",
2828
"test-dev": "mocha -R spec ./test/server.js && karma start karma.conf.js --single-run=true",
2929
"build": "gulp lib",
3030
"docs": "gulp docs",
31+
"lint": "eslint src",
3132
"dist": "gulp dist-build"
3233
},
3334
"homepage": "http://jquense.github.io/react-widgets/docs/",

src/configure.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ var warning = require('react/lib/warning')
44
NumberLocalizer
55
, DateLocalizer } = require('./util/localizers')
66
, {
7-
GlobalizeNumberLocalizer
8-
, GlobalizeDateLocalizer } = require('./globalize-localizer')
7+
globalizeNumberLocalizer
8+
, globalizeDateLocalizer } = require('./globalize-localizers')
99

1010
module.exports = {
1111

1212
setGlobalizeInstance: depreciateMethod(function (globalize) {
13-
configuration.locale.date = GlobalizeDateLocalizer(globalize)
14-
configuration.locale.number = GlobalizeNumberLocalizer(globalize)
13+
configuration.locale.date = globalizeDateLocalizer(globalize)
14+
configuration.locale.number = globalizeNumberLocalizer(globalize)
1515
}),
1616

1717
setAnimate(animatefn) {

src/globalize-localizer.js renamed to src/globalize-localizers.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
var { NumberLocalizer, DateLocalizer } = require('./util/localizers')
22
var dates = require('date-arithmetic')
3-
var propTypes = require('./util/propTypes')
43

5-
function GlobalizeDateLocalizer(globalize){
4+
function globalizeDateLocalizer(globalize){
65
const shortNames = Object.create(null);
76

87
function getCulture(culture){
@@ -47,7 +46,7 @@ function GlobalizeDateLocalizer(globalize){
4746
`${l.format(dt, l.formats.year, culture)} - ${l.format(dates.endOf(dt, 'decade'), l.formats.year, culture)}`,
4847

4948
century: (dt, culture, l) =>
50-
`${l.format(dt, l.formats.year, culture)} - ${l.format(dates.endOf(dt, 'century'), l.formats.year, culture)}`,
49+
`${l.format(dt, l.formats.year, culture)} - ${l.format(dates.endOf(dt, 'century'), l.formats.year, culture)}`
5150
},
5251

5352
firstOfWeek,
@@ -67,7 +66,7 @@ function GlobalizeDateLocalizer(globalize){
6766
return localizer
6867
}
6968

70-
function GlobalizeNumberLocalizer(globalize) {
69+
function globalizeNumberLocalizer(globalize) {
7170
var localizer = new NumberLocalizer({
7271

7372
formats: {
@@ -89,5 +88,5 @@ function GlobalizeNumberLocalizer(globalize) {
8988
}
9089

9190
module.exports = {
92-
GlobalizeNumberLocalizer, GlobalizeDateLocalizer
91+
globalizeNumberLocalizer, globalizeDateLocalizer
9392
}

src/index.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11

2-
var invariant = require('react/lib/invariant')
3-
4-
if ("production" !== process.env.NODE_ENV) {
2+
if (process.env.NODE_ENV !== 'production' ) {
53
[
64
Array.prototype.some,
75
Array.prototype.filter,
8-
Array.prototype.reduce,
6+
Array.prototype.reduce
97
].forEach(method => {
108
if ( !method ) throw new Error(
119
'One or more ES5 features is not available to ReactWidgets: http://jquense.github.io/react-widgets/docs/#/getting-started/browser' )
@@ -29,6 +27,6 @@ module.exports = {
2927

3028
utils: {
3129
ReplaceTransitionGroup: require('./ReplaceTransitionGroup'),
32-
SlideTransition: require('./SlideTransition'),
30+
SlideTransition: require('./SlideTransition')
3331
}
3432
}

src/mixins/DataFilterMixin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module.exports = {
1313
value: React.PropTypes.any,
1414
filter: CustomPropTypes.filter,
1515
caseSensitive: React.PropTypes.bool,
16-
minLength: React.PropTypes.number,
16+
minLength: React.PropTypes.number
1717
},
1818

1919
getDefaultProps(){

src/mixins/DataHelpersMixin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module.exports = {
2020

2121
propTypes: {
2222
valueField: React.PropTypes.string,
23-
textField: propTypes.accessor,
23+
textField: propTypes.accessor
2424
},
2525

2626
_dataValue(item){
@@ -61,7 +61,7 @@ module.exports = {
6161
// make an attempt to see if we were passed in dataItem vs just a valueField value
6262
// either an object with the right prop, or a primitive
6363
// { valueField: 5 } || "hello" [ "hello" ]
64-
if( has(item, field) || typeof(first) === typeof(val))
64+
if( has(item, field) || typeof first === typeof val)
6565
return item
6666

6767
idx = this._dataIndexOf(data, this._dataValue(item))

src/mixins/ListMovementMixin.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
'use strict';
22
var React = require('react')
3-
, _ = require('../util/_')
43
, filter = require('../util/filter')
54
, helper = require('./DataHelpersMixin')
65

76
module.exports = {
87

98
propTypes: {
10-
textField: React.PropTypes.string,
9+
textField: React.PropTypes.string
1110
},
1211

1312
first() {

src/mixins/PopupScrollToMixin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ module.exports = {
2424
state.scrollCancel = scrollTo(selected, list)
2525
}
2626
}
27-
},
27+
}
2828
}

src/mixins/WidgetMixin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module.exports = {
1414
readOnly: React.PropTypes.oneOfType([
1515
React.PropTypes.bool,
1616
React.PropTypes.oneOf(['readOnly'])
17-
]),
17+
])
1818
},
1919

2020
isDisabled(){
@@ -40,5 +40,5 @@ module.exports = {
4040
if ( !(this.isDisabled() || (!disabledOnly && this.isReadOnly())) )
4141
return handler
4242
return function(){}
43-
},
43+
}
4444
}

src/util/_.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ var _ =
1212
if (a instanceof Date && b instanceof Date)
1313
return a.getTime() === b.getTime()
1414

15-
if(typeof a != 'object' && typeof b != 'object')
15+
if(typeof a !== 'object' && typeof b !== 'object')
1616
return a === b
1717

18-
if(typeof a != typeof b ) return false
18+
if(typeof a !== typeof b ) return false
1919

2020
return shallowEqual(a, b)
2121
},

src/util/caret.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
/*eslint-disable no-empty */
12
'use strict';
2-
module.exports = function caret(el, start, end ){
33

4+
module.exports = function caret(el, start, end ){
45
if ( start === undefined)
56
return get(el)
67

@@ -45,8 +46,8 @@ function set(el, start, end){
4546
el.focus();
4647
rangeEl = el.createTextRange();
4748
rangeEl.collapse(true);
48-
rangeEl.moveStart("character", start);
49-
rangeEl.moveEnd("character", end - start);
49+
rangeEl.moveStart('character', start);
50+
rangeEl.moveEnd('character', end - start);
5051
rangeEl.select();
5152
}
5253
}

src/util/compat.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
'use strict';
22
var React = require('react')
33
, _ = require('./_')
4-
, version = React.version.split('.').map(parseFloat);
54

5+
var version = React.version.split('.').map(parseFloat);
66

7-
var compat = module.exports = {
7+
module.exports = {
88

99
version(){
1010
return version;

src/util/configuration.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
var globalize
2-
, {
3-
GlobalizeNumberLocalizer
4-
, GlobalizeDateLocalizer } = require('../globalize-localizer')
1+
var {
2+
globalizeNumberLocalizer
3+
, globalizeDateLocalizer } = require('../globalize-localizers')
4+
5+
var globalize;
56

67
try {
78
globalize = require('globalize')
@@ -10,21 +11,20 @@ try {
1011
if ( process.env.NODE_ENV !== 'production') {
1112
var desc = { get(){
1213
throw new Error(
13-
"Globalize.js is available but is still set as the localization strategy. " +
14-
"Please include Globalize.js or provide an alternative localization strategy.")
14+
'Globalize.js is available but is still set as the localization strategy. ' +
15+
'Please include Globalize.js or provide an alternative localization strategy.')
1516
}}
1617
Object.defineProperties(globalize,
1718
{ format: desc, parseDate: desc, parseFloat: desc, findClosestCulture: desc, culture: desc })
1819
}
1920
}
2021

21-
console.log('hhhher', globalize)
22-
var config = module.exports = {
22+
module.exports = {
2323

2424
animate: require('./dom/animate'),
2525

2626
locale: {
27-
date: GlobalizeDateLocalizer(globalize),
28-
number: GlobalizeNumberLocalizer(globalize)
27+
date: globalizeDateLocalizer(globalize),
28+
number: globalizeNumberLocalizer(globalize)
2929
}
3030
}

src/util/constants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ module.exports = {
3232
[views.MONTH]: 'day',
3333
[views.YEAR]: views.MONTH,
3434
[views.DECADE]: views.YEAR,
35-
[views.CENTURY]: views.DECADE,
35+
[views.CENTURY]: views.DECADE
3636
}
3737
}

src/util/dates.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ var dates = module.exports = Object.assign(dateMath, {
1818
},
1919

2020
monthsInYear: function(year){
21-
var months = [0,1,2,3,4,5,6,7,8,9,10,11]
21+
var months = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
2222
, date = new Date(year, 0, 1)
2323

2424
return months.map( i => dates.month(date, i))

src/util/dom/animate.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
"use strict";
2-
var canUseDOM = require('dom-helpers/util/inDOM')
3-
, hyphenate = require('dom-helpers/util/hyphenate')
1+
'use strict';
2+
var hyphenate = require('dom-helpers/util/hyphenate')
43
, css = require('dom-helpers/style')
54
, on = require('dom-helpers/events/on')
65
, off = require('dom-helpers/events/off')
@@ -35,7 +34,7 @@ function animate(node, properties, duration, easing, callback){
3534
var cssProperties = []
3635
, fakeEvent = { target: node, currentTarget: node }
3736
, cssValues = {}
38-
, transforms =''
37+
, transforms = ''
3938
, fired;
4039

4140
if ( typeof easing === 'function' )

src/util/filter.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
"use strict";
2-
1+
'use strict';
32
var common = {
43
eq: function(a, b){ return a === b },
54
neq: function(a, b){ return a !== b },

src/util/localizers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ function _format(localizer, formatter, value, format, culture) {
3333
}
3434

3535
function checkFormats(requiredFormats, formats){
36-
if( "production" !== process.env.NODE_ENV)
36+
if( process.env.NODE_ENV !== 'production' )
3737
requiredFormats.forEach(
38-
f => invariant(has(formats , f), 'localizer missing required format: `%s`', f ))
38+
f => invariant(has(formats, f), 'localizer missing required format: `%s`', f ))
3939
}
4040

4141
class NumberLocalizer {

src/util/propTypes.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var filterTypes = Object.keys(filters).filter( i => i !== 'filter')
88
module.exports = {
99

1010
elementType: createChainableTypeChecker(
11-
function (props, propName, componentName, location) {
11+
function (props, propName, componentName) {
1212

1313
if( typeof props[propName] !== 'function'){
1414
if ( React.isValidElement(props[propName]))
@@ -50,7 +50,7 @@ function createChainableTypeChecker(validate) {
5050
if (props[propName] == null) {
5151
if (isRequired) {
5252
return new Error(
53-
"Required prop `" + propName + "` was not specified in `" + componentName + "`.");
53+
'Required prop `' + propName + '` was not specified in `' + componentName + '`.');
5454
}
5555
}
5656
else

src/util/validateListInterface.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
'use strict';
2-
var METHODS = ['next','prev', 'first', 'last'];
2+
var METHODS = ['next', 'prev', 'first', 'last'];
33

44
module.exports = function validateListComponent(list){
55

6-
if( "production" !== process.env.NODE_ENV){
6+
if( process.env.NODE_ENV !== 'production' ){
77
METHODS.forEach( method =>
88
assert(typeof list[method] === 'function', 'List components must implement a `' + method +'()` method') )
99
}

webpack.configs.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,9 @@ module.exports = {
197197

198198
loaders: [
199199
{ test: /\.json$/, loader: "json" },
200-
{ test: /\.raw$/, loader: "raw" }
201-
],
200+
{ test: /\.raw$/, loader: "raw" },
201+
{ test: /\.md$/, loader: 'babel-loader!' + path.join(__dirname, './docs/vendor/mdLoader') }
202+
]
202203
}),
203204

204205
test: makeConfig({

0 commit comments

Comments
 (0)