Skip to content

Commit 11544fe

Browse files
TrySoundSTRML
authored andcommitted
Reduce eslint config (react-grid-layout#686)
* Reduce eslint config * Tweak name
1 parent aee8228 commit 11544fe

21 files changed

+44
-119
lines changed

.eslintrc

-50
This file was deleted.

.eslintrc.json

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"root": true,
3+
"parser": "babel-eslint",
4+
"plugins": [
5+
"react",
6+
"flowtype"
7+
],
8+
"extends": [
9+
"eslint:recommended",
10+
"plugin:react/recommended",
11+
"plugin:flowtype/recommended"
12+
],
13+
"rules": {
14+
"no-console": 0,
15+
"no-use-before-define": [2, "nofunc"],
16+
"prefer-const": 2,
17+
"react/jsx-boolean-value": [2, "always"]
18+
},
19+
"env": {
20+
"browser": true,
21+
"node": true,
22+
"es6": true
23+
}
24+
}

lib/ResponsiveReactGridLayout.jsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ export default class ResponsiveReactGridLayout extends React.Component<
240240
}
241241

242242
render() {
243-
// eslint-disable-next-line no-unused-vars
243+
/* eslint-disable no-unused-vars */
244244
const {
245245
breakpoint,
246246
breakpoints,
@@ -251,6 +251,7 @@ export default class ResponsiveReactGridLayout extends React.Component<
251251
onWidthChange,
252252
...other
253253
} = this.props;
254+
/* eslint-enable no-unused-vars */
254255

255256
return (
256257
<ReactGridLayout

lib/components/WidthProvider.jsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type ProviderT = (
2121
ComposedComponent: ReactComponentType<any>
2222
) => ReactComponentType<any>;
2323
const WidthProvider: ProviderT = ComposedComponent =>
24-
class extends React.Component<Props, State> {
24+
class WidthProvider extends React.Component<Props, State> {
2525
static defaultProps = {
2626
measureBeforeMount: false
2727
};
@@ -53,8 +53,9 @@ const WidthProvider: ProviderT = ComposedComponent =>
5353
window.removeEventListener("resize", this.onWindowResize);
5454
}
5555

56-
onWindowResize = (_event: ?Event) => {
56+
onWindowResize = () => {
5757
if (!this.mounted) return;
58+
// eslint-disable-next-line
5859
const node = ReactDOM.findDOMNode(this); // Flow casts this to Text | Element
5960
if (node instanceof HTMLElement)
6061
this.setState({ width: node.offsetWidth });

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"css-loader": "^0.28.7",
6060
"ejs": "^2.4.1",
6161
"eslint": "^4.13.0",
62+
"eslint-plugin-flowtype": "^2.40.1",
6263
"eslint-plugin-mocha": "^4.11.0",
6364
"eslint-plugin-react": "^7.5.1",
6465
"exports-loader": "^0.6.4",

test/examples/.eslintrc.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"rules": {
3+
"react/prop-types": 0
4+
}
5+
}

test/examples/0-showcase.jsx

-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
import React from "react";
2-
import PropTypes from "prop-types";
32
import _ from "lodash";
43
import { Responsive, WidthProvider } from "react-grid-layout";
54
const ResponsiveReactGridLayout = WidthProvider(Responsive);
65

76
class ShowcaseLayout extends React.Component {
8-
static propTypes = {
9-
onLayoutChange: PropTypes.func.isRequired
10-
};
11-
127
static defaultProps = {
138
className: "layout",
149
rowHeight: 30,

test/examples/1-basic.jsx

-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
import React from "react";
2-
import PropTypes from "prop-types";
32
import _ from "lodash";
43
import RGL, { WidthProvider } from "react-grid-layout";
54

65
const ReactGridLayout = WidthProvider(RGL);
76

87
class BasicLayout extends React.PureComponent {
9-
static propTypes = {
10-
onLayoutChange: PropTypes.func.isRequired
11-
};
12-
138
static defaultProps = {
149
className: "layout",
1510
items: 20,

test/examples/10-dynamic-min-max-wh.jsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from "react";
2-
import PropTypes from "prop-types";
32
import _ from "lodash";
43
import RGL, { WidthProvider } from "react-grid-layout";
54

@@ -52,7 +51,7 @@ class DynamicMinMaxLayout extends React.PureComponent {
5251
this.props.onLayoutChange(layout);
5352
}
5453

55-
onResize(layout, oldLayoutItem, layoutItem, placeholder, e) {
54+
onResize(layout, oldLayoutItem, layoutItem, placeholder) {
5655
// `oldLayoutItem` contains the state of the item before the resize.
5756
// You can modify `layoutItem` to enforce constraints.
5857

test/examples/11-no-vertical-compact.jsx

-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
import React from "react";
2-
import PropTypes from "prop-types";
32
import _ from "lodash";
43
import RGL, { WidthProvider } from "react-grid-layout";
54

65
const ReactGridLayout = WidthProvider(RGL);
76

87
class NoCompactingLayout extends React.PureComponent {
9-
static propTypes = {
10-
onLayoutChange: PropTypes.func.isRequired
11-
};
12-
138
static defaultProps = {
149
className: "layout",
1510
items: 50,

test/examples/12-prevent-collision.jsx

-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
import React from "react";
2-
import PropTypes from "prop-types";
32
import _ from "lodash";
43
import RGL, { WidthProvider } from "react-grid-layout";
54

65
const ReactGridLayout = WidthProvider(RGL);
76

87
class NoCompactingLayout extends React.PureComponent {
9-
static propTypes = {
10-
onLayoutChange: PropTypes.func.isRequired
11-
};
12-
138
static defaultProps = {
149
className: "layout",
1510
items: 50,

test/examples/13-error-case.jsx

-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
import React from "react";
2-
import PropTypes from "prop-types";
32
import RGL, { WidthProvider } from "react-grid-layout";
43

54
const ReactGridLayout = WidthProvider(RGL);
65

76
class BasicLayout extends React.PureComponent {
8-
static propTypes = {
9-
onLayoutChange: PropTypes.func.isRequired
10-
};
11-
127
static defaultProps = {
138
className: "layout",
149
items: 3,

test/examples/2-no-dragging.jsx

-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
import React from "react";
2-
import PropTypes from "prop-types";
32
import _ from "lodash";
43
import RGL, { WidthProvider } from "react-grid-layout";
54

65
const ReactGridLayout = WidthProvider(RGL);
76

87
class NoDraggingLayout extends React.PureComponent {
9-
static propTypes: {
10-
onLayoutChange: PropTypes.func.isRequired
11-
};
12-
138
static defaultProps = {
149
className: "layout",
1510
isDraggable: false,

test/examples/3-messy.jsx

-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
import React from "react";
2-
import PropTypes from "prop-types";
32
import _ from "lodash";
43
import RGL, { WidthProvider } from "react-grid-layout";
54

65
const ReactGridLayout = WidthProvider(RGL);
76

87
class MessyLayout extends React.PureComponent {
9-
static propTypes = {
10-
onLayoutChange: PropTypes.func.isRequired
11-
};
12-
138
static defaultProps = {
149
className: "layout",
1510
items: 20,

test/examples/4-grid-property.jsx

-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
import React from "react";
2-
import PropTypes from "prop-types";
32
import _ from "lodash";
43
import RGL, { WidthProvider } from "react-grid-layout";
54

65
const ReactGridLayout = WidthProvider(RGL);
76

87
class GridPropertyLayout extends React.PureComponent {
9-
static propTypes = {
10-
onLayoutChange: PropTypes.func.isRequired
11-
};
12-
138
static defaultProps = {
149
isDraggable: true,
1510
isResizable: true,

test/examples/5-static-elements.jsx

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import React from "react";
2-
import PropTypes from "prop-types";
3-
import _ from "lodash";
42
import RGL, { WidthProvider } from "react-grid-layout";
53

64
const ReactGridLayout = WidthProvider(RGL);

test/examples/7-localstorage.jsx

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import React from "react";
2-
import PropTypes from "prop-types";
3-
import _ from "lodash";
42
import RGL, { WidthProvider } from "react-grid-layout";
53

64
const ReactGridLayout = WidthProvider(RGL);
@@ -45,7 +43,6 @@ class LocalStorageLayout extends React.PureComponent {
4543
<div>
4644
<button onClick={this.resetLayout}>Reset Layout</button>
4745
<ReactGridLayout
48-
ref="rgl"
4946
{...this.props}
5047
layout={this.state.layout}
5148
onLayoutChange={this.onLayoutChange}

test/examples/9-min-max-wh.jsx

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from "react";
2-
import PropTypes from "prop-types";
32
import _ from "lodash";
43
import RGL, { WidthProvider } from "react-grid-layout";
54

test/spec/.eslintrc

-17
This file was deleted.

test/spec/utils-test.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// @flow
2+
/* eslint-env jest */
23

34
import {
45
bottom,

yarn.lock

+7-1
Original file line numberDiff line numberDiff line change
@@ -2169,6 +2169,12 @@ escope@^3.6.0:
21692169
esrecurse "^4.1.0"
21702170
estraverse "^4.1.1"
21712171

2172+
eslint-plugin-flowtype@^2.40.1:
2173+
version "2.40.1"
2174+
resolved "https://registry.yarnpkg.com/eslint-plugin-flowtype/-/eslint-plugin-flowtype-2.40.1.tgz#f78a8e6a4cc6da831dd541eb61e803ff0279b796"
2175+
dependencies:
2176+
lodash "^4.15.0"
2177+
21722178
eslint-plugin-mocha@^4.11.0:
21732179
version "4.11.0"
21742180
resolved "https://registry.yarnpkg.com/eslint-plugin-mocha/-/eslint-plugin-mocha-4.11.0.tgz#91193a2f55e20a5e35974054a0089d30198ee578"
@@ -3900,7 +3906,7 @@ lodash.uniq@^4.5.0:
39003906
version "4.5.0"
39013907
resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773"
39023908

3903-
lodash@^4.14.0, lodash@^4.17.2, lodash@^4.17.4, lodash@^4.2.0, lodash@^4.3.0, lodash@^4.6.1:
3909+
lodash@^4.14.0, lodash@^4.15.0, lodash@^4.17.2, lodash@^4.17.4, lodash@^4.2.0, lodash@^4.3.0, lodash@^4.6.1:
39043910
version "4.17.4"
39053911
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae"
39063912

0 commit comments

Comments
 (0)