Skip to content

Commit e380255

Browse files
Added linting, updated info, improved promise handling
1 parent 101693c commit e380255

22 files changed

+3004
-654
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ root = true
33
end_of_line = lf
44
insert_final_newline = true
55

6-
[*.js]
6+
[*.{js,vue}]
77
charset = utf-8
88
indent_style = space
99
indent_size = 2

.eslintrc.js

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,26 @@
11
module.exports = {
2-
"env": {
3-
"browser": true,
4-
"es6": true
5-
},
6-
"extends": "eslint:recommended",
7-
"parserOptions": {
8-
"sourceType": "module",
9-
"ecmaVersion": 2017
10-
},
11-
"rules": {
12-
"indent": [
13-
"error",
14-
4
15-
],
16-
"linebreak-style": [
17-
"error",
18-
"unix"
19-
],
20-
"quotes": [
21-
"error",
22-
"single"
23-
],
24-
"semi": [
25-
"error",
26-
"never"
27-
]
28-
}
29-
};
2+
env: {
3+
browser: true,
4+
node: true,
5+
es6: true,
6+
},
7+
extends: [
8+
'plugin:vue/recommended',
9+
'plugin:promise/recommended',
10+
'prettier',
11+
'eslint:recommended',
12+
],
13+
plugins: ['prettier', 'promise'],
14+
parserOptions: {
15+
sourceType: 'module',
16+
ecmaVersion: 2017,
17+
},
18+
rules: {
19+
'prettier/prettier': 'error',
20+
'no-console': 0,
21+
indent: ['error', 2],
22+
'linebreak-style': ['error', 'unix'],
23+
quotes: ['error', 'single'],
24+
semi: ['error', 'never'],
25+
},
26+
}

.gitignore

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
1-
.DS_Store
2-
node_modules/
1+
.*
2+
~*
3+
34
dist/
5+
node_modules/
6+
7+
ios/
8+
android/
9+
electron/
10+
11+
# ignore log files
12+
*.log
413
npm-debug.log*
514
yarn-debug.log*
615
yarn-error.log*
716

8-
# Editor directories and files
9-
.idea
10-
.vscode
11-
.tern-*
12-
*.suo
13-
*.ntvs*
14-
*.njsproj
15-
*.sln
16-
android/
17+
!.gitignore
18+
!.editorconfig
19+
!.eslintrc.js
20+
!.prettierrc

.prettierrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"printWidth": 100,
3+
"singleQuote": true,
4+
"semi": false,
5+
"trailingComma": "es5"
6+
}

build/build.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,21 @@ rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
1919
webpack(webpackConfig, (err, stats) => {
2020
spinner.stop()
2121
if (err) throw err
22-
process.stdout.write(stats.toString({
23-
colors: true,
24-
modules: false,
25-
children: false, // If you are using ts-loader, setting this to true will make TypeScript errors show up during build.
26-
chunks: false,
27-
chunkModules: false
28-
}) + '\n\n')
22+
process.stdout.write(
23+
stats.toString({
24+
colors: true,
25+
modules: false,
26+
children: false, // If you are using ts-loader, setting this to true will make TypeScript errors show up during build.
27+
chunks: false,
28+
chunkModules: false,
29+
}) + '\n\n'
30+
)
2931

3032
if (stats.hasErrors()) {
3133
console.log(chalk.red(' Build failed with errors.\n'))
3234
process.exit(1)
3335
}
3436

3537
console.log(chalk.cyan(' Build complete.\n'))
36-
console.log(chalk.yellow(
37-
' Tip: built files are meant to be served over an HTTP server.\n' +
38-
' Opening index.html over file:// won\'t work.\n'
39-
))
4038
})
4139
})

build/check-versions.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,42 @@ const semver = require('semver')
44
const packageConfig = require('../package.json')
55
const shell = require('shelljs')
66

7-
function exec (cmd) {
8-
return require('child_process').execSync(cmd).toString().trim()
7+
function exec(cmd) {
8+
return require('child_process')
9+
.execSync(cmd)
10+
.toString()
11+
.trim()
912
}
1013

1114
const versionRequirements = [
1215
{
1316
name: 'node',
1417
currentVersion: semver.clean(process.version),
15-
versionRequirement: packageConfig.engines.node
16-
}
18+
versionRequirement: packageConfig.engines.node,
19+
},
1720
]
1821

1922
if (shell.which('npm')) {
2023
versionRequirements.push({
2124
name: 'npm',
2225
currentVersion: exec('npm --version'),
23-
versionRequirement: packageConfig.engines.npm
26+
versionRequirement: packageConfig.engines.npm,
2427
})
2528
}
2629

27-
module.exports = function () {
30+
module.exports = function() {
2831
const warnings = []
2932

3033
for (let i = 0; i < versionRequirements.length; i++) {
3134
const mod = versionRequirements[i]
3235

3336
if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) {
34-
warnings.push(mod.name + ': ' +
35-
chalk.red(mod.currentVersion) + ' should be ' +
36-
chalk.green(mod.versionRequirement)
37+
warnings.push(
38+
mod.name +
39+
': ' +
40+
chalk.red(mod.currentVersion) +
41+
' should be ' +
42+
chalk.green(mod.versionRequirement)
3743
)
3844
}
3945
}

build/utils.js

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,42 @@ const config = require('../config')
44
const ExtractTextPlugin = require('extract-text-webpack-plugin')
55
const packageConfig = require('../package.json')
66

7-
exports.assetsPath = function (_path) {
8-
const assetsSubDirectory = process.env.NODE_ENV === 'production'
9-
? config.build.assetsSubDirectory
10-
: config.dev.assetsSubDirectory
7+
exports.assetsPath = function(_path) {
8+
const assetsSubDirectory =
9+
process.env.NODE_ENV === 'production'
10+
? config.build.assetsSubDirectory
11+
: config.dev.assetsSubDirectory
1112

1213
return path.posix.join(assetsSubDirectory, _path)
1314
}
1415

15-
exports.cssLoaders = function (options) {
16+
exports.cssLoaders = function(options) {
1617
options = options || {}
1718

1819
const cssLoader = {
1920
loader: 'css-loader',
2021
options: {
21-
sourceMap: options.sourceMap
22-
}
22+
sourceMap: options.sourceMap,
23+
},
2324
}
2425

2526
const postcssLoader = {
2627
loader: 'postcss-loader',
2728
options: {
28-
sourceMap: options.sourceMap
29-
}
29+
sourceMap: options.sourceMap,
30+
},
3031
}
3132

3233
// generate loader string to be used with extract text plugin
33-
function generateLoaders (loader, loaderOptions) {
34+
function generateLoaders(loader, loaderOptions) {
3435
const loaders = options.usePostCSS ? [cssLoader, postcssLoader] : [cssLoader]
3536

3637
if (loader) {
3738
loaders.push({
3839
loader: loader + '-loader',
3940
options: Object.assign({}, loaderOptions, {
40-
sourceMap: options.sourceMap
41-
})
41+
sourceMap: options.sourceMap,
42+
}),
4243
})
4344
}
4445

@@ -47,7 +48,7 @@ exports.cssLoaders = function (options) {
4748
if (options.extract) {
4849
return ExtractTextPlugin.extract({
4950
use: loaders,
50-
fallback: 'vue-style-loader'
51+
fallback: 'vue-style-loader',
5152
})
5253
} else {
5354
return ['vue-style-loader'].concat(loaders)
@@ -62,20 +63,20 @@ exports.cssLoaders = function (options) {
6263
sass: generateLoaders('sass', { indentedSyntax: true }),
6364
scss: generateLoaders('sass'),
6465
stylus: generateLoaders('stylus'),
65-
styl: generateLoaders('stylus')
66+
styl: generateLoaders('stylus'),
6667
}
6768
}
6869

6970
// Generate loaders for standalone style files (outside of .vue)
70-
exports.styleLoaders = function (options) {
71+
exports.styleLoaders = function(options) {
7172
const output = []
7273
const loaders = exports.cssLoaders(options)
7374

7475
for (const extension in loaders) {
7576
const loader = loaders[extension]
7677
output.push({
7778
test: new RegExp('\\.' + extension + '$'),
78-
use: loader
79+
use: loader,
7980
})
8081
}
8182

@@ -95,7 +96,7 @@ exports.createNotifierCallback = () => {
9596
title: packageConfig.name,
9697
message: severity + ': ' + error.name,
9798
subtitle: filename || '',
98-
icon: path.join(__dirname, 'logo.png')
99+
icon: path.join(__dirname, 'logo.png'),
99100
})
100101
}
101102
}

build/vue-loader.conf.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,19 @@
22
const utils = require('./utils')
33
const config = require('../config')
44
const isProduction = process.env.NODE_ENV === 'production'
5-
const sourceMapEnabled = isProduction
6-
? config.build.productionSourceMap
7-
: config.dev.cssSourceMap
5+
const sourceMapEnabled = isProduction ? config.build.productionSourceMap : config.dev.cssSourceMap
86

97
module.exports = {
108
loaders: utils.cssLoaders({
119
sourceMap: sourceMapEnabled,
12-
extract: isProduction
10+
extract: isProduction,
1311
}),
1412
cssSourceMap: sourceMapEnabled,
1513
cacheBusting: config.dev.cacheBusting,
1614
transformToRequire: {
1715
video: ['src', 'poster'],
1816
source: 'src',
1917
img: 'src',
20-
image: 'xlink:href'
21-
}
18+
image: 'xlink:href',
19+
},
2220
}

0 commit comments

Comments
 (0)