Fixed some linting warnings and some mis-spacing in SyntheticEvent warnings.
Michael McDermott committed
Mar 2, 2016 at 18:40 UTC
18af9bc91e5edf7c33d0b7dfb465def09119fc65
10 files changed
+49
-30
.eslintrc
+1
-2
@@ -34,8 +34,7 @@ rules:
34
quotes: [2, single, avoid-escape]
35
space-after-keywords: 2
36
space-before-blocks: 2
37
- # TODO: enable this rule after https://github.com/eslint/eslint/pull/3768 lands
38
- space-before-keywords: 0
37
+ space-before-keywords: 2
38
strict: [2, global]
39
40
# JSX
packages/react/addons.js
+2
@@ -3,11 +3,13 @@
3
var warning = require('fbjs/lib/warning');
4
warning(
5
false,
6
+ /* eslint-disable no-useless-concat */
7
// Require examples in this string must be split to prevent React's
8
// build tools from mistaking them for real requires.
9
// Otherwise the build tools will attempt to build a 'react-addons-{addon}' module.
10
'require' + "('react/addons') is deprecated. " +
11
'Access using require' + "('react-addons-{addon}') instead."
12
);
13
+/* eslint-enable no-useless-concat */
14
15
module.exports = require('./lib/ReactWithAddons');
src/renderers/dom/client/syntheticEvents/SyntheticEvent.js
+3
-3
@@ -275,9 +275,9 @@ function getPooledWarningPropertyDefinition(propName, getVal) {
275
var warningCondition = false;
276
warning(
277
warningCondition,
278
- 'This synthetic event is reused for performance reasons. If you\'re seeing this,' +
279
- 'you\'re %s `%s` on a released/nullified synthetic event. %s.' +
280
- 'If you must keep the original synthetic event around, use event.persist().' +
278
+ 'This synthetic event is reused for performance reasons. If you\'re seeing this, ' +
279
+ 'you\'re %s `%s` on a released/nullified synthetic event. %s. ' +
280
+ 'If you must keep the original synthetic event around, use event.persist(). ' +
281
'See https://fb.me/react-event-pooling for more information.',
282
action,
283
propName,
src/renderers/dom/client/syntheticEvents/__tests__/SyntheticEvent-test.js
+19
-20
@@ -88,9 +88,9 @@ describe('SyntheticEvent', function() {
88
expect(syntheticEvent.target).toBe(null);
89
expect(console.error.calls.length).toBe(3); // once for each property accessed
90
expect(console.error.argsForCall[0][0]).toBe( // assert the first warning for accessing `type`
91
- 'Warning: This synthetic event is reused for performance reasons. If you\'re seeing this,' +
92
- 'you\'re accessing the property `type` on a released/nullified synthetic event. This is set to null.' +
93
- 'If you must keep the original synthetic event around, use event.persist().' +
91
+ 'Warning: This synthetic event is reused for performance reasons. If you\'re seeing this, ' +
92
+ 'you\'re accessing the property `type` on a released/nullified synthetic event. This is set to null. ' +
93
+ 'If you must keep the original synthetic event around, use event.persist(). ' +
94
'See https://fb.me/react-event-pooling for more information.'
95
);
96
});
@@ -103,10 +103,10 @@ describe('SyntheticEvent', function() {
103
expect(syntheticEvent.type = 'MouseEvent').toBe('MouseEvent');
104
expect(console.error.calls.length).toBe(1);
105
expect(console.error.argsForCall[0][0]).toBe(
106
- 'Warning: This synthetic event is reused for performance reasons. If you\'re seeing this,' +
107
- 'you\'re setting the property `type` on a released/nullified synthetic event. This is effectively a no-op.' +
108
- 'If you must keep the original synthetic event around, use event.persist().' +
109
- 'See https://fb.me/react-event-pooling for more information.'
106
+ 'Warning: This synthetic event is reused for performance reasons. If you\'re seeing this, ' +
107
+ 'you\'re setting the property `type` on a released/nullified synthetic event. This is ' +
108
+ 'effectively a no-op. If you must keep the original synthetic event around, use ' +
109
+ 'event.persist(). See https://fb.me/react-event-pooling for more information.'
110
);
111
});
112
@@ -117,10 +117,10 @@ describe('SyntheticEvent', function() {
117
syntheticEvent.preventDefault();
118
expect(console.error.calls.length).toBe(1);
119
expect(console.error.argsForCall[0][0]).toBe(
120
- 'Warning: This synthetic event is reused for performance reasons. If you\'re seeing this,' +
121
- 'you\'re accessing the method `preventDefault` on a released/nullified synthetic event. This is a no-op function.' +
122
- 'If you must keep the original synthetic event around, use event.persist().' +
123
- 'See https://fb.me/react-event-pooling for more information.'
120
+ 'Warning: This synthetic event is reused for performance reasons. If you\'re seeing this, ' +
121
+ 'you\'re accessing the method `preventDefault` on a released/nullified synthetic event. ' +
122
+ 'This is a no-op function. If you must keep the original synthetic event around, ' +
123
+ 'use event.persist(). See https://fb.me/react-event-pooling for more information.'
124
);
125
});
126
@@ -131,10 +131,10 @@ describe('SyntheticEvent', function() {
131
syntheticEvent.stopPropagation();
132
expect(console.error.calls.length).toBe(1);
133
expect(console.error.argsForCall[0][0]).toBe(
134
- 'Warning: This synthetic event is reused for performance reasons. If you\'re seeing this,' +
135
- 'you\'re accessing the method `stopPropagation` on a released/nullified synthetic event. This is a no-op function.' +
136
- 'If you must keep the original synthetic event around, use event.persist().' +
137
- 'See https://fb.me/react-event-pooling for more information.'
134
+ 'Warning: This synthetic event is reused for performance reasons. If you\'re seeing this, ' +
135
+ 'you\'re accessing the method `stopPropagation` on a released/nullified synthetic event. ' +
136
+ 'This is a no-op function. If you must keep the original synthetic event around, ' +
137
+ 'use event.persist(). See https://fb.me/react-event-pooling for more information.'
138
);
139
});
140
@@ -154,9 +154,9 @@ describe('SyntheticEvent', function() {
154
155
expect(console.error.calls.length).toBe(1);
156
expect(console.error.argsForCall[0][0]).toBe(
157
- 'Warning: This synthetic event is reused for performance reasons. If you\'re seeing this,' +
158
- 'you\'re accessing the property `nativeEvent` on a released/nullified synthetic event. This is set to null.' +
159
- 'If you must keep the original synthetic event around, use event.persist().' +
157
+ 'Warning: This synthetic event is reused for performance reasons. If you\'re seeing this, ' +
158
+ 'you\'re accessing the property `nativeEvent` on a released/nullified synthetic event. ' +
159
+ 'This is set to null. If you must keep the original synthetic event around, use event.persist(). ' +
160
'See https://fb.me/react-event-pooling for more information.'
161
);
162
});
@@ -172,8 +172,7 @@ describe('SyntheticEvent', function() {
172
expect(console.error.argsForCall[0][0]).toBe(
173
'Warning: This synthetic event is reused for performance reasons. If you\'re ' +
174
'seeing this, you\'re adding a new property in the synthetic event object. ' +
175
- 'The property is never released. See ' +
176
- 'https://fb.me/react-event-pooling for more information.'
175
+ 'The property is never released. See https://fb.me/react-event-pooling for more information.'
176
);
177
} else {
178
expect(console.error.calls.length).toBe(0);
src/renderers/dom/shared/DOMProperty.js
+3
@@ -142,7 +142,10 @@ var DOMPropertyInjection = {
142
},
143
};
144
145
+/* eslint-disable max-len */
146
var ATTRIBUTE_NAME_START_CHAR = ':A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD';
147
+/* eslint-enable max-len */
148
+
149
150
/**
151
* DOMProperty exports lookup objects that can be used like functions:
src/renderers/dom/shared/DOMPropertyOperations.js
+2
-1
@@ -18,7 +18,8 @@ var ReactPerf = require('ReactPerf');
18
var quoteAttributeValueForBrowser = require('quoteAttributeValueForBrowser');
19
var warning = require('warning');
20
21
-var VALID_ATTRIBUTE_NAME_REGEX = new RegExp('^[' + DOMProperty.ATTRIBUTE_NAME_START_CHAR + '][' + DOMProperty.ATTRIBUTE_NAME_CHAR + ']*$');
21
+var VALID_ATTRIBUTE_NAME_REGEX = new RegExp('^[' + DOMProperty.ATTRIBUTE_NAME_START_CHAR +
22
+ '][' + DOMProperty.ATTRIBUTE_NAME_CHAR + ']*$');
23
var illegalAttributeNameCache = {};
24
var validatedAttributeNameCache = {};
25
src/renderers/shared/reconciler/__tests__/ReactMultiChildText-test.js
+3
-1
@@ -184,7 +184,9 @@ describe('ReactMultiChildText', function() {
184
['', 'foo', <div>{true}{<div />}{1.2}{''}</div>, 'foo'], ['', 'foo', <div />, 'foo'],
185
]);
186
expect(console.error.calls.length).toBe(1);
187
- expect(console.error.argsForCall[0][0]).toContain('Warning: Each child in an array or iterator should have a unique "key" prop.');
187
+ expect(console.error.argsForCall[0][0]).toContain(
188
+ 'Warning: Each child in an array or iterator should have a unique "key" prop.'
189
+ );
190
});
191
192
it('should throw if rendering both HTML and children', function() {
src/shared/utils/__tests__/traverseAllChildren-test.js
+6
-2
@@ -82,7 +82,9 @@ describe('traverseAllChildren', function() {
82
);
83
expect(traverseContext.length).toEqual(1);
84
expect(console.error.calls.length).toBe(1);
85
- expect(console.error.argsForCall[0][0]).toContain('Warning: Each child in an array or iterator should have a unique "key" prop.');
85
+ expect(console.error.argsForCall[0][0]).toContain(
86
+ 'Warning: Each child in an array or iterator should have a unique "key" prop.'
87
+ );
88
});
89
90
it('should be called for each child', function() {
@@ -326,7 +328,9 @@ describe('traverseAllChildren', function() {
328
);
329
330
expect(console.error.calls.length).toBe(1);
329
- expect(console.error.argsForCall[0][0]).toContain('Warning: Each child in an array or iterator should have a unique "key" prop.');
331
+ expect(console.error.argsForCall[0][0]).toContain(
332
+ 'Warning: Each child in an array or iterator should have a unique "key" prop.'
333
+ );
334
});
335
336
it('should be called for each child in an iterable with keys', function() {
src/shared/utils/deprecated.js
+2
@@ -31,6 +31,7 @@ function deprecated(fnName, newModule, newPackage, ctx, fn) {
31
var newFn = function() {
32
warning(
33
warned,
34
+ /* eslint-disable no-useless-concat */
35
// Require examples in this string must be split to prevent React's
36
// build tools from mistaking them for real requires.
37
// Otherwise the build tools will attempt to build a '%s' module.
@@ -41,6 +42,7 @@ function deprecated(fnName, newModule, newPackage, ctx, fn) {
42
fnName,
43
newPackage
44
);
45
+ /* eslint-enable no-useless-concat */
46
warned = true;
47
return fn.apply(ctx, arguments);
48
};
src/test/__tests__/ReactTestUtils-test.js
+8
-1
@@ -201,7 +201,14 @@ describe('ReactTestUtils', function() {
201
this.setState({ clicked: true });
202
},
203
render: function() {
204
- return <div ref={() => {}} onClick={this.handleUserClick} className={this.state.clicked ? 'clicked' : ''}></div>;
204
+ return (
205
+ <div
206
+ ref={() => {}}
207
+ onClick={this.handleUserClick}
208
+ className={this.state.clicked ? 'clicked' : ''}
209
+ >
210
+ </div>
211
+ );
212
},
213
});
214