Skip to content
This repository was archived by the owner on Oct 30, 2023. It is now read-only.

Commit dced7f8

Browse files
committed
Update code with ESLint Syntax
1 parent 708a1f8 commit dced7f8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+4345
-3911
lines changed

.eslintrc.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module.exports = {
2+
root: true,
3+
parser: 'babel-eslint',
4+
parserOptions: {
5+
sourceType: 'module'
6+
},
7+
env: {
8+
browser: true,
9+
},
10+
plugins: [
11+
"html"
12+
],
13+
extends: 'standard',
14+
rules: {
15+
"no-debugger": process.env.NODE_ENV === 'production' ? 2 : 0,
16+
"indent": [2, "tab"],
17+
"no-tabs": 0,
18+
"eqeqeq": ["off"]
19+
}
20+
}

build/build.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,27 @@ const spinner = ora('building for production...')
1515
spinner.start()
1616

1717
rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
18-
if (err) throw err
19-
webpack(webpackConfig, function (err, stats) {
20-
spinner.stop()
21-
if (err) throw err
22-
process.stdout.write(stats.toString({
23-
colors: true,
24-
modules: false,
25-
children: false,
26-
chunks: false,
27-
chunkModules: false
28-
}) + '\n\n')
18+
if (err) throw err
19+
webpack(webpackConfig, function (err, stats) {
20+
spinner.stop()
21+
if (err) throw err
22+
process.stdout.write(stats.toString({
23+
colors: true,
24+
modules: false,
25+
children: false,
26+
chunks: false,
27+
chunkModules: false
28+
}) + '\n\n')
2929

30-
if (stats.hasErrors()) {
31-
console.log(chalk.red(' Build failed with errors.\n'))
32-
process.exit(1)
33-
}
30+
if (stats.hasErrors()) {
31+
console.log(chalk.red(' Build failed with errors.\n'))
32+
process.exit(1)
33+
}
3434

35-
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' +
35+
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' +
3838
' Opening index.html over file:// won\'t work.\n'
39-
))
40-
})
39+
))
40+
})
4141
})

build/check-versions.js

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,46 +4,46 @@ const semver = require('semver')
44
const packageConfig = require('../package.json')
55
const shell = require('shelljs')
66
function exec (cmd) {
7-
return require('child_process').execSync(cmd).toString().trim()
7+
return require('child_process').execSync(cmd).toString().trim()
88
}
99

1010
const versionRequirements = [
11-
{
12-
name: 'node',
13-
currentVersion: semver.clean(process.version),
14-
versionRequirement: packageConfig.engines.node
15-
}
11+
{
12+
name: 'node',
13+
currentVersion: semver.clean(process.version),
14+
versionRequirement: packageConfig.engines.node
15+
}
1616
]
1717

1818
if (shell.which('npm')) {
19-
versionRequirements.push({
20-
name: 'npm',
21-
currentVersion: exec('npm --version'),
22-
versionRequirement: packageConfig.engines.npm
23-
})
19+
versionRequirements.push({
20+
name: 'npm',
21+
currentVersion: exec('npm --version'),
22+
versionRequirement: packageConfig.engines.npm
23+
})
2424
}
2525

2626
module.exports = function () {
27-
const warnings = []
28-
for (let i = 0; i < versionRequirements.length; i++) {
29-
const mod = versionRequirements[i]
30-
if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) {
31-
warnings.push(mod.name + ': ' +
27+
const warnings = []
28+
for (let i = 0; i < versionRequirements.length; i++) {
29+
const mod = versionRequirements[i]
30+
if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) {
31+
warnings.push(mod.name + ': ' +
3232
chalk.red(mod.currentVersion) + ' should be ' +
3333
chalk.green(mod.versionRequirement)
34-
)
35-
}
36-
}
34+
)
35+
}
36+
}
3737

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

build/dev-client.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
/* eslint-disable */
21
require('eventsource-polyfill')
32
var hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true')
43

54
hotClient.subscribe(function (event) {
6-
if (event.action === 'reload') {
7-
window.location.reload()
8-
}
5+
if (event.action === 'reload') {
6+
window.location.reload()
7+
}
98
})

build/dev-server.js

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ require('./check-versions')()
22

33
var config = require('../config')
44
if (!process.env.NODE_ENV) {
5-
process.env.NODE_ENV = JSON.parse(config.dev.env.NODE_ENV)
5+
process.env.NODE_ENV = JSON.parse(config.dev.env.NODE_ENV)
66
}
77

88
var opn = require('opn')
@@ -24,28 +24,28 @@ var app = express()
2424
var compiler = webpack(webpackConfig)
2525

2626
var devMiddleware = require('webpack-dev-middleware')(compiler, {
27-
publicPath: webpackConfig.output.publicPath,
28-
quiet: true
27+
publicPath: webpackConfig.output.publicPath,
28+
quiet: true
2929
})
3030

3131
var hotMiddleware = require('webpack-hot-middleware')(compiler, {
32-
log: () => {}
32+
log: () => {}
3333
})
3434
// force page reload when html-webpack-plugin template changes
3535
compiler.plugin('compilation', function (compilation) {
36-
compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) {
37-
hotMiddleware.publish({ action: 'reload' })
38-
cb()
39-
})
36+
compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) {
37+
hotMiddleware.publish({ action: 'reload' })
38+
cb()
39+
})
4040
})
4141

4242
// proxy api requests
4343
Object.keys(proxyTable).forEach(function (context) {
44-
var options = proxyTable[context]
45-
if (typeof options === 'string') {
46-
options = { target: options }
47-
}
48-
app.use(proxyMiddleware(options.filter || context, options))
44+
var options = proxyTable[context]
45+
if (typeof options === 'string') {
46+
options = { target: options }
47+
}
48+
app.use(proxyMiddleware(options.filter || context, options))
4949
})
5050

5151
// handle fallback for HTML5 history API
@@ -66,24 +66,24 @@ var uri = 'http://localhost:' + port
6666

6767
var _resolve
6868
var readyPromise = new Promise(resolve => {
69-
_resolve = resolve
69+
_resolve = resolve
7070
})
7171

7272
console.log('> Starting dev server...')
7373
devMiddleware.waitUntilValid(() => {
74-
console.log('> Listening at ' + uri + '\n')
75-
// when env is testing, don't need open it
76-
if (autoOpenBrowser && process.env.NODE_ENV !== 'testing') {
77-
opn(uri)
78-
}
79-
_resolve()
74+
console.log('> Listening at ' + uri + '\n')
75+
// when env is testing, don't need open it
76+
if (autoOpenBrowser && process.env.NODE_ENV !== 'testing') {
77+
opn(uri)
78+
}
79+
_resolve()
8080
})
8181

8282
var server = app.listen(port)
8383

8484
module.exports = {
85-
ready: readyPromise,
86-
close: () => {
87-
server.close()
88-
}
85+
ready: readyPromise,
86+
close: () => {
87+
server.close()
88+
}
8989
}

0 commit comments

Comments
 (0)