Skip to content
Permalink
Browse files

Setup linting and prettier config.

  • Loading branch information...
ghengeveld committed Dec 30, 2018
1 parent 23c5f86 commit c0001565da3a8b4b140fa4d601c8933ff69d9ca7
Showing with 47 additions and 4 deletions.
  1. +23 −0 .eslintrc
  2. +5 −0 .prettierrc
  3. +10 −1 package.json
  4. +9 −3 src/spec.js
@@ -0,0 +1,23 @@
{
"extends": [
"plugin:prettier/recommended",
"plugin:promise/recommended",
"plugin:react/recommended"
],
"parser": "babel-eslint",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
}
},
"plugins": ["jest", "promise", "react"],
"rules": {
"react/display-name": "off",
"react/prop-types": "off"
},
"settings": {
"react": {
"version": "16.3"
}
}
}
@@ -0,0 +1,5 @@
{
"printWidth": 100,
"semi": false,
"trailingComma": "es5"
}
@@ -27,26 +27,35 @@
],
"scripts": {
"build": "babel src -d lib",
"lint": "eslint src",
"test": "jest src",
"test:watch": "npm run test -- --watch",
"test:compat": "npm run test:backwards && npm run test:forwards && npm run test:latest",
"test:backwards": "npm i react@16.3.1 react-dom@16.3.1 && npm test",
"test:forwards": "npm i react@next react-dom@next && npm test",
"test:latest": "npm i react@latest react-dom@latest && npm test",
"prepublishOnly": "npm run test:compat && npm run build"
"prepublishOnly": "npm run lint && npm run test:compat && npm run build"
},
"dependencies": {},
"peerDependencies": {
"react": ">=16.3.1"
},
"devDependencies": {
"babel-cli": "6.26.0",
"babel-eslint": "10.0.1",
"babel-preset-env": "1.7.0",
"babel-preset-flow": "6.23.0",
"babel-preset-react": "6.24.1",
"babel-preset-stage-2": "6.24.1",
"eslint": "5.11.1",
"eslint-config-prettier": "3.3.0",
"eslint-plugin-jest": "22.1.2",
"eslint-plugin-prettier": "3.0.1",
"eslint-plugin-promise": "4.0.1",
"eslint-plugin-react": "7.12.0",
"jest": "23.6.0",
"jest-dom": "2.1.0",
"prettier": "1.15.3",
"react": "16.6.3",
"react-dom": "16.6.3",
"react-testing-library": "5.2.3"
@@ -31,7 +31,9 @@ describe("Async", () => {

test("passes rejection error to children as render prop", async () => {
const promiseFn = () => Promise.reject("oops")
const { getByText } = render(<Async promiseFn={promiseFn}>{({ error }) => error || null}</Async>)
const { getByText } = render(
<Async promiseFn={promiseFn}>{({ error }) => error || null}</Async>
)
await waitForElement(() => getByText("oops"))
})

@@ -110,7 +112,9 @@ describe("Async", () => {
}
}
const promiseFn = jest.fn().mockReturnValue(resolveTo())
const { getByText } = render(<Counter>{count => <Async promiseFn={promiseFn} watch={count} />}</Counter>)
const { getByText } = render(
<Counter>{count => <Async promiseFn={promiseFn} watch={count} />}</Counter>
)
expect(promiseFn).toHaveBeenCalledTimes(1)
fireEvent.click(getByText("increment"))
expect(promiseFn).toHaveBeenCalledTimes(2)
@@ -327,7 +331,9 @@ describe("Async.Resolved", () => {
const deferFn = () => rejectTo("fail")
const { getByText, queryByText } = render(
<Async promiseFn={promiseFn} deferFn={deferFn}>
<Async.Resolved persist>{(data, { run }) => <button onClick={run}>{data}</button>}</Async.Resolved>
<Async.Resolved persist>
{(data, { run }) => <button onClick={run}>{data}</button>}
</Async.Resolved>
<Async.Rejected>{error => error}</Async.Rejected>
</Async>
)

0 comments on commit c000156

Please sign in to comment.
You can’t perform that action at this time.