mirror of
https://github.com/bobwen-dev/react-templates
synced 2025-04-12 00:56:39 +02:00
eslint fixes
This commit is contained in:
parent
08f6a601f2
commit
a90e88582c
12
.eslintrc
12
.eslintrc
@ -125,13 +125,13 @@
|
|||||||
"wrap-iife": 2,
|
"wrap-iife": 2,
|
||||||
"no-multi-str": 2,
|
"no-multi-str": 2,
|
||||||
|
|
||||||
"quote-props": [1, "as-needed"],
|
"quote-props": [2, "as-needed"],
|
||||||
"no-multi-spaces": 1,
|
"no-multi-spaces": 2,
|
||||||
"key-spacing": [1, { "beforeColon": false, "afterColon": true }],
|
"key-spacing": [2, { "beforeColon": false, "afterColon": true }],
|
||||||
"comma-spacing": 1,
|
"comma-spacing": 2,
|
||||||
"space-unary-ops": [1, { "words": true, "nonwords": false }],
|
"space-unary-ops": [2, { "words": true, "nonwords": false }],
|
||||||
"indent": [2, 4],
|
"indent": [2, 4],
|
||||||
"space-before-function-paren": [1, {"anonymous": "always", "named": "never"}],
|
"space-before-function-paren": [2, {"anonymous": "always", "named": "never"}],
|
||||||
|
|
||||||
"react/display-name": 2,
|
"react/display-name": 2,
|
||||||
"react/jsx-quotes": 1,
|
"react/jsx-quotes": 1,
|
||||||
|
@ -33,7 +33,7 @@ function convertFile(source, target, options, context) {
|
|||||||
}
|
}
|
||||||
var js;
|
var js;
|
||||||
if (options.modules === 'jsrt') {
|
if (options.modules === 'jsrt') {
|
||||||
js = convertJSRTToJS(html, options)
|
js = convertJSRTToJS(html, options);
|
||||||
} else {
|
} else {
|
||||||
js = convertTemplateToReact(html, options);
|
js = convertTemplateToReact(html, options);
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ function handleSingleFile(currentOptions, filename) {
|
|||||||
try {
|
try {
|
||||||
var sourceExt = path.extname(filename);
|
var sourceExt = path.extname(filename);
|
||||||
var outputFilename;
|
var outputFilename;
|
||||||
if (sourceExt == '.rt') {
|
if (sourceExt === '.rt') {
|
||||||
if (currentOptions.modules !== 'typescript') {
|
if (currentOptions.modules !== 'typescript') {
|
||||||
outputFilename = filename + '.js';
|
outputFilename = filename + '.js';
|
||||||
} else {
|
} else {
|
||||||
@ -64,7 +64,7 @@ function handleSingleFile(currentOptions, filename) {
|
|||||||
}
|
}
|
||||||
} else if (sourceExt === '.jsrt'){
|
} else if (sourceExt === '.jsrt'){
|
||||||
outputFilename = filename.replace(/\.jsrt$/, '.js');
|
outputFilename = filename.replace(/\.jsrt$/, '.js');
|
||||||
currentOptions = _.assign({},currentOptions, {'modules' : 'jsrt'});
|
currentOptions = _.assign({}, currentOptions, {modules: 'jsrt'});
|
||||||
} else {
|
} else {
|
||||||
context.error('invalid file, only handle rt/jsrt files', filename);
|
context.error('invalid file, only handle rt/jsrt files', filename);
|
||||||
return;
|
return;
|
||||||
|
@ -464,7 +464,7 @@ function convertJSRTToJS(text, options) {
|
|||||||
options.modules = 'jsrt';
|
options.modules = 'jsrt';
|
||||||
var templateMatcherJSRT = /<template>([^]*?)<\/template>/gm;
|
var templateMatcherJSRT = /<template>([^]*?)<\/template>/gm;
|
||||||
var code = text.replace(templateMatcherJSRT, function (template, html) {
|
var code = text.replace(templateMatcherJSRT, function (template, html) {
|
||||||
return convertTemplateToReact(html, options).replace(/;$/,'');
|
return convertTemplateToReact(html, options).replace(/;$/, '');
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
var tree = esprima.parse(code, {range: true, tokens: true, comment: true});
|
var tree = esprima.parse(code, {range: true, tokens: true, comment: true});
|
||||||
|
@ -156,7 +156,7 @@ test('convert jsrt and test source results', function (t) {
|
|||||||
function check(file) {
|
function check(file) {
|
||||||
var filename = path.join(dataPath, file);
|
var filename = path.join(dataPath, file);
|
||||||
var js = readFileNormalized(filename);
|
var js = readFileNormalized(filename);
|
||||||
var expected = readFileNormalized(path.join(dataPath, file.replace('.jsrt','.js')));
|
var expected = readFileNormalized(path.join(dataPath, file.replace('.jsrt', '.js')));
|
||||||
// var expected = fs.readFileSync(filename.replace(".html", ".js")).toString();
|
// var expected = fs.readFileSync(filename.replace(".html", ".js")).toString();
|
||||||
var actual = reactTemplates.convertJSRTToJS(js).replace(/\r/g, '').trim();
|
var actual = reactTemplates.convertJSRTToJS(js).replace(/\r/g, '').trim();
|
||||||
compareAndWrite(t, actual, expected, filename);
|
compareAndWrite(t, actual, expected, filename);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user