Skip to content

Commit

Permalink
chore: 代码风格切换到prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
sigoden committed Nov 13, 2021
1 parent dc77bba commit 1c9b8a2
Show file tree
Hide file tree
Showing 23 changed files with 1,687 additions and 1,424 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
max_line_length = 80
trim_trailing_whitespace = true

[*.md]
max_line_length = 0
22 changes: 9 additions & 13 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
process.env.NODE_ENV = 'development'
process.env.NODE_ENV = "development";

module.exports = {
parser: '@babel/eslint-parser',
extends: [
'react-app',
'standard',
'standard-jsx',
'standard-react',
],
parser: "@babel/eslint-parser",
extends: ["react-app", "plugin:prettier/recommended"],
plugins: ["react"],
globals: {
chrome: 'readonly',
chrome: "readonly",
globalThis: true,
},
ignorePatterns: ['build', 'tmp'],
ignorePatterns: ["build", "tmp"],
rules: {
'react/prop-types': 0,
'comma-dangle': ['error', 'always-multiline'],
"@typescript-eslint/no-explicit-any": 0,
},
}
};
18 changes: 8 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"build": "node scripts/build.js",
"start": "node scripts/webserver.js",
"lint": "eslint ."
"lint": "eslint --ext js,jsx ."
},
"dependencies": {
"@emotion/react": "^11.5.0",
Expand Down Expand Up @@ -35,19 +35,17 @@
"copy-webpack-plugin": "^9.0.1",
"css-loader": "^6.5.0",
"eslint": "^8.1.0",
"eslint-config-prettier": "^8.3.0",
"eslint-config-react-app": "^6.0.0",
"eslint-config-standard": "^16.0.3",
"eslint-config-standard-jsx": "^10.0.0",
"eslint-config-standard-react": "^11.0.1",
"eslint-plugin-flowtype": "^8.0.3",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^5.1.1",
"eslint-plugin-react": "^7.26.1",
"eslint-plugin-react-hooks": "^4.2.1-alpha-9c8161ba8-20211028",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-react": "^7.27.0",
"eslint-plugin-react-hooks": "^4.3.0",
"file-loader": "^6.2.0",
"html-webpack-plugin": "^5.5.0",
"prettier": "^2.4.1",
"react-hot-loader": "^4.13.0",
"shelljs": "^0.8.4",
"source-map-loader": "^3.0.0",
Expand Down
18 changes: 9 additions & 9 deletions scripts/build.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Do this as the first thing so that any code reading it knows the right env.
process.env.NODE_ENV = 'production'
process.env.ASSET_PATH = '/'
process.env.NODE_ENV = "production";
process.env.ASSET_PATH = "/";

const shell = require('shelljs')
const webpack = require('webpack')
const config = require('../webpack.config')
const shell = require("shelljs");
const webpack = require("webpack");
const config = require("../webpack.config");

config.mode = 'production'
config.mode = "production";

shell.rm('-rf', 'build')
shell.rm("-rf", "build");
webpack(config, function (err) {
if (err) throw err
})
if (err) throw err;
});
40 changes: 20 additions & 20 deletions scripts/webserver.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
// Do this as the first thing so that any code reading it knows the right env.
process.env.NODE_ENV = 'development'
process.env.ASSET_PATH = '/'
process.env.NODE_ENV = "development";
process.env.ASSET_PATH = "/";

const WebpackDevServer = require('webpack-dev-server')
const webpack = require('webpack')
const config = require('../webpack.config')
const path = require('path')
const WebpackDevServer = require("webpack-dev-server");
const webpack = require("webpack");
const config = require("../webpack.config");
const path = require("path");

const PORT = process.env.PORT || 3000
const PORT = process.env.PORT || 3000;

for (const entryName in config.entry) {
if (['popup', 'background'].indexOf(entryName) > -1) {
if (["popup", "background"].indexOf(entryName) > -1) {
config.entry[entryName] = [
'webpack/hot/dev-server',
"webpack/hot/dev-server",
`webpack-dev-server/client?hot=true&hostname=localhost&port=${PORT}`,
].concat(config.entry[entryName])
].concat(config.entry[entryName]);
}
}

const compiler = webpack(config)
const compiler = webpack(config);

const server = new WebpackDevServer(
{
https: false,
client: false,
host: 'localhost',
host: "localhost",
port: PORT,
static: {
directory: path.join(__dirname, '../build'),
directory: path.join(__dirname, "../build"),
},
devMiddleware: {
publicPath: `http://localhost:${PORT}/`,
writeToDisk: true,
},
headers: {
'Access-Control-Allow-Origin': '*',
"Access-Control-Allow-Origin": "*",
},
allowedHosts: 'all',
allowedHosts: "all",
},
compiler,
)
compiler
);

;(async () => {
await server.start()
})()
(async () => {
await server.start();
})();
8 changes: 4 additions & 4 deletions src/background.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { init } from './background/chrome'
import { bootstrap } from './background/store'
import { init } from "./background/chrome";
import { bootstrap } from "./background/store";

init()
bootstrap()
init();
bootstrap();
Loading

0 comments on commit 1c9b8a2

Please sign in to comment.