Skip to content

Commit

Permalink
Integrate with ESlint.
Browse files Browse the repository at this point in the history
  • Loading branch information
trekhleb committed Jun 29, 2019
1 parent 3d5b07b commit 40162bf
Show file tree
Hide file tree
Showing 5 changed files with 262 additions and 21 deletions.
31 changes: 31 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module.exports = {
"env": {
"browser": true,
"es6": true
},
"extends": [
"google",
"plugin:react/recommended"
],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 2018,
"sourceType": "module"
},
"plugins": [
"react"
],
"settings": {
"react": {
"version": "detect"
},
},
"rules": {
}
};
9 changes: 7 additions & 2 deletions demo/Demo.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from 'react';
import { usePosition } from '../src/usePosition';
import PropTypes from 'prop-types';
import {usePosition} from '../src/usePosition';

export const Demo = ({watch}) => {
const { latitude, longitude, timestamp, accuracy, error } = usePosition(watch);
const {latitude, longitude, timestamp, accuracy, error} = usePosition(watch);

return (
<code>
Expand All @@ -14,3 +15,7 @@ export const Demo = ({watch}) => {
</code>
);
};

Demo.propTypes = {
watch: PropTypes.bool,
};
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
"main": "dist/usePosition.min.js",
"scripts": {
"test": "jest --coverage",
"lint": "eslint src/**/*.js demo/**/*.js",
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook",
"build": "rollup -c -o dist/usePosition.min.js",
"prepublishOnly": "yarn run build",
"ci": "yarn test && yarn build && yarn run build-storybook",
"ci": "yarn run lint && yarn test && yarn build && yarn run build-storybook",
"predeploy": "yarn run ci && yarn run build-storybook",
"deploy": "gh-pages -d storybook-static"
},
Expand Down Expand Up @@ -41,8 +42,12 @@
"@storybook/addons": "^5.1.9",
"@storybook/react": "^5.1.9",
"babel-loader": "^8.0.6",
"eslint": "^6.0.1",
"eslint-config-google": "^0.13.0",
"eslint-plugin-react": "^7.14.2",
"gh-pages": "^2.0.1",
"jest": "^24.8.0",
"prop-types": "^15.7.2",
"react": "^16.8.0",
"react-test-renderer": "^16.8.6",
"rollup": "^1.16.3",
Expand Down
4 changes: 2 additions & 2 deletions src/usePosition.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ export const usePosition = (watch = false) => {
} else {
geo.getCurrentPosition(onChange, onError, settings);
}

return () => watcher && geo.clearWatch(watcher);
}, [settings]);

return { ...position, error };
return {...position, error};
};
Loading

0 comments on commit 40162bf

Please sign in to comment.