Skip to content

Commit

Permalink
improve code quality
Browse files Browse the repository at this point in the history
  • Loading branch information
icebob committed Aug 23, 2016
1 parent 2d2a819 commit cd7029f
Show file tree
Hide file tree
Showing 7 changed files with 216 additions and 213 deletions.
14 changes: 7 additions & 7 deletions dev/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ module.exports = {
prettyJSON: function(json) {
if (json) {
json = JSON.stringify(json, undefined, 4);
json = json.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
json = json.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) {
var cls = 'number';
var cls = "number";
if (/^"/.test(match)) {
if (/:$/.test(match)) {
cls = 'key';
cls = "key";
} else {
cls = 'string';
cls = "string";
}
} else if (/true|false/.test(match)) {
cls = 'boolean';
cls = "boolean";
} else if (/null/.test(match)) {
cls = 'null';
cls = "null";
}
return '<span class="' + cls + '">' + match + '</span>';
return "<span class="" + cls + "">" + match + "</span>";
});
}
}
Expand Down
16 changes: 9 additions & 7 deletions examples/simple/main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
var VueFormGenerator = window.VueFormGenerator;

var vm = new Vue({
el: "#app",
components: {
Expand All @@ -8,21 +10,21 @@ var vm = new Vue({
prettyJSON: function(json) {
if (json) {
json = JSON.stringify(json, undefined, 4);
json = json.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
json = json.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) {
var cls = 'number';
var cls = "number";
if (/^"/.test(match)) {
if (/:$/.test(match)) {
cls = 'key';
cls = "key";
} else {
cls = 'string';
cls = "string";
}
} else if (/true|false/.test(match)) {
cls = 'boolean';
cls = "boolean";
} else if (/null/.test(match)) {
cls = 'null';
cls = "null";
}
return '<span class="' + cls + '">' + match + '</span>';
return "<span class="" + cls + "">" + match + "</span>";
});
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/unit/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// require all test files (files that ends with .spec.js)
var testsContext = require.context('./specs', true, /\.spec$/);
var testsContext = require.context("./specs", true, /\.spec$/);
testsContext.keys().forEach(testsContext);


// require all src files except main.js for coverage.
// you can also change this to match only the subset of files that
// you want coverage for.
var srcContext = require.context('src', true, /\.(js|vue)$/);
var srcContext = require.context("src", true, /\.(js|vue)$/);
srcContext.keys().forEach(srcContext);
48 changes: 24 additions & 24 deletions test/unit/karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
var wsConfig = require('./webpack.test.config');
var wsConfig = require("./webpack.test.config");

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

browsers: ['PhantomJS'],
browsers: ["PhantomJS"],

reporters: ['spec', 'coverage'],
reporters: ["spec", "coverage"],

frameworks: ['mocha', 'chai', 'sinon-chai'],
frameworks: ["mocha", "chai", "sinon-chai"],

files: [
'https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.3/jquery.js',
'https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.13.0/moment.min.js',
'https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/js/bootstrap.js',
'https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.10.0/js/bootstrap-select.min.js',
'https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/js/bootstrap-datetimepicker.min.js',
'https://cdnjs.cloudflare.com/ajax/libs/spectrum/1.8.0/spectrum.js',
'https://cdnjs.cloudflare.com/ajax/libs/jquery.maskedinput/1.4.1/jquery.maskedinput.js',
'https://cdnjs.cloudflare.com/ajax/libs/ion-rangeslider/2.1.4/js/ion.rangeSlider.js',
'https://rawgit.com/monterail/vue-multiselect/master/lib/vue-multiselect.min.js',
'https://rawgit.com/nosir/cleave.js/master/dist/cleave.min.js',
'https://nosir.github.io/cleave.js/lib/cleave-phone.i18n.js',
'https://cdnjs.cloudflare.com/ajax/libs/noUiSlider/8.5.1/nouislider.js',
'https://cdnjs.cloudflare.com/ajax/libs/pikaday/1.4.0/pikaday.min.js',

'./index.js'
"https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.3/jquery.js",
"https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.13.0/moment.min.js",
"https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/js/bootstrap.js",
"https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.10.0/js/bootstrap-select.min.js",
"https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/js/bootstrap-datetimepicker.min.js",
"https://cdnjs.cloudflare.com/ajax/libs/spectrum/1.8.0/spectrum.js",
"https://cdnjs.cloudflare.com/ajax/libs/jquery.maskedinput/1.4.1/jquery.maskedinput.js",
"https://cdnjs.cloudflare.com/ajax/libs/ion-rangeslider/2.1.4/js/ion.rangeSlider.js",
"https://rawgit.com/monterail/vue-multiselect/master/lib/vue-multiselect.min.js",
"https://rawgit.com/nosir/cleave.js/master/dist/cleave.min.js",
"https://nosir.github.io/cleave.js/lib/cleave-phone.i18n.js",
"https://cdnjs.cloudflare.com/ajax/libs/noUiSlider/8.5.1/nouislider.js",
"https://cdnjs.cloudflare.com/ajax/libs/pikaday/1.4.0/pikaday.min.js",

"./index.js"
],

exclude: [],

preprocessors: {
'./index.js': ['webpack', 'sourcemap']
"./index.js": ["webpack", "sourcemap"]
},

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

coverageReporter: {
dir: './coverage',
dir: "./coverage",
reporters: [
{ type: 'lcov', subdir: '.' },
{ type: 'text-summary' }
{ type: "lcov", subdir: "." },
{ type: "text-summary" }
]
}
}
Expand Down
131 changes: 66 additions & 65 deletions test/unit/webpack.test.config.js
Original file line number Diff line number Diff line change
@@ -1,74 +1,75 @@
var path = require("path");
var webpack = require('webpack');
var sourceDir = path.resolve(__dirname, '../../src');

module.exports = {
devtool: '#inline-source-map',
module: {
preLoaders: [
{
test: /\.js$/,
loader: 'isparta',
include: sourceDir,
exclude: /node_modules/
}
],
devtool: '#inline-source-map',
module: {
preLoaders: [
{
test: /\.js$/,
loader: 'isparta',
include: sourceDir,
exclude: /node_modules/
}
],

loaders: [
{
"test": /\.vue$/,
"loader": "vue"
},
{
"test": /\.js$/,
//"include": /test\/unit/,
"exclude": /node_modules/,
"loader": "babel"
},
{
"test": /\.css?$/,
"loader": "style!css"
},
{
"test": /\.scss?$/,
"loader": "style!css!sass"
},
{
"test": /\.jade?$/,
"loader": "jade"
},
{
test: /\.(woff2?|svg)$/,
loader: 'url'
//loader: 'url?limit=10000'
},
{
test: /\.(ttf|eot)$/,
loader: 'url'
}
],
noParse: [
/node_modules\/sinon\//,
]
},
loaders: [
{
"test": /\.vue$/,
"loader": "vue"
},
{
"test": /\.js$/,
//"include": /test\/unit/,
"exclude": /node_modules/,
"loader": "babel"
},
{
"test": /\.css?$/,
"loader": "style!css"
},
{
"test": /\.scss?$/,
"loader": "style!css!sass"
},
{
"test": /\.jade?$/,
"loader": "jade"
},
{
test: /\.(woff2?|svg)$/,
loader: 'url'
//loader: 'url?limit=10000'
},
{
test: /\.(ttf|eot)$/,
loader: 'url'
}
],
noParse: [
/node_modules\/sinon\//,
]
},

resolve: {
packageAlias: 'browser',
alias: {
'src': sourceDir,
'sinon': 'sinon/pkg/sinon'
}
},
plugins: [
],
resolve: {
packageAlias: 'browser',
alias: {
'src': sourceDir,
'sinon': 'sinon/pkg/sinon'
}
},
plugins: [
],

vue: {
autoprefixer: {
browsers: ['last 2 versions']
},
loaders: {
js: 'isparta'
}
}
vue: {
autoprefixer: {
browsers: ['last 2 versions']
},
loaders: {
js: 'isparta'
}
}

};
Loading

0 comments on commit cd7029f

Please sign in to comment.