Skip to content

Commit 77004e2

Browse files
TrySoundjquense
authored andcommitted
feat: drop warning (#1455)
Maintainers of `warning` refuses evaluation saying it's a 1:1 fork of fbjs version. I tend to replace it with just console statements warpped in NODE_ENV check. Looks much simpler to me, does not require additional tools like babel plugin and does not require commonjs module.
1 parent 0acb000 commit 77004e2

File tree

4 files changed

+14
-11
lines changed

4 files changed

+14
-11
lines changed

.eslintrc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ env:
66
es6: true
77
rules:
88
global-require: off
9-
no-unused-vars: [2, {
9+
no-console: ['error', {
10+
allow: ['warn', 'error', 'info']
11+
}]
12+
no-unused-vars: ['error', {
1013
vars: all,
1114
args: after-used,
1215
varsIgnorePattern: ^_,

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,7 @@
137137
"memoize-one": "^4.0.3",
138138
"prop-types": "^15.6.2",
139139
"react-overlays": "^2.0.0-0",
140-
"uncontrollable": "^7.0.0",
141-
"warning": "^4.0.2"
140+
"uncontrollable": "^7.0.0"
142141
},
143142
"resolutions": {
144143
"babel-core": "7.0.0-bridge.0"

src/Calendar.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
DayLayoutAlgorithmPropType,
1010
views as componentViews,
1111
} from './utils/propTypes'
12-
import warning from 'warning'
1312

1413
import { notify } from './utils/helpers'
1514
import { navigate, views } from './utils/constants'
@@ -942,7 +941,9 @@ class Calendar extends React.Component {
942941
if (viewComponent.range) {
943942
onRangeChange(viewComponent.range(date, { localizer }), view)
944943
} else {
945-
warning(true, 'onRangeChange prop not supported for this view')
944+
if (process.env.NODE_ENV !== 'production') {
945+
console.error('onRangeChange prop not supported for this view')
946+
}
946947
}
947948
}
948949
}

src/localizers/globalize.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import * as dates from '../utils/dates'
22
import oldGlobalize from './oldGlobalize'
33
import { DateLocalizer } from '../localizer'
4-
import warning from 'warning'
54

65
let dateRangeFormat = ({ start, end }, culture, local) =>
76
local.format(start, { date: 'short' }, culture) +
@@ -62,11 +61,12 @@ export default function(globalize) {
6261
const firstDay = weekData.firstDay[territory || '001']
6362
return days.indexOf(firstDay)
6463
} catch (e) {
65-
warning(
66-
true,
67-
`Failed to accurately determine first day of the week.
68-
Is supplemental data loaded into CLDR?`
69-
)
64+
if (process.env.NODE_ENV !== 'production') {
65+
console.error(
66+
'Failed to accurately determine first day of the week.' +
67+
' Is supplemental data loaded into CLDR?'
68+
)
69+
}
7070
// maybe cldr supplemental is not loaded? revert to original method
7171
const date = new Date()
7272
//cldr-data doesn't seem to be zero based

0 commit comments

Comments
 (0)