Skip to content

Commit e6879dd

Browse files
committed
chore(dev): rework lint action and proper pre-commit linting
1 parent 556eceb commit e6879dd

File tree

8 files changed

+435
-328
lines changed

8 files changed

+435
-328
lines changed

.github/workflows/lint.yml

+5-9
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,15 @@ jobs:
2020
uses: actions/checkout@v2
2121

2222
- name: Set up Node.js
23-
uses: actions/setup-node@v1
23+
uses: actions/setup-node@v2
2424
with:
2525
node-version: 14
2626

2727
- name: Install Node.js dependencies
2828
run: yarn
2929

30-
- name: Run linters
31-
uses: wearerequired/lint-action@v1
32-
with:
33-
eslint: true
34-
prettier: true
30+
- name: Run Prettier
31+
run: yarn fmt:check
3532

36-
# Flow is not supported by lint-action, so we run it raw
37-
- name: Run Flow
38-
run: yarn flow
33+
- name: Run ESLint/Flow
34+
run: yarn lint

.husky/pre-commit

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
. "$(dirname "$0")/_/husky.sh"
33

44
yarn lint-staged
5-
make lint
5+
yarn flow
66
make test

.travis.yml

-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ node_js:
66
script:
77
- make build test
88
cache: yarn
9-

CHANGELOG.md

+353-265
Large diffs are not rendered by default.

README.md

+65-47
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ or autogenerated.
1414
RGL is React-only and does not require jQuery.
1515

1616
![BitMEX UI](http://i.imgur.com/oo1NT6c.gif)
17+
1718
> GIF from production usage on [BitMEX.com](https://www.bitmex.com)
1819
1920
[**[Demo](https://react-grid-layout.github.io/react-grid-layout/) | [Changelog](/CHANGELOG.md) | [CodeSandbox Editable demo](https://codesandbox.io/s/5wy3rz5z1x?module=%2Fsrc%2FShowcaseLayout.js)**]
@@ -77,32 +78,32 @@ RGL is React-only and does not require jQuery.
7778
- [Statsout](https://statsout.com/)
7879
- [Datto RMM](https://www.datto.com/uk/products/rmm/)
7980

80-
*Know of others? Create a PR to let me know!*
81+
_Know of others? Create a PR to let me know!_
8182

8283
## Features
8384

84-
* 100% React - no jQuery
85-
* Compatible with server-rendered apps
86-
* Draggable widgets
87-
* Resizable widgets
88-
* Static widgets
89-
* Configurable packing: horizontal, vertical, or off
90-
* Bounds checking for dragging and resizing
91-
* Widgets may be added or removed without rebuilding grid
92-
* Layout can be serialized and restored
93-
* Responsive breakpoints
94-
* Separate layouts per responsive breakpoint
95-
* Grid Items placed using CSS Transforms
96-
* Performance with CSS Transforms: [on](http://i.imgur.com/FTogpLp.jpg) / [off](http://i.imgur.com/gOveMm8.jpg), note paint (green) as % of time
97-
* Compatibility with `<React.StrictMode>`
98-
99-
|Version | Compatibility |
100-
|----------------|------------------|
101-
| >= 0.17.0 | React 16 & 17 |
102-
| >= 0.11.3 | React 0.14 & 15 |
103-
| >= 0.10.0 | React 0.14 |
104-
| 0.8. - 0.9.2 | React 0.13 |
105-
| < 0.8 | React 0.12 |
85+
- 100% React - no jQuery
86+
- Compatible with server-rendered apps
87+
- Draggable widgets
88+
- Resizable widgets
89+
- Static widgets
90+
- Configurable packing: horizontal, vertical, or off
91+
- Bounds checking for dragging and resizing
92+
- Widgets may be added or removed without rebuilding grid
93+
- Layout can be serialized and restored
94+
- Responsive breakpoints
95+
- Separate layouts per responsive breakpoint
96+
- Grid Items placed using CSS Transforms
97+
- Performance with CSS Transforms: [on](http://i.imgur.com/FTogpLp.jpg) / [off](http://i.imgur.com/gOveMm8.jpg), note paint (green) as % of time
98+
- Compatibility with `<React.StrictMode>`
99+
100+
| Version | Compatibility |
101+
| ------------ | --------------- |
102+
| >= 0.17.0 | React 16 & 17 |
103+
| >= 0.11.3 | React 0.14 & 15 |
104+
| >= 0.10.0 | React 0.14 |
105+
| 0.8. - 0.9.2 | React 0.13 |
106+
| < 0.8 | React 0.12 |
106107

107108
## Installation
108109

@@ -129,41 +130,53 @@ produce a grid with three items where:
129130
- users will be able to freely drag and resize item `c`
130131

131132
```js
132-
import GridLayout from 'react-grid-layout';
133+
import GridLayout from "react-grid-layout";
133134

134135
class MyFirstGrid extends React.Component {
135136
render() {
136137
// layout is an array of objects, see the demo for more complete usage
137138
const layout = [
138-
{i: 'a', x: 0, y: 0, w: 1, h: 2, static: true},
139-
{i: 'b', x: 1, y: 0, w: 3, h: 2, minW: 2, maxW: 4},
140-
{i: 'c', x: 4, y: 0, w: 1, h: 2}
139+
{ i: "a", x: 0, y: 0, w: 1, h: 2, static: true },
140+
{ i: "b", x: 1, y: 0, w: 3, h: 2, minW: 2, maxW: 4 },
141+
{ i: "c", x: 4, y: 0, w: 1, h: 2 }
141142
];
142143
return (
143-
<GridLayout className="layout" layout={layout} cols={12} rowHeight={30} width={1200}>
144+
<GridLayout
145+
className="layout"
146+
layout={layout}
147+
cols={12}
148+
rowHeight={30}
149+
width={1200}
150+
>
144151
<div key="a">a</div>
145152
<div key="b">b</div>
146153
<div key="c">c</div>
147154
</GridLayout>
148-
)
155+
);
149156
}
150157
}
151158
```
152159

153160
You may also choose to set layout properties directly on the children:
154161

155162
```js
156-
import GridLayout from 'react-grid-layout';
163+
import GridLayout from "react-grid-layout";
157164

158165
class MyFirstGrid extends React.Component {
159166
render() {
160167
return (
161168
<GridLayout className="layout" cols={12} rowHeight={30} width={1200}>
162-
<div key="a" data-grid={{x: 0, y: 0, w: 1, h: 2, static: true}}>a</div>
163-
<div key="b" data-grid={{x: 1, y: 0, w: 3, h: 2, minW: 2, maxW: 4}}>b</div>
164-
<div key="c" data-grid={{x: 4, y: 0, w: 1, h: 2}}>c</div>
169+
<div key="a" data-grid={{ x: 0, y: 0, w: 1, h: 2, static: true }}>
170+
a
171+
</div>
172+
<div key="b" data-grid={{ x: 1, y: 0, w: 3, h: 2, minW: 2, maxW: 4 }}>
173+
b
174+
</div>
175+
<div key="c" data-grid={{ x: 4, y: 0, w: 1, h: 2 }}>
176+
c
177+
</div>
165178
</GridLayout>
166-
)
179+
);
167180
}
168181
}
169182
```
@@ -178,21 +191,24 @@ excludes `React`, so it must be otherwise available in your application, either
178191
To make RGL responsive, use the `<ResponsiveReactGridLayout>` element:
179192

180193
```js
181-
import { Responsive as ResponsiveGridLayout } from 'react-grid-layout';
194+
import { Responsive as ResponsiveGridLayout } from "react-grid-layout";
182195

183196
class MyResponsiveGrid extends React.Component {
184197
render() {
185198
// {lg: layout1, md: layout2, ...}
186199
const layouts = getLayoutsFromSomewhere();
187200
return (
188-
<ResponsiveGridLayout className="layout" layouts={layouts}
189-
breakpoints={{lg: 1200, md: 996, sm: 768, xs: 480, xxs: 0}}
190-
cols={{lg: 12, md: 10, sm: 6, xs: 4, xxs: 2}}>
201+
<ResponsiveGridLayout
202+
className="layout"
203+
layouts={layouts}
204+
breakpoints={{ lg: 1200, md: 996, sm: 768, xs: 480, xxs: 0 }}
205+
cols={{ lg: 12, md: 10, sm: 6, xs: 4, xxs: 2 }}
206+
>
191207
<div key="1">1</div>
192208
<div key="2">2</div>
193209
<div key="3">3</div>
194210
</ResponsiveGridLayout>
195-
)
211+
);
196212
}
197213
}
198214
```
@@ -215,7 +231,7 @@ positions on drag events. In simple cases a HOC `WidthProvider` can be used to a
215231
width upon initialization and window resize events.
216232

217233
```js
218-
import { Responsive, WidthProvider } from 'react-grid-layout';
234+
import { Responsive, WidthProvider } from "react-grid-layout";
219235

220236
const ResponsiveGridLayout = WidthProvider(Responsive);
221237

@@ -224,14 +240,17 @@ class MyResponsiveGrid extends React.Component {
224240
// {lg: layout1, md: layout2, ...}
225241
var layouts = getLayoutsFromSomewhere();
226242
return (
227-
<ResponsiveGridLayout className="layout" layouts={layouts}
228-
breakpoints={{lg: 1200, md: 996, sm: 768, xs: 480, xxs: 0}}
229-
cols={{lg: 12, md: 10, sm: 6, xs: 4, xxs: 2}}>
243+
<ResponsiveGridLayout
244+
className="layout"
245+
layouts={layouts}
246+
breakpoints={{ lg: 1200, md: 996, sm: 768, xs: 480, xxs: 0 }}
247+
cols={{ lg: 12, md: 10, sm: 6, xs: 4, xxs: 2 }}
248+
>
230249
<div key="1">1</div>
231250
<div key="2">2</div>
232251
<div key="3">3</div>
233252
</ResponsiveGridLayout>
234-
)
253+
);
235254
}
236255
}
237256
```
@@ -494,7 +513,6 @@ will be draggable, even if the item is marked `static: true`.
494513
495514
`<ReactGridLayout>` has [an optimized `shouldComponentUpdate` implementation](lib/ReactGridLayout.jsx), but it relies on the user memoizing the `children` array:
496515
497-
498516
```js
499517
// lib/ReactGridLayout.jsx
500518
// ...
@@ -517,7 +535,7 @@ If you memoize your children, you can take advantage of this, and reap faster re
517535
function MyGrid(props) {
518536
const children = React.useMemo(() => {
519537
return new Array(props.count).fill(undefined).map((val, idx) => {
520-
return <div key={idx} data-grid={{x: idx, y: 1, w: 1, h: 1}} />;
538+
return <div key={idx} data-grid={{ x: idx, y: 1, w: 1, h: 1 }} />;
521539
});
522540
}, [props.count]);
523541
return <ReactGridLayout cols={12}>{children}</ReactGridLayout>;
@@ -540,7 +558,7 @@ const CustomGridItemComponent = React.forwardRef(({style, className, ...props},
540558
return (
541559
<div style={{ /* styles */, ...style}} className={className} ref={ref}>
542560
{/* Some other content */}
543-
</div>
561+
</div>
544562
);
545563
}
546564
```

index-dev.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ module.exports = require("./lib/ReactGridLayout").default;
22
module.exports.utils = require("./lib/utils");
33
module.exports.Responsive = require("./lib/ResponsiveReactGridLayout").default;
44
module.exports.Responsive.utils = require("./lib/responsiveUtils");
5-
module.exports.WidthProvider = require("./lib/components/WidthProvider").default;
5+
module.exports.WidthProvider =
6+
require("./lib/components/WidthProvider").default;

index.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
module.exports = require("./build/ReactGridLayout").default;
22
module.exports.utils = require("./build/utils");
3-
module.exports.Responsive = require("./build/ResponsiveReactGridLayout").default;
3+
module.exports.Responsive =
4+
require("./build/ResponsiveReactGridLayout").default;
45
module.exports.Responsive.utils = require("./build/responsiveUtils");
5-
module.exports.WidthProvider = require("./build/components/WidthProvider").default;
6+
module.exports.WidthProvider =
7+
require("./build/components/WidthProvider").default;

package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
"dev": "make dev",
1313
"prepublishOnly": "make build",
1414
"validate": "npm ls",
15-
"flow": "flow"
15+
"flow": "flow",
16+
"fmt": "prettier --write ./**.{json,js,yml,md}",
17+
"fmt:check": "prettier --check ./**.{json,js,yml,md}"
1618
},
1719
"repository": {
1820
"type": "git",
@@ -106,7 +108,8 @@
106108
},
107109
"lint-staged": {
108110
"*.{js,jsx,css}": [
109-
"prettier --write"
111+
"eslint --ext .js,.jsx --fix",
112+
"yarn fmt"
110113
]
111114
}
112115
}

0 commit comments

Comments
 (0)