From 88af19eb63d9116f71c4c342a84c0112e4c38de3 Mon Sep 17 00:00:00 2001 From: Xinyu Liu Date: Tue, 18 Dec 2018 19:11:54 +0800 Subject: [PATCH] chore: lint code with always comma-dangle --- .eslintrc.js | 8 +++++--- docs/.vuepress/config.js | 30 +++++++++++++++--------------- scripts/dev/index.js | 6 +++--- scripts/rollup.config.js | 16 ++++++++-------- scripts/utils.js | 2 +- scripts/webpack.config.js | 32 ++++++++++++++++---------------- src/components/vue-showdown.js | 18 +++++++++--------- src/index.js | 2 +- 8 files changed, 58 insertions(+), 56 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 14cd848..ed9c96e 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -2,7 +2,9 @@ module.exports = { root: true, parser: 'babel-eslint', extends: [ - 'standard' - ] + 'standard', + ], + rules: { + 'comma-dangle': ['error', 'always-multiline'], + }, } - \ No newline at end of file diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js index f6f0d35..f448668 100644 --- a/docs/.vuepress/config.js +++ b/docs/.vuepress/config.js @@ -4,16 +4,16 @@ module.exports = { '/': { lang: 'en-US', title: 'Vue Showdown', - description: 'Use showdown.js in Vue' + description: 'Use showdown.js in Vue', }, '/zh/': { lang: 'zh-CN', title: 'Vue Showdown', - description: '在 Vue 中快速使用 showdown.js' - } + description: '在 Vue 中快速使用 showdown.js', + }, }, head: [ - ['link', { rel: 'icon', href: `/logo.png` }] + ['link', { rel: 'icon', href: `/logo.png` }], ], serviceWorker: true, themeConfig: { @@ -29,13 +29,13 @@ module.exports = { nav: [ { text: 'Guide', - link: '/guide/' + link: '/guide/', }, { text: 'Playground', - link: '/playground/' - } - ] + link: '/playground/', + }, + ], }, '/zh/': { label: '简体中文', @@ -45,14 +45,14 @@ module.exports = { nav: [ { text: '指南', - link: '/zh/guide/' + link: '/zh/guide/', }, { text: 'Playground', - link: '/zh/playground/' - } - ] - } - } - } + link: '/zh/playground/', + }, + ], + }, + }, + }, } diff --git a/scripts/dev/index.js b/scripts/dev/index.js index ce1291e..df342d4 100644 --- a/scripts/dev/index.js +++ b/scripts/dev/index.js @@ -41,8 +41,8 @@ new Vue({ underline: false, completeHTMLDocument: false, metadata: false, - splitAdjacentBlockquotes: false - } + splitAdjacentBlockquotes: false, + }, } - } + }, }) diff --git a/scripts/rollup.config.js b/scripts/rollup.config.js index 32dfddd..c965465 100644 --- a/scripts/rollup.config.js +++ b/scripts/rollup.config.js @@ -8,20 +8,20 @@ const utils = require('./utils') export default [ { file: 'vue-showdown.js', - format: 'umd' + format: 'umd', }, { file: 'vue-showdown.min.js', - format: 'umd' + format: 'umd', }, { file: 'vue-showdown.common.js', - format: 'cjs' + format: 'cjs', }, { file: 'vue-showdown.esm.js', - format: 'es' - } + format: 'es', + }, ].map(opts => { const config = { input: utils.srcPath('index.js'), @@ -29,13 +29,13 @@ export default [ file: opts.file, format: opts.format, dir: utils.distPath(), - name: 'VueShowdown' + name: 'VueShowdown', }, plugins: [ resolve(), cjs(), - babel() - ] + babel(), + ], } if (/min\.js$/.test(opts.file)) { config.plugins.push(uglify()) diff --git a/scripts/utils.js b/scripts/utils.js index 1d2629b..de9c3a0 100644 --- a/scripts/utils.js +++ b/scripts/utils.js @@ -27,5 +27,5 @@ function distPath (...args) { module.exports = { rootPath, srcPath, - distPath + distPath, } diff --git a/scripts/webpack.config.js b/scripts/webpack.config.js index 8a48d48..9d86c41 100644 --- a/scripts/webpack.config.js +++ b/scripts/webpack.config.js @@ -9,11 +9,11 @@ const webpackDevConfig = { mode: 'development', devtool: 'cheap-module-eval-source-map', entry: { - app: './scripts/dev/index.js' + app: './scripts/dev/index.js', }, output: { path: utils.distPath(), - filename: '[name].js' + filename: '[name].js', }, devServer: { contentBase: false, @@ -21,14 +21,14 @@ const webpackDevConfig = { compress: true, host: process.platform === 'win32' ? 'localhost' : '0.0.0.0', port: 8000, - quiet: true + quiet: true, }, resolve: { extensions: ['.js', '.vue'], alias: { 'vue-showdown': utils.srcPath(), - 'vue$': 'vue/dist/vue.esm.js' - } + 'vue$': 'vue/dist/vue.esm.js', + }, }, module: { rules: [ @@ -38,16 +38,16 @@ const webpackDevConfig = { loader: 'eslint-loader', exclude: /node_modules/, options: { - fix: true - } + fix: true, + }, }, { test: /\.js$/, exclude: /node_modules/, - loader: 'babel-loader' - } - ] + loader: 'babel-loader', + }, + ], }, plugins: [ new webpack.HotModuleReplacementPlugin(), @@ -55,8 +55,8 @@ const webpackDevConfig = { new HtmlWebpackPlugin({ filename: 'index.html', template: 'scripts/dev/index.html', - inject: true - }) + inject: true, + }), ], node: { Buffer: false, @@ -67,8 +67,8 @@ const webpackDevConfig = { fs: 'empty', net: 'empty', tls: 'empty', - child_process: 'empty' - } + child_process: 'empty', + }, } module.exports = new Promise((resolve, reject) => { @@ -80,8 +80,8 @@ module.exports = new Promise((resolve, reject) => { webpackDevConfig.devServer.port = port webpackDevConfig.plugins.push(new FriendlyErrorsPlugin({ compilationSuccessInfo: { - messages: [`Webpack dev server is listening: http://${webpackDevConfig.devServer.host}:${port}`] - } + messages: [`Webpack dev server is listening: http://${webpackDevConfig.devServer.host}:${port}`], + }, })) resolve(webpackDevConfig) } diff --git a/src/components/vue-showdown.js b/src/components/vue-showdown.js index f8d5528..1d2d2cc 100644 --- a/src/components/vue-showdown.js +++ b/src/components/vue-showdown.js @@ -10,7 +10,7 @@ export default { markdown: { type: String, required: false, - default: null + default: null, }, /** @@ -19,7 +19,7 @@ export default { tag: { type: String, required: false, - default: 'div' + default: 'div', }, /** @@ -31,7 +31,7 @@ export default { type: String, required: false, default: 'vanilla', - validator: flavor => ['original', 'vanilla', 'github'].includes(flavor) + validator: flavor => ['original', 'vanilla', 'github'].includes(flavor), }, /** @@ -84,8 +84,8 @@ export default { required: false, default () { return Object.create(null) - } - } + }, + }, }, computed: { @@ -97,14 +97,14 @@ export default { }, outputHtml () { return this.converter ? this.converter.makeHtml(this.inputMarkdown) : '' - } + }, }, render (h) { return h(this.tag, { domProps: { - innerHTML: this.outputHtml - } + innerHTML: this.outputHtml, + }, }) - } + }, } diff --git a/src/index.js b/src/index.js index 07d4d9f..700dfeb 100644 --- a/src/index.js +++ b/src/index.js @@ -8,7 +8,7 @@ const VueShowdown = { } Vue.component('VueShowdown', VueShowdownComponent) }, - VueShowdown: VueShowdownComponent + VueShowdown: VueShowdownComponent, } export default VueShowdown