chore(cli): update eslint config and prettier codes

This commit is contained in:
陈嘉涵
2020-01-19 11:42:22 +08:00
parent 633e9cf59d
commit 1691451813
52 changed files with 383 additions and 363 deletions

View File

@@ -8,7 +8,7 @@ const cleanCss = new CleanCss();
export async function compileCss(source: string | Buffer) {
const config = await postcssrc({}, POSTCSS_CONFIG_FILE);
const { css } = await postcss(config.plugins as any).process(source, {
from: undefined
from: undefined,
});
return cleanCss.minify(css).styles;

View File

@@ -13,14 +13,14 @@ class TildeResolver extends FileManager {
const TildeResolverPlugin = {
install(lessInstance: unknown, pluginManager: any) {
pluginManager.addFileManager(new TildeResolver());
}
},
};
export async function compileLess(filePath: string) {
const source = readFileSync(filePath, 'utf-8');
const { css } = await render(source, {
filename: filePath,
plugins: [TildeResolverPlugin]
plugins: [TildeResolverPlugin],
});
return css;

View File

@@ -57,7 +57,7 @@ function compileTemplate(template: string) {
const result = compileUtils.compileTemplate({
compiler,
source: template,
isProduction: true
isProduction: true,
} as any);
return result.code;
@@ -73,7 +73,7 @@ export function parseSfc(filePath: string) {
const descriptor = compileUtils.parse({
source,
compiler,
needMap: false
needMap: false,
} as any);
return descriptor;

View File

@@ -39,7 +39,7 @@ function watch() {
getPort(
{
port: config.devServer!.port
port: config.devServer!.port,
},
(err, port) => {
if (err) {

View File

@@ -11,7 +11,7 @@ import {
ES_DIR,
SRC_DIR,
LIB_DIR,
STYPE_DEPS_JSON_FILE
STYPE_DEPS_JSON_FILE,
} from '../common/constant';
function getDeps(component: string): string[] {
@@ -41,12 +41,12 @@ function getRelativePath(component: string, style: string, ext: string) {
const OUTPUT_CONFIG = [
{
dir: ES_DIR,
template: (dep: string) => `import '${dep}';`
template: (dep: string) => `import '${dep}';`,
},
{
dir: LIB_DIR,
template: (dep: string) => `require('${dep}');`
}
template: (dep: string) => `require('${dep}');`,
},
];
function genEntry(params: {
@@ -92,7 +92,7 @@ export function genComponentStyle(
baseFile,
component,
filename: 'index.js',
ext: '.css'
ext: '.css',
});
if (CSS_LANG !== 'css') {
@@ -100,7 +100,7 @@ export function genComponentStyle(
baseFile,
component,
filename: CSS_LANG + '.js',
ext: '.' + CSS_LANG
ext: '.' + CSS_LANG,
});
}
});

View File

@@ -1,6 +1,11 @@
import { get } from 'lodash';
import { join } from 'path';
import { pascalize, getComponents, smartOutputFile, normalizePath } from '../common';
import {
pascalize,
getComponents,
smartOutputFile,
normalizePath,
} from '../common';
import { SRC_DIR, getPackageJson, getVantConfig } from '../common/constant';
type Options = {

View File

@@ -6,14 +6,14 @@ import {
removeExt,
getVantConfig,
smartOutputFile,
normalizePath
normalizePath,
} from '../common';
import {
SRC_DIR,
DOCS_DIR,
getPackageJson,
VANT_CONFIG_FILE,
SITE_DESKTOP_SHARED_FILE
SITE_DESKTOP_SHARED_FILE,
} from '../common/constant';
type DocumentItem = {
@@ -52,7 +52,7 @@ function resolveDocuments(components: string[]): DocumentItem[] {
components.forEach(component => {
docs.push({
name: formatName(component, lang),
path: join(SRC_DIR, component, fileName)
path: join(SRC_DIR, component, fileName),
});
});
});
@@ -60,7 +60,7 @@ function resolveDocuments(components: string[]): DocumentItem[] {
components.forEach(component => {
docs.push({
name: formatName(component),
path: join(SRC_DIR, component, 'README.md')
path: join(SRC_DIR, component, 'README.md'),
});
});
}
@@ -69,7 +69,7 @@ function resolveDocuments(components: string[]): DocumentItem[] {
const pairs = parse(path).name.split('.');
return {
name: formatName(pairs[0], pairs[1] || defaultLang),
path
path,
};
});

View File

@@ -7,7 +7,7 @@ import {
decamelize,
getVantConfig,
smartOutputFile,
normalizePath
normalizePath,
} from '../common';
type DemoItem = {
@@ -25,7 +25,10 @@ import './package-style';
function genImports(demos: DemoItem[]) {
return demos
.map(item => `import ${item.name} from '${removeExt(normalizePath(item.path))}';`)
.map(
item =>
`import ${item.name} from '${removeExt(normalizePath(item.path))}';`
)
.join('\n');
}
@@ -73,7 +76,7 @@ function genCode(components: string[]) {
.map(component => ({
component,
name: pascalize(component),
path: join(SRC_DIR, component, 'demo/index.vue')
path: join(SRC_DIR, component, 'demo/index.vue'),
}))
.filter(item => existsSync(item.path));

View File

@@ -14,7 +14,7 @@ export function genVeturConfig() {
path: SRC_DIR,
test: /zh-CN\.md/,
outputDir: join(ROOT, 'vetur'),
...options
...options,
});
}
}

View File

@@ -15,10 +15,10 @@ export async function genSiteEntry() {
genStyleDepsMap()
.then(() => {
genPackageEntry({
outputPath: PACKAGE_ENTRY_FILE
outputPath: PACKAGE_ENTRY_FILE,
});
genPacakgeStyle({
outputPath: replaceExt(PACKAGE_STYLE_FILE, `.${CSS_LANG}`)
outputPath: replaceExt(PACKAGE_STYLE_FILE, `.${CSS_LANG}`),
});
genSiteMobileShared();
genSiteDesktopShared();