Skip to content

Commit a754f9f

Browse files
authored
[tiny][lint] Fixing some lint failures I noticed while publishing (#43)
* [tiny][lint] Fixing some lint failures I noticed while publishing * fix formatting of backgroundSize * Gulp@3 doesnt work with node@12, remove it since it was just used for tests, use enzyme for test rather than trying to touch the dom directly. * remove gulp and godaddy-test-tools
1 parent a03ec78 commit a754f9f

File tree

9 files changed

+8953
-15484
lines changed

9 files changed

+8953
-15484
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ lib-cov
1212

1313
# Coverage directory used by tools like istanbul
1414
coverage
15+
.nyc_output/
1516

1617
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
1718
.grunt

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ lib-cov
1212

1313
# Coverage directory used by tools like istanbul
1414
coverage
15+
.nyc_output/
1516

1617
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
1718
.grunt

gulpfile.babel.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

package-lock.json

Lines changed: 8687 additions & 15293 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
"prebuild": "npm run clean",
2626
"build": "babel src -d lib && lessc src/carousel.less lib/carousel.css && postcss --no-map --use autoprefixer -o lib/carousel.css lib/carousel.css",
2727
"eslint": "eslint-godaddy-react src/ test/",
28-
"unit": "gulp unit-coverage",
29-
"pretest": "npm run eslint",
30-
"test": "npm run unit",
28+
"unit": "mocha --require setup-env \"test/unit/**/*.tests.js\"",
29+
"posttest": "npm run eslint",
30+
"test": "nyc --reporter=text --reporter=json-summary npm run unit",
3131
"prepublish": "npm run test && npm run build",
3232
"storybook": "start-storybook"
3333
},
@@ -48,33 +48,36 @@
4848
"autoprefixer": "^7.2.6",
4949
"babel-cli": "^6.26.0",
5050
"babel-core": "^6.26.3",
51-
"babel-eslint": "^8.2.6",
52-
"babel-loader": "^7.1.5",
51+
"babel-eslint": "^10.0.3",
52+
"babel-loader": "^7.0.0",
5353
"babel-polyfill": "^6.26.0",
5454
"babel-preset-es2015": "^6.24.1",
5555
"babel-preset-react": "^6.24.1",
5656
"babel-preset-stage-2": "^6.24.1",
5757
"babel-register": "^6.26.0",
5858
"chai": "^4.2.0",
5959
"css-loader": "^0.28.11",
60-
"eslint": "^4.19.1",
61-
"eslint-config-godaddy-react": "^2.2.2",
60+
"enzyme": "^3.11.0",
61+
"enzyme-adapter-react-16": "^1.15.2",
62+
"eslint": "^6.8.0",
63+
"eslint-config-godaddy-react": "^6.0.0",
6264
"eslint-plugin-json": "^1.4.0",
65+
"eslint-plugin-jsx-a11y": "^6.2.3",
6366
"eslint-plugin-mocha": "^4.12.1",
6467
"eslint-plugin-react": "^7.14.3",
65-
"godaddy-test-tools": "^9.2.0",
66-
"gulp": "3.9.0",
6768
"html-webpack-plugin": "^2.30.1",
68-
"jsdom": "^11.12.0",
69+
"jsdom": "^16.2.0",
6970
"less": "^2.7.3",
7071
"less-loader": "^4.1.0",
71-
"mocha": "^5.2.0",
72+
"mocha": "^7.0.1",
73+
"nyc": "^15.0.0",
7274
"postcss-cli": "^5.0.1",
7375
"react": "^16.9.0",
7476
"react-dom": "^16.9.0",
75-
"rimraf": "^2.7.1",
76-
"sinon": "^4.5.0",
77-
"sinon-chai": "^2.14.0",
77+
"rimraf": "^3.0.2",
78+
"setup-env": "^1.2.3",
79+
"sinon": "^9.0.0",
80+
"sinon-chai": "^3.5.0",
7881
"style-loader": "^0.20.3",
7982
"webpack": "^3.12.0"
8083
}

src/index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/* eslint
2+
jsx-a11y/mouse-events-have-key-events: 0,
3+
jsx-a11y/no-noninteractive-element-interactions: 0,
4+
jsx-a11y/click-events-have-key-events: 0 */
15
import React, { Component, Children, cloneElement } from 'react';
26
import PropTypes from 'prop-types';
37
import nth from 'lodash.nth';
@@ -211,6 +215,7 @@ export default class Carousel extends Component {
211215
const startIndex = currentSlide - Math.floor(imagesToPrefetch / 2);
212216
const endIndex = startIndex + imagesToPrefetch;
213217
const pendingImages = [];
218+
214219
const currentImage = slides[currentSlide].props.src;
215220

216221
for (let index = startIndex; index < endIndex; index++) {
@@ -383,8 +388,8 @@ export default class Carousel extends Component {
383388

384389
if (arrows) {
385390
arr = arr.concat([
386-
{ component: Arrow, props: { direction: 'left' }},
387-
{ component: Arrow, props: { direction: 'right' }}
391+
{ component: Arrow, props: { direction: 'left' } },
392+
{ component: Arrow, props: { direction: 'right' } }
388393
]);
389394
}
390395

src/stories/index.stories.js

Lines changed: 79 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { Fragment, useState } from 'react';
2+
import PropTypes from 'prop-types';
23
import Carousel from '../index';
34

45
require('../carousel.less');
@@ -19,7 +20,7 @@ const IMAGES = [
1920
'http://picsum.photos/325/300'
2021
];
2122

22-
const imgElements = IMAGES.map((image, index) => <img src={ image } key={ index } />);
23+
const imgElements = IMAGES.map((image, index) => <img src={ image } key={ index } alt='A sample' />);
2324

2425
const CustomDots = ({ numSlides, selectedIndex, goToSlide, title }) => {
2526
const dots = [];
@@ -52,6 +53,13 @@ const CustomDots = ({ numSlides, selectedIndex, goToSlide, title }) => {
5253
);
5354
};
5455

56+
CustomDots.propTypes = {
57+
numSlides: PropTypes.number.isRequired,
58+
selectedIndex: PropTypes.number,
59+
goToSlide: PropTypes.func.isRequired,
60+
title: PropTypes.node
61+
};
62+
5563
export const infiniteWithCellPadding = () =>
5664
<Carousel width='450px' cellPadding={ 5 }>
5765
{ imgElements }
@@ -75,8 +83,8 @@ export const fadeTransition = () =>
7583

7684
export const infiniteWithOnly2Slides = () =>
7785
<Carousel width='450px' arrows={ false } slideHeight='300px'>
78-
<img src='http://picsum.photos/325/300'/>
79-
<img src='http://picsum.photos/350/300'/>
86+
<img src='http://picsum.photos/325/300' alt='A sample' />
87+
<img src='http://picsum.photos/350/300' alt='A sample' />
8088
</Carousel>;
8189

8290
export const infiniteWithOnly1Slide = () =>
@@ -86,7 +94,7 @@ export const infiniteWithOnly1Slide = () =>
8694
arrows={ false }
8795
dots={ false }
8896
>
89-
<img src='http://picsum.photos/325/300'/>
97+
<img src='http://picsum.photos/325/300' alt='A sample' />
9098
</Carousel>;
9199

92100
export const autoplayWithBackgroundImages = () =>
@@ -97,10 +105,30 @@ export const autoplayWithBackgroundImages = () =>
97105
arrows={ false }
98106
autoplay={ true }
99107
>
100-
<div style={{ backgroundImage: 'url(http://picsum.photos/600/300)', backgroundSize: 'cover', height: '100%', width: '100%' }}/>
101-
<div style={{ backgroundImage: 'url(http://picsum.photos/650/300)', backgroundSize: 'cover', height: '100%', width: '100%' }}/>
102-
<div style={{ backgroundImage: 'url(http://picsum.photos/675/300)', backgroundSize: 'cover', height: '100%', width: '100%' }}/>
103-
<div style={{ backgroundImage: 'url(http://picsum.photos/700/300)', backgroundSize: 'cover', height: '100%', width: '100%' }}/>
108+
<div style={{
109+
backgroundImage: 'url(http://picsum.photos/600/300)',
110+
backgroundSize: 'cover',
111+
height: '100%',
112+
width: '100%'
113+
}}/>
114+
<div style={{
115+
backgroundImage: 'url(http://picsum.photos/650/300)',
116+
backgroundSize: 'cover',
117+
height: '100%',
118+
width: '100%'
119+
}}/>
120+
<div style={{
121+
backgroundImage: 'url(http://picsum.photos/675/300)',
122+
backgroundSize: 'cover',
123+
height: '100%',
124+
width: '100%'
125+
}}/>
126+
<div style={{
127+
backgroundImage: 'url(http://picsum.photos/700/300)',
128+
backgroundSize: 'cover',
129+
height: '100%',
130+
width: '100%'
131+
}}/>
104132
</Carousel>;
105133

106134
export const backgroundImagesWithFade = () =>
@@ -113,13 +141,48 @@ export const backgroundImagesWithFade = () =>
113141
autoplay={ true }
114142
arrows={ true }
115143
>
116-
<div style={{ backgroundImage: 'url(http://picsum.photos/600/300)', backgroundSize: 'cover', height: '100%', width: '100%' }}/>
117-
<div style={{ backgroundImage: 'url(http://picsum.photos/650/300)', backgroundSize: 'cover', height: '100%', width: '100%' }}/>
118-
<div style={{ backgroundImage: 'url(http://picsum.photos/675/300)', backgroundSize: 'cover', height: '100%', width: '100%' }}/>
119-
<div style={{ backgroundImage: 'url(http://picsum.photos/700/300)', backgroundSize: 'cover', height: '100%', width: '100%' }}/>
120-
<div style={{ backgroundImage: 'url(http://picsum.photos/750/300)', backgroundSize: 'cover', height: '100%', width: '100%' }}/>
121-
<div style={{ backgroundImage: 'url(http://picsum.photos/725/300)', backgroundSize: 'cover', height: '100%', width: '100%' }}/>
122-
<div style={{ backgroundImage: 'url(http://picsum.photos/625/300)', backgroundSize: 'cover', height: '100%', width: '100%' }}/>
144+
<div style={{
145+
backgroundImage: 'url(http://picsum.photos/600/300)',
146+
backgroundSize: 'cover',
147+
height: '100%',
148+
width: '100%'
149+
}}/>
150+
<div style={{
151+
backgroundImage: 'url(http://picsum.photos/650/300)',
152+
backgroundSize: 'cover',
153+
height: '100%',
154+
width: '100%'
155+
}}/>
156+
<div style={{
157+
backgroundImage: 'url(http://picsum.photos/675/300)',
158+
backgroundSize: 'cover',
159+
height: '100%',
160+
width: '100%'
161+
}}/>
162+
<div style={{
163+
backgroundImage: 'url(http://picsum.photos/700/300)',
164+
backgroundSize: 'cover',
165+
height: '100%',
166+
width: '100%'
167+
}}/>
168+
<div style={{
169+
backgroundImage: 'url(http://picsum.photos/750/300)',
170+
backgroundSize: 'cover',
171+
height: '100%',
172+
width: '100%'
173+
}}/>
174+
<div style={{
175+
backgroundImage: 'url(http://picsum.photos/725/300)',
176+
backgroundSize: 'cover',
177+
height: '100%',
178+
width: '100%'
179+
}}/>
180+
<div style={{
181+
backgroundImage: 'url(http://picsum.photos/625/300)',
182+
backgroundSize: 'cover',
183+
height: '100%',
184+
width: '100%'
185+
}}/>
123186
</Carousel>;
124187

125188
export const customDotsComponent = () =>
@@ -157,7 +220,7 @@ export const addImages = () => {
157220
controls={ [{ component: CustomDots, props: { title: 'My Slides' }, position: 'top' }] }
158221
>
159222
{
160-
images.map((image, index) => <img key={ index } src={ image }/>)
223+
images.map((image, index) => <img key={ index } src={ image } alt='A sample' />)
161224
}
162225
</Carousel>
163226
<button onClick={ addImage }>Add Image</button>

0 commit comments

Comments
 (0)