diff --git a/.eslintrc b/.eslintrc deleted file mode 100755 index ecfd5dc..0000000 --- a/.eslintrc +++ /dev/null @@ -1,57 +0,0 @@ -{ - "parser": "babel-eslint", - "plugins": [ - "react" - ], - "env": { - "browser": true, - "node": true, - "es6": true, - "mocha": true - }, - "globals": { - "__DEV__": true, - "__SERVER__": true - }, - "ecmaFeatures": { - "jsx": true - }, - "rules": { - // Strict mode - "strict": [2, "never"], - - // Code style - "indent": [2, 2], - "quotes": [2, "single"], - "no-unused-vars": 1, - "no-undef": 1, - "object-curly-spacing": [2, "always"], - - // JSX - "jsx-quotes": 1, - - // React - "react/display-name": 0, - "react/jsx-boolean-value": 1, - "react/jsx-closing-bracket-location": 1, - "react/jsx-curly-spacing": 1, - "react/jsx-max-props-per-line": 0, - "react/jsx-indent-props": 0, - "react/jsx-no-duplicate-props": 1, - "react/jsx-no-undef": 1, - "react/jsx-sort-prop-types": 0, - "react/jsx-sort-props": 0, - "react/jsx-uses-react": 1, - "react/jsx-uses-vars": 1, - "react/no-danger": 0, - "react/no-set-state": 0, - "react/no-did-mount-set-state": 1, - "react/no-did-update-set-state": 1, - "react/no-multi-comp": 1, - "react/no-unknown-property": 1, - //"react/prop-types": 1, // does not work with inherited propTypes - "react/require-extension": 1, - "react/self-closing-comp": 1, - "react/wrap-multilines": 1 - } -} diff --git a/.eslintrc.yml b/.eslintrc.yml new file mode 100755 index 0000000..66a726c --- /dev/null +++ b/.eslintrc.yml @@ -0,0 +1,53 @@ +parser: babel-eslint + +plugins: + - react + +extends: + - plugin:import/errors + - plugin:import/warnings + +env: + browser: true + node: true + es6: true + mocha: true + +ecmaFeatures: + jsx: true + +rules: + # Strict mode + strict: [2, never] + + # Code style + indent: [2, 2] + quotes: [2, single] + no-unused-vars: 1 + no-undef: 1 + object-curly-spacing: [2, always] + + # JSX + jsx-quotes: 1 + + # React + react/display-name: 0 + react/jsx-boolean-value: 1 + react/jsx-closing-bracket-location: 1 + react/jsx-curly-spacing: 1 + react/jsx-max-props-per-line: 0 + react/jsx-indent-props: 0 + react/jsx-no-duplicate-props: 1 + react/jsx-no-undef: 1 + react/jsx-sort-prop-types: 0 + react/jsx-sort-props: 0 + react/jsx-uses-react: 1 + react/jsx-uses-vars: 1 + react/no-danger: 0 + react/no-set-state: 0 + react/no-did-mount-set-state: 1 + react/no-did-update-set-state: 1 + react/no-multi-comp: 1 + react/no-unknown-property: 1 + react/self-closing-comp: 1 + react/jsx-wrap-multilines: 1 diff --git a/.npmignore b/.npmignore index d75113c..d73e948 100644 --- a/.npmignore +++ b/.npmignore @@ -11,3 +11,4 @@ /node_modules /playground /test +/yarn.lock diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f178c2..51d4138 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # CHANGELOG +## 0.2.0 (April 17th, 2017) + +- Added prop-types package to be compatible with React 16 +- Added typescript definitions + ## 0.1.10 (September 22th, 2016) - Fixed issue with IE diff --git a/LICENSE.txt b/LICENSE similarity index 96% rename from LICENSE.txt rename to LICENSE index 27cd8c4..e5dbd3f 100644 --- a/LICENSE.txt +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright © 2016 Gabriel Bull +Copyright © 2016-present Gabriel Bull Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..e0844c9 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,27 @@ +export as namespace ReactAim; +export = ReactAim; + +import { Component, ReactElement } from 'react'; + +declare namespace ReactAim { + type TargetSpec = { + mouseEnter: (props: any, component: ReactElement) => void, + mouseLeave: (props, component: ReactElement) => void, + aimMove: (props, component: ReactElement, distance: number) => void, + aimStart: (props, component: ReactElement, distance: number) => void, + aimStop: (props, component: ReactElement) => void + } + + function target(): Component; + function target(spec: TargetSpec): Component; + function target(source: any, spec: TargetSpec): Component; + + type SourceSpec = { + mouseEnter: (props: any, component: ReactElement) => void, + mouseLeave: (props, component: ReactElement) => void, + }; + + function source(): Component; + function source(spec: SourceSpec): Component; + function source(target: any, spec: SourceSpec): Component; +} diff --git a/package.json b/package.json index 56492cf..60aa5cc 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,10 @@ { "name": "react-aim", "author": "Gabriel Bull", - "version": "0.1.10", + "version": "0.2.0", "description": "Determine the cursor aim for triggering mouse events.", "main": "./lib/index.js", + "types": "./index.d.ts", "keywords": [ "react", "react-component", @@ -40,6 +41,7 @@ "react-dom": "^15.0 || ^16.0" }, "devDependencies": { + "@types/react": "^15.0.22", "babel-core": "^6.24.1", "babel-eslint": "^7.2.2", "babel-loader": "^6.4.1", @@ -49,6 +51,7 @@ "babel-preset-stage-0": "^6.24.1", "chai": "^3.5.0", "eslint": "^3.19.0", + "eslint-plugin-import": "^2.2.0", "eslint-plugin-react": "^6.10.3", "html-webpack-plugin": "^2.28.0", "mocha": "^3.2.0", diff --git a/src/source.js b/src/source.js index 1fa8ed4..69eb6a4 100644 --- a/src/source.js +++ b/src/source.js @@ -1,4 +1,5 @@ -import React, { Component, PropTypes } from 'react'; +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; import ReactDOM from 'react-dom'; import monitor from './monitor' diff --git a/src/target.js b/src/target.js index 679f793..28e8ce8 100644 --- a/src/target.js +++ b/src/target.js @@ -1,4 +1,5 @@ -import React, { Component, PropTypes } from 'react'; +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; import ReactDOM from 'react-dom'; import monitor from './monitor'