Style: change 2 spaces to 4

This commit is contained in:
jas0ncn 2018-09-02 02:57:09 +08:00
parent 37739d7f44
commit c81a02b2fc
15 changed files with 212 additions and 195 deletions

View File

@ -1,17 +1,17 @@
{ {
"presets": [ "presets": [
["@babel/preset-env", {"modules": false}], ["@babel/preset-env", {"modules": false}],
"@babel/preset-react" "@babel/preset-react"
], ],
"plugins": [ "plugins": [
"react-hot-loader/babel" "react-hot-loader/babel"
], ],
"env": { "env": {
"production": { "production": {
"presets": ["minify"] "presets": ["minify"]
}, },
"test": { "test": {
"presets": ["@babel/preset-env", "@babel/preset-react"] "presets": ["@babel/preset-env", "@babel/preset-react"]
}
} }
}
} }

12
.editorconfig Normal file
View File

@ -0,0 +1,12 @@
# http://editorconfig.org
root = true
[*]
indent_style = space
indent_size = 4
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false

View File

@ -1,3 +1,3 @@
{ {
"extends": "stylelint-config-standard" "extends": "stylelint-config-standard"
} }

View File

@ -1,22 +1,22 @@
language: node_js language: node_js
sudo: false sudo: false
node_js: node_js:
- "stable" - "stable"
cache: cache:
directories: directories:
- "$HOME/.npm" - "$HOME/.npm"
install: install:
- "npm ci" - "npm ci"
script: script:
- "npm run lint" - "npm run lint"
before_deploy: before_deploy:
- "npm run build" - "npm run build"
deploy: deploy:
provider: pages provider: pages
skip-cleanup: true skip-cleanup: true
local-dir: dist local-dir: dist
github-token: $GITHUB_TOKEN github-token: $GITHUB_TOKEN
on: on:
repo: Dreamacro/clash-dashboard repo: Dreamacro/clash-dashboard
branch: master branch: master
tags: true tags: true

View File

@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2018 Dreamacro Copyright (c) 2018 ClashTeam
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@ -5,52 +5,52 @@ const StyleLintPlugin = require('stylelint-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin') const HtmlWebpackPlugin = require('html-webpack-plugin')
module.exports = { module.exports = {
resolve: { resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx'], extensions: ['.ts', '.tsx', '.js', '.jsx'],
}, },
context: resolve(__dirname, '../../src'), context: resolve(__dirname, '../../src'),
module: { module: {
rules: [ rules: [
{ {
test: /\.js$/, test: /\.js$/,
use: ['babel-loader', 'source-map-loader'], use: ['babel-loader', 'source-map-loader'],
exclude: /node_modules/, exclude: /node_modules/,
}, },
{ {
test: /\.tsx?$/, test: /\.tsx?$/,
use: ['babel-loader', 'awesome-typescript-loader'], use: ['babel-loader', 'awesome-typescript-loader'],
}, },
{ {
test: /\.css$/, test: /\.css$/,
use: ['style-loader', { loader: 'css-loader', options: { importLoaders: 1 } }], use: ['style-loader', { loader: 'css-loader', options: { importLoaders: 1 } }],
}, },
{ {
test: /\.scss$/, test: /\.scss$/,
loaders: [ loaders: [
'style-loader', 'style-loader',
{ loader: 'css-loader', options: { importLoaders: 1 } }, { loader: 'css-loader', options: { importLoaders: 1 } },
'sass-loader', 'sass-loader',
],
},
{
test: /\.(jpe?g|png|gif|svg)$/i,
loaders: [
'file-loader?hash=sha512&digest=hex&name=img/[hash].[ext]',
'image-webpack-loader?bypassOnDebug&optipng.optimizationLevel=7&gifsicle.interlaced=false',
],
},
], ],
}, },
{ plugins: [
test: /\.(jpe?g|png|gif|svg)$/i, new CheckerPlugin(),
loaders: [ new StyleLintPlugin(),
'file-loader?hash=sha512&digest=hex&name=img/[hash].[ext]', new HtmlWebpackPlugin({ template: 'index.html.ejs', }),
'image-webpack-loader?bypassOnDebug&optipng.optimizationLevel=7&gifsicle.interlaced=false',
],
},
], ],
}, externals: {
plugins: [ 'react': 'React',
new CheckerPlugin(), 'react-dom': 'ReactDOM',
new StyleLintPlugin(), },
new HtmlWebpackPlugin({ template: 'index.html.ejs', }), performance: {
], hints: false,
externals: { },
'react': 'React',
'react-dom': 'ReactDOM',
},
performance: {
hints: false,
},
} }

View File

@ -4,19 +4,19 @@ const webpack = require('webpack')
const commonConfig = require('./common') const commonConfig = require('./common')
module.exports = merge(commonConfig, { module.exports = merge(commonConfig, {
mode: 'development', mode: 'development',
entry: [ entry: [
'react-hot-loader/patch', // activate HMR for React 'react-hot-loader/patch', // activate HMR for React
'webpack-dev-server/client?http://localhost:8080',// bundle the client for webpack-dev-server and connect to the provided endpoint 'webpack-dev-server/client?http://localhost:8080',// bundle the client for webpack-dev-server and connect to the provided endpoint
'webpack/hot/only-dev-server', // bundle the client for hot reloading, only- means to only hot reload for successful updates 'webpack/hot/only-dev-server', // bundle the client for hot reloading, only- means to only hot reload for successful updates
'./index.tsx' // the entry point of our app './index.tsx' // the entry point of our app
], ],
devServer: { devServer: {
hot: true, // enable HMR on the server hot: true, // enable HMR on the server
}, },
devtool: 'cheap-module-eval-source-map', devtool: 'cheap-module-eval-source-map',
plugins: [ plugins: [
new webpack.HotModuleReplacementPlugin(), // enable HMR globally new webpack.HotModuleReplacementPlugin(), // enable HMR globally
new webpack.NamedModulesPlugin(), // prints more readable module names in the browser console on HMR updates new webpack.NamedModulesPlugin(), // prints more readable module names in the browser console on HMR updates
], ],
}) })

View File

@ -5,13 +5,13 @@ const { resolve } = require('path')
const commonConfig = require('./common') const commonConfig = require('./common')
module.exports = merge(commonConfig, { module.exports = merge(commonConfig, {
mode: 'production', mode: 'production',
entry: './index.tsx', entry: './index.tsx',
output: { output: {
filename: 'js/bundle.[hash].min.js', filename: 'js/bundle.[hash].min.js',
path: resolve(__dirname, '../../dist'), path: resolve(__dirname, '../../dist'),
publicPath: '/', publicPath: '/',
}, },
devtool: 'source-map', devtool: 'source-map',
plugins: [], plugins: [],
}) })

View File

@ -6,6 +6,6 @@ const sourceDir = 'dist'
app.use(express.static(sourceDir)) app.use(express.static(sourceDir))
app.listen(portNumber, () => { app.listen(portNumber, () => {
console.log(`Express web server started: http://localhost:${portNumber}`) console.log(`Express web server started: http://localhost:${portNumber}`)
console.log(`Serving content from /${sourceDir}/`) console.log(`Serving content from /${sourceDir}/`)
}) })

View File

@ -1,65 +1,65 @@
{ {
"name": "clash-dashboard", "name": "clash-dashboard",
"version": "0.1.0", "version": "0.1.0",
"description": "Web port of clash.", "description": "Web port of clash.",
"keywords": [ "keywords": [
"clash", "clash",
"dashboard" "dashboard"
], ],
"author": "Dreamacro", "author": "Dreamacro",
"license": "MIT", "license": "MIT",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/Dreamacro/clash-dashboard.git" "url": "git+https://github.com/Dreamacro/clash-dashboard.git"
}, },
"bugs": { "bugs": {
"url": "https://github.com/Dreamacro/clash-dashboard/issues" "url": "https://github.com/Dreamacro/clash-dashboard/issues"
}, },
"homepage": "https://github.com/Dreamacro/clash-dashboard", "homepage": "https://github.com/Dreamacro/clash-dashboard",
"scripts": { "scripts": {
"build": "npm run clean-dist && webpack -p --config=configs/webpack/prod.js", "build": "npm run clean-dist && webpack -p --config=configs/webpack/prod.js",
"clean-dist": "rm -f -r -d dist", "clean-dist": "rm -f -r -d dist",
"lint": "npm run lint:ts && npm run lint:sass", "lint": "npm run lint:ts && npm run lint:sass",
"lint:ts": "tslint './src/**/*.ts*' --format stylish --force", "lint:ts": "tslint './src/**/*.ts*' --format stylish --force",
"lint:sass": "stylelint ./src/**/*.scss", "lint:sass": "stylelint ./src/**/*.scss",
"start": "npm run start-dev", "start": "npm run start-dev",
"start-dev": "webpack-dev-server --config=configs/webpack/dev.js", "start-dev": "webpack-dev-server --config=configs/webpack/dev.js",
"start-prod": "npm run build && node express.js" "start-prod": "npm run build && node express.js"
}, },
"devDependencies": { "devDependencies": {
"@babel/cli": "^7.0.0", "@babel/cli": "^7.0.0",
"@babel/core": "^7.0.0", "@babel/core": "^7.0.0",
"@babel/preset-env": "^7.0.0", "@babel/preset-env": "^7.0.0",
"@babel/preset-react": "^7.0.0", "@babel/preset-react": "^7.0.0",
"@types/node": "^10.7.1", "@types/node": "^10.7.1",
"@types/react": "^16.4.11", "@types/react": "^16.4.11",
"@types/react-dom": "^16.0.7", "@types/react-dom": "^16.0.7",
"awesome-typescript-loader": "^5.2.0", "awesome-typescript-loader": "^5.2.0",
"babel-loader": "^8.0.0", "babel-loader": "^8.0.0",
"css-loader": "^1.0.0", "css-loader": "^1.0.0",
"express": "^4.16.3", "express": "^4.16.3",
"file-loader": "^2.0.0", "file-loader": "^2.0.0",
"html-webpack-plugin": "^3.2.0", "html-webpack-plugin": "^3.2.0",
"image-webpack-loader": "^4.3.1", "image-webpack-loader": "^4.3.1",
"node-sass": "^4.9.3", "node-sass": "^4.9.3",
"react": "^16.4.2", "react": "^16.4.2",
"react-addons-test-utils": "^15.6.2", "react-addons-test-utils": "^15.6.2",
"react-dom": "^16.4.2", "react-dom": "^16.4.2",
"react-hot-loader": "^4.3.4", "react-hot-loader": "^4.3.4",
"sass-loader": "^7.1.0", "sass-loader": "^7.1.0",
"style-loader": "^0.23.0", "style-loader": "^0.23.0",
"stylelint": "^9.5.0", "stylelint": "^9.5.0",
"stylelint-config-standard": "^18.2.0", "stylelint-config-standard": "^18.2.0",
"stylelint-webpack-plugin": "^0.10.5", "stylelint-webpack-plugin": "^0.10.5",
"tslint": "^5.11.0", "tslint": "^5.11.0",
"tslint-config-standard": "^7.1.0", "tslint-config-standard": "^7.1.0",
"typescript": "^3.0.1", "typescript": "^3.0.1",
"uglifyjs-webpack-plugin": "^1.3.0", "uglifyjs-webpack-plugin": "^1.3.0",
"webpack": "^4.17.1", "webpack": "^4.17.1",
"webpack-cli": "^3.1.0", "webpack-cli": "^3.1.0",
"webpack-dev-middleware": "^3.1.3", "webpack-dev-middleware": "^3.1.3",
"webpack-dev-server": "^3.1.5", "webpack-dev-server": "^3.1.5",
"webpack-merge": "^4.1.4" "webpack-merge": "^4.1.4"
}, },
"dependencies": {} "dependencies": {}
} }

View File

@ -2,11 +2,11 @@ $bg-color: yellow;
$border-color: red; $border-color: red;
.app { .app {
font-family: helvetica, arial, sans-serif; font-family: helvetica, arial, sans-serif;
padding: 2em; padding: 2em;
border: 5px solid $border-color; border: 5px solid $border-color;
p { p {
background-color: $bg-color; background-color: $bg-color;
} }
} }

View File

@ -5,12 +5,12 @@ export interface AppProps {
} }
export default class App extends React.Component<AppProps, {}> { export default class App extends React.Component<AppProps, {}> {
render () { render () {
return ( return (
<div className='app'> <div className='app'>
<h1>Hello World!</h1> <h1>Hello World!</h1>
<p>Foo to the barz</p> <p>Foo to the barz</p>
</div> </div>
) )
} }
} }

View File

@ -6,23 +6,23 @@ import App from './components/App'
const rootEl = document.getElementById('root') const rootEl = document.getElementById('root')
render( render(
<AppContainer> <AppContainer>
<App /> <App />
</AppContainer>, </AppContainer>,
rootEl rootEl
) )
// Hot Module Replacement API // Hot Module Replacement API
declare let module: { hot: any } declare let module: { hot: any }
if (module.hot) { if (module.hot) {
module.hot.accept('./components/App', () => { module.hot.accept('./components/App', () => {
const NewApp = require('./components/App').default const NewApp = require('./components/App').default
render( render(
<AppContainer> <AppContainer>
<NewApp /> <NewApp />
</AppContainer>, </AppContainer>,
rootEl rootEl
) )
}) })
} }

View File

@ -1,3 +1,8 @@
{ {
"extends": "tslint-config-standard" "extends": "tslint-config-standard",
"rules": [
{
"indent": [true, "spaces", 4]
}
]
} }