[improvement] update eslint config (#2288)

This commit is contained in:
neverland
2018-12-14 14:24:23 +08:00
committed by GitHub
parent d2751ffdfa
commit 16e4889a92
141 changed files with 6387 additions and 7536 deletions

View File

@@ -3,11 +3,10 @@
*/
import Vue from 'vue';
import i18n from '../../packages/mixins/i18n';
import Vant, { Lazyload } from '../../packages';
import VantDoc, { DemoBlock, DemoSection } from 'vant-doc';
import VueRouter from 'vue-router';
import { Locale } from '../../packages';
import VantDoc, { DemoBlock, DemoSection } from 'vant-doc';
import i18n from '../../packages/mixins/i18n';
import Vant, { Lazyload, Locale } from '../../packages';
import { camelize } from '../../packages/utils';
Vue
@@ -86,12 +85,12 @@ export function wrapper(promise, name) {
component = component.default;
name = 'demo-' + name;
component.name = name;
const { i18n } = component;
if (i18n) {
const { i18n: config } = component;
if (config) {
const formattedI18n = {};
const camelizedName = camelize(name);
Object.keys(i18n).forEach(key => {
formattedI18n[key] = { [camelizedName]: i18n[key] };
Object.keys(config).forEach(key => {
formattedI18n[key] = { [camelizedName]: config[key] };
});
Locale.add(formattedI18n);
}

View File

@@ -1,3 +1,4 @@
/* eslint-disable */
// This file is auto gererated by build/build-entry.js
import { wrapper } from './demo-common';

View File

@@ -1,3 +1,4 @@
/* eslint-disable */
// This file is auto gererated by build/build-entry.js
export default {
'changelog.en-US': () => import('../markdown/changelog.en-US.md'),

View File

@@ -1,8 +1,8 @@
import Vue from 'vue';
import VueRouter from 'vue-router';
import VantDoc, { progress } from 'vant-doc';
import App from './DocsApp';
import routes from './router';
import VantDoc, { progress } from 'vant-doc';
import { isMobile } from './utils';
Vue.use(VueRouter).use(VantDoc);
@@ -33,8 +33,8 @@ if (process.env.NODE_ENV !== 'production') {
Vue.config.productionTip = false;
}
new Vue({ // eslint-disable-line
new Vue({
el: '#app',
render: h => h(App),
router,
el: '#app'
router
});

View File

@@ -1,9 +1,9 @@
import '../../packages/index.less';
import Vue from 'vue';
import VueRouter from 'vue-router';
import { progress } from 'vant-doc';
import App from './WapApp';
import routes from './router';
import { progress } from 'vant-doc';
import 'vant-doc/helper/touch-simulator';
const router = new VueRouter({
@@ -32,7 +32,7 @@ if (process.env.NODE_ENV !== 'production') {
Vue.config.productionTip = false;
}
new Vue({ // eslint-disable-line
new Vue({
el: '#app',
render: h => h(App),
router

View File

@@ -9,10 +9,10 @@ import './utils/iframe-router';
const registerRoute = (isDemo) => {
const route = [{
path: '*',
redirect: to => `/${Vue.prototype.$vantLang}/`
redirect: () => `/${Vue.prototype.$vantLang}/`
}];
Object.keys(docConfig).forEach((lang, index) => {
Object.keys(docConfig).forEach((lang) => {
if (isDemo) {
route.push({
path: `/${lang}`,
@@ -26,17 +26,6 @@ const registerRoute = (isDemo) => {
});
}
const navs = docConfig[lang].nav || [];
navs.forEach(nav => {
if (nav.groups) {
nav.groups.forEach(group => {
group.list.forEach(page => addRoute(page, lang));
});
} else {
addRoute(nav, lang);
}
});
function addRoute(page, lang) {
let { path } = page;
if (path) {
@@ -65,6 +54,17 @@ const registerRoute = (isDemo) => {
});
}
}
const navs = docConfig[lang].nav || [];
navs.forEach(nav => {
if (nav.groups) {
nav.groups.forEach(group => {
group.list.forEach(page => addRoute(page, lang));
});
} else {
addRoute(nav, lang);
}
});
});
return route;

View File

@@ -3,9 +3,9 @@
*/
import { setLang } from './lang';
import { iframeReady, isMobile } from './';
import { iframeReady, isMobile } from '.';
window.syncPath = function(dir) {
window.syncPath = function () {
const router = window.vueRouter;
const isInIframe = window !== window.top;
const currentDir = router.history.current.path;
@@ -28,7 +28,7 @@ window.syncPath = function(dir) {
}
};
window.changePath = function(lang, path = '') {
window.changePath = function (lang, path = '') {
setLang(lang);
window.vueRouter.replace(path);
};

View File

@@ -14,11 +14,9 @@ const langMap = {
};
let currentLang = '';
setLang(getDefaultLang());
function getDefaultLang() {
const langs = Object.keys(langMap);
const hash = location.hash;
const { hash } = location;
for (let i = 0; i < langs.length; i++) {
if (hash.indexOf(langs[i]) !== -1) {
@@ -42,3 +40,5 @@ export function setLang(lang) {
Locale.use(lang, langMap[lang].messages);
document.title = langMap[lang].title;
}
setLang(getDefaultLang());