Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,11 @@ src/test
test/the-files-to-test.generated.js
# This is synced with a different file internally, don't want to lint it yet
vendor/fbtransform/syntax.js
vendor/jasmine/
vendor/jasmine-jsreporter/
# But not in docs/_js/examples/*
docs/_js/*.js
docs/js/
# This should be more like examples/**/thirdparty/** but
# we should fix https://github.com/facebook/esprima/pull/85 first
examples/
3 changes: 3 additions & 0 deletions docs/_js/examples/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
rules:
block-scoped-var: false
no-undef: false
12 changes: 7 additions & 5 deletions docs/extractCode.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
'use strict';

var argv = require('optimist').argv;
var fs = require('fs');

var CODE_SAMPLE = /```[\S]+\s*[\s\S]*?```/g;
var PARTS = /```[\S]+\s*\/\/\s+(.+?)\n([\s\S]*?)```/;

function truncate(s, n) {
n = n || 256
n = n || 256;
if (s.length < n) {
return s;
return s;
}
return s.substring(0, n) + '...';
}
Expand All @@ -27,9 +29,9 @@ function main(dest, filenames) {
if (!extracted) {
throw new Error('Code sample did not match correct format in ' + filename + ': ' + truncate(codeSample));
}
var filename = extracted[1];
var content = extracted[2].replace(/\*\*/g, '');
fs.writeFileSync(argv.dest + '/' + filename, content);
var codeSampleFilename = extracted[1];
var codeSampleContent = extracted[2].replace(/\*\*/g, '');
fs.writeFileSync(argv.dest + '/' + codeSampleFilename, codeSampleContent);
});
});
}
Expand Down
2 changes: 2 additions & 0 deletions examples/basic-commonjs/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

var React = require('react');

var ExampleApplication = React.createClass({
Expand Down
2 changes: 2 additions & 0 deletions examples/jquery-bootstrap/js/app.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

// Simple pure-React component so we don't have to remember
// Bootstrap's classes
var BootstrapButton = React.createClass({
Expand Down
2 changes: 2 additions & 0 deletions examples/server-rendering/jsapp/src/App.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

var React = require('react');

var App = React.createClass({
Expand Down
8 changes: 5 additions & 3 deletions examples/server-rendering/reactserver/server.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

var React = require('react');
var express = require('express');
var path = require('path');
Expand All @@ -11,9 +13,9 @@ var app = express();
// in the querystring and return a static HTML representation of the component.
// Note that this is a backend service hit by your actual web app. Even so,
// you would probably put Varnish in front of this in production.
app.get('/', function(req, res){
var component = require(path.resolve(req.query['module']));
var props = JSON.parse(req.query['props'] || '{}');
app.get('/', function(req, res) {
var component = require(path.resolve(req.query.module));
var props = JSON.parse(req.query.props || '{}');

res.send(React.renderToString(component(props)));
});
Expand Down
10 changes: 1 addition & 9 deletions grunt/tasks/eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,7 @@ module.exports = function() {
var done = this.async();
grunt.util.spawn({
cmd: 'node_modules/.bin/eslint',
args: [
'src/',
'Gruntfile.js',
'grunt/',
'main.js',
'perf/',
'test/',
'vendor/fbtransform'
]
args: ['.']
}, function(err, result, code) {
if (err) {
grunt.log.error('Lint failed');
Expand Down
2 changes: 1 addition & 1 deletion jest/preprocessor.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"use strict";
'use strict';

var ReactTools = require('../main.js');

Expand Down
12 changes: 9 additions & 3 deletions jest/ts-preprocessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,15 @@ function compile(defaultLib, content, contentFilename) {
throw new Error('Expected only one dependency.');
}
},
getCanonicalFileName: function(filename) { return filename; },
getCurrentDirectory: function() { return ''; },
getNewLine: function() { return '\n'; }
getCanonicalFileName: function(filename) {
return filename;
},
getCurrentDirectory: function() {
return '';
},
getNewLine: function() {
return '\n';
}
};
var program = ts.createProgram([contentFilename], tsOptions, compilerHost);
var errors = program.getDiagnostics();
Expand Down
8 changes: 6 additions & 2 deletions npm-jsx_orphaned_brackets_transformer/run.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#!/usr/bin/env node

'use strict';

var esprima = require('esprima-fb');
var FileFinder = require('node-find-files');
var fs = require('graceful-fs');
var jstransform = require('jstransform');
var path = require('path');
var visitReactTag = require('./transforms/react').visitReactTag;

/*eslint-disable no-shadow*/
var S = esprima.Syntax;

var USAGE =
Expand Down Expand Up @@ -143,7 +145,9 @@ if (require.main === module) {
var absPath = path.resolve(arg);

fs.stat(absPath, function(err, stat) {
if (err) throw err;
if (err) {
throw err;
}

if (stat.isFile()) {
transformFile(absPath);
Expand Down
2 changes: 1 addition & 1 deletion npm-jsx_orphaned_brackets_transformer/transforms/react.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
/*global exports:true*/
"use strict";
'use strict';
var Syntax = require('esprima-fb').Syntax;
var utils = require('jstransform/src/utils');

Expand Down
8 changes: 5 additions & 3 deletions vendor/browser-transforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
*/
/* jshint browser: true */
/* jslint evil: true */
/*eslint-disable no-eval */
/*eslint-disable block-scoped-var */

'use strict';

Expand Down Expand Up @@ -141,7 +143,7 @@ function transformCode(code, url, options) {

var source;
if (url == null) {
source = "Inline JSX script";
source = 'Inline JSX script';
inlineScriptCount++;
if (inlineScriptCount > 1) {
source += ' (' + inlineScriptCount + ')';
Expand Down Expand Up @@ -202,7 +204,7 @@ function load(url, successCallback, errorCallback) {
successCallback(xhr.responseText);
} else {
errorCallback();
throw new Error("Could not load " + url);
throw new Error('Could not load ' + url);
}
}
};
Expand Down Expand Up @@ -316,7 +318,7 @@ function runScripts() {

// Listen for load event if we're in a browser and then kick off finding and
// running of scripts.
if (typeof window !== "undefined" && window !== null) {
if (typeof window !== 'undefined' && window !== null) {
headEl = document.getElementsByTagName('head')[0];
dummyAnchor = document.createElement('a');

Expand Down
2 changes: 1 addition & 1 deletion vendor/inline-source-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

'use strict';

/*eslint-disable no-undef*/
var Buffer = require('buffer').Buffer;

function inlineSourceMap(sourceMap, sourceCode, sourceFilename) {
Expand Down