Skip to content

Commit e1030ab

Browse files
committed
Modernize eslint + prettier configuration
1 parent 2194bff commit e1030ab

9 files changed

Lines changed: 49 additions & 58 deletions

File tree

.eslintrc.json

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,12 @@
55
"node": true,
66
"mocha": true
77
},
8-
"extends": "eslint:recommended",
9-
"parserOptions": {
10-
"ecmaVersion": 6,
11-
"sourceType": "module",
12-
"ecmaFeatures": {
13-
"jsx": true
14-
}
15-
},
16-
"plugins": [],
17-
"rules": {
18-
"semi": "error"
19-
}
8+
"extends": [
9+
"eslint:recommended",
10+
"standard",
11+
"prettier"
12+
],
13+
"plugins": [
14+
"prettier"
15+
]
2016
}

.prettierrc

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

package.json

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,32 +34,33 @@
3434
"start": "run-s watch"
3535
},
3636
"peerDependencies": {
37-
"react": ">=15.0.0",
38-
"cytoscape": "^3.2.19"
37+
"cytoscape": "^3.2.19",
38+
"react": ">=15.0.0"
3939
},
4040
"devDependencies": {
4141
"chai": "^4.1.2",
42-
"eslint": "^4.6.1",
43-
"eslint-config-standard": "^10.2.1",
42+
"eslint": "^8.19.0",
43+
"eslint-config-prettier": "^8.5.0",
44+
"eslint-config-standard": "^17.0.0",
4445
"eslint-plugin-import": "^2.7.0",
45-
"eslint-plugin-node": "^5.1.1",
46-
"eslint-plugin-promise": "^3.5.0",
47-
"eslint-plugin-standard": "^3.0.1",
46+
"eslint-plugin-n": "^15.2.4",
47+
"eslint-plugin-prettier": "^4.2.1",
48+
"eslint-plugin-promise": "^6.0.0",
4849
"immutable": "^3.8.2",
4950
"microbundle": "^0.15.0",
5051
"mocha": "^5.2.0",
5152
"mocha-chrome": "^1.1.0",
5253
"npm-run-all": "^4.1.1",
53-
"prettier": "^1.13.7",
54+
"prettier": "^2.7.1",
5455
"react": "^16.4.1",
5556
"react-docgen": "^2.21.0",
5657
"react-dom": "^16.4.1",
5758
"rimraf": "^2.6.2"
5859
},
59-
"engines": {
60-
"node": ">=8.11.3"
61-
},
6260
"dependencies": {
6361
"prop-types": "^15.6.2"
62+
},
63+
"prettier": {
64+
"singleQuote": true
6465
}
6566
}

src/component.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export default class CytoscapeComponent extends React.Component {
3939

4040
constructor(props) {
4141
super(props);
42-
this.displayName = `CytoscapeComponent`;
42+
this.displayName = 'CytoscapeComponent';
4343
this.containerRef = React.createRef();
4444
}
4545

@@ -55,7 +55,7 @@ export default class CytoscapeComponent extends React.Component {
5555
motionBlur,
5656
motionBlurOpacity,
5757
wheelSensitivity,
58-
pixelRatio
58+
pixelRatio,
5959
} = this.props;
6060

6161
const cy = (this._cy = new Cytoscape({
@@ -67,7 +67,7 @@ export default class CytoscapeComponent extends React.Component {
6767
motionBlur,
6868
motionBlurOpacity,
6969
wheelSensitivity,
70-
pixelRatio
70+
pixelRatio,
7171
}));
7272

7373
if (global) {
@@ -103,7 +103,7 @@ export default class CytoscapeComponent extends React.Component {
103103
ref: this.containerRef,
104104
id,
105105
className,
106-
style
106+
style,
107107
});
108108
}
109109
}

src/defaults.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
import { shallowObjDiff } from './diff';
22
import { get, toJson, forEach } from './json';
33

4-
export const identity = x => x;
4+
export const identity = (x) => x;
55

66
export const elements = [
77
{ data: { id: 'a', label: 'Example node A' } },
88
{ data: { id: 'b', label: 'Example node B' } },
9-
{ data: { id: 'e', source: 'a', target: 'b' } }
9+
{ data: { id: 'e', source: 'a', target: 'b' } },
1010
];
1111

1212
export const stylesheet = [
1313
{
1414
selector: 'node',
1515
style: {
16-
label: 'data(label)'
17-
}
18-
}
16+
label: 'data(label)',
17+
},
18+
},
1919
];
2020

2121
export const zoom = 1;
2222

2323
export const pan = {
2424
x: 0,
25-
y: 0
25+
y: 0,
2626
};
2727

2828
export const defaults = {
@@ -33,5 +33,5 @@ export const defaults = {
3333
elements,
3434
stylesheet,
3535
zoom,
36-
pan
36+
pan,
3737
};

src/diff.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
const typeofObj = typeof {};
2-
31
const eitherIsNil = (a, b) => a == null || b == null;
42

53
export const hashDiff = (a, b) => {
@@ -17,13 +15,13 @@ export const shallowObjDiff = (a, b) => {
1715
}
1816

1917
// non-object values can be compared with the equality operator
20-
if (typeof a !== typeofObj || typeof b !== typeofObj) {
18+
if (typeof a !== 'object' || typeof b !== 'object') {
2119
return a !== b;
2220
}
2321

24-
let aKeys = Object.keys(a);
25-
let bKeys = Object.keys(b);
26-
let mismatches = key => a[key] !== b[key];
22+
const aKeys = Object.keys(a);
23+
const bKeys = Object.keys(b);
24+
const mismatches = (key) => a[key] !== b[key];
2725

2826
if (aKeys.length !== bKeys.length) {
2927
return true;

src/json.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export const get = (obj, key) => (obj != null ? obj[key] : null);
22

3-
export const toJson = obj => obj;
3+
export const toJson = (obj) => obj;
44

55
export const forEach = (arr, iterator) => arr.forEach(iterator);

src/patch.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ export const patch = (cy, json1, json2, diff, toJson, get, forEach) => {
4646
'boxSelectionEnabled',
4747
'autoungrabify',
4848
'autolock',
49-
'autounselectify'
50-
].forEach(key => {
49+
'autounselectify',
50+
].forEach((key) => {
5151
if (isDiffAtKey(json1, json2, diff, key)) {
5252
patchJson(cy, key, atKey(json1, key), atKey(json2, key), toJson);
5353
}
@@ -87,19 +87,19 @@ const patchElements = (cy, eles1, eles2, toJson, get, forEach, diff) => {
8787
const toPatch = [];
8888
const eles1Map = {};
8989
const eles2Map = {};
90-
const eles1HasId = id => eles1Map[id] != null;
91-
const eles2HasId = id => eles2Map[id] != null;
92-
const getEle1 = id => eles1Map[id];
93-
const getId = ele => get(get(ele, 'data'), 'id');
90+
const eles1HasId = (id) => eles1Map[id] != null;
91+
const eles2HasId = (id) => eles2Map[id] != null;
92+
const getEle1 = (id) => eles1Map[id];
93+
const getId = (ele) => get(get(ele, 'data'), 'id');
9494

95-
forEach(eles2, ele2 => {
95+
forEach(eles2, (ele2) => {
9696
const id = getId(ele2);
9797

9898
eles2Map[id] = ele2;
9999
});
100100

101101
if (eles1 != null) {
102-
forEach(eles1, ele1 => {
102+
forEach(eles1, (ele1) => {
103103
const id = getId(ele1);
104104

105105
eles1Map[id] = ele1;
@@ -110,7 +110,7 @@ const patchElements = (cy, eles1, eles2, toJson, get, forEach, diff) => {
110110
});
111111
}
112112

113-
forEach(eles2, ele2 => {
113+
forEach(eles2, (ele2) => {
114114
const id = getId(ele2);
115115
const ele1 = getEle1(id);
116116

@@ -138,17 +138,17 @@ const patchElement = (cy, ele1, ele2, toJson, get, diff) => {
138138
const id = get(get(ele2, 'data'), 'id');
139139
const cyEle = cy.getElementById(id);
140140
const patch = {};
141-
let jsonKeys = [
141+
const jsonKeys = [
142142
'data',
143143
'position',
144144
'selected',
145145
'selectable',
146146
'locked',
147147
'grabbable',
148-
'classes'
148+
'classes',
149149
];
150150

151-
jsonKeys.forEach(key => {
151+
jsonKeys.forEach((key) => {
152152
const data2 = get(ele2, key);
153153

154154
if (diff(data2, get(ele1, key))) {

src/types.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,5 +271,5 @@ export const types = {
271271
* A rendering hint that specifies, for renderers which support the hint, the pixel ratio that
272272
* should be used. May be 'auto' or a positive number.
273273
*/
274-
pixelRatio: oneOfType([string, object])
274+
pixelRatio: oneOfType([string, object]),
275275
};

0 commit comments

Comments
 (0)