Skip to content

Commit 9efc33a

Browse files
committed
upgrade to webpack 5. Update eslint to prettier defaults - arrow function style.
1 parent 98ad6c8 commit 9efc33a

15 files changed

+956
-2127
lines changed

.eslintrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"prefer-spread": 0,
1010
"prefer-template": 2,
1111
"arrow-body-style": [2, "as-needed"],
12-
"arrow-parens": [2, "as-needed"],
12+
"arrow-parens": 2,
1313
"arrow-spacing": [
1414
2,
1515
{

.prettierrc

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"singleQuote": true,
33
"semi": false,
4-
"printWidth": 120
4+
"printWidth": 120,
5+
"trailingComma": "none"
56
}

dist/customScroll.css

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/reactCustomScroll.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/exampleDist/example.js

+302-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* @license
3+
* Lodash <https://lodash.com/>
4+
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
5+
* Released under MIT license <https://lodash.com/license>
6+
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
7+
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
8+
*/

example/firstComp/firstComp.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export class FirstComp extends Component {
2929
return demoText.text
3030
}
3131
getDynamicContent() {
32-
return times(index => `Content #${index}`, this.state.dynamicContentCounter)
32+
return times((index) => `Content #${index}`, this.state.dynamicContentCounter)
3333
}
3434
addContent = () => {
3535
this.setState({
@@ -130,7 +130,7 @@ export class FirstComp extends Component {
130130
<div className="panel-content-custom panel-content">
131131
<div className="content-fill">
132132
{map(
133-
content => (
133+
(content) => (
134134
<div className="dynamic-content" key={content}>
135135
{content}
136136
</div>

karma.conf.js

+11-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
const path = require('path')
2+
const KarmaWebpack = require('karma-webpack')
23

3-
module.exports = config => {
4+
module.exports = (config) => {
45
config.set({
56
browsers: ['ChromeHeadless', 'FirefoxHeadless'],
67
// browsers: ['Chrome'],
78
frameworks: ['jasmine'],
89
singleRun: false,
910
reporters: ['dots'], //report results in this format
1011
files: [
11-
{pattern: 'src/test/*.spec.js', watched: false}
12+
{ pattern: 'src/test/*.spec.js', watched: false }
1213
// each file acts as entry point for the webpack configuration
1314
],
1415

@@ -33,23 +34,25 @@ module.exports = config => {
3334
use: [
3435
{
3536
loader: 'style-loader'
36-
}, {
37+
},
38+
{
3739
loader: 'css-loader',
3840
options: {
3941
modules: {
40-
localIdentName: 'rcs-[local]'
41-
},
42-
localsConvention: 'dashes'
42+
localIdentName: 'rcs-[local]',
43+
exportLocalsConvention: 'dashes'
44+
}
4345
}
44-
}, {
46+
},
47+
{
4548
loader: 'sass-loader'
4649
}
4750
]
4851
}
4952
]
5053
},
5154
resolve: {
52-
modules: [path.resolve(__dirname, "src/main"), "node_modules"]
55+
modules: [path.resolve(__dirname, 'src/main'), 'node_modules']
5356
}
5457
},
5558

package.json

+10-9
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,26 @@
3535
"eslint": "^6.8.0",
3636
"eslint-plugin-lodash": "^6.0.0",
3737
"eslint-plugin-react": "^7.18.3",
38-
"extract-text-webpack-plugin": "4.0.0-beta.0",
3938
"jasmine": "^3.5.0",
4039
"jasmine-core": "^3.5.0",
4140
"karma": "^6.2.3",
4241
"karma-chrome-launcher": "^3.1.0",
43-
"karma-firefox-launcher": "^1.3.0",
42+
"karma-firefox-launcher": "^2.1.0",
4443
"karma-jasmine": "^3.1.0",
4544
"karma-sourcemap-loader": "^0.3.7",
46-
"karma-webpack": "^4.0.2",
45+
"karma-webpack": "^5.0.0",
4746
"lodash": "^4.17.21",
47+
"mini-css-extract-plugin": "^1.6.0",
4848
"node-sass": "^4.13.1",
4949
"postcss-cli": "^7.1.0",
50-
"prettier": "^1.19.1",
50+
"prettier": "^2.3.0",
5151
"prop-types": "^15.7.2",
5252
"react": "^16.12.0",
5353
"react-dom": "^16.12.0",
54-
"sass-loader": "^8.0.2",
55-
"style-loader": "^1.1.3",
56-
"webpack": "^4.41.5",
57-
"webpack-cli": "^3.3.10"
54+
"sass-loader": "^11.1.1",
55+
"style-loader": "^1.3.0",
56+
"webpack": "^5.37.0",
57+
"webpack-cli": "^4.7.0"
5858
},
5959
"peerDependencies": {
6060
"prop-types": "*",
@@ -70,5 +70,6 @@
7070
"ui component",
7171
"ui",
7272
"component"
73-
]
73+
],
74+
"dependencies": {}
7475
}

src/main/.eslintrc

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"react/prop-types": 2,
44
"react/sort-comp": 2,
55
"arrow-body-style": [2, "as-needed"],
6-
"arrow-parens": [2, "as-needed"],
76
"arrow-spacing": [2, { "before": true, "after": true }],
87
"constructor-super": 2,
98
"generator-star-spacing": [2, {"before": true, "after": false}],

src/main/cs.scss

+7-3
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,19 @@
2323

2424
-webkit-overflow-scrolling: touch;
2525

26-
&:after{
26+
&:after {
2727
content: '';
2828
position: absolute;
2929
top: 0;
3030
right: 0;
3131
left: 0;
3232
height: 0;
33-
background-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.2) 0%, rgba(0, 0, 0, 0.05) 60%, rgba(0, 0, 0, 0) 100%);
33+
background-image: linear-gradient(
34+
to bottom,
35+
rgba(0, 0, 0, 0.2) 0%,
36+
rgba(0, 0, 0, 0.05) 60%,
37+
rgba(0, 0, 0, 0) 100%
38+
);
3439
pointer-events: none;
3540
transition: height 0.1s ease-in;
3641
will-change: height;
@@ -81,4 +86,3 @@
8186
border-radius: 3px;
8287
}
8388
}
84-

src/main/customScroll.js

+20-31
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class CustomScroll extends Component {
8888
this.hideScrollThumb.cancel()
8989
document.removeEventListener('mousemove', this.onHandleDrag)
9090
document.removeEventListener('mouseup', this.onHandleDragEnd)
91-
91+
9292
if (this.innerContainerRef.current) {
9393
this.innerContainerRef.current.removeEventListener('wheel', this.blockOuterScroll)
9494
}
@@ -99,7 +99,7 @@ class CustomScroll extends Component {
9999
scrollHandleRef = createRef()
100100
contentWrapperRef = createRef()
101101

102-
adjustFreezePosition = prevProps => {
102+
adjustFreezePosition = (prevProps) => {
103103
if (!this.contentWrapperRef.current) {
104104
return
105105
}
@@ -123,7 +123,7 @@ class CustomScroll extends Component {
123123
}
124124
}
125125

126-
updateScrollPosition = scrollValue => {
126+
updateScrollPosition = (scrollValue) => {
127127
const innerContainer = this.getScrolledElement()
128128
const updatedScrollTop = ensureWithinLimits(scrollValue, 0, this.contentHeight - this.visibleHeight)
129129
innerContainer.scrollTop = updatedScrollTop
@@ -132,7 +132,7 @@ class CustomScroll extends Component {
132132
})
133133
}
134134

135-
onClick = event => {
135+
onClick = (event) => {
136136
if (!this.hasScroll || !this.isMouseEventOnCustomScrollbar(event) || this.isMouseEventOnScrollHandle(event)) {
137137
return
138138
}
@@ -142,7 +142,7 @@ class CustomScroll extends Component {
142142
this.updateScrollPosition(newScrollValue)
143143
}
144144

145-
isMouseEventOnCustomScrollbar = event => {
145+
isMouseEventOnCustomScrollbar = (event) => {
146146
if (!this.customScrollbarRef.current) {
147147
return false
148148
}
@@ -171,15 +171,15 @@ class CustomScroll extends Component {
171171
return isEventPosOnLayout(event, customScrollbarLayout)
172172
}
173173

174-
isMouseEventOnScrollHandle = event => {
174+
isMouseEventOnScrollHandle = (event) => {
175175
if (!this.scrollHandleRef.current) {
176176
return false
177177
}
178178
const scrollHandle = reactDOM.findDOMNode(this.scrollHandleRef.current)
179179
return isEventPosOnDomNode(event, scrollHandle)
180180
}
181181

182-
calculateNewScrollHandleTop = clickEvent => {
182+
calculateNewScrollHandleTop = (clickEvent) => {
183183
const domNode = reactDOM.findDOMNode(this)
184184
const boundingRect = domNode.getBoundingClientRect()
185185
const currentTop = boundingRect.top + window.pageYOffset
@@ -196,7 +196,7 @@ class CustomScroll extends Component {
196196
return newScrollHandleTop
197197
}
198198

199-
getScrollValueFromHandlePosition = handlePosition => handlePosition / this.scrollRatio
199+
getScrollValueFromHandlePosition = (handlePosition) => handlePosition / this.scrollRatio
200200

201201
getScrollHandleStyle = () => {
202202
const handlePosition = this.state.scrollPos * this.scrollRatio
@@ -207,13 +207,13 @@ class CustomScroll extends Component {
207207
}
208208
}
209209

210-
adjustCustomScrollPosToContentPos = scrollPosition => {
210+
adjustCustomScrollPosToContentPos = (scrollPosition) => {
211211
this.setState({
212212
scrollPos: scrollPosition
213213
})
214214
}
215215

216-
onScroll = event => {
216+
onScroll = (event) => {
217217
if (this.props.freezePosition) {
218218
return
219219
}
@@ -226,7 +226,7 @@ class CustomScroll extends Component {
226226

227227
getScrolledElement = () => this.innerContainerRef.current
228228

229-
onMouseDown = event => {
229+
onMouseDown = (event) => {
230230
if (!this.hasScroll || !this.isMouseEventOnScrollHandle(event)) {
231231
return
232232
}
@@ -246,7 +246,7 @@ class CustomScroll extends Component {
246246
})
247247
}
248248

249-
onHandleDrag = event => {
249+
onHandleDrag = (event) => {
250250
event.preventDefault()
251251
const mouseDeltaY = event.pageY - this.startDragMousePos
252252
const handleTopPosition = ensureWithinLimits(
@@ -258,7 +258,7 @@ class CustomScroll extends Component {
258258
this.updateScrollPosition(newScrollValue)
259259
}
260260

261-
onHandleDragEnd = e => {
261+
onHandleDragEnd = (e) => {
262262
this.setState({
263263
onDrag: false
264264
})
@@ -267,7 +267,7 @@ class CustomScroll extends Component {
267267
document.removeEventListener('mouseup', this.onHandleDragEnd)
268268
}
269269

270-
blockOuterScroll = e => {
270+
blockOuterScroll = (e) => {
271271
if (this.props.allowOuterScroll) {
272272
return
273273
}
@@ -327,7 +327,7 @@ class CustomScroll extends Component {
327327
return result
328328
}
329329

330-
enforceMinHandleHeight = calculatedStyle => {
330+
enforceMinHandleHeight = (calculatedStyle) => {
331331
const minHeight = this.props.minScrollHandleHeight
332332
if (calculatedStyle.height >= minHeight) {
333333
return calculatedStyle
@@ -352,14 +352,11 @@ class CustomScroll extends Component {
352352
const className = [
353353
this.props.className || '',
354354
styles.customScroll,
355-
this.state.onDrag ? styles.scrollHandleDragged : '',
356-
].join('')
355+
this.state.onDrag ? styles.scrollHandleDragged : ''
356+
].join(' ')
357357

358358
return (
359-
<div
360-
className={className}
361-
style={rootStyle}
362-
>
359+
<div className={className} style={rootStyle}>
363360
<div
364361
className={styles.outerContainer}
365362
style={this.getOuterContainerStyle()}
@@ -374,11 +371,7 @@ class CustomScroll extends Component {
374371
className={`${styles.customScrollbar} ${this.props.rtl ? styles.customScrollbarRtl : ''}`}
375372
key="scrollbar"
376373
>
377-
<div
378-
ref={this.scrollHandleRef}
379-
className={styles.customScrollHandle}
380-
style={scrollHandleStyle}
381-
>
374+
<div ref={this.scrollHandleRef} className={styles.customScrollHandle} style={scrollHandleStyle}>
382375
<div className={this.props.handleClass} />
383376
</div>
384377
</div>
@@ -390,11 +383,7 @@ class CustomScroll extends Component {
390383
style={scrollStyles.innerContainer}
391384
onScroll={this.onScroll}
392385
>
393-
<div
394-
className={styles.contentWrapper}
395-
ref={this.contentWrapperRef}
396-
style={scrollStyles.contentWrapper}
397-
>
386+
<div className={styles.contentWrapper} ref={this.contentWrapperRef} style={scrollStyles.contentWrapper}>
398387
{this.props.children}
399388
</div>
400389
</div>

0 commit comments

Comments
 (0)