Skip to content

Commit 4161926

Browse files
Updates for eslint
1 parent 9ce8fd1 commit 4161926

File tree

5 files changed

+37
-37
lines changed

5 files changed

+37
-37
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"test": "spago test --no-install"
66
},
77
"devDependencies": {
8-
"eslint": "^7.6.0"
8+
"eslint": "^7.6.0",
9+
"purescript-psa": "^0.8.0"
910
}
1011
}

src/React.js

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,42 @@
1-
/* global exports */
21
"use strict";
32

43
var React = require("react");
54

65
function createClass(baseClass) {
76
function bindProperty(instance, prop, value) {
87
switch (prop) {
9-
case 'state':
10-
case 'render':
11-
case 'componentDidMount':
12-
case 'componentWillUnmount':
8+
case "state":
9+
case "render":
10+
case "componentDidMount":
11+
case "componentWillUnmount":
1312
instance[prop] = value;
1413
break;
1514

16-
case 'componentDidCatch':
17-
case 'componentWillUpdate':
18-
case 'shouldComponentUpdate':
19-
case 'getSnapshotBeforeUpdate':
15+
case "componentDidCatch":
16+
case "componentWillUpdate":
17+
case "shouldComponentUpdate":
18+
case "getSnapshotBeforeUpdate":
2019
instance[prop] = function (a, b) { return value(a)(b)(); };
2120
break;
2221

23-
case 'componentDidUpdate':
22+
case "componentDidUpdate":
2423
instance[prop] = function (a, b, c) { return value(a)(b)(c)(); };
2524
break;
2625

27-
case 'unsafeComponentWillMount':
28-
instance['UNSAFE_componentWillMount'] = value;
26+
case "unsafeComponentWillMount":
27+
instance["UNSAFE_componentWillMount"] = value;
2928
break;
3029

31-
case 'unsafeComponentWillReceiveProps':
32-
instance['UNSAFE_componentWillReceiveProps'] = function (a) { return value(a)(); };
30+
case "unsafeComponentWillReceiveProps":
31+
instance["UNSAFE_componentWillReceiveProps"] = function (a) { return value(a)(); };
3332
break;
3433

35-
case 'unsafeComponentWillUpdate':
36-
instance['UNSAFE_componentWillUpdate'] = function (a, b) { return value(a)(b)(); };
34+
case "unsafeComponentWillUpdate":
35+
instance["UNSAFE_componentWillUpdate"] = function (a, b) { return value(a)(b)(); };
3736
break;
3837

3938
default:
40-
throw new Error('[purescript-react] Not a component property: ' + prop);
39+
throw new Error("[purescript-react] Not a component property: " + prop);
4140
}
4241
}
4342

@@ -47,7 +46,9 @@ function createClass(baseClass) {
4746
baseClass.call(this, props);
4847
var spec = ctrFn(this)();
4948
for (var k in spec) {
50-
bindProperty(this, k, spec[k]);
49+
if (Object.prototype.hasOwnProperty.call(spec, k)) {
50+
bindProperty(this, k, spec[k]);
51+
}
5152
}
5253
};
5354

@@ -60,7 +61,13 @@ function createClass(baseClass) {
6061
};
6162
}
6263

63-
function createClassWithDerivedState(classCtr) {
64+
var componentImpl = createClass(React.Component);
65+
exports.componentImpl = componentImpl;
66+
67+
var pureComponentImpl = createClass(React.PureComponent);
68+
exports.pureComponentImpl = pureComponentImpl;
69+
70+
function createClassWithDerivedState() {
6471
return function(displayName) {
6572
return function(getDerivedStateFromProps) {
6673
return function(ctrFn) {
@@ -72,12 +79,7 @@ function createClassWithDerivedState(classCtr) {
7279
};
7380
}
7481

75-
var componentImpl = createClass(React.Component);
76-
exports.componentImpl = componentImpl;
7782
exports.componentWithDerivedStateImpl = createClassWithDerivedState(componentImpl);
78-
79-
var pureComponentImpl = createClass(React.PureComponent);
80-
exports.pureComponentImpl = pureComponentImpl;
8183
exports.pureComponentWithDerivedStateImpl = createClassWithDerivedState(pureComponentImpl);
8284

8385
exports.statelessComponent = function(x) { return x; };
@@ -118,7 +120,7 @@ exports.setStateWithCallbackImpl = setStateWithCallbackImpl;
118120
function getState(this_) {
119121
return function(){
120122
if (!this_.state) {
121-
throw new Error('[purescript-react] Cannot get state within constructor');
123+
throw new Error("[purescript-react] Cannot get state within constructor");
122124
}
123125
return this_.state;
124126
};
@@ -157,7 +159,7 @@ function createElementDynamic(class_) {
157159
return React.createElement(class_, props, children);
158160
};
159161
};
160-
};
162+
}
161163
exports.createElementDynamicImpl = createElementDynamic;
162164
exports.createElementTagNameDynamic = createElementDynamic;
163165

src/React/DOM/Props.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
/* global exports */
21
"use strict";
32

4-
var React = require("react");
5-
63
function unsafeMkProps(key) {
74
return function(value){
85
var result = {};
@@ -19,7 +16,7 @@ function unsafeUnfoldProps(key) {
1916
props[key] = result;
2017

2118
for (var subprop in value) {
22-
if (value.hasOwnProperty(subprop)) {
19+
if (Object.prototype.hasOwnProperty.call(value, subprop)) {
2320
result[subprop] = value[subprop];
2421
}
2522
}
@@ -34,7 +31,7 @@ function unsafePrefixProps(prefix) {
3431
var result = {};
3532

3633
for (var prop in value) {
37-
if (value.hasOwnProperty(prop)) {
34+
if (Object.prototype.hasOwnProperty.call(value, prop)) {
3835
result[prefix + prop] = value[prop];
3936
}
4037
}
@@ -51,12 +48,12 @@ function unsafeFromPropsArray(props) {
5148
var prop = props[i];
5249

5350
for (var key in prop) {
54-
if (prop.hasOwnProperty(key)) {
51+
if (Object.prototype.hasOwnProperty.call(prop, key)) {
5552
result[key] = prop[key];
5653
}
5754
}
5855
}
5956

6057
return result;
61-
};
58+
}
6259
exports.unsafeFromPropsArray = unsafeFromPropsArray;

src/React/Ref.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ exports.createRef = React.createRef;
66

77
exports.liftCallbackRef = function(ref) {
88
return { current: ref };
9-
}
9+
};
1010

1111
exports.getCurrentRef_ = function(ref) {
1212
return ref.current;
13-
}
13+
};

src/React/SyntheticEvent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
'use strict';
1+
"use strict";
22

33
exports.preventDefault = function preventDefault(event) {
44
return function() {

0 commit comments

Comments
 (0)