1
0
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:
ido 2014-12-03 11:36:34 +02:00
parent b32bba381c
commit 84c4864602
13 changed files with 1177 additions and 39 deletions

@ -65,7 +65,6 @@
"space-in-brackets": [0, "never"], "space-in-brackets": [0, "never"],
"space-infix-ops": 2, "space-infix-ops": 2,
"space-return-throw-case": 2, "space-return-throw-case": 2,
"space-unary-word-ops": 2,
"strict": 2, "strict": 2,
"valid-typeof": 2, "valid-typeof": 2,
"wrap-regex": 0, "wrap-regex": 0,
@ -128,7 +127,8 @@
"quote-props": [1, "as-needed"], "quote-props": [1, "as-needed"],
"no-multi-spaces": 1, "no-multi-spaces": 1,
"key-spacing": [1, { "beforeColon": false, "afterColon": true }], "key-spacing": [1, { "beforeColon": false, "afterColon": true }],
"comma-spacing": 1 "comma-spacing": 1,
"space-unary-ops": [1, { "words": true, "nonwords": false }]
}, },
"env": { "env": {
"browser": false, "browser": false,

@ -138,7 +138,7 @@ module.exports = function (grunt) {
grunt.registerTask('rt', function () { grunt.registerTask('rt', function () {
var reactTemplates = require('./src/cli'); 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}; var conf = {commonJS: true, force: true};
conf._ = files; conf._ = files;
var ret = reactTemplates.executeOptions(conf); var ret = reactTemplates.executeOptions(conf);

@ -17,9 +17,9 @@
<link rel="shortcut icon" href="https://facebook.github.io//react/favicon.ico"> <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="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/syntax.css">
<link rel="stylesheet" href="https://facebook.github.io//react/css/codemirror.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/react.css">-->
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script> <script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
<script type="text/javascript">try{Typekit.load();}catch(e){}</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-shim.min.js"></script>
<script type="text/javascript" src="/react/js/es5-sham.min.js"></script> <script type="text/javascript" src="/react/js/es5-sham.min.js"></script>
<![endif]--> <![endif]-->
<script type="text/javascript" src="/react/js/codemirror.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/javascript.js"></script>-->
<script type="text/javascript" src="/react/js/react.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/JSXTransformer.js"></script>-->
<script type="text/javascript" src="/react/js/live_editor.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/showdown.js"></script>-->
<!-- Latest compiled and minified CSS --> <!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.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"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap-theme.min.css">
<!-- Latest compiled and minified JavaScript --> <!-- Latest compiled and minified JavaScript -->
<link rel="stylesheet" href="playground/playground.css"/> <link rel="stylesheet" href="playground/css/home.css"/>
</head> </head>
<body> <body>

@ -12,7 +12,7 @@
<!-- Latest compiled and minified JavaScript --> <!-- Latest compiled and minified JavaScript -->
<link rel="stylesheet" href="playground/playground.css"/> <link rel="stylesheet" href="playground/css/playground.css"/>
</head> </head>
<body> <body>
<div id="container"> <div id="container">

@ -36,7 +36,7 @@
"grunt": "^0.4.5", "grunt": "^0.4.5",
"grunt-browserify": "^3.2.0", "grunt-browserify": "^3.2.0",
"grunt-contrib-watch": "^0.6.1", "grunt-contrib-watch": "^0.6.1",
"grunt-eslint": "^2.0.0", "grunt-eslint": "^2.1.0",
"grunt-node-tap": "^0.1.61", "grunt-node-tap": "^0.1.61",
"tape": "^3.0.2" "tape": "^3.0.2"
} }

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. * Created by avim on 12/2/2014.
*/ */
'use strict';
var React = require('react/addons'); var React = require('react/addons');
var _ = require('lodash'); var _ = require('lodash');
var fiddleTemplate = require('./fiddle.rt.js'); var fiddleTemplate = require('./fiddle.rt.js');
@ -11,10 +12,10 @@ function generateRandomId() {
return (c == 'x' ? r : (r & 0x3 | 0x8)).toString(16); return (c == 'x' ? r : (r & 0x3 | 0x8)).toString(16);
}); });
return uuid; return uuid;
}; }
var Fiddle = React.createClass({ var Fiddle = React.createClass({
displayName: "Fiddle", displayName: 'Fiddle',
componentDidMount: function () { componentDidMount: function () {
if (window.location.hash) { if (window.location.hash) {
var newHash = window.location.hash.replace("#", ""); var newHash = window.location.hash.replace("#", "");
@ -37,7 +38,7 @@ var Fiddle = React.createClass({
var firebase = new Firebase('https://reacttemplates.firebaseio-demo.com/'); var firebase = new Firebase('https://reacttemplates.firebaseio-demo.com/');
firebase.child("fiddles").child(newHash).set(playgroundState, function () { firebase.child("fiddles").child(newHash).set(playgroundState, function () {
Firebase.goOffline(); Firebase.goOffline();
alert("saved the fiddle, you can share your url") alert("saved the fiddle, you can share your url");
}.bind(this)); }.bind(this));
}, },

@ -1,31 +1,32 @@
/** /**
* Created by avim on 12/2/2014. * Created by avim on 12/2/2014.
*/ */
'use strict';
var React = require('react/addons'); var React = require('react/addons');
var _ = require('lodash'); var _ = require('lodash');
var introTemplate = require('./intro.rt.js'); var introTemplate = require('./intro.rt.js');
var path = require('path'); var path = require('path');
var fs = require('fs'); var fs = require('fs');
var helloCode = fs.readFileSync(__dirname+"/samples/hello.code").toString(); var helloCode = fs.readFileSync(__dirname + '/samples/hello.code').toString();
var helloRT = fs.readFileSync(__dirname+"/samples/hello.rt").toString(); var helloRT = fs.readFileSync(__dirname + '/samples/hello.rt').toString();
var todoCode = fs.readFileSync(__dirname+"/samples/todo.code").toString(); var todoCode = fs.readFileSync(__dirname + '/samples/todo.code').toString();
var todoRT = fs.readFileSync(__dirname+"/samples/todo.rt").toString(); var todoRT = fs.readFileSync(__dirname + '/samples/todo.rt').toString();
var samples = [ var samples = [
[helloCode,helloRT], [helloCode, helloRT],
[todoCode,todoRT] [todoCode, todoRT]
]; ];
samples = _.map(samples,function (tuple) { samples = _.map(samples, function (tuple) {
return {templateProps:tuple[0],templateHTML:tuple[1]} return {templateProps: tuple[0], templateHTML: tuple[1]};
}); });
var intro = React.createClass({ var intro = React.createClass({
displayName:"Intro", displayName: 'Intro',
getInitialState: function (){ getInitialState: function () {
return { return {
samples:samples samples: samples
} };
}, },
render: function () { render: function () {
return introTemplate.apply(this); return introTemplate.apply(this);

@ -1,9 +1,10 @@
/** /**
* Created by avim on 12/2/2014. * Created by avim on 12/2/2014.
*/ */
'use strict';
var _ = require('lodash'); var _ = require('lodash');
var React = require('react/addons'); var React = require('react/addons');
var reactTemplates = require('../src/reactTemplates.js') var reactTemplates = require('../src/reactTemplates.js');
var brace = require('brace'); var brace = require('brace');
require('brace/mode/javascript'); require('brace/mode/javascript');
require('brace/mode/html'); require('brace/mode/html');

@ -1,14 +1,15 @@
/** /**
* Created by avim on 12/2/2014. * Created by avim on 12/2/2014.
*/ */
'use strict';
var React = require('react/addons'); var React = require('react/addons');
var fiddle = require('./fiddle.js'); var fiddle = require('./fiddle.js');
var intro = require('./intro.js'); var intro = require('./intro.js');
window.initFiddle = function () { window.initFiddle = function () {
window.fiddle = React.render(fiddle(), document.getElementById('container')); window.fiddle = React.render(fiddle(), document.getElementById('container'));
} };
window.initIntro = function () { window.initIntro = function () {
window.intro = React.render(intro(), document.getElementById('container')); window.intro = React.render(intro(), document.getElementById('container'));
} };

@ -22,12 +22,12 @@ function generateTemplateSource(html) {
function generateTemplateFunction(code) { function generateTemplateFunction(code) {
try { try {
var defineMap = {"react/addons": React, lodash: _}; var defineMap = {'react/addons': React, lodash: _};
var define = function (requirementsNames, content) { var define = function (requirementsNames, content) {
var requirements = _.map(requirementsNames,function (reqName) { var requirements = _.map(requirementsNames, function (reqName) {
return defineMap[reqName]; return defineMap[reqName];
}); });
return content.apply(this,requirements); return content.apply(this, requirements);
}; };
/*eslint no-eval:0*/ /*eslint no-eval:0*/
var res = eval(code); var res = eval(code);

@ -64,8 +64,8 @@ function convertText(node, context, txt) {
if (curlyCounter !== 0) { if (curlyCounter !== 0) {
throw buildError("Failed to parse text '" + txt + "'", context, node); throw buildError("Failed to parse text '" + txt + "'", context, node);
} else { } else {
var needsParens = start !== 0 || end !== txt.length -1; var needsParens = start !== 0 || end !== txt.length - 1;
res += (first ? '' : '+') + (needsParens?'(':'')+txt.substr(start + 1, end - start - 2)+(needsParens?')':''); res += (first ? '' : '+') + (needsParens ? '(' : '') + txt.substr(start + 1, end - start - 2) + (needsParens ? ')' : '');
first = false; first = false;
txt = txt.substr(end); txt = txt.substr(end);
} }
@ -332,7 +332,7 @@ function extractDefinesFromJSXTag(html, defines) {
function convertTemplateToReact(html, options) { function convertTemplateToReact(html, options) {
var rootNode = cheerio.load(html, {lowerCaseTags: false, lowerCaseAttributeNames: false, xmlMode: true, withStartIndices: true}); var rootNode = cheerio.load(html, {lowerCaseTags: false, lowerCaseAttributeNames: false, xmlMode: true, withStartIndices: true});
options = options || {}; options = options || {};
var defines = {"react/addons": 'React', lodash: '_'}; var defines = {'react/addons': 'React', lodash: '_'};
html = extractDefinesFromJSXTag(html, defines); html = extractDefinesFromJSXTag(html, defines);
var context = defaultContext(); var context = defaultContext();
context.html = html; context.html = html;