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;
|
||||
if (currentOptions.modules !== 'typescript') {
|
||||
ext = '.js';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
ext = '.ts';
|
||||
}
|
||||
api.convertFile(filename, filename + ext, currentOptions, context);
|
||||
|
@ -26,7 +26,7 @@ var templatePJSTemplate = _.template('var <%= name %> = function () {\n' +
|
||||
'<%= injectedFunctions %>\n' +
|
||||
'return <%= body %>\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 templateProp = 'rt-repeat';
|
||||
@ -352,14 +352,12 @@ function convertTemplateToReact(html, options) {
|
||||
throw RTCodeError.build("rt-require needs 'dependency' and 'as' attributes", context, tag);
|
||||
} else if (tag.children.length) {
|
||||
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;
|
||||
}
|
||||
else {
|
||||
defines['./'+tag.attribs.dependency] = tag.attribs.as;
|
||||
}
|
||||
}
|
||||
//}
|
||||
} else if (firstTag === null) {
|
||||
firstTag = tag;
|
||||
} else {
|
||||
@ -373,11 +371,10 @@ function convertTemplateToReact(html, options) {
|
||||
var requirePaths = _(defines).keys().map(function (reqName) { return '"' + reqName + '"'; }).value().join(',');
|
||||
var requireVars = _(defines).values().value().join(',');
|
||||
var vars;
|
||||
if (options.modules !== 'typescript') {
|
||||
vars = _(defines).map(function (reqVar, reqPath) { return 'var ' + reqVar + " = require('" + reqPath + "');"; }).join('\n');
|
||||
}
|
||||
else {
|
||||
if (options.modules === 'typescript') {
|
||||
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};
|
||||
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});
|
||||
tree = escodegen.attachComments(tree, tree.comments, tree.tokens);
|
||||
code = escodegen.generate(tree, {comment: true});
|
||||
}
|
||||
catch ( e ) {
|
||||
} catch (e) {
|
||||
throw new RTCodeError(e.message, e.index, -1);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user