mirror of
https://github.com/zebrajr/react.git
synced 2025-12-07 12:20:38 +01:00
Use babel-eslint and update eslint
- Removes esprima-fb dependency
- Tightens up eslintrc with some minor rules we were pretty-much
following anyways.
- Adds pretty colors to the `grunt lint` output
- Breaks block-scoped-var :(
This commit is contained in:
parent
1df466b23a
commit
58fb322e21
17
.eslintrc
17
.eslintrc
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
parser: esprima-fb
|
parser: babel-eslint
|
||||||
|
|
||||||
env:
|
env:
|
||||||
browser: true
|
browser: true
|
||||||
|
|
@ -17,16 +17,18 @@ rules:
|
||||||
strict: 2
|
strict: 2
|
||||||
# We actually have a transform to support this and we fix this for bundled
|
# We actually have a transform to support this and we fix this for bundled
|
||||||
# releases but not for the npm package, so enforce it strictly
|
# releases but not for the npm package, so enforce it strictly
|
||||||
no-comma-dangle: 2
|
comma-dangle: [2, never]
|
||||||
# Make this a warning for now. We do this in a few places so we might need to
|
# Make this a warning for now. We do this in a few places so we might need to
|
||||||
# disable
|
# disable
|
||||||
no-unused-expressions: 2
|
no-unused-expressions: 2
|
||||||
block-scoped-var: 2
|
|
||||||
eol-last: 2
|
eol-last: 2
|
||||||
dot-notation: 2
|
dot-notation: 2
|
||||||
|
dot-location: [2, property]
|
||||||
consistent-return: 2
|
consistent-return: 2
|
||||||
no-unused-vars: [2, args: none]
|
no-unused-vars: [2, args: none]
|
||||||
quotes: [2, 'single']
|
quotes: [2, single]
|
||||||
|
no-shadow: 2
|
||||||
|
no-multi-spaces: 2
|
||||||
|
|
||||||
# WARNINGS
|
# WARNINGS
|
||||||
# This is the only one that's hard to track since we don't lint just changes.
|
# This is the only one that's hard to track since we don't lint just changes.
|
||||||
|
|
@ -46,6 +48,9 @@ rules:
|
||||||
no-use-before-define: 0
|
no-use-before-define: 0
|
||||||
# We do this in a few places to align values
|
# We do this in a few places to align values
|
||||||
key-spacing: 0
|
key-spacing: 0
|
||||||
|
# It's nice to be able to leave catch blocks empty
|
||||||
|
no-empty: 0
|
||||||
|
|
||||||
# DISABLED. These currently cause errors when running.
|
# BROKEN. We'd like to turn these back on.
|
||||||
no-multi-spaces: 0
|
# causes a ton of noise, eslint is too picky?
|
||||||
|
block-scoped-var: 0
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,8 @@ module.exports = function() {
|
||||||
var done = this.async();
|
var done = this.async();
|
||||||
grunt.util.spawn({
|
grunt.util.spawn({
|
||||||
cmd: 'node_modules/.bin/eslint',
|
cmd: 'node_modules/.bin/eslint',
|
||||||
args: ['.']
|
args: ['.'],
|
||||||
|
opts: {stdio: 'inherit'} // allows colors to passthrough
|
||||||
}, function(err, result, code) {
|
}, function(err, result, code) {
|
||||||
if (err) {
|
if (err) {
|
||||||
grunt.log.error('Lint failed');
|
grunt.log.error('Lint failed');
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ var EXAMPLES_PATH = 'examples/';
|
||||||
var EXAMPLES_GLOB = [EXAMPLES_PATH + '**/*.*'];
|
var EXAMPLES_GLOB = [EXAMPLES_PATH + '**/*.*'];
|
||||||
|
|
||||||
var STARTER_PATH = 'starter/';
|
var STARTER_PATH = 'starter/';
|
||||||
var STARTER_GLOB = [STARTER_PATH + '/**/*.*'];
|
var STARTER_GLOB = [STARTER_PATH + '/**/*.*'];
|
||||||
|
|
||||||
var STARTER_BUILD_PATH = 'build/starter/';
|
var STARTER_BUILD_PATH = 'build/starter/';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*eslint-disable no-comma-dangle*/
|
/*eslint-disable comma-dangle*/
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
@ -157,11 +157,11 @@ function updateReactCreateClassToES6(file, api, options) {
|
||||||
)
|
)
|
||||||
.filter(isFunctionExpression);
|
.filter(isFunctionExpression);
|
||||||
|
|
||||||
const findAutobindNamesFor = (root, fnNames, literalOrIdentifier) => {
|
const findAutobindNamesFor = (subtree, fnNames, literalOrIdentifier) => {
|
||||||
const node = literalOrIdentifier;
|
const node = literalOrIdentifier;
|
||||||
const autobindNames = {};
|
const autobindNames = {};
|
||||||
|
|
||||||
j(root)
|
j(subtree)
|
||||||
.find(j.MemberExpression, {
|
.find(j.MemberExpression, {
|
||||||
object: node.name ? {
|
object: node.name ? {
|
||||||
type: node.type,
|
type: node.type,
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*eslint-disable no-comma-dangle*/
|
/*eslint-disable comma-dangle*/
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*eslint-disable no-comma-dangle*/
|
/*eslint-disable comma-dangle*/
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*eslint-disable no-comma-dangle*/
|
/*eslint-disable comma-dangle*/
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
@ -47,7 +47,7 @@ module.exports = function(j) {
|
||||||
const findReactCreateClass = path =>
|
const findReactCreateClass = path =>
|
||||||
path
|
path
|
||||||
.findVariableDeclarators()
|
.findVariableDeclarators()
|
||||||
.filter(path => findReactCreateClassCallExpression(path).size() > 0);
|
.filter(decl => findReactCreateClassCallExpression(decl).size() > 0);
|
||||||
|
|
||||||
const findReactCreateClassModuleExports = path =>
|
const findReactCreateClassModuleExports = path =>
|
||||||
path
|
path
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"babel": "^5.3.3",
|
"babel": "^5.3.3",
|
||||||
|
"babel-eslint": "^3.1.9",
|
||||||
"benchmark": "~1.0.0",
|
"benchmark": "~1.0.0",
|
||||||
"browserify": "^9.0.3",
|
"browserify": "^9.0.3",
|
||||||
"bundle-collapser": "^1.1.1",
|
"bundle-collapser": "^1.1.1",
|
||||||
|
|
@ -38,8 +39,7 @@
|
||||||
"derequire": "^2.0.0",
|
"derequire": "^2.0.0",
|
||||||
"envify": "^3.0.0",
|
"envify": "^3.0.0",
|
||||||
"es5-shim": "^4.0.0",
|
"es5-shim": "^4.0.0",
|
||||||
"eslint": "^0.14.1",
|
"eslint": "^0.21.2",
|
||||||
"esprima-fb": "^15001.1.0-dev-harmony-fb",
|
|
||||||
"grunt": "~0.4.2",
|
"grunt": "~0.4.2",
|
||||||
"grunt-cli": "^0.1.13",
|
"grunt-cli": "^0.1.13",
|
||||||
"grunt-compare-size": "~0.4.0",
|
"grunt-compare-size": "~0.4.0",
|
||||||
|
|
|
||||||
|
|
@ -23,10 +23,13 @@ var warning = require('warning');
|
||||||
* create a keyed fragment. The resulting data structure is opaque, for now.
|
* create a keyed fragment. The resulting data structure is opaque, for now.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
var fragmentKey;
|
||||||
|
var didWarnKey;
|
||||||
|
var canWarnForReactFragment;
|
||||||
|
|
||||||
if (__DEV__) {
|
if (__DEV__) {
|
||||||
var fragmentKey = '_reactFragment';
|
fragmentKey = '_reactFragment';
|
||||||
var didWarnKey = '_reactDidWarn';
|
didWarnKey = '_reactDidWarn';
|
||||||
var canWarnForReactFragment = false;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Feature test. Don't even try to issue this warning if we can't use
|
// Feature test. Don't even try to issue this warning if we can't use
|
||||||
|
|
@ -49,7 +52,9 @@ if (__DEV__) {
|
||||||
);
|
);
|
||||||
|
|
||||||
canWarnForReactFragment = true;
|
canWarnForReactFragment = true;
|
||||||
} catch (x) { }
|
} catch (x) {
|
||||||
|
canWarnForReactFragment = false;
|
||||||
|
}
|
||||||
|
|
||||||
var proxyPropertyAccessWithWarning = function(obj, key) {
|
var proxyPropertyAccessWithWarning = function(obj, key) {
|
||||||
Object.defineProperty(obj, key, {
|
Object.defineProperty(obj, key, {
|
||||||
|
|
|
||||||
|
|
@ -212,8 +212,8 @@ var ReactBrowserEventEmitter = assign({}, ReactEventEmitterMixin, {
|
||||||
listenTo: function(registrationName, contentDocumentHandle) {
|
listenTo: function(registrationName, contentDocumentHandle) {
|
||||||
var mountAt = contentDocumentHandle;
|
var mountAt = contentDocumentHandle;
|
||||||
var isListening = getListeningForDocument(mountAt);
|
var isListening = getListeningForDocument(mountAt);
|
||||||
var dependencies = EventPluginRegistry.
|
var dependencies =
|
||||||
registrationNameDependencies[registrationName];
|
EventPluginRegistry.registrationNameDependencies[registrationName];
|
||||||
|
|
||||||
var topLevelTypes = EventConstants.topLevelTypes;
|
var topLevelTypes = EventConstants.topLevelTypes;
|
||||||
for (var i = 0; i < dependencies.length; i++) {
|
for (var i = 0; i < dependencies.length; i++) {
|
||||||
|
|
|
||||||
|
|
@ -150,7 +150,7 @@ if (ExecutionEnvironment.canUseDOM) {
|
||||||
* (For old IE.) Replacement getter/setter for the `value` property that gets
|
* (For old IE.) Replacement getter/setter for the `value` property that gets
|
||||||
* set on the active element.
|
* set on the active element.
|
||||||
*/
|
*/
|
||||||
var newValueProp = {
|
var newValueProp = {
|
||||||
get: function() {
|
get: function() {
|
||||||
return activeElementValueProp.get.call(this);
|
return activeElementValueProp.get.call(this);
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user