Skip to content

Commit 0e4a0b5

Browse files
committed
format code with prettier
1 parent 527c001 commit 0e4a0b5

File tree

7 files changed

+1988
-97
lines changed

7 files changed

+1988
-97
lines changed

content-scripts/App.jsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
import React from 'react'
2-
import ReactDOM from 'react-dom'
3-
import Index from './components/'
4-
5-
const Element = document.createElement("div");
6-
Element.setAttribute("id" , "dfghbnjmERHJKFGHNMVBNMFBNMbmvvxnbdgf");
7-
document.body.appendChild(Element);
8-
ReactDOM.render(<Index />, document.getElementById("dfghbnjmERHJKFGHNMVBNMFBNMbmvvxnbdgf"));
1+
import React from "react";
2+
import ReactDOM from "react-dom";
3+
import Index from "./components/";
4+
5+
const Element = document.createElement("div");
6+
Element.setAttribute("id", "dfghbnjmERHJKFGHNMVBNMFBNMbmvvxnbdgf");
7+
document.body.appendChild(Element);
8+
ReactDOM.render(
9+
<Index />,
10+
document.getElementById("dfghbnjmERHJKFGHNMVBNMFBNMbmvvxnbdgf")
11+
);
Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
import React from 'react';
1+
import React from "react";
22

33
export default class Index extends React.Component {
4-
constructor(props){
5-
super(props);
6-
}
7-
render() {
8-
return (
9-
<div></div>
10-
);
11-
}
4+
constructor(props) {
5+
super(props);
6+
}
7+
render() {
8+
return <div></div>;
9+
}
1210
}

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
"dev": "webpack --watch --progress --colors --config webpack.config.js --mode=development",
99
"test": "webpack --progress --colors --config webpack.config.js --mode=production"
1010
},
11+
"husky": {
12+
"hooks": {
13+
"pre-commit": "pretty-quick --staged"
14+
}
15+
},
1116
"keywords": [],
1217
"author": "",
1318
"license": "ISC",
@@ -22,6 +27,7 @@
2227
"copy-webpack-plugin": "^5.0.4",
2328
"file-loader": "^4.2.0",
2429
"image-webpack-loader": "^5.0.0",
30+
"prettier": "1.18.2",
2531
"react-hot-loader": "^4.12.10",
2632
"webpack": "^4.39.1",
2733
"webpack-cli": "^3.3.6",

src/app/manifest.json

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,9 @@
99
},
1010
"default_locale": "en",
1111
"background": {
12-
"scripts": [
13-
"background.bundle.js"
14-
]
12+
"scripts": ["background.bundle.js"]
1513
},
16-
"permissions": [
17-
"history" ,
18-
"webNavigation" ,
19-
"*://*/*"
20-
],
14+
"permissions": ["history", "webNavigation", "*://*/*"],
2115
"browser_action": {
2216
"default_icon": {
2317
"19": "images/icon-19.png",

src/background.js

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,24 @@
1-
import "@babel/polyfill"
1+
import "@babel/polyfill";
22

3-
let AppInitState = 0 // it means app is off on startup
3+
let AppInitState = 0; // it means app is off on startup
44

55
class Main {
6-
constructor() {
7-
8-
}
9-
popUpClickSetup() {
10-
chrome
11-
.browserAction
12-
.onClicked
13-
.addListener((tab) => {
14-
if(this.toggleApp()) {
15-
16-
} else {
17-
this.stopApp()
18-
}
19-
});
20-
}
21-
22-
toggleApp = () => {
23-
AppInitState = AppInitState?0:1;
24-
return AppInitState
25-
}
26-
27-
stopApp = () => {
28-
AppInitState = 0
29-
}
30-
6+
constructor() {}
7+
popUpClickSetup() {
8+
chrome.browserAction.onClicked.addListener(tab => {
9+
if (this.toggleApp()) {
10+
} else {
11+
this.stopApp();
12+
}
13+
});
14+
}
15+
16+
toggleApp = () => {
17+
AppInitState = AppInitState ? 0 : 1;
18+
return AppInitState;
19+
};
20+
21+
stopApp = () => {
22+
AppInitState = 0;
23+
};
3124
}
32-
33-
34-

webpack.config.js

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,56 @@
1-
const webpack = require('webpack');
2-
const CopyWebpackPlugin = require('copy-webpack-plugin');
1+
const webpack = require("webpack");
2+
const CopyWebpackPlugin = require("copy-webpack-plugin");
33

44
module.exports = {
55
entry: {
6-
content_script: './content-scripts/App.jsx',
7-
background: './src/background.js',
8-
popup: './popup-page/App.jsx',
9-
option: './option-page/App.jsx',
6+
content_script: "./content-scripts/App.jsx",
7+
background: "./src/background.js",
8+
popup: "./popup-page/App.jsx",
9+
option: "./option-page/App.jsx"
1010
},
1111
module: {
1212
rules: [
1313
{
1414
test: /\.(js|jsx)$/,
1515
exclude: /node_modules/,
16-
use: ['babel-loader']
16+
use: ["babel-loader"]
1717
},
1818
{
1919
test: /\.(gif|png|jpe?g|svg)$/i,
2020
use: [
21-
'file-loader',
21+
"file-loader",
2222
{
23-
loader: 'image-webpack-loader',
23+
loader: "image-webpack-loader",
2424
options: {
2525
bypassOnDebug: true, // webpack@1.x
26-
disable: true, // webpack@2.x and newer
27-
},
28-
},
26+
disable: true // webpack@2.x and newer
27+
}
28+
}
2929
]
3030
}
3131
]
3232
},
3333
resolve: {
34-
extensions: ['*', '.js', '.jsx']
34+
extensions: ["*", ".js", ".jsx"]
3535
},
3636
output: {
37-
path: __dirname + '/dist',
38-
publicPath: '/',
39-
filename: '[name].bundle.js'
37+
path: __dirname + "/dist",
38+
publicPath: "/",
39+
filename: "[name].bundle.js"
4040
},
4141
plugins: [
42-
new CopyWebpackPlugin([
43-
{ from: './popup-page/popup.html', force: true } ,
44-
{ from: './option-page/option.html', force: true } ,
45-
{ from: './src/app/', force: true }
46-
], {}),
42+
new CopyWebpackPlugin(
43+
[
44+
{ from: "./popup-page/popup.html", force: true },
45+
{ from: "./option-page/option.html", force: true },
46+
{ from: "./src/app/", force: true }
47+
],
48+
{}
49+
),
4750
new webpack.HotModuleReplacementPlugin()
4851
],
4952
devServer: {
50-
contentBase: './dist',
53+
contentBase: "./dist",
5154
hot: true
5255
}
5356
};

0 commit comments

Comments
 (0)