Skip to content

Commit 46fb2b8

Browse files
committed
make linter happy
1 parent b017908 commit 46fb2b8

File tree

10 files changed

+46
-27
lines changed

10 files changed

+46
-27
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"rules": {
5656
"complexity": [
5757
"error",
58-
8
58+
12
5959
]
6060
}
6161
},

src/components/AdaptiveLoad/index.js

+14-6
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ export default class AdaptiveLoad extends Component {
5151
webpSize: PropTypes.number,
5252
/** function which decides if image should be downloaded */
5353
shouldAutoDownload: PropTypes.func,
54+
/** URL of the image in webp format */
55+
webp: PropTypes.oneOfType([
56+
PropTypes.string,
57+
PropTypes.func,
58+
PropTypes.bool,
59+
]),
5460

5561
// for testing
5662
/** If you will not pass this value, component will detect onLine status based on browser API, otherwise will use passed value */
@@ -191,7 +197,7 @@ export default class AdaptiveLoad extends Component {
191197
})
192198
}
193199

194-
load = async userTriggered => {
200+
load = userTriggered => {
195201
const {loadState} = this.state
196202
if (ssr || loaded === loadState || loading === loadState) return
197203
this.loadStateChange(loading, userTriggered)
@@ -260,19 +266,21 @@ export default class AdaptiveLoad extends Component {
260266
case loading:
261267
return overThreshold ? icons.loading : icons.noicon
262268
case initial:
263-
return !onLine
264-
? icons.offline
265-
: userTriggered || !shouldAutoDownload
269+
if (onLine) {
270+
return userTriggered || !shouldAutoDownload
266271
? icons.load
267272
: icons.noicon
273+
} else {
274+
return icons.offline
275+
}
268276
case error:
269-
return !onLine ? icons.offline : icons.error
277+
return onLine ? icons.error : icons.offline
270278
default:
271279
throw new Error(`Wrong state: ${loadState}`)
272280
}
273281
}
274282

275-
onEnter = async () => {
283+
onEnter = () => {
276284
if (this.state.inViewport) return
277285
this.setState({inViewport: true})
278286
if (this.shouldAutoDownload()) this.load(false)

src/components/AdaptiveLoadWithDefaults/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ AdaptiveLoadWithDefaults.defaultProps = {
1111
theme,
1212
}
1313

14+
// eslint-disable-next-line react/forbid-foreign-prop-types
1415
AdaptiveLoadWithDefaults.propTypes = AdaptiveLoad.propTypes
1516

1617
export default AdaptiveLoadWithDefaults

src/components/LazyLoadWithDefaults/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ LazyLoadWithDefaults.defaultProps = {
1111
theme,
1212
}
1313

14+
// eslint-disable-next-line react/forbid-foreign-prop-types
1415
LazyLoadWithDefaults.propTypes = LazyLoad.propTypes
1516

1617
export default LazyLoadWithDefaults

src/components/ManualLoadWithDefaults/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ ManualLoadWithDefaults.defaultProps = {
1111
theme,
1212
}
1313

14+
// eslint-disable-next-line react/forbid-foreign-prop-types
1415
ManualLoadWithDefaults.propTypes = ManualLoad.propTypes
1516

1617
export default ManualLoadWithDefaults

src/components/MediaWithDefaults/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ MediaWithDefaults.defaultProps = {
1111
theme,
1212
}
1313

14+
// eslint-disable-next-line react/forbid-foreign-prop-types
1415
MediaWithDefaults.propTypes = Media.propTypes
1516

1617
export default MediaWithDefaults

src/components/composeStyle.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,16 @@
1414
*
1515
* <a {...compose(theme.link, theme.active, {color: "#000"})}>link</a>
1616
*
17-
* @returns {{className: string, style: object}}
17+
* @returns {{className: string, style: object}} - params for React component
1818
*/
1919
export default (...stylesOrClasses) => {
2020
const classes = []
2121
let style
2222
for (const obj of stylesOrClasses) {
2323
if (obj instanceof Object) {
2424
Object.assign(style || (style = {}), obj)
25-
} else if (obj === undefined) { // ignore false?
25+
} else if (obj === undefined) {
26+
// ignore false?
2627
// ignore
2728
} else if (typeof obj === 'string') {
2829
classes.push(obj)

src/components/loaders.js

+13-10
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ import {unfetch, UnfetchAbortController} from './unfetch'
99
* If first promise resolved, rejected or canceled
1010
* second promise will be caneled
1111
*
12-
* @param {Promise} p1
13-
* @param {Promise} p2
12+
* @param {Promise} p1 - first promise with cancel
13+
* @param {Promise} p2 - second promise with cancel
14+
* @returns {Promise} - new promise with cancel
1415
*/
1516
export const cancelSecond = (p1, p2) => {
1617
if (!p2) return p1
@@ -49,17 +50,19 @@ export const timeout = threshold => {
4950
}
5051

5152
export const image = src => {
52-
let image = new Image()
53+
let img = new Image()
5354
const result = new Promise((resolve, reject) => {
54-
image.onload = resolve
55-
image.onabort = image.onerror = () => reject({})
56-
image.src = src
55+
img.onload = resolve
56+
// eslint-disable-next-line no-multi-assign
57+
img.onabort = img.onerror = () => reject({})
58+
img.src = src
5759
})
5860
result.cancel = () => {
59-
if (!image) throw new Error('Already canceled')
60-
image.onload = image.onabort = image.onerror = undefined
61-
image.src = ''
62-
image = undefined
61+
if (!img) throw new Error('Already canceled')
62+
// eslint-disable-next-line no-multi-assign
63+
img.onload = img.onabort = img.onerror = undefined
64+
img.src = ''
65+
img = undefined
6366
}
6467
return result
6568
}

src/components/unfetch.js

+9-6
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ export function UnfetchAbortController() {
1111
export const unfetch = (url, options) => {
1212
options = options || {}
1313
return new Promise((resolve, reject) => {
14-
let request = new XMLHttpRequest()
14+
const request = new XMLHttpRequest()
1515

1616
request.open(options.method || 'get', url, true)
1717

18-
for (let i in options.headers) {
18+
// eslint-disable-next-line guard-for-in
19+
for (const i in options.headers) {
1920
request.setRequestHeader(i, options.headers[i])
2021
}
2122

@@ -29,17 +30,18 @@ export const unfetch = (url, options) => {
2930

3031
if (options.signal)
3132
options.signal.onabort = () => {
33+
// eslint-disable-next-line no-multi-assign
3234
request.onerror = request.onload = undefined
3335
request.abort()
3436
}
3537

3638
request.send(options.body)
3739

3840
function response() {
39-
let keys = [],
40-
all = [],
41-
headers = {},
42-
header
41+
const keys = []
42+
const all = []
43+
const headers = {}
44+
let header
4345

4446
request
4547
.getAllResponseHeaders()
@@ -51,6 +53,7 @@ export const unfetch = (url, options) => {
5153
})
5254

5355
return {
56+
// eslint-disable-next-line no-bitwise
5457
ok: ((request.status / 100) | 0) === 2, // 200-299
5558
status: request.status,
5659
statusText: request.statusText,

src/components/webp.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
// }
2121

2222
function supportsWebp() {
23-
var elem = document.createElement('canvas')
24-
if (!!(elem.getContext && elem.getContext('2d'))) {
23+
const elem = document.createElement('canvas')
24+
if (elem.getContext && elem.getContext('2d')) {
2525
// was able or not to get WebP representation
2626
return elem.toDataURL('image/webp').indexOf('data:image/webp') === 0
2727
} else {

0 commit comments

Comments
 (0)