fecs lint
This commit is contained in:
parent
c374e3a4ad
commit
3b6bcd2897
18
.fecsignore
Normal file
18
.fecsignore
Normal file
@ -0,0 +1,18 @@
|
||||
src/fonteditor/template/dialog/*
|
||||
src/fonteditor/template/export/*
|
||||
src/editor/shapes/*
|
||||
src/ttf/data/*
|
||||
build/*
|
||||
css/*
|
||||
demo/*
|
||||
dep/*
|
||||
font/*
|
||||
node_modules
|
||||
release
|
||||
test
|
||||
index.html
|
||||
index-en.html
|
||||
empty.html
|
||||
edp-build-config.js
|
||||
edp-build-config-node.js
|
||||
edp-webserver-config.js
|
@ -5,7 +5,8 @@
|
||||
|
||||
var esprima = require('esprima');
|
||||
var estraverse = require('estraverse');
|
||||
var escodegen = require('escodegen');
|
||||
|
||||
|
||||
var SYNTAX = estraverse.Syntax;
|
||||
|
||||
// 顶级模块,用来生成相对位置
|
||||
@ -32,7 +33,8 @@ function getAst(code) {
|
||||
ast = esprima.parse(code, {
|
||||
range: true
|
||||
});
|
||||
} catch (ex) {
|
||||
}
|
||||
catch (e) {
|
||||
throw 'can\'t parse amd code';
|
||||
}
|
||||
|
||||
@ -41,12 +43,12 @@ function getAst(code) {
|
||||
|
||||
/**
|
||||
* 获取define的factory
|
||||
*
|
||||
* @param {Object} defineExpr define表达式
|
||||
* @return {astNode}
|
||||
*/
|
||||
function getDefineFactory(defineExpr) {
|
||||
|
||||
var args = defineExpr['arguments'];
|
||||
var args = defineExpr.arguments;
|
||||
var factoryAst;
|
||||
|
||||
// 解析参数
|
||||
@ -74,9 +76,9 @@ function getDefineBlock(code) {
|
||||
// require('fs').writeFileSync('ast.json', JSON.stringify(ast));
|
||||
estraverse.traverse(ast, {
|
||||
enter: function (node, parent) {
|
||||
if ( node.type == SYNTAX.ExpressionStatement
|
||||
&& node.expression.type == SYNTAX.CallExpression
|
||||
&& node.expression.callee.name == 'define'
|
||||
if (node.type === SYNTAX.ExpressionStatement
|
||||
&& node.expression.type === SYNTAX.CallExpression
|
||||
&& node.expression.callee.name === 'define'
|
||||
) {
|
||||
|
||||
var factory = getDefineFactory(node.expression);
|
||||
@ -101,17 +103,7 @@ function getDefineBlock(code) {
|
||||
var body = factory.body.body;
|
||||
var returnRange = defineBlock.returnRange = [];
|
||||
|
||||
// 替换return
|
||||
for (var i = 0, l = body.length; i < l; i++) {
|
||||
// 直接在函数体里的return
|
||||
if (body[i].type === SYNTAX.ReturnStatement) {
|
||||
returnRange.push(body[i].range);
|
||||
}
|
||||
// 在函数内部块里的return
|
||||
else if (body[i].type !== SYNTAX.FunctionExpression) {
|
||||
var functionEnter = 0;
|
||||
estraverse.traverse(body[i], {
|
||||
enter: function (returnNode) {
|
||||
var enterHandler = function (returnNode) {
|
||||
if (
|
||||
returnNode.type === SYNTAX.FunctionExpression
|
||||
|| returnNode.type === SYNTAX.FunctionDeclaration
|
||||
@ -121,7 +113,19 @@ function getDefineBlock(code) {
|
||||
else if (returnNode.type === SYNTAX.ReturnStatement) {
|
||||
returnRange.push(returnNode.range);
|
||||
}
|
||||
};
|
||||
|
||||
// 替换return
|
||||
for (var i = 0, l = body.length; i < l; i++) {
|
||||
// 直接在函数体里的return
|
||||
if (body[i].type === SYNTAX.ReturnStatement) {
|
||||
returnRange.push(body[i].range);
|
||||
}
|
||||
// 在函数内部块里的return
|
||||
else if (body[i].type !== SYNTAX.FunctionExpression) {
|
||||
|
||||
estraverse.traverse(body[i], {
|
||||
enter: enterHandler
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -202,16 +206,6 @@ function replaceRequire(code, codeDepth) {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 生成commonjs代码
|
||||
* @param {Object} ast ast树
|
||||
* @return {string} 生成后的代码
|
||||
*/
|
||||
function genCommonJS(ast) {
|
||||
return escodegen.generate(ast);
|
||||
}
|
||||
|
||||
module.exports = function (code, codeDepth) {
|
||||
|
||||
if (codeDepth && codeDepth[codeDepth.length - 1] !== '/') {
|
||||
|
@ -3,6 +3,7 @@
|
||||
* @author mengke01(kekee000@gmail.com)
|
||||
*/
|
||||
|
||||
/* eslint-disable*/
|
||||
|
||||
// 测试define函数
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
* @author mengke01(kekee000@gmail.com)
|
||||
*/
|
||||
|
||||
/* eslint-disable*/
|
||||
|
||||
// 测试define函数
|
||||
define(
|
||||
|
@ -1,4 +0,0 @@
|
||||
fonteditor/template/dialog/*
|
||||
fonteditor/template/export/*
|
||||
editor/shapes/*
|
||||
ttf/data/*
|
@ -124,7 +124,7 @@ define(
|
||||
var buffer = e.target.result;
|
||||
var imported = svg2ttf(buffer);
|
||||
// 设置单个字形名字
|
||||
if (imported.glyf && imported.glyf.length == 1) {
|
||||
if (imported.glyf && imported.glyf.length === 1) {
|
||||
imported.glyf[0].name = fName;
|
||||
}
|
||||
fileReader = null;
|
||||
|
Loading…
x
Reference in New Issue
Block a user