Skip to content

Commit cd7029f

Browse files
committed
improve code quality
1 parent 2d2a819 commit cd7029f

File tree

7 files changed

+216
-213
lines changed

7 files changed

+216
-213
lines changed

dev/utils.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@ module.exports = {
44
prettyJSON: function(json) {
55
if (json) {
66
json = JSON.stringify(json, undefined, 4);
7-
json = json.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
7+
json = json.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
88
return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) {
9-
var cls = 'number';
9+
var cls = "number";
1010
if (/^"/.test(match)) {
1111
if (/:$/.test(match)) {
12-
cls = 'key';
12+
cls = "key";
1313
} else {
14-
cls = 'string';
14+
cls = "string";
1515
}
1616
} else if (/true|false/.test(match)) {
17-
cls = 'boolean';
17+
cls = "boolean";
1818
} else if (/null/.test(match)) {
19-
cls = 'null';
19+
cls = "null";
2020
}
21-
return '<span class="' + cls + '">' + match + '</span>';
21+
return "<span class="" + cls + "">" + match + "</span>";
2222
});
2323
}
2424
}

examples/simple/main.js

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
var VueFormGenerator = window.VueFormGenerator;
2+
13
var vm = new Vue({
24
el: "#app",
35
components: {
@@ -8,21 +10,21 @@ var vm = new Vue({
810
prettyJSON: function(json) {
911
if (json) {
1012
json = JSON.stringify(json, undefined, 4);
11-
json = json.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
13+
json = json.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
1214
return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) {
13-
var cls = 'number';
15+
var cls = "number";
1416
if (/^"/.test(match)) {
1517
if (/:$/.test(match)) {
16-
cls = 'key';
18+
cls = "key";
1719
} else {
18-
cls = 'string';
20+
cls = "string";
1921
}
2022
} else if (/true|false/.test(match)) {
21-
cls = 'boolean';
23+
cls = "boolean";
2224
} else if (/null/.test(match)) {
23-
cls = 'null';
25+
cls = "null";
2426
}
25-
return '<span class="' + cls + '">' + match + '</span>';
27+
return "<span class="" + cls + "">" + match + "</span>";
2628
});
2729
}
2830
}

test/unit/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// require all test files (files that ends with .spec.js)
2-
var testsContext = require.context('./specs', true, /\.spec$/);
2+
var testsContext = require.context("./specs", true, /\.spec$/);
33
testsContext.keys().forEach(testsContext);
44

55

66
// require all src files except main.js for coverage.
77
// you can also change this to match only the subset of files that
88
// you want coverage for.
9-
var srcContext = require.context('src', true, /\.(js|vue)$/);
9+
var srcContext = require.context("src", true, /\.(js|vue)$/);
1010
srcContext.keys().forEach(srcContext);

test/unit/karma.conf.js

+24-24
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
1-
var wsConfig = require('./webpack.test.config');
1+
var wsConfig = require("./webpack.test.config");
22

33
module.exports = function(config) {
44
var settings = {
55
// base path that will be used to resolve all patterns (eg. files, exclude)
6-
basePath: '',
6+
basePath: "",
77

8-
browsers: ['PhantomJS'],
8+
browsers: ["PhantomJS"],
99

10-
reporters: ['spec', 'coverage'],
10+
reporters: ["spec", "coverage"],
1111

12-
frameworks: ['mocha', 'chai', 'sinon-chai'],
12+
frameworks: ["mocha", "chai", "sinon-chai"],
1313

1414
files: [
15-
'https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.3/jquery.js',
16-
'https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.13.0/moment.min.js',
17-
'https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/js/bootstrap.js',
18-
'https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.10.0/js/bootstrap-select.min.js',
19-
'https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/js/bootstrap-datetimepicker.min.js',
20-
'https://cdnjs.cloudflare.com/ajax/libs/spectrum/1.8.0/spectrum.js',
21-
'https://cdnjs.cloudflare.com/ajax/libs/jquery.maskedinput/1.4.1/jquery.maskedinput.js',
22-
'https://cdnjs.cloudflare.com/ajax/libs/ion-rangeslider/2.1.4/js/ion.rangeSlider.js',
23-
'https://rawgit.com/monterail/vue-multiselect/master/lib/vue-multiselect.min.js',
24-
'https://rawgit.com/nosir/cleave.js/master/dist/cleave.min.js',
25-
'https://nosir.github.io/cleave.js/lib/cleave-phone.i18n.js',
26-
'https://cdnjs.cloudflare.com/ajax/libs/noUiSlider/8.5.1/nouislider.js',
27-
'https://cdnjs.cloudflare.com/ajax/libs/pikaday/1.4.0/pikaday.min.js',
28-
29-
'./index.js'
15+
"https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.3/jquery.js",
16+
"https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.13.0/moment.min.js",
17+
"https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/js/bootstrap.js",
18+
"https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.10.0/js/bootstrap-select.min.js",
19+
"https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/js/bootstrap-datetimepicker.min.js",
20+
"https://cdnjs.cloudflare.com/ajax/libs/spectrum/1.8.0/spectrum.js",
21+
"https://cdnjs.cloudflare.com/ajax/libs/jquery.maskedinput/1.4.1/jquery.maskedinput.js",
22+
"https://cdnjs.cloudflare.com/ajax/libs/ion-rangeslider/2.1.4/js/ion.rangeSlider.js",
23+
"https://rawgit.com/monterail/vue-multiselect/master/lib/vue-multiselect.min.js",
24+
"https://rawgit.com/nosir/cleave.js/master/dist/cleave.min.js",
25+
"https://nosir.github.io/cleave.js/lib/cleave-phone.i18n.js",
26+
"https://cdnjs.cloudflare.com/ajax/libs/noUiSlider/8.5.1/nouislider.js",
27+
"https://cdnjs.cloudflare.com/ajax/libs/pikaday/1.4.0/pikaday.min.js",
28+
29+
"./index.js"
3030
],
3131

3232
exclude: [],
3333

3434
preprocessors: {
35-
'./index.js': ['webpack', 'sourcemap']
35+
"./index.js": ["webpack", "sourcemap"]
3636
},
3737

3838
webpack: wsConfig,
@@ -52,10 +52,10 @@ module.exports = function(config) {
5252
singleRun: true,
5353

5454
coverageReporter: {
55-
dir: './coverage',
55+
dir: "./coverage",
5656
reporters: [
57-
{ type: 'lcov', subdir: '.' },
58-
{ type: 'text-summary' }
57+
{ type: "lcov", subdir: "." },
58+
{ type: "text-summary" }
5959
]
6060
}
6161
}

test/unit/webpack.test.config.js

+66-65
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,75 @@
11
var path = require("path");
22
var webpack = require('webpack');
33
var sourceDir = path.resolve(__dirname, '../../src');
4+
45
module.exports = {
5-
devtool: '#inline-source-map',
6-
7-
module: {
8-
preLoaders: [
9-
{
10-
test: /\.js$/,
11-
loader: 'isparta',
12-
include: sourceDir,
13-
exclude: /node_modules/
14-
}
15-
],
6+
devtool: '#inline-source-map',
7+
8+
module: {
9+
preLoaders: [
10+
{
11+
test: /\.js$/,
12+
loader: 'isparta',
13+
include: sourceDir,
14+
exclude: /node_modules/
15+
}
16+
],
1617

17-
loaders: [
18-
{
19-
"test": /\.vue$/,
20-
"loader": "vue"
21-
},
22-
{
23-
"test": /\.js$/,
24-
//"include": /test\/unit/,
25-
"exclude": /node_modules/,
26-
"loader": "babel"
27-
},
28-
{
29-
"test": /\.css?$/,
30-
"loader": "style!css"
31-
},
32-
{
33-
"test": /\.scss?$/,
34-
"loader": "style!css!sass"
35-
},
36-
{
37-
"test": /\.jade?$/,
38-
"loader": "jade"
39-
},
40-
{
41-
test: /\.(woff2?|svg)$/,
42-
loader: 'url'
43-
//loader: 'url?limit=10000'
44-
},
45-
{
46-
test: /\.(ttf|eot)$/,
47-
loader: 'url'
48-
}
49-
],
50-
noParse: [
51-
/node_modules\/sinon\//,
52-
]
53-
},
18+
loaders: [
19+
{
20+
"test": /\.vue$/,
21+
"loader": "vue"
22+
},
23+
{
24+
"test": /\.js$/,
25+
//"include": /test\/unit/,
26+
"exclude": /node_modules/,
27+
"loader": "babel"
28+
},
29+
{
30+
"test": /\.css?$/,
31+
"loader": "style!css"
32+
},
33+
{
34+
"test": /\.scss?$/,
35+
"loader": "style!css!sass"
36+
},
37+
{
38+
"test": /\.jade?$/,
39+
"loader": "jade"
40+
},
41+
{
42+
test: /\.(woff2?|svg)$/,
43+
loader: 'url'
44+
//loader: 'url?limit=10000'
45+
},
46+
{
47+
test: /\.(ttf|eot)$/,
48+
loader: 'url'
49+
}
50+
],
51+
noParse: [
52+
/node_modules\/sinon\//,
53+
]
54+
},
5455

55-
resolve: {
56-
packageAlias: 'browser',
57-
alias: {
58-
'src': sourceDir,
59-
'sinon': 'sinon/pkg/sinon'
60-
}
61-
},
62-
plugins: [
63-
],
56+
resolve: {
57+
packageAlias: 'browser',
58+
alias: {
59+
'src': sourceDir,
60+
'sinon': 'sinon/pkg/sinon'
61+
}
62+
},
63+
plugins: [
64+
],
6465

65-
vue: {
66-
autoprefixer: {
67-
browsers: ['last 2 versions']
68-
},
69-
loaders: {
70-
js: 'isparta'
71-
}
72-
}
66+
vue: {
67+
autoprefixer: {
68+
browsers: ['last 2 versions']
69+
},
70+
loaders: {
71+
js: 'isparta'
72+
}
73+
}
7374

7475
};

0 commit comments

Comments
 (0)