Skip to content

Commit 5bede6f

Browse files
committed
重新初始化到vue+js
1 parent 6905f95 commit 5bede6f

26 files changed

+311
-722
lines changed

.editorconfig

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
root = true
22

3-
43
[*]
54
charset = utf-8
65
indent_style = space
76
indent_size = 2
87
end_of_line = lf
98
insert_final_newline = true
10-
trim_trailing_whitespace = true
9+
trim_trailing_whitespace = true

.eslintrc.js

Lines changed: 24 additions & 164 deletions
Original file line numberDiff line numberDiff line change
@@ -1,167 +1,27 @@
11
// https://eslint.org/docs/user-guide/configuring
22

33
module.exports = {
4-
root: true,
5-
parser: 'babel-eslint',
6-
parserOptions: {
7-
sourceType: 'module'
8-
},
9-
env: {
10-
browser: true,
11-
},
12-
// https://github.com/standard/standard/blob/master/docs/RULES-en.md
13-
extends: 'standard',
14-
// required to lint *.vue files
15-
plugins: [
16-
'html'
17-
],
18-
// add your custom rules here
19-
'rules': {
20-
// // allow paren-less arrow functions
21-
// 'arrow-parens': 0,
22-
// // allow async-await
23-
// 'generator-star-spacing': 0,
24-
// // allow debugger during development
25-
// 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
26-
"indent": [0, 2],
27-
"comma-dangle": ["error", "never"], //是否允许对象中出现结尾逗号
28-
"no-cond-assign": 2, //条件语句的条件中不允许出现赋值运算符
29-
"no-console": process.env.NODE_ENV === 'production' ? 2 : 0, //不允许出现console语句
30-
"no-constant-condition": 2, //条件语句的条件中不允许出现恒定不变的量
31-
"no-control-regex": 2, //正则表达式中不允许出现控制字符
32-
"no-debugger": process.env.NODE_ENV === 'production' ? 2 : 0, //不允许出现debugger语句
33-
"no-dupe-args": 2, //函数定义的时候不允许出现重复的参数
34-
"no-dupe-keys": 2, //对象中不允许出现重复的键
35-
"no-duplicate-case": 2, //switch语句中不允许出现重复的case标签
36-
"no-empty": 2, //不允许出现空的代码块
37-
"no-empty-character-class": 2, //正则表达式中不允许出现空的字符组
38-
"no-ex-assign": 2, //在try catch语句中不允许重新分配异常变量
39-
"no-extra-boolean-cast": 2, //不允许出现不必要的布尔值转换
40-
"no-extra-parens": 0, //不允许出现不必要的圆括号
41-
"no-extra-semi": 2, //不允许出现不必要的分号
42-
"no-func-assign": 2, //不允许重新分配函数声明
43-
"no-inner-declarations": ["error", "functions"], //不允许在嵌套代码块里声明函数
44-
"no-invalid-regexp": 2, //不允许在RegExp构造函数里出现无效的正则表达式
45-
"no-irregular-whitespace": 0, //不允许出现不规则的空格
46-
"no-negated-in-lhs": 2, //不允许在in表达式语句中对最左边的运算数使用取反操作
47-
"no-obj-calls": 2, //不允许把全局对象属性当做函数来调用
48-
"no-regex-spaces": 2, //正则表达式中不允许出现多个连续空格
49-
"quote-props": 2, //对象中的属性名是否需要用引号引起来
50-
"no-sparse-arrays": 2, //数组中不允许出现空位置
51-
"no-unreachable": 2, //在return,throw,continue,break语句后不允许出现不可能到达的语句
52-
"use-isnan": 2, //要求检查NaN的时候使用isNaN()
53-
"valid-jsdoc": ["error", {
54-
"requireReturn": false,
55-
"requireParamDescription": false,
56-
"requireReturnDescription": true
57-
}], //强制JSDoc注释
58-
"valid-typeof": ["error", {
59-
"requireStringLiterals": true
60-
}], //在使用typeof表达式比较的时候强制使用有效的字符串
61-
"block-scoped-var": 2, //将变量声明放在合适的代码块里
62-
"complexity": 0, //限制条件语句的复杂度
63-
"consistent-return": 2, //无论有没有返回值都强制要求return语句返回一个值
64-
"curly": ["error", "all"], //强制使用花括号的风格
65-
"default-case": 0, //在switch语句中需要有default语句
66-
"dot-notation": ["error", { "allowKeywords": false, "allowPattern": "" }], //获取对象属性的时候使用点号
67-
"eqeqeq": ["error", "smart"], //比较的时候使用严格等于
68-
"no-alert": 1, //不允许使用alert,confirm,prompt语句
69-
"no-caller": 2, //不允许使用arguments.callee和arguments.caller属性
70-
"guard-for-in": 0, //监视for in循环,防止出现不可预料的情况
71-
"no-div-regex": 2, //不能使用看起来像除法的正则表达式
72-
"no-else-return": 0, //如果if语句有return,else里的return不用放在else里
73-
"no-labels": ["error", {
74-
"allowLoop": false,
75-
"allowSwitch": false
76-
}], //不允许标签语句
77-
"no-eq-null": 2, //不允许对null用==或者!=
78-
"no-eval": 2, //不允许使用eval()
79-
"no-extend-native": 2, //不允许扩展原生对象
80-
"no-extra-bind": 2, //不允许不必要的函数绑定
81-
"no-fallthrough": 2, //不允许switch按顺序全部执行所有case
82-
"no-floating-decimal": 2, //不允许浮点数缺失数字
83-
"no-implied-eval": 2, //不允许使用隐式eval()
84-
"no-iterator": 2, //不允许使用__iterator__属性
85-
"no-lone-blocks": 2, //不允许不必要的嵌套代码块
86-
"no-loop-func": 2, //不允许在循环语句中进行函数声明
87-
"no-multi-spaces": 0, //不允许出现多余的空格
88-
"no-multi-str": 2, //不允许用\来让字符串换行
89-
"no-global-assign": 2, //不允许重新分配原生对象
90-
"no-new": 2, //不允许new一个实例后不赋值或者不比较
91-
"no-new-func": 2, //不允许使用new Function
92-
"no-new-wrappers": 2, //不允许使用new String,Number和Boolean对象
93-
"no-octal": 2, //不允许使用八进制字面值
94-
"no-octal-escape": 2, //不允许使用八进制转义序列
95-
"no-param-reassign": 0, //不允许重新分配函数参数"no-proto": 2, //不允许使用__proto__属性
96-
"no-redeclare": 2, //不允许变量重复声明
97-
"no-return-assign": 2, //不允许在return语句中使用分配语句
98-
"no-script-url": 2, //不允许使用javascript:void(0)
99-
"no-self-compare": 2, //不允许自己和自己比较
100-
"no-sequences": 2, //不允许使用逗号表达式
101-
"no-throw-literal": 2, //不允许抛出字面量错误 throw "error"
102-
"no-unused-expressions": 2, //不允许无用的表达式
103-
"no-void": 2, //不允许void操作符
104-
"no-warning-comments": [1, { "terms": ["todo", "fixme", "any other term"] }], //不允许警告备注
105-
"no-with": 2, //不允许使用with语句
106-
"radix": 1, //使用parseInt时强制使用基数来指定是十进制还是其他进制
107-
"vars-on-top": 0, //var必须放在作用域顶部
108-
"wrap-iife": [2, "any"], //立即执行表达式的括号风格
109-
"yoda": [2, "never", { "exceptRange": true }], //不允许在if条件中使用yoda条件
110-
"strict": [2, "function"], //使用严格模式
111-
"no-catch-shadow": 2, //不允许try catch语句接受的err变量与外部变量重名"no-delete-var": 2, //不允许使用delete操作符
112-
"no-label-var": 2, //不允许标签和变量同名
113-
"no-shadow": 2, //外部作用域中的变量不能与它所包含的作用域中的变量或参数同名
114-
"no-shadow-restricted-names": 2, //js关键字和保留字不能作为函数名或者变量名
115-
"no-undef": 2, //不允许未声明的变量
116-
"no-undef-init": 2, //不允许初始化变量时给变量赋值undefined
117-
"no-undefined": 2, //不允许把undefined当做标识符使用
118-
"no-unused-vars": [2, { "vars": "all", "args": "after-used" }], //不允许有声明后未使用的变量或者参数
119-
"no-use-before-define": [0, "nofunc"], //不允许在未定义之前就使用变量"indent": 2, //强制一致的缩进风格
120-
"brace-style": [2, "1tbs", { "allowSingleLine": false }], //大括号风格
121-
"camelcase": [2, { "properties": "never" }], //强制驼峰命名规则
122-
"comma-style": [2, "last"], //逗号风格
123-
"consistent-this": [0, "self"], //当获取当前环境的this是用一样的风格
124-
"eol-last": 0, //文件以换行符结束
125-
"func-names": 0, //函数表达式必须有名字
126-
"func-style": 0, //函数风格,规定只能使用函数声明或者函数表达式
127-
"key-spacing": [0, { "beforeColon": false, "afterColon": true }], //对象字面量中冒号的前后空格
128-
"max-nested-callbacks": 0, //回调嵌套深度
129-
"new-cap": [2, { "newIsCap": true, "capIsNew": false }], //构造函数名字首字母要大写
130-
"new-parens": 2, //new时构造函数必须有小括号
131-
"newline-after-var": 0, //变量声明后必须空一行
132-
"no-array-constructor": 2, //不允许使用数组构造器
133-
"no-inline-comments": 0, //不允许行内注释
134-
"no-lonely-if": 0, //不允许else语句内只有if语句
135-
"no-mixed-spaces-and-tabs": [0, "smart-tabs"], //不允许混用tab和空格
136-
"no-multiple-empty-lines": [2, { "max": 2 }], //空行最多不能超过两行
137-
"no-nested-ternary": 2, //不允许使用嵌套的三目运算符
138-
"no-new-object": 2, //禁止使用new Object()
139-
"fun-call-spacing": 0, //函数调用时,函数名与()之间不能有空格
140-
"no-ternary": 0, //不允许使用三目运算符
141-
"no-trailing-spaces": 2, //一行最后不允许有空格
142-
"no-underscore-dangle": 2, //不允许标识符以下划线开头
143-
"no-extra-parens": 0, //不允许出现多余的括号
144-
"one-var": 0, //强制变量声明放在一起
145-
"operator-assignment": 0, //赋值运算符的风格
146-
"padded-blocks": [2, "never"], //块内行首行尾是否空行
147-
"quote-props": 0, //对象字面量中属性名加引号
148-
"quotes": [1, "single", "avoid-escape"], //引号风格
149-
"semi": [0, "always"], //强制语句分号结尾
150-
"semi-spacing": [0, { "before": false, "after": true }], //分后前后空格
151-
"sort-vars": 0, //变量声明时排序
152-
"space-before-blocks": [0, "always"], //块前的空格
153-
"space-before-function-paren": [0, { "anonymous": "always", "named": "never" }], //函数定义时括号前的空格
154-
"space-infix-ops": [0, { "int32Hint": true }], //操作符周围的空格
155-
"keyword-spacing": 0, //关键字前后的空格
156-
"space-unary-ops": [0, { "words": true, "nonwords": false }], //一元运算符前后不要加空格
157-
"wrap-regex": 2, //正则表达式字面量用括号括起来
158-
"no-var": 0, //使用let和const代替var
159-
"generator-star-spacing": [0, "both"], //生成器函数前后空格
160-
"max-depth": 0, //嵌套块深度
161-
"max-len": 0, //一行最大长度,单位为字符
162-
"max-params": 0, //函数最多能有多少个参数
163-
"max-statements": 0, //函数内最多有几个声明
164-
"no-bitwise": 0, //不允许使用位运算符
165-
"no-plusplus": 0 //不允许使用++ --运算符
166-
}
167-
}
4+
root: true,
5+
parser: 'babel-eslint',
6+
parserOptions: {
7+
sourceType: 'module'
8+
},
9+
env: {
10+
browser: true,
11+
},
12+
// https://github.com/standard/standard/blob/master/docs/RULES-en.md
13+
extends: 'standard',
14+
// required to lint *.vue files
15+
plugins: [
16+
'html'
17+
],
18+
// add your custom rules here
19+
'rules': {
20+
// allow paren-less arrow functions
21+
'arrow-parens': 0,
22+
// allow async-await
23+
'generator-star-spacing': 0,
24+
// allow debugger during development
25+
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
26+
}
27+
}

build/dev-client.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable */
22
'use strict'
33
require('eventsource-polyfill')
4-
const hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true')
4+
var hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true')
55

66
hotClient.subscribe(function (event) {
77
if (event.action === 'reload') {

build/dev-server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ app.use(hotMiddleware)
5151

5252
// proxy api requests
5353
Object.keys(proxyTable).forEach(function (context) {
54-
const options = proxyTable[context]
54+
let options = proxyTable[context]
5555
if (typeof options === 'string') {
5656
options = { target: options }
5757
}

build/webpack.base.conf.js

Lines changed: 66 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -4,76 +4,73 @@ const utils = require('./utils')
44
const config = require('../config')
55
const vueLoaderConfig = require('./vue-loader.conf')
66

7-
function resolve(dir) {
8-
return path.join(__dirname, '..', dir)
7+
function resolve (dir) {
8+
return path.join(__dirname, '..', dir)
99
}
1010

1111
module.exports = {
12-
entry: {
13-
app: './src/main.js'
14-
},
15-
output: {
16-
path: config.build.assetsRoot,
17-
filename: '[name].[hash:8].js',
18-
publicPath: process.env.NODE_ENV === 'production' ?
19-
config.build.assetsPublicPath : config.dev.assetsPublicPath
20-
},
21-
resolve: {
22-
extensions: ['.js', '.vue', '.json'],
23-
alias: {
24-
'vue$': 'vue/dist/vue.esm.js',
25-
'@': resolve('src'),
26-
}
27-
},
28-
module: {
29-
rules: [{
30-
test: /\.(js|vue)$/,
31-
loader: 'eslint-loader',
32-
enforce: 'pre',
33-
include: [resolve('src'), resolve('test')],
34-
options: {
35-
formatter: require('eslint-friendly-formatter')
36-
}
37-
},
38-
{
39-
test: /\.vue$/,
40-
loader: 'vue-loader',
41-
options: vueLoaderConfig
42-
},
43-
{
44-
test: /\.js$/,
45-
loader: 'babel-loader',
46-
include: [resolve('src'), resolve('test')]
47-
},
48-
{
49-
test: /\.s[ac]ss$/,
50-
loader: 'style-loader!css-loader!sass-loader',
51-
include: [resolve('src'), resolve('test')]
52-
},
53-
{
54-
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
55-
loader: 'url-loader',
56-
options: {
57-
limit: 10000,
58-
name: utils.assetsPath('img/[name].[hash:8].[ext]')
59-
}
60-
},
61-
{
62-
test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
63-
loader: 'url-loader',
64-
options: {
65-
limit: 10000,
66-
name: utils.assetsPath('media/[name].[hash:8].[ext]')
67-
}
68-
},
69-
{
70-
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
71-
loader: 'url-loader',
72-
options: {
73-
limit: 10000,
74-
name: utils.assetsPath('fonts/[name].[hash:8].[ext]')
75-
}
76-
}
77-
]
12+
entry: {
13+
app: './src/main.js'
14+
},
15+
output: {
16+
path: config.build.assetsRoot,
17+
filename: '[name].js',
18+
publicPath: process.env.NODE_ENV === 'production'
19+
? config.build.assetsPublicPath
20+
: config.dev.assetsPublicPath
21+
},
22+
resolve: {
23+
extensions: ['.js', '.vue', '.json'],
24+
alias: {
25+
'vue$': 'vue/dist/vue.esm.js',
26+
'@': resolve('src'),
7827
}
79-
}
28+
},
29+
module: {
30+
rules: [
31+
{
32+
test: /\.(js|vue)$/,
33+
loader: 'eslint-loader',
34+
enforce: 'pre',
35+
include: [resolve('src'), resolve('test')],
36+
options: {
37+
formatter: require('eslint-friendly-formatter')
38+
}
39+
},
40+
{
41+
test: /\.vue$/,
42+
loader: 'vue-loader',
43+
options: vueLoaderConfig
44+
},
45+
{
46+
test: /\.js$/,
47+
loader: 'babel-loader',
48+
include: [resolve('src'), resolve('test')]
49+
},
50+
{
51+
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
52+
loader: 'url-loader',
53+
options: {
54+
limit: 10000,
55+
name: utils.assetsPath('img/[name].[hash:7].[ext]')
56+
}
57+
},
58+
{
59+
test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
60+
loader: 'url-loader',
61+
options: {
62+
limit: 10000,
63+
name: utils.assetsPath('media/[name].[hash:7].[ext]')
64+
}
65+
},
66+
{
67+
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
68+
loader: 'url-loader',
69+
options: {
70+
limit: 10000,
71+
name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
72+
}
73+
}
74+
]
75+
}
76+
}

0 commit comments

Comments
 (0)