Skip to content

Commit 58fb322

Browse files
committed
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 :(
1 parent 1df466b commit 58fb322

File tree

11 files changed

+35
-24
lines changed

11 files changed

+35
-24
lines changed

Diff for: .eslintrc

+11-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
parser: esprima-fb
2+
parser: babel-eslint
33

44
env:
55
browser: true
@@ -17,16 +17,18 @@ rules:
1717
strict: 2
1818
# We actually have a transform to support this and we fix this for bundled
1919
# releases but not for the npm package, so enforce it strictly
20-
no-comma-dangle: 2
20+
comma-dangle: [2, never]
2121
# Make this a warning for now. We do this in a few places so we might need to
2222
# disable
2323
no-unused-expressions: 2
24-
block-scoped-var: 2
2524
eol-last: 2
2625
dot-notation: 2
26+
dot-location: [2, property]
2727
consistent-return: 2
2828
no-unused-vars: [2, args: none]
29-
quotes: [2, 'single']
29+
quotes: [2, single]
30+
no-shadow: 2
31+
no-multi-spaces: 2
3032

3133
# WARNINGS
3234
# This is the only one that's hard to track since we don't lint just changes.
@@ -46,6 +48,9 @@ rules:
4648
no-use-before-define: 0
4749
# We do this in a few places to align values
4850
key-spacing: 0
51+
# It's nice to be able to leave catch blocks empty
52+
no-empty: 0
4953

50-
# DISABLED. These currently cause errors when running.
51-
no-multi-spaces: 0
54+
# BROKEN. We'd like to turn these back on.
55+
# causes a ton of noise, eslint is too picky?
56+
block-scoped-var: 0

Diff for: grunt/tasks/eslint.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ module.exports = function() {
66
var done = this.async();
77
grunt.util.spawn({
88
cmd: 'node_modules/.bin/eslint',
9-
args: ['.']
9+
args: ['.'],
10+
opts: {stdio: 'inherit'} // allows colors to passthrough
1011
}, function(err, result, code) {
1112
if (err) {
1213
grunt.log.error('Lint failed');

Diff for: grunt/tasks/release.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var EXAMPLES_PATH = 'examples/';
1515
var EXAMPLES_GLOB = [EXAMPLES_PATH + '**/*.*'];
1616

1717
var STARTER_PATH = 'starter/';
18-
var STARTER_GLOB = [STARTER_PATH + '/**/*.*'];
18+
var STARTER_GLOB = [STARTER_PATH + '/**/*.*'];
1919

2020
var STARTER_BUILD_PATH = 'build/starter/';
2121

Diff for: npm-react-codemod/transforms/class.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*/
1010

11-
/*eslint-disable no-comma-dangle*/
11+
/*eslint-disable comma-dangle*/
1212

1313
'use strict';
1414

@@ -157,11 +157,11 @@ function updateReactCreateClassToES6(file, api, options) {
157157
)
158158
.filter(isFunctionExpression);
159159

160-
const findAutobindNamesFor = (root, fnNames, literalOrIdentifier) => {
160+
const findAutobindNamesFor = (subtree, fnNames, literalOrIdentifier) => {
161161
const node = literalOrIdentifier;
162162
const autobindNames = {};
163163

164-
j(root)
164+
j(subtree)
165165
.find(j.MemberExpression, {
166166
object: node.name ? {
167167
type: node.type,

Diff for: npm-react-codemod/transforms/findDOMNode.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*/
1010

11-
/*eslint-disable no-comma-dangle*/
11+
/*eslint-disable comma-dangle*/
1212

1313
'use strict';
1414

Diff for: npm-react-codemod/transforms/pure-render-mixin.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*/
1010

11-
/*eslint-disable no-comma-dangle*/
11+
/*eslint-disable comma-dangle*/
1212

1313
'use strict';
1414

Diff for: npm-react-codemod/transforms/utils/ReactUtils.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*/
1010

11-
/*eslint-disable no-comma-dangle*/
11+
/*eslint-disable comma-dangle*/
1212

1313
'use strict';
1414

@@ -47,7 +47,7 @@ module.exports = function(j) {
4747
const findReactCreateClass = path =>
4848
path
4949
.findVariableDeclarators()
50-
.filter(path => findReactCreateClassCallExpression(path).size() > 0);
50+
.filter(decl => findReactCreateClassCallExpression(decl).size() > 0);
5151

5252
const findReactCreateClassModuleExports = path =>
5353
path

Diff for: package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
},
3131
"devDependencies": {
3232
"babel": "^5.3.3",
33+
"babel-eslint": "^3.1.9",
3334
"benchmark": "~1.0.0",
3435
"browserify": "^9.0.3",
3536
"bundle-collapser": "^1.1.1",
@@ -38,8 +39,7 @@
3839
"derequire": "^2.0.0",
3940
"envify": "^3.0.0",
4041
"es5-shim": "^4.0.0",
41-
"eslint": "^0.14.1",
42-
"esprima-fb": "^15001.1.0-dev-harmony-fb",
42+
"eslint": "^0.21.2",
4343
"grunt": "~0.4.2",
4444
"grunt-cli": "^0.1.13",
4545
"grunt-compare-size": "~0.4.0",

Diff for: src/addons/ReactFragment.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,13 @@ var warning = require('warning');
2323
* create a keyed fragment. The resulting data structure is opaque, for now.
2424
*/
2525

26+
var fragmentKey;
27+
var didWarnKey;
28+
var canWarnForReactFragment;
29+
2630
if (__DEV__) {
27-
var fragmentKey = '_reactFragment';
28-
var didWarnKey = '_reactDidWarn';
29-
var canWarnForReactFragment = false;
31+
fragmentKey = '_reactFragment';
32+
didWarnKey = '_reactDidWarn';
3033

3134
try {
3235
// Feature test. Don't even try to issue this warning if we can't use
@@ -49,7 +52,9 @@ if (__DEV__) {
4952
);
5053

5154
canWarnForReactFragment = true;
52-
} catch (x) { }
55+
} catch (x) {
56+
canWarnForReactFragment = false;
57+
}
5358

5459
var proxyPropertyAccessWithWarning = function(obj, key) {
5560
Object.defineProperty(obj, key, {

Diff for: src/renderers/dom/client/ReactBrowserEventEmitter.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,8 @@ var ReactBrowserEventEmitter = assign({}, ReactEventEmitterMixin, {
212212
listenTo: function(registrationName, contentDocumentHandle) {
213213
var mountAt = contentDocumentHandle;
214214
var isListening = getListeningForDocument(mountAt);
215-
var dependencies = EventPluginRegistry.
216-
registrationNameDependencies[registrationName];
215+
var dependencies =
216+
EventPluginRegistry.registrationNameDependencies[registrationName];
217217

218218
var topLevelTypes = EventConstants.topLevelTypes;
219219
for (var i = 0; i < dependencies.length; i++) {

Diff for: src/renderers/dom/client/eventPlugins/ChangeEventPlugin.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ if (ExecutionEnvironment.canUseDOM) {
150150
* (For old IE.) Replacement getter/setter for the `value` property that gets
151151
* set on the active element.
152152
*/
153-
var newValueProp = {
153+
var newValueProp = {
154154
get: function() {
155155
return activeElementValueProp.get.call(this);
156156
},

0 commit comments

Comments
 (0)