Skip to content

Commit 3c6ba37

Browse files
committed
chore: Add prettier.
1 parent 3633939 commit 3c6ba37

31 files changed

+870
-877
lines changed

.eslintrc.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
// http://eslint.org/docs/user-guide/configuring
22

33
module.exports = {
4-
extends: [
5-
'plugin:vue/recommended'
6-
],
4+
extends: ['plugin:vue/recommended'],
75
// add your custom rules here
8-
'rules': {
6+
rules: {
97
// allow debugger during development
10-
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
11-
}
12-
}
8+
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
9+
},
10+
};

.postcssrc.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// https://github.com/michael-ciniawsky/postcss-load-config
22

33
module.exports = {
4-
"plugins": {
4+
plugins: {
55
// to edit target browsers: use "browserslist" field in package.json
6-
"autoprefixer": {}
7-
}
8-
}
6+
autoprefixer: {},
7+
},
8+
};

.prettierrc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "all",
4+
"printWidth": 100,
5+
"overrides": [
6+
{
7+
"files": ".prettierrc",
8+
"options": { "parser": "json" }
9+
}
10+
]
11+
}

build/build.js

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,34 @@
1-
require('./check-versions')()
1+
require('./check-versions')();
22

3-
process.env.NODE_ENV = 'production'
3+
process.env.NODE_ENV = 'production';
44

5-
const path = require('path')
6-
const chalk = require('chalk')
7-
const webpack = require('webpack')
8-
const webpackConfig = require('./webpack.prod.conf')
5+
const path = require('path');
6+
const chalk = require('chalk');
7+
const webpack = require('webpack');
8+
const webpackConfig = require('./webpack.prod.conf');
99

10-
webpack(webpackConfig, function (err, stats) {
11-
if (err) throw err
12-
process.stdout.write(stats.toString({
13-
colors: true,
14-
modules: false,
15-
children: false,
16-
chunks: false,
17-
chunkModules: false
18-
}) + '\n\n')
10+
webpack(webpackConfig, function(err, stats) {
11+
if (err) throw err;
12+
process.stdout.write(
13+
stats.toString({
14+
colors: true,
15+
modules: false,
16+
children: false,
17+
chunks: false,
18+
chunkModules: false,
19+
}) + '\n\n',
20+
);
1921

2022
if (stats.hasErrors()) {
21-
console.log(chalk.red(' Build failed with errors.\n'))
22-
process.exit(1)
23+
console.log(chalk.red(' Build failed with errors.\n'));
24+
process.exit(1);
2325
}
2426

25-
console.log(chalk.cyan(' Build complete.\n'))
26-
console.log(chalk.yellow(
27-
' Tip: built files are meant to be served over an HTTP server.\n' +
28-
' Opening index.html over file:// won\'t work.\n'
29-
))
30-
})
27+
console.log(chalk.cyan(' Build complete.\n'));
28+
console.log(
29+
chalk.yellow(
30+
' Tip: built files are meant to be served over an HTTP server.\n' +
31+
" Opening index.html over file:// won't work.\n",
32+
),
33+
);
34+
});

build/check-versions.js

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,54 @@
1-
const chalk = require('chalk')
2-
const semver = require('semver')
3-
const packageConfig = require('../package.json')
4-
const shell = require('shelljs')
5-
function exec (cmd) {
6-
return require('child_process').execSync(cmd).toString().trim()
1+
const chalk = require('chalk');
2+
const semver = require('semver');
3+
const packageConfig = require('../package.json');
4+
const shell = require('shelljs');
5+
function exec(cmd) {
6+
return require('child_process')
7+
.execSync(cmd)
8+
.toString()
9+
.trim();
710
}
811

912
const versionRequirements = [
1013
{
1114
name: 'node',
1215
currentVersion: semver.clean(process.version),
13-
versionRequirement: packageConfig.engines.node
14-
}
15-
]
16+
versionRequirement: packageConfig.engines.node,
17+
},
18+
];
1619

1720
if (shell.which('npm')) {
1821
versionRequirements.push({
1922
name: 'npm',
2023
currentVersion: exec('npm --version'),
21-
versionRequirement: packageConfig.engines.npm
22-
})
24+
versionRequirement: packageConfig.engines.npm,
25+
});
2326
}
2427

25-
module.exports = function () {
26-
const warnings = []
28+
module.exports = function() {
29+
const warnings = [];
2730
for (let i = 0; i < versionRequirements.length; i++) {
28-
const mod = versionRequirements[i]
31+
const mod = versionRequirements[i];
2932
if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) {
30-
warnings.push(mod.name + ': ' +
31-
chalk.red(mod.currentVersion) + ' should be ' +
32-
chalk.green(mod.versionRequirement)
33-
)
33+
warnings.push(
34+
mod.name +
35+
': ' +
36+
chalk.red(mod.currentVersion) +
37+
' should be ' +
38+
chalk.green(mod.versionRequirement),
39+
);
3440
}
3541
}
3642

3743
if (warnings.length) {
38-
console.log('')
39-
console.log(chalk.yellow('To use this template, you must update following to modules:'))
40-
console.log()
44+
console.log('');
45+
console.log(chalk.yellow('To use this template, you must update following to modules:'));
46+
console.log();
4147
for (let i = 0; i < warnings.length; i++) {
42-
const warning = warnings[i]
43-
console.log(' ' + warning)
48+
const warning = warnings[i];
49+
console.log(' ' + warning);
4450
}
45-
console.log()
46-
process.exit(1)
51+
console.log();
52+
process.exit(1);
4753
}
48-
}
54+
};

build/dev-client.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/* eslint-disable */
2-
require('eventsource-polyfill')
3-
const hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true')
2+
require('eventsource-polyfill');
3+
const hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true');
44

5-
hotClient.subscribe(function (event) {
5+
hotClient.subscribe(function(event) {
66
if (event.action === 'reload') {
7-
window.location.reload()
7+
window.location.reload();
88
}
9-
})
9+
});

build/dev-server.js

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,90 @@
1-
require('./check-versions')()
1+
require('./check-versions')();
22

3-
const config = require('../config')
3+
const config = require('../config');
44

55
if (!process.env.NODE_ENV) {
6-
process.env.NODE_ENV = JSON.parse(config.dev.env.NODE_ENV)
6+
process.env.NODE_ENV = JSON.parse(config.dev.env.NODE_ENV);
77
}
88

9-
const open = require('open')
10-
const path = require('path')
11-
const chalk = require('chalk')
12-
const express = require('express')
13-
const webpack = require('webpack')
14-
const proxyMiddleware = require('http-proxy-middleware')
9+
const open = require('open');
10+
const path = require('path');
11+
const chalk = require('chalk');
12+
const express = require('express');
13+
const webpack = require('webpack');
14+
const proxyMiddleware = require('http-proxy-middleware');
1515
const webpackDevMiddleware = require('webpack-dev-middleware');
1616
const webpackHotMiddleware = require('webpack-hot-middleware');
17-
const webpackConfig = (process.env.NODE_ENV === 'testing' || process.env.NODE_ENV === 'production')
18-
? require('./webpack.prod.conf')
19-
: require('./webpack.dev.conf')
17+
const webpackConfig =
18+
process.env.NODE_ENV === 'testing' || process.env.NODE_ENV === 'production'
19+
? require('./webpack.prod.conf')
20+
: require('./webpack.dev.conf');
2021

2122
// default port where dev server listens for incoming traffic
22-
const port = process.env.PORT || config.dev.port
23+
const port = process.env.PORT || config.dev.port;
2324
// automatically open browser, if not set will be false
24-
const autoOpenBrowser = !!config.dev.autoOpenBrowser
25+
const autoOpenBrowser = !!config.dev.autoOpenBrowser;
2526
// Define HTTP proxies to your custom API backend
2627
// https://github.com/chimurai/http-proxy-middleware
27-
const proxyTable = config.dev.proxyTable
28+
const proxyTable = config.dev.proxyTable;
2829

29-
const app = express()
30+
const app = express();
3031

31-
const compiler = webpack(webpackConfig)
32+
const compiler = webpack(webpackConfig);
3233

3334
const wdmInstance = webpackDevMiddleware(compiler, {
3435
publicPath: webpackConfig.output.publicPath,
35-
quiet: true
36-
})
36+
quiet: true,
37+
});
3738

3839
const hotMiddleware = webpackHotMiddleware(compiler, {
3940
log: false,
40-
heartbeat: 2000
41-
})
41+
heartbeat: 2000,
42+
});
4243

4344
// force page reload when html-webpack-plugin template changes
4445
compiler.hooks.compilation.tap('html-webpack-plugin-after-emit', () => {
4546
hotMiddleware.publish({
46-
action: 'reload'
47+
action: 'reload',
4748
});
4849
});
4950

5051
// proxy api requests
51-
Object.keys(proxyTable).forEach((context) => {
52-
const options = proxyTable[context]
52+
Object.keys(proxyTable).forEach(context => {
53+
const options = proxyTable[context];
5354
if (typeof options === 'string') {
54-
options = { target: options }
55+
options = { target: options };
5556
}
56-
app.use(proxyMiddleware(options.filter || context, options))
57-
})
57+
app.use(proxyMiddleware(options.filter || context, options));
58+
});
5859

5960
// handle fallback for HTML5 history API
60-
app.use(require('connect-history-api-fallback')())
61+
app.use(require('connect-history-api-fallback')());
6162

6263
// serve webpack bundle output
63-
app.use(wdmInstance)
64+
app.use(wdmInstance);
6465

6566
// enable hot-reload and state-preserving
6667
// compilation error display
67-
app.use(hotMiddleware)
68+
app.use(hotMiddleware);
6869

6970
// serve pure static assets
70-
const staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory)
71-
app.use(staticPath, express.static('./static'))
71+
const staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory);
72+
app.use(staticPath, express.static('./static'));
7273

73-
module.exports = new Promise((resolve) => {
74-
console.log('> Starting dev server...')
75-
const server = app.listen(port, (err) => {
74+
module.exports = new Promise(resolve => {
75+
console.log('> Starting dev server...');
76+
const server = app.listen(port, err => {
7677
if (err) {
7778
console.error(err);
7879
}
7980

8081
wdmInstance.waitUntilValid(() => {
81-
const uri = 'http://localhost:' + port
82+
const uri = 'http://localhost:' + port;
8283
if (autoOpenBrowser && process.env.NODE_ENV !== 'testing') {
83-
open(uri)
84-
console.log('> Listening at ' + uri + '\n')
84+
open(uri);
85+
console.log('> Listening at ' + uri + '\n');
8586
}
86-
})
87+
});
8788
});
8889

8990
resolve({

build/utils.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
const path = require('path')
2-
const config = require('../config')
3-
4-
exports.assetsPath = function (_path) {
5-
const assetsSubDirectory = process.env.NODE_ENV === 'production'
6-
? config.build.assetsSubDirectory
7-
: config.dev.assetsSubDirectory
8-
return path.posix.join(assetsSubDirectory, _path)
9-
}
1+
const path = require('path');
2+
const config = require('../config');
103

4+
exports.assetsPath = function(_path) {
5+
const assetsSubDirectory =
6+
process.env.NODE_ENV === 'production'
7+
? config.build.assetsSubDirectory
8+
: config.dev.assetsSubDirectory;
9+
return path.posix.join(assetsSubDirectory, _path);
10+
};

0 commit comments

Comments
 (0)