Skip to content

Commit 173cb4a

Browse files
committed
feat: update eslint && scripts
1 parent e788cca commit 173cb4a

File tree

7 files changed

+40
-32
lines changed

7 files changed

+40
-32
lines changed

.eslintrc

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,12 @@
11
{
2-
"parser": "babel-eslint",
32
"env": {
43
"browser": true,
54
"node": true,
65
"jest": true
76
},
8-
"extends": [
9-
"eslint:recommended",
10-
"plugin:react/recommended"
11-
],
12-
"plugins": [
13-
"react-hooks"
14-
],
7+
"extends": "airbnb",
158
"rules": {
16-
"react-hooks/rules-of-hooks": "error"
17-
},
18-
"settings": {
19-
"react": {
20-
"version": "16.7.0-alpha"
21-
}
9+
"consistent-return": 0,
10+
"react/jsx-one-expression-per-line": 0
2211
}
2312
}

README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ yarn add @use-hooks/video-meta
4848

4949
## Usage
5050

51-
```jsx
51+
```js
5252
import React from 'react';
53+
5354
import useVideoMeta from '@use-hooks/video-meta';
5455

5556
export default function App() {
@@ -62,16 +63,21 @@ export default function App() {
6263

6364
return (
6465
<div>
65-
<video src={url} controls height={200} />
66-
<div>Width: {width}, Height: {height}, Duration: {duration}</div>
66+
<h2>DEMO of <span style={{ color: '#F44336' }}>@use-hooks/video-meta</span></h2>
67+
<div>
68+
{/* eslint-disable-next-line */}
69+
<video src={url} controls height={200} />
70+
<div>Width: {width}, Height: {height}, Duration: {duration}</div>
71+
</div>
6772
</div>
6873
);
6974
}
75+
7076
```
7177

72-
See `./example` for a full [example](https://use-hooks.github.io/react-hooks-video-meta/).
78+
[Live Show](https://use-hooks.github.io/react-hooks-video-meta/)
7379

74-
## Have a try
80+
## Development
7581

7682
> Node >= v8 LTS
7783

__tests__/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
const hooks = require('../src/index').default;
2+
13
describe('hooks test', () => {
24
it('should be a function', () => {
3-
expect(require('../src/index').default).toEqual(expect.any(Function));
5+
expect(hooks).toEqual(expect.any(Function));
46
});
5-
});
7+
});

example/App.js renamed to example/App.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export default function App() {
1414
<div>
1515
<h2>DEMO of <span style={{ color: '#F44336' }}>@use-hooks/video-meta</span></h2>
1616
<div>
17+
{/* eslint-disable-next-line */}
1718
<video src={url} controls height={200} />
1819
<div>Width: {width}, Height: {height}, Duration: {duration}</div>
1920
</div>
File renamed without changes.

package.json

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@use-hooks/video-meta",
33
"version": "1.0.0",
4-
"description": "Custom React Hooks for video meta",
4+
"description": "Custom React Hooks for video meta.",
55
"main": "dist/index.js",
66
"files": [
77
"dist"
@@ -11,8 +11,9 @@
1111
"start": "webpack-dev-server --progress --color",
1212
"build": "webpack --env build",
1313
"example": "webpack --env example",
14-
"lint": "eslint src",
15-
"lint:fix": "eslint src --fix",
14+
"readme": "use-hooks-readme",
15+
"lint": "eslint src example --ext .js*",
16+
"lint:fix": "eslint src example --ext .js* --fix",
1617
"prepublishOnly": "npm run build"
1718
},
1819
"repository": {
@@ -33,17 +34,19 @@
3334
"@babel/preset-env": "^7.2.0",
3435
"@babel/preset-react": "^7.0.0",
3536
"babel-core": "^7.0.0-bridge.0",
36-
"babel-eslint": "^10.0.1",
3737
"babel-jest": "^23.6.0",
3838
"babel-loader": "^8.0.4",
3939
"eslint": "^5.10.0",
40+
"eslint-config-airbnb": "^17.1.0",
41+
"eslint-plugin-import": "^2.14.0",
42+
"eslint-plugin-jsx-a11y": "^6.1.2",
4043
"eslint-plugin-react": "^7.11.1",
41-
"eslint-plugin-react-hooks": "^0.0.0",
4244
"html-webpack-plugin": "^3.2.0",
4345
"husky": "^1.2.0",
4446
"jest": "^23.6.0",
4547
"lint-staged": "^8.1.0",
4648
"regenerator-runtime": "^0.13.1",
49+
"use-hooks-readme": "^1.0.1",
4750
"webpack": "^4.27.1",
4851
"webpack-cli": "^3.1.2",
4952
"webpack-dev-server": "^3.1.10"
@@ -54,13 +57,16 @@
5457
}
5558
},
5659
"lint-staged": {
57-
"*.js": [
60+
"*.{js,jsx}": [
5861
"eslint --fix",
5962
"git add"
63+
],
64+
"*.{js,jsx,json}": [
65+
"use-hooks-readme",
66+
"git add README.md"
6067
]
6168
},
6269
"dependencies": {
63-
"axios": "^0.18.0",
6470
"react": "^16.7.0-alpha.2",
6571
"react-dom": "^16.7.0-alpha.2"
6672
},

webpack.config.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ const path = require('path');
22
const webpack = require('webpack');
33
const HtmlWebpackPlugin = require('html-webpack-plugin');
44

5-
module.exports = function(env) {
5+
module.exports = (env) => {
66
const isExample = env === 'example';
77
const isBuild = env === 'build';
88
const isDev = !env;
99

1010
return {
1111
mode: isBuild ? 'production' : 'development',
12-
entry: isBuild ? './src' : './example/index.js',
12+
entry: isBuild ? './src' : './example',
1313

1414
output: {
1515
path: path.join(__dirname, isExample ? '__site__' : 'dist'),
@@ -35,10 +35,14 @@ module.exports = function(env) {
3535
},
3636
} : {},
3737

38+
resolve: {
39+
extensions: ['.js', '.jsx', '.json'],
40+
},
41+
3842
module: {
3943
rules: [
4044
{
41-
test: /\.js?$/,
45+
test: /\.jsx?$/,
4246
exclude: /node_modules/,
4347
use: ['babel-loader'],
4448
},
@@ -52,5 +56,5 @@ module.exports = function(env) {
5256
isDev && new webpack.NamedModulesPlugin(),
5357
isDev && new webpack.HotModuleReplacementPlugin(),
5458
].filter(Boolean),
55-
}
59+
};
5660
};

0 commit comments

Comments
 (0)