Skip to content

Commit be49c02

Browse files
committed
add eslint
1 parent 660bb2d commit be49c02

File tree

6 files changed

+433
-22
lines changed

6 files changed

+433
-22
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
[![npm downloads](https://img.shields.io/npm/dm/react-popper-tooltip.svg)](https://www.npmjs.com/package/react-popper-tooltip)
44
[![Dependency Status](https://david-dm.org/mohsinulhaq/react-popper-tooltip.svg)](https://david-dm.org/mohsinulhaq/react-popper-tooltip)
55
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
6+
![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)
67

78
React tooltip component based on [react-popper](https://github.com/FezVrasta/react-popper), the
89
React wrapper around [popper.js](https://popper.js.org/) library.

docs/examples/EscapeToClose.js

100755100644
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import React from 'react';
2+
import T from 'prop-types';
23

34
export default class EscapeToClose extends React.Component {
5+
static propTypes = {
6+
closeTooltip: T.func.required,
7+
children: T.object
8+
};
9+
410
componentDidMount() {
511
document.addEventListener('keydown', this._handleKeyDown);
612
}

docs/examples/utils.js

100755100644
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
import React from 'react';
2+
import T from 'prop-types';
23

34
export class StateContainer extends React.Component {
5+
static propTypes = {
6+
children: T.func.required
7+
};
8+
49
state = {
510
on: false
611
};
712

8-
set = on => this.setState({on});
13+
set = on => this.setState({ on });
914

1015
toggle = () => this.setState(prevState => ({ on: !prevState.on }));
1116

package.json

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@
1919
"build": "yarn build:cjs; yarn build:esm; mkdir -p dist && cp src/styles.css dist",
2020
"build:cjs": "babel --delete-dir-on-start src -d lib/cjs",
2121
"build:esm": "babel --delete-dir-on-start --env-name esm src -d lib/esm",
22-
"prepare": "yarn build && yarn docs:deploy",
22+
"prepublishOnly": "yarn lint && yarn build && yarn docs:deploy",
2323
"docs": "docz dev",
2424
"docs:build": "docz build",
25-
"docs:deploy": "yarn docs:build && cp .docz/dist/index.html .docz/dist/404.html && gh-pages -d .docz/dist"
25+
"docs:deploy": "yarn docs:build && cp .docz/dist/index.html .docz/dist/404.html && gh-pages -d .docz/dist",
26+
"lint": "eslint ."
2627
},
28+
"pre-commit": "lint",
2729
"keywords": [
2830
"react",
2931
"tooltip",
@@ -40,6 +42,58 @@
4042
"prettier": {
4143
"singleQuote": true
4244
},
45+
"eslintConfig": {
46+
"env": {
47+
"browser": true,
48+
"es6": true,
49+
"node": true
50+
},
51+
"parser": "babel-eslint",
52+
"extends": [
53+
"eslint:recommended",
54+
"plugin:react/recommended",
55+
"plugin:jsx-a11y/recommended",
56+
"plugin:prettier/recommended"
57+
],
58+
"parserOptions": {
59+
"ecmaFeatures": {
60+
"jsx": true
61+
},
62+
"ecmaVersion": 2018,
63+
"sourceType": "module"
64+
},
65+
"plugins": [
66+
"react",
67+
"jsx-a11y"
68+
],
69+
"settings": {
70+
"react": {
71+
"version": "latest"
72+
}
73+
},
74+
"rules": {
75+
"indent": [
76+
"error",
77+
2
78+
],
79+
"linebreak-style": [
80+
"error",
81+
"unix"
82+
],
83+
"quotes": [
84+
"error",
85+
"single"
86+
],
87+
"semi": [
88+
"error",
89+
"always"
90+
]
91+
}
92+
},
93+
"eslintIgnore": [
94+
"dist",
95+
"lib"
96+
],
4397
"peerDependencies": {
4498
"react": "^16.3.0",
4599
"react-dom": "^16.3.0"
@@ -55,9 +109,16 @@
55109
"@babel/plugin-transform-runtime": "^7.1.0",
56110
"@babel/preset-env": "^7.1.0",
57111
"@babel/preset-react": "^7.0.0",
112+
"babel-eslint": "^9.0.0",
58113
"docz": "^0.11.2",
59114
"docz-plugin-css": "^0.11.0",
115+
"eslint": "^5.6.0",
116+
"eslint-config-prettier": "^3.1.0",
117+
"eslint-plugin-jsx-a11y": "^6.1.1",
118+
"eslint-plugin-prettier": "^2.6.2",
119+
"eslint-plugin-react": "^7.11.1",
60120
"gh-pages": "^2.0.0",
121+
"pre-commit": "^1.2.2",
61122
"prop-types": "^15.6.2",
62123
"react": "^16.5.2",
63124
"react-dom": "^16.5.2"

src/Tooltip.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable react/no-find-dom-node */
12
import React, { PureComponent } from 'react';
23
import { findDOMNode } from 'react-dom';
34
import T from 'prop-types';

0 commit comments

Comments
 (0)