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
b32bba381c
commit
84c4864602
@ -65,7 +65,6 @@
|
||||
"space-in-brackets": [0, "never"],
|
||||
"space-infix-ops": 2,
|
||||
"space-return-throw-case": 2,
|
||||
"space-unary-word-ops": 2,
|
||||
"strict": 2,
|
||||
"valid-typeof": 2,
|
||||
"wrap-regex": 0,
|
||||
@ -128,7 +127,8 @@
|
||||
"quote-props": [1, "as-needed"],
|
||||
"no-multi-spaces": 1,
|
||||
"key-spacing": [1, { "beforeColon": false, "afterColon": true }],
|
||||
"comma-spacing": 1
|
||||
"comma-spacing": 1,
|
||||
"space-unary-ops": [1, { "words": true, "nonwords": false }]
|
||||
},
|
||||
"env": {
|
||||
"browser": false,
|
||||
|
@ -138,7 +138,7 @@ module.exports = function (grunt) {
|
||||
|
||||
grunt.registerTask('rt', function () {
|
||||
var reactTemplates = require('./src/cli');
|
||||
var files = grunt.file.expand('playground/**/*.rt');
|
||||
var files = grunt.file.expand('playground/*.rt');
|
||||
var conf = {commonJS: true, force: true};
|
||||
conf._ = files;
|
||||
var ret = reactTemplates.executeOptions(conf);
|
||||
|
20
home.html
20
home.html
@ -17,9 +17,9 @@
|
||||
<link rel="shortcut icon" href="https://facebook.github.io//react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="https://facebook.github.io//react/css/syntax.css">
|
||||
<link rel="stylesheet" href="https://facebook.github.io//react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="https://facebook.github.io//react/css/react.css">
|
||||
<link rel="stylesheet" href="https://facebook.github.io/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="https://facebook.github.io/react/css/codemirror.css">
|
||||
<!--<link rel="stylesheet" href="https://facebook.github.io//react/css/react.css">-->
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
@ -29,12 +29,12 @@
|
||||
<script type="text/javascript" src="/react/js/es5-shim.min.js"></script>
|
||||
<script type="text/javascript" src="/react/js/es5-sham.min.js"></script>
|
||||
<![endif]-->
|
||||
<script type="text/javascript" src="/react/js/codemirror.js"></script>
|
||||
<script type="text/javascript" src="/react/js/javascript.js"></script>
|
||||
<script type="text/javascript" src="/react/js/react.js"></script>
|
||||
<script type="text/javascript" src="/react/js/JSXTransformer.js"></script>
|
||||
<script type="text/javascript" src="/react/js/live_editor.js"></script>
|
||||
<script type="text/javascript" src="/react/js/showdown.js"></script>
|
||||
<!--<script type="text/javascript" src="/react/js/codemirror.js"></script>-->
|
||||
<!--<script type="text/javascript" src="/react/js/javascript.js"></script>-->
|
||||
<!--<script type="text/javascript" src="/react/js/react.js"></script>-->
|
||||
<!--<script type="text/javascript" src="/react/js/JSXTransformer.js"></script>-->
|
||||
<!--<script type="text/javascript" src="/react/js/live_editor.js"></script>-->
|
||||
<!--<script type="text/javascript" src="/react/js/showdown.js"></script>-->
|
||||
|
||||
<!-- Latest compiled and minified CSS -->
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
|
||||
@ -42,7 +42,7 @@
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap-theme.min.css">
|
||||
<!-- Latest compiled and minified JavaScript -->
|
||||
|
||||
<link rel="stylesheet" href="playground/playground.css"/>
|
||||
<link rel="stylesheet" href="playground/css/home.css"/>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
<!-- Latest compiled and minified JavaScript -->
|
||||
|
||||
|
||||
<link rel="stylesheet" href="playground/playground.css"/>
|
||||
<link rel="stylesheet" href="playground/css/playground.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">
|
||||
|
@ -36,7 +36,7 @@
|
||||
"grunt": "^0.4.5",
|
||||
"grunt-browserify": "^3.2.0",
|
||||
"grunt-contrib-watch": "^0.6.1",
|
||||
"grunt-eslint": "^2.0.0",
|
||||
"grunt-eslint": "^2.1.0",
|
||||
"grunt-node-tap": "^0.1.61",
|
||||
"tape": "^3.0.2"
|
||||
}
|
||||
|
1134
playground/css/home.css
Normal file
1134
playground/css/home.css
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,7 @@
|
||||
/**
|
||||
* Created by avim on 12/2/2014.
|
||||
*/
|
||||
'use strict';
|
||||
var React = require('react/addons');
|
||||
var _ = require('lodash');
|
||||
var fiddleTemplate = require('./fiddle.rt.js');
|
||||
@ -11,10 +12,10 @@ function generateRandomId() {
|
||||
return (c == 'x' ? r : (r & 0x3 | 0x8)).toString(16);
|
||||
});
|
||||
return uuid;
|
||||
};
|
||||
}
|
||||
|
||||
var Fiddle = React.createClass({
|
||||
displayName: "Fiddle",
|
||||
displayName: 'Fiddle',
|
||||
componentDidMount: function () {
|
||||
if (window.location.hash) {
|
||||
var newHash = window.location.hash.replace("#", "");
|
||||
@ -37,7 +38,7 @@ var Fiddle = React.createClass({
|
||||
var firebase = new Firebase('https://reacttemplates.firebaseio-demo.com/');
|
||||
firebase.child("fiddles").child(newHash).set(playgroundState, function () {
|
||||
Firebase.goOffline();
|
||||
alert("saved the fiddle, you can share your url")
|
||||
alert("saved the fiddle, you can share your url");
|
||||
}.bind(this));
|
||||
|
||||
},
|
||||
|
@ -1,31 +1,32 @@
|
||||
/**
|
||||
* Created by avim on 12/2/2014.
|
||||
*/
|
||||
'use strict';
|
||||
var React = require('react/addons');
|
||||
var _ = require('lodash');
|
||||
var introTemplate = require('./intro.rt.js');
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
|
||||
var helloCode = fs.readFileSync(__dirname+"/samples/hello.code").toString();
|
||||
var helloRT = fs.readFileSync(__dirname+"/samples/hello.rt").toString();
|
||||
var todoCode = fs.readFileSync(__dirname+"/samples/todo.code").toString();
|
||||
var todoRT = fs.readFileSync(__dirname+"/samples/todo.rt").toString();
|
||||
var helloCode = fs.readFileSync(__dirname + '/samples/hello.code').toString();
|
||||
var helloRT = fs.readFileSync(__dirname + '/samples/hello.rt').toString();
|
||||
var todoCode = fs.readFileSync(__dirname + '/samples/todo.code').toString();
|
||||
var todoRT = fs.readFileSync(__dirname + '/samples/todo.rt').toString();
|
||||
var samples = [
|
||||
[helloCode,helloRT],
|
||||
[todoCode,todoRT]
|
||||
[helloCode, helloRT],
|
||||
[todoCode, todoRT]
|
||||
];
|
||||
samples = _.map(samples,function (tuple) {
|
||||
return {templateProps:tuple[0],templateHTML:tuple[1]}
|
||||
samples = _.map(samples, function (tuple) {
|
||||
return {templateProps: tuple[0], templateHTML: tuple[1]};
|
||||
});
|
||||
|
||||
|
||||
var intro = React.createClass({
|
||||
displayName:"Intro",
|
||||
getInitialState: function (){
|
||||
displayName: 'Intro',
|
||||
getInitialState: function () {
|
||||
return {
|
||||
samples:samples
|
||||
}
|
||||
samples: samples
|
||||
};
|
||||
},
|
||||
render: function () {
|
||||
return introTemplate.apply(this);
|
||||
|
@ -1,9 +1,10 @@
|
||||
/**
|
||||
* Created by avim on 12/2/2014.
|
||||
*/
|
||||
'use strict';
|
||||
var _ = require('lodash');
|
||||
var React = require('react/addons');
|
||||
var reactTemplates = require('../src/reactTemplates.js')
|
||||
var reactTemplates = require('../src/reactTemplates.js');
|
||||
var brace = require('brace');
|
||||
require('brace/mode/javascript');
|
||||
require('brace/mode/html');
|
||||
|
@ -1,14 +1,15 @@
|
||||
/**
|
||||
* Created by avim on 12/2/2014.
|
||||
*/
|
||||
'use strict';
|
||||
var React = require('react/addons');
|
||||
var fiddle = require('./fiddle.js');
|
||||
var intro = require('./intro.js');
|
||||
|
||||
window.initFiddle = function () {
|
||||
window.fiddle = React.render(fiddle(), document.getElementById('container'));
|
||||
}
|
||||
};
|
||||
|
||||
window.initIntro = function () {
|
||||
window.intro = React.render(intro(), document.getElementById('container'));
|
||||
}
|
||||
};
|
||||
|
@ -22,12 +22,12 @@ function generateTemplateSource(html) {
|
||||
|
||||
function generateTemplateFunction(code) {
|
||||
try {
|
||||
var defineMap = {"react/addons": React, lodash: _};
|
||||
var defineMap = {'react/addons': React, lodash: _};
|
||||
var define = function (requirementsNames, content) {
|
||||
var requirements = _.map(requirementsNames,function (reqName) {
|
||||
var requirements = _.map(requirementsNames, function (reqName) {
|
||||
return defineMap[reqName];
|
||||
});
|
||||
return content.apply(this,requirements);
|
||||
return content.apply(this, requirements);
|
||||
};
|
||||
/*eslint no-eval:0*/
|
||||
var res = eval(code);
|
||||
|
@ -64,8 +64,8 @@ function convertText(node, context, txt) {
|
||||
if (curlyCounter !== 0) {
|
||||
throw buildError("Failed to parse text '" + txt + "'", context, node);
|
||||
} else {
|
||||
var needsParens = start !== 0 || end !== txt.length -1;
|
||||
res += (first ? '' : '+') + (needsParens?'(':'')+txt.substr(start + 1, end - start - 2)+(needsParens?')':'');
|
||||
var needsParens = start !== 0 || end !== txt.length - 1;
|
||||
res += (first ? '' : '+') + (needsParens ? '(' : '') + txt.substr(start + 1, end - start - 2) + (needsParens ? ')' : '');
|
||||
first = false;
|
||||
txt = txt.substr(end);
|
||||
}
|
||||
@ -332,7 +332,7 @@ function extractDefinesFromJSXTag(html, defines) {
|
||||
function convertTemplateToReact(html, options) {
|
||||
var rootNode = cheerio.load(html, {lowerCaseTags: false, lowerCaseAttributeNames: false, xmlMode: true, withStartIndices: true});
|
||||
options = options || {};
|
||||
var defines = {"react/addons": 'React', lodash: '_'};
|
||||
var defines = {'react/addons': 'React', lodash: '_'};
|
||||
html = extractDefinesFromJSXTag(html, defines);
|
||||
var context = defaultContext();
|
||||
context.html = html;
|
||||
|
Loading…
x
Reference in New Issue
Block a user