Skip to content

Commit

Permalink
✅ Add eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonpittman committed Sep 13, 2020
1 parent 014a598 commit d41442e
Show file tree
Hide file tree
Showing 7 changed files with 990 additions and 29 deletions.
4 changes: 2 additions & 2 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"presets": ["@babel/preset-env", "@babel/preset-react"]
}
"presets": ["@babel/preset-env", "@babel/preset-react"],
}
Binary file removed animation.gif
Binary file not shown.
28 changes: 25 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
"browser",
"callback"
],
"main": "index.js",
"files": [
"dist"
],
"main": "dist/index.js",
"scripts": {
"build": "babel src --out-dir .",
"bump": "npm version",
"build": "yarn test && babel src --out-dir dist --ignore 'src/__tests__'",
"example": "cd example && yarn install && yarn package",
"prepublishOnly": "yarn build",
"test": "jest",
Expand All @@ -41,8 +43,18 @@
"@testing-library/react": "^11.0.2",
"@testing-library/react-hooks": "^3.4.1",
"@testing-library/user-event": "^12.1.4",
"eslint": "^7.9.0",
"eslint-plugin-jest": "^24.0.1",
"eslint-plugin-jest-dom": "^3.2.3",
"eslint-plugin-jsx-a11y": "^6.3.1",
"eslint-plugin-react": "^7.20.6",
"eslint-plugin-react-hooks": "^4.1.2",
"eslint-plugin-testing-library": "^3.8.0",
"husky": ">=4",
"jest": "^26.4.2",
"lint-staged": ">=10",
"nodemon": "^2.0.2",
"prettier": "^2.1.1",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-test-renderer": "^16.13.1"
Expand All @@ -56,5 +68,15 @@
},
"peerDependencies": {
"react": "^16.13.1"
},
"dependencies": {},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.{js,jsx,ts,tsx,mdx,html,css,md}": "prettier --write",
"*.{js,jsx,ts,tsx}": "eslint --cache --fix"
}
}
1 change: 0 additions & 1 deletion src/__tests__/useDismiss.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from "react";
import { render, screen } from "@testing-library/react";
import "@testing-library/jest-dom";
import userEvent from "@testing-library/user-event";
import useDismiss from "..";

Expand Down
1 change: 0 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export { useClickAway } from "./useDismiss";
export { useEscape } from "./useDismiss";
export { default } from "./useDismiss";

8 changes: 4 additions & 4 deletions src/useDismiss.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const containsRef = (ref, event) => ref.current.contains(event.target);
export const useClickAway = (callback) => {
const ref = useRef(null);
useEffect(() => {
const listener = (event) => {
const listener = (event) => {
if (!ref || !ref.current || containsRef(ref, event)) {
return;
}
Expand All @@ -20,7 +20,7 @@ export const useClickAway = (callback) => {
};
}, [callback]);

return ref
return ref;
};

export const useEscape = (callback) => {
Expand All @@ -39,7 +39,7 @@ export const useEscape = (callback) => {
};
}, [callback]);

return ref
return ref;
};

const useDismiss = (callback) => {
Expand Down Expand Up @@ -67,7 +67,7 @@ const useDismiss = (callback) => {
};
}, [callback]);

return ref
return ref;
};

export default useDismiss;
Loading

0 comments on commit d41442e

Please sign in to comment.