Merge pull request #3209 from chicoxyzzy/eslint-everywhere

lint from root
This commit is contained in:
Paul O’Shannessy
2015-02-19 20:59:44 -08:00
14 changed files with 53 additions and 28 deletions
+8
View File
@@ -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
View File
@@ -0,0 +1,3 @@
rules:
block-scoped-var: false
no-undef: false
+7 -5
View File
@@ -1,3 +1,5 @@
'use strict';
var argv = require('optimist').argv;
var fs = require('fs');
@@ -5,9 +7,9 @@ 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) + '...';
}
@@ -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);
});
});
}
+2
View File
@@ -1,3 +1,5 @@
'use strict';
var React = require('react');
var ExampleApplication = React.createClass({
+2
View File
@@ -1,3 +1,5 @@
'use strict';
// Simple pure-React component so we don't have to remember
// Bootstrap's classes
var BootstrapButton = React.createClass({
@@ -1,3 +1,5 @@
'use strict';
var React = require('react');
var App = React.createClass({
@@ -1,3 +1,5 @@
'use strict';
var React = require('react');
var express = require('express');
var path = require('path');
@@ -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)));
});
+1 -9
View File
@@ -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');
+1 -1
View File
@@ -1,4 +1,4 @@
"use strict";
'use strict';
var ReactTools = require('../main.js');
+9 -3
View File
@@ -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();
+6 -2
View File
@@ -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 =
@@ -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);
+1 -1
View File
@@ -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');
+5 -3
View File
@@ -8,6 +8,8 @@
*/
/* jshint browser: true */
/* jslint evil: true */
/*eslint-disable no-eval */
/*eslint-disable block-scoped-var */
'use strict';
@@ -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 + ')';
@@ -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);
}
}
};
@@ -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');
+1 -1
View File
@@ -8,7 +8,7 @@
*/
'use strict';
/*eslint-disable no-undef*/
var Buffer = require('buffer').Buffer;
function inlineSourceMap(sourceMap, sourceCode, sourceFilename) {