mirror of
https://github.com/bobwen-dev/react-templates
synced 2025-04-12 00:56:39 +02:00
fix eslint issues
This commit is contained in:
parent
4788d3d5f8
commit
cd12a3a4bf
@ -61,8 +61,7 @@ function handleSingleFile(currentOptions, filename) {
|
|||||||
var ext;
|
var ext;
|
||||||
if (currentOptions.modules !== 'typescript') {
|
if (currentOptions.modules !== 'typescript') {
|
||||||
ext = '.js';
|
ext = '.js';
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ext = '.ts';
|
ext = '.ts';
|
||||||
}
|
}
|
||||||
api.convertFile(filename, filename + ext, currentOptions, context);
|
api.convertFile(filename, filename + ext, currentOptions, context);
|
||||||
|
@ -26,7 +26,7 @@ var templatePJSTemplate = _.template('var <%= name %> = function () {\n' +
|
|||||||
'<%= injectedFunctions %>\n' +
|
'<%= injectedFunctions %>\n' +
|
||||||
'return <%= body %>\n' +
|
'return <%= body %>\n' +
|
||||||
'};\n');
|
'};\n');
|
||||||
var templateTypescriptTemplate = _.template("<%= vars %>\n\n<%= injectedFunctions %>\nvar fn = function() { return <%= body %> };\nexport = fn\n");
|
var templateTypescriptTemplate = _.template('<%= vars %>\n\n<%= injectedFunctions %>\nvar fn = function() { return <%= body %> };\nexport = fn\n');
|
||||||
var htmlSelfClosingTags = ['area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr'];
|
var htmlSelfClosingTags = ['area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr'];
|
||||||
|
|
||||||
var templateProp = 'rt-repeat';
|
var templateProp = 'rt-repeat';
|
||||||
@ -352,14 +352,12 @@ function convertTemplateToReact(html, options) {
|
|||||||
throw RTCodeError.build("rt-require needs 'dependency' and 'as' attributes", context, tag);
|
throw RTCodeError.build("rt-require needs 'dependency' and 'as' attributes", context, tag);
|
||||||
} else if (tag.children.length) {
|
} else if (tag.children.length) {
|
||||||
throw RTCodeError.build('rt-require may have no children', context, tag);
|
throw RTCodeError.build('rt-require may have no children', context, tag);
|
||||||
} else {
|
}
|
||||||
if (options.modules !== 'typescript') {
|
//if (options.modules === 'typescript') {
|
||||||
|
// defines['./' + tag.attribs.dependency] = tag.attribs.as;
|
||||||
|
//} else {
|
||||||
defines[tag.attribs.dependency] = tag.attribs.as;
|
defines[tag.attribs.dependency] = tag.attribs.as;
|
||||||
}
|
//}
|
||||||
else {
|
|
||||||
defines['./'+tag.attribs.dependency] = tag.attribs.as;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (firstTag === null) {
|
} else if (firstTag === null) {
|
||||||
firstTag = tag;
|
firstTag = tag;
|
||||||
} else {
|
} else {
|
||||||
@ -373,11 +371,10 @@ function convertTemplateToReact(html, options) {
|
|||||||
var requirePaths = _(defines).keys().map(function (reqName) { return '"' + reqName + '"'; }).value().join(',');
|
var requirePaths = _(defines).keys().map(function (reqName) { return '"' + reqName + '"'; }).value().join(',');
|
||||||
var requireVars = _(defines).values().value().join(',');
|
var requireVars = _(defines).values().value().join(',');
|
||||||
var vars;
|
var vars;
|
||||||
if (options.modules !== 'typescript') {
|
if (options.modules === 'typescript') {
|
||||||
vars = _(defines).map(function (reqVar, reqPath) { return 'var ' + reqVar + " = require('" + reqPath + "');"; }).join('\n');
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
vars = _(defines).map(function (reqVar, reqPath) { return 'import ' + reqVar + " = require('" + reqPath + "');"; }).join('\n');
|
vars = _(defines).map(function (reqVar, reqPath) { return 'import ' + reqVar + " = require('" + reqPath + "');"; }).join('\n');
|
||||||
|
} else {
|
||||||
|
vars = _(defines).map(function (reqVar, reqPath) { return 'var ' + reqVar + " = require('" + reqPath + "');"; }).join('\n');
|
||||||
}
|
}
|
||||||
var data = {body: body, injectedFunctions: '', requireNames: requireVars, requirePaths: requirePaths, vars: vars, name: options.name};
|
var data = {body: body, injectedFunctions: '', requireNames: requireVars, requirePaths: requirePaths, vars: vars, name: options.name};
|
||||||
data.injectedFunctions = context.injectedFunctions.join('\n');
|
data.injectedFunctions = context.injectedFunctions.join('\n');
|
||||||
@ -387,8 +384,7 @@ function convertTemplateToReact(html, options) {
|
|||||||
var tree = esprima.parse(code, {range: true, tokens: true, comment: true});
|
var tree = esprima.parse(code, {range: true, tokens: true, comment: true});
|
||||||
tree = escodegen.attachComments(tree, tree.comments, tree.tokens);
|
tree = escodegen.attachComments(tree, tree.comments, tree.tokens);
|
||||||
code = escodegen.generate(tree, {comment: true});
|
code = escodegen.generate(tree, {comment: true});
|
||||||
}
|
} catch (e) {
|
||||||
catch ( e ) {
|
|
||||||
throw new RTCodeError(e.message, e.index, -1);
|
throw new RTCodeError(e.message, e.index, -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user