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,
|
||||
"no-multi-str": 2,
|
||||
|
||||
"quote-props": [1, "as-needed"],
|
||||
"no-multi-spaces": 1,
|
||||
"key-spacing": [1, { "beforeColon": false, "afterColon": true }],
|
||||
"comma-spacing": 1,
|
||||
"space-unary-ops": [1, { "words": true, "nonwords": false }],
|
||||
"quote-props": [2, "as-needed"],
|
||||
"no-multi-spaces": 2,
|
||||
"key-spacing": [2, { "beforeColon": false, "afterColon": true }],
|
||||
"comma-spacing": 2,
|
||||
"space-unary-ops": [2, { "words": true, "nonwords": false }],
|
||||
"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/jsx-quotes": 1,
|
||||
|
@ -33,7 +33,7 @@ function convertFile(source, target, options, context) {
|
||||
}
|
||||
var js;
|
||||
if (options.modules === 'jsrt') {
|
||||
js = convertJSRTToJS(html, options)
|
||||
js = convertJSRTToJS(html, options);
|
||||
} else {
|
||||
js = convertTemplateToReact(html, options);
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ function handleSingleFile(currentOptions, filename) {
|
||||
try {
|
||||
var sourceExt = path.extname(filename);
|
||||
var outputFilename;
|
||||
if (sourceExt == '.rt') {
|
||||
if (sourceExt === '.rt') {
|
||||
if (currentOptions.modules !== 'typescript') {
|
||||
outputFilename = filename + '.js';
|
||||
} else {
|
||||
@ -64,7 +64,7 @@ function handleSingleFile(currentOptions, filename) {
|
||||
}
|
||||
} else if (sourceExt === '.jsrt'){
|
||||
outputFilename = filename.replace(/\.jsrt$/, '.js');
|
||||
currentOptions = _.assign({},currentOptions, {'modules' : 'jsrt'});
|
||||
currentOptions = _.assign({}, currentOptions, {modules: 'jsrt'});
|
||||
} else {
|
||||
context.error('invalid file, only handle rt/jsrt files', filename);
|
||||
return;
|
||||
|
@ -464,7 +464,7 @@ function convertJSRTToJS(text, options) {
|
||||
options.modules = 'jsrt';
|
||||
var templateMatcherJSRT = /<template>([^]*?)<\/template>/gm;
|
||||
var code = text.replace(templateMatcherJSRT, function (template, html) {
|
||||
return convertTemplateToReact(html, options).replace(/;$/,'');
|
||||
return convertTemplateToReact(html, options).replace(/;$/, '');
|
||||
});
|
||||
try {
|
||||
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) {
|
||||
var filename = path.join(dataPath, file);
|
||||
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 actual = reactTemplates.convertJSRTToJS(js).replace(/\r/g, '').trim();
|
||||
compareAndWrite(t, actual, expected, filename);
|
||||
|
Loading…
x
Reference in New Issue
Block a user