Skip to content

Commit

Permalink
chore(dev): fix lint/prettier flows
Browse files Browse the repository at this point in the history
  • Loading branch information
STRML committed Dec 17, 2021
1 parent ee87a83 commit 556eceb
Show file tree
Hide file tree
Showing 14 changed files with 119 additions and 108 deletions.
5 changes: 3 additions & 2 deletions .babelrc.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
// @flow

const es6Compat = process.env.BABEL_ES_COMPAT === "6" || process.env.NODE_ENV === "test";
const es6Compat =
process.env.BABEL_ES_COMPAT === "6" || process.env.NODE_ENV === "test";

module.exports = {
presets: [
[
"@babel/preset-env",
{
targets: es6Compat ? "maintained node versions" : "> 0.25%, not dead"
},
}
],
"@babel/react",
"@babel/preset-flow"
Expand Down
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
node_modules/**/*
build
dist
flow-typed
18 changes: 4 additions & 14 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
{
"root": true,
"parser": "@babel/eslint-parser",
"plugins": [
"react",
"flowtype",
"unicorn"
],
"plugins": ["react", "flowtype", "unicorn"],
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:flowtype/recommended"
],
"rules": {
"no-console": "off",
"no-use-before-define": [
"error",
"nofunc"
],
"no-use-before-define": ["error", "nofunc"],
"no-unused-vars": [
"warn",
{
Expand All @@ -26,10 +19,7 @@
}
],
"prefer-const": "error",
"react/jsx-boolean-value": [
"error",
"always"
],
"react/jsx-boolean-value": ["error", "always"],
"unicorn/better-regex": "warn",
"unicorn/expiring-todo-comments": "error",
"unicorn/no-abusive-eslint-disable": "error"
Expand All @@ -44,4 +34,4 @@
"version": "detect"
}
}
}
}
72 changes: 33 additions & 39 deletions .github/changelog-configuration.json
Original file line number Diff line number Diff line change
@@ -1,41 +1,35 @@
{
"categories": [
{
"title": "## 🚀 Features",
"labels": ["feature"]
},
{
"title": "## 🐛 Fixes",
"labels": ["fix"]
},
{
"title": "## 🧪 Tests",
"labels": ["test"]
}
],
"ignore_labels": [
"ignore_changelog"
],
"sort": "ASC",
"template": "${{CHANGELOG}}\n\n<details open>\n<summary>Uncategorized</summary>\n\n${{UNCATEGORIZED}}\n</details>",
"pr_template": "- ${{TITLE}}\n - PR: #${{NUMBER}}",
"empty_template": "- no changes",
"label_extractor": [
{
"pattern": "\\[Issue\\]",
"on_property": "title",
"method": "match"
}
],
"transformers": [
],
"max_tags_to_fetch": 200,
"max_pull_requests": 200,
"max_back_track_time_days": 365,
"exclude_merge_branches": [
],
"tag_resolver": {
"categories": [
{
"title": "## 🚀 Features",
"labels": ["feature"]
},
"base_branches": [
]
}
{
"title": "## 🐛 Fixes",
"labels": ["fix"]
},
{
"title": "## 🧪 Tests",
"labels": ["test"]
}
],
"ignore_labels": ["ignore_changelog"],
"sort": "ASC",
"template": "${{CHANGELOG}}\n\n<details open>\n<summary>Uncategorized</summary>\n\n${{UNCATEGORIZED}}\n</details>",
"pr_template": "- ${{TITLE}}\n - PR: #${{NUMBER}}",
"empty_template": "- no changes",
"label_extractor": [
{
"pattern": "\\[Issue\\]",
"on_property": "title",
"method": "match"
}
],
"transformers": [],
"max_tags_to_fetch": 200,
"max_pull_requests": 200,
"max_back_track_time_days": 365,
"exclude_merge_branches": [],
"tag_resolver": {},
"base_branches": []
}
2 changes: 1 addition & 1 deletion .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ infrastructure:
- .travis.yml
- build.sh
- package.json
- webpack*
- webpack*
6 changes: 3 additions & 3 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: 'changelog'
name: "changelog"
on:
push:
tags:
- '*'
- "*"

jobs:
release:
Expand All @@ -27,4 +27,4 @@ jobs:
release_name: ${{ github.ref }}
body: ${{steps.github_release.outputs.changelog}}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build and Deploy to GitHub Pages
on:
push:
tags:
- '*'
- "*"
jobs:
build-and-deploy:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name: Pull request labeler
on:
schedule:
- cron: '*/5 * * * *'
- cron: "*/5 * * * *"
jobs:
labeler:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ jobs:

# Flow is not supported by lint-action, so we run it raw
- name: Run Flow
run: yarn flow
run: yarn flow
22 changes: 11 additions & 11 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
name: "Close stale issues and PRs"
on:
schedule:
- cron: "0 0,6,12,18 * * *"
- cron: "0 0,6,12,18 * * *"

jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this issue will be closed in 7 days'
stale-pr-message: 'This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this PR will be closed in 7 days'
stale-pr-label: 'stale'
exempt-pr-label: 'stale'
days-before-stale: 90
days-before-close: 30
operations-per-run: 30
- uses: actions/stale@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: "This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this issue will be closed in 7 days"
stale-pr-message: "This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this PR will be closed in 7 days"
stale-pr-label: "stale"
exempt-pr-label: "stale"
days-before-stale: 90
days-before-close: 30
operations-per-run: 30
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
dist/
examples/
__mocks__/
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ view-example:
# FIXME flow is usually global
lint:
@$(BIN)/flow
@$(BIN)/eslint --ext .js,.jsx $(LIB) $(TEST)
@$(BIN)/eslint --ext .js,.jsx

test:
env NODE_ENV=test $(BIN)/jest
Expand Down
8 changes: 4 additions & 4 deletions test/dev-hook.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'react-hot-loader';
import { hot } from 'react-hot-loader/root';
import DevLayout from './examples/0-showcase.jsx';
import makeLayout from './test-hook';
import "react-hot-loader";
import { hot } from "react-hot-loader/root";
import DevLayout from "./examples/0-showcase.jsx";
import makeLayout from "./test-hook";

const Layout = makeLayout(DevLayout);

Expand Down
82 changes: 52 additions & 30 deletions test/spec/lifecycle-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,60 +37,82 @@ describe("Lifecycle tests", function () {
expect(wrapper).toMatchSnapshot();
});

describe('data-grid', () => {
describe("data-grid", () => {
it("Creates layout based on properties", async function () {
const wrapper = mount(
<ReactGridLayout className="layout" cols={12} rowHeight={30} width={1200}>
<div key="a" data-grid={{x: 0, y: 0, w: 1, h: 2, static: true}}>a</div>
<div key="b" data-grid={{x: 1, y: 0, w: 3, h: 2, minW: 2, maxW: 4}}>b</div>
<div key="c" data-grid={{x: 4, y: 0, w: 1, h: 2}}>c</div>
<ReactGridLayout
className="layout"
cols={12}
rowHeight={30}
width={1200}
>
<div key="a" data-grid={{ x: 0, y: 0, w: 1, h: 2, static: true }}>
a
</div>
<div
key="b"
data-grid={{ x: 1, y: 0, w: 3, h: 2, minW: 2, maxW: 4 }}
>
b
</div>
<div key="c" data-grid={{ x: 4, y: 0, w: 1, h: 2 }}>
c
</div>
</ReactGridLayout>
);
expect(wrapper).toMatchSnapshot();
expect(wrapper.state().layout).toMatchObject([
{
"h": 2,
"i": "a",
"static": true,
"w": 1,
"x": 0,
"y": 0,
h: 2,
i: "a",
static: true,
w: 1,
x: 0,
y: 0
},
{
"h": 2,
"i": "b",
"static": false,
"w": 3,
"x": 1,
"y": 0,
h: 2,
i: "b",
static: false,
w: 3,
x: 1,
y: 0
},
{
"h": 2,
"i": "c",
"static": false,
"w": 1,
"x": 4,
"y": 0,
},
h: 2,
i: "c",
static: false,
w: 1,
x: 4,
y: 0
}
]);
});

it("Null items in list", async function () {
const wrapper = mount(
// $FlowIgnore
<ReactGridLayout className="layout" cols={12} rowHeight={30} width={1200}>
<div key="a" data-grid={{x: 0, y: 0, w: 1, h: 2, static: true}}>a</div>
<ReactGridLayout
className="layout"
cols={12}
rowHeight={30}
width={1200}
// $FlowIgnore
>
<div key="a" data-grid={{ x: 0, y: 0, w: 1, h: 2, static: true }}>
a
</div>
{false}
{null}
<div key="c" data-grid={{x: 4, y: 0, w: 1, h: 2}}>c</div>
<div key="c" data-grid={{ x: 4, y: 0, w: 1, h: 2 }}>
c
</div>
</ReactGridLayout>
);

expect(wrapper).toMatchSnapshot();
expect(wrapper.state().layout).toHaveLength(2); // Only two truthy items
});
})

});

describe("WidthProvider", () => {
it("Renders with WidthProvider", async function () {
Expand Down

0 comments on commit 556eceb

Please sign in to comment.