mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Fixed some linting warnings and some mis-spacing in SyntheticEvent warnings.
This commit is contained in:
@@ -34,8 +34,7 @@ rules:
|
||||
quotes: [2, single, avoid-escape]
|
||||
space-after-keywords: 2
|
||||
space-before-blocks: 2
|
||||
# TODO: enable this rule after https://github.com/eslint/eslint/pull/3768 lands
|
||||
space-before-keywords: 0
|
||||
space-before-keywords: 2
|
||||
strict: [2, global]
|
||||
|
||||
# JSX
|
||||
|
||||
@@ -3,11 +3,13 @@
|
||||
var warning = require('fbjs/lib/warning');
|
||||
warning(
|
||||
false,
|
||||
/* eslint-disable no-useless-concat */
|
||||
// Require examples in this string must be split to prevent React's
|
||||
// build tools from mistaking them for real requires.
|
||||
// Otherwise the build tools will attempt to build a 'react-addons-{addon}' module.
|
||||
'require' + "('react/addons') is deprecated. " +
|
||||
'Access using require' + "('react-addons-{addon}') instead."
|
||||
);
|
||||
/* eslint-enable no-useless-concat */
|
||||
|
||||
module.exports = require('./lib/ReactWithAddons');
|
||||
|
||||
@@ -275,9 +275,9 @@ function getPooledWarningPropertyDefinition(propName, getVal) {
|
||||
var warningCondition = false;
|
||||
warning(
|
||||
warningCondition,
|
||||
'This synthetic event is reused for performance reasons. If you\'re seeing this,' +
|
||||
'you\'re %s `%s` on a released/nullified synthetic event. %s.' +
|
||||
'If you must keep the original synthetic event around, use event.persist().' +
|
||||
'This synthetic event is reused for performance reasons. If you\'re seeing this, ' +
|
||||
'you\'re %s `%s` on a released/nullified synthetic event. %s. ' +
|
||||
'If you must keep the original synthetic event around, use event.persist(). ' +
|
||||
'See https://fb.me/react-event-pooling for more information.',
|
||||
action,
|
||||
propName,
|
||||
|
||||
@@ -88,9 +88,9 @@ describe('SyntheticEvent', function() {
|
||||
expect(syntheticEvent.target).toBe(null);
|
||||
expect(console.error.calls.length).toBe(3); // once for each property accessed
|
||||
expect(console.error.argsForCall[0][0]).toBe( // assert the first warning for accessing `type`
|
||||
'Warning: This synthetic event is reused for performance reasons. If you\'re seeing this,' +
|
||||
'you\'re accessing the property `type` on a released/nullified synthetic event. This is set to null.' +
|
||||
'If you must keep the original synthetic event around, use event.persist().' +
|
||||
'Warning: This synthetic event is reused for performance reasons. If you\'re seeing this, ' +
|
||||
'you\'re accessing the property `type` on a released/nullified synthetic event. This is set to null. ' +
|
||||
'If you must keep the original synthetic event around, use event.persist(). ' +
|
||||
'See https://fb.me/react-event-pooling for more information.'
|
||||
);
|
||||
});
|
||||
@@ -103,10 +103,10 @@ describe('SyntheticEvent', function() {
|
||||
expect(syntheticEvent.type = 'MouseEvent').toBe('MouseEvent');
|
||||
expect(console.error.calls.length).toBe(1);
|
||||
expect(console.error.argsForCall[0][0]).toBe(
|
||||
'Warning: This synthetic event is reused for performance reasons. If you\'re seeing this,' +
|
||||
'you\'re setting the property `type` on a released/nullified synthetic event. This is effectively a no-op.' +
|
||||
'If you must keep the original synthetic event around, use event.persist().' +
|
||||
'See https://fb.me/react-event-pooling for more information.'
|
||||
'Warning: This synthetic event is reused for performance reasons. If you\'re seeing this, ' +
|
||||
'you\'re setting the property `type` on a released/nullified synthetic event. This is ' +
|
||||
'effectively a no-op. If you must keep the original synthetic event around, use ' +
|
||||
'event.persist(). See https://fb.me/react-event-pooling for more information.'
|
||||
);
|
||||
});
|
||||
|
||||
@@ -117,10 +117,10 @@ describe('SyntheticEvent', function() {
|
||||
syntheticEvent.preventDefault();
|
||||
expect(console.error.calls.length).toBe(1);
|
||||
expect(console.error.argsForCall[0][0]).toBe(
|
||||
'Warning: This synthetic event is reused for performance reasons. If you\'re seeing this,' +
|
||||
'you\'re accessing the method `preventDefault` on a released/nullified synthetic event. This is a no-op function.' +
|
||||
'If you must keep the original synthetic event around, use event.persist().' +
|
||||
'See https://fb.me/react-event-pooling for more information.'
|
||||
'Warning: This synthetic event is reused for performance reasons. If you\'re seeing this, ' +
|
||||
'you\'re accessing the method `preventDefault` on a released/nullified synthetic event. ' +
|
||||
'This is a no-op function. If you must keep the original synthetic event around, ' +
|
||||
'use event.persist(). See https://fb.me/react-event-pooling for more information.'
|
||||
);
|
||||
});
|
||||
|
||||
@@ -131,10 +131,10 @@ describe('SyntheticEvent', function() {
|
||||
syntheticEvent.stopPropagation();
|
||||
expect(console.error.calls.length).toBe(1);
|
||||
expect(console.error.argsForCall[0][0]).toBe(
|
||||
'Warning: This synthetic event is reused for performance reasons. If you\'re seeing this,' +
|
||||
'you\'re accessing the method `stopPropagation` on a released/nullified synthetic event. This is a no-op function.' +
|
||||
'If you must keep the original synthetic event around, use event.persist().' +
|
||||
'See https://fb.me/react-event-pooling for more information.'
|
||||
'Warning: This synthetic event is reused for performance reasons. If you\'re seeing this, ' +
|
||||
'you\'re accessing the method `stopPropagation` on a released/nullified synthetic event. ' +
|
||||
'This is a no-op function. If you must keep the original synthetic event around, ' +
|
||||
'use event.persist(). See https://fb.me/react-event-pooling for more information.'
|
||||
);
|
||||
});
|
||||
|
||||
@@ -154,9 +154,9 @@ describe('SyntheticEvent', function() {
|
||||
|
||||
expect(console.error.calls.length).toBe(1);
|
||||
expect(console.error.argsForCall[0][0]).toBe(
|
||||
'Warning: This synthetic event is reused for performance reasons. If you\'re seeing this,' +
|
||||
'you\'re accessing the property `nativeEvent` on a released/nullified synthetic event. This is set to null.' +
|
||||
'If you must keep the original synthetic event around, use event.persist().' +
|
||||
'Warning: This synthetic event is reused for performance reasons. If you\'re seeing this, ' +
|
||||
'you\'re accessing the property `nativeEvent` on a released/nullified synthetic event. ' +
|
||||
'This is set to null. If you must keep the original synthetic event around, use event.persist(). ' +
|
||||
'See https://fb.me/react-event-pooling for more information.'
|
||||
);
|
||||
});
|
||||
@@ -172,8 +172,7 @@ describe('SyntheticEvent', function() {
|
||||
expect(console.error.argsForCall[0][0]).toBe(
|
||||
'Warning: This synthetic event is reused for performance reasons. If you\'re ' +
|
||||
'seeing this, you\'re adding a new property in the synthetic event object. ' +
|
||||
'The property is never released. See ' +
|
||||
'https://fb.me/react-event-pooling for more information.'
|
||||
'The property is never released. See https://fb.me/react-event-pooling for more information.'
|
||||
);
|
||||
} else {
|
||||
expect(console.error.calls.length).toBe(0);
|
||||
|
||||
@@ -142,7 +142,10 @@ var DOMPropertyInjection = {
|
||||
},
|
||||
};
|
||||
|
||||
/* eslint-disable max-len */
|
||||
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';
|
||||
/* eslint-enable max-len */
|
||||
|
||||
|
||||
/**
|
||||
* DOMProperty exports lookup objects that can be used like functions:
|
||||
|
||||
@@ -18,7 +18,8 @@ var ReactPerf = require('ReactPerf');
|
||||
var quoteAttributeValueForBrowser = require('quoteAttributeValueForBrowser');
|
||||
var warning = require('warning');
|
||||
|
||||
var VALID_ATTRIBUTE_NAME_REGEX = new RegExp('^[' + DOMProperty.ATTRIBUTE_NAME_START_CHAR + '][' + DOMProperty.ATTRIBUTE_NAME_CHAR + ']*$');
|
||||
var VALID_ATTRIBUTE_NAME_REGEX = new RegExp('^[' + DOMProperty.ATTRIBUTE_NAME_START_CHAR +
|
||||
'][' + DOMProperty.ATTRIBUTE_NAME_CHAR + ']*$');
|
||||
var illegalAttributeNameCache = {};
|
||||
var validatedAttributeNameCache = {};
|
||||
|
||||
|
||||
@@ -184,7 +184,9 @@ describe('ReactMultiChildText', function() {
|
||||
['', 'foo', <div>{true}{<div />}{1.2}{''}</div>, 'foo'], ['', 'foo', <div />, 'foo'],
|
||||
]);
|
||||
expect(console.error.calls.length).toBe(1);
|
||||
expect(console.error.argsForCall[0][0]).toContain('Warning: Each child in an array or iterator should have a unique "key" prop.');
|
||||
expect(console.error.argsForCall[0][0]).toContain(
|
||||
'Warning: Each child in an array or iterator should have a unique "key" prop.'
|
||||
);
|
||||
});
|
||||
|
||||
it('should throw if rendering both HTML and children', function() {
|
||||
|
||||
@@ -82,7 +82,9 @@ describe('traverseAllChildren', function() {
|
||||
);
|
||||
expect(traverseContext.length).toEqual(1);
|
||||
expect(console.error.calls.length).toBe(1);
|
||||
expect(console.error.argsForCall[0][0]).toContain('Warning: Each child in an array or iterator should have a unique "key" prop.');
|
||||
expect(console.error.argsForCall[0][0]).toContain(
|
||||
'Warning: Each child in an array or iterator should have a unique "key" prop.'
|
||||
);
|
||||
});
|
||||
|
||||
it('should be called for each child', function() {
|
||||
@@ -326,7 +328,9 @@ describe('traverseAllChildren', function() {
|
||||
);
|
||||
|
||||
expect(console.error.calls.length).toBe(1);
|
||||
expect(console.error.argsForCall[0][0]).toContain('Warning: Each child in an array or iterator should have a unique "key" prop.');
|
||||
expect(console.error.argsForCall[0][0]).toContain(
|
||||
'Warning: Each child in an array or iterator should have a unique "key" prop.'
|
||||
);
|
||||
});
|
||||
|
||||
it('should be called for each child in an iterable with keys', function() {
|
||||
|
||||
@@ -31,6 +31,7 @@ function deprecated(fnName, newModule, newPackage, ctx, fn) {
|
||||
var newFn = function() {
|
||||
warning(
|
||||
warned,
|
||||
/* eslint-disable no-useless-concat */
|
||||
// Require examples in this string must be split to prevent React's
|
||||
// build tools from mistaking them for real requires.
|
||||
// Otherwise the build tools will attempt to build a '%s' module.
|
||||
@@ -41,6 +42,7 @@ function deprecated(fnName, newModule, newPackage, ctx, fn) {
|
||||
fnName,
|
||||
newPackage
|
||||
);
|
||||
/* eslint-enable no-useless-concat */
|
||||
warned = true;
|
||||
return fn.apply(ctx, arguments);
|
||||
};
|
||||
|
||||
@@ -201,7 +201,14 @@ describe('ReactTestUtils', function() {
|
||||
this.setState({ clicked: true });
|
||||
},
|
||||
render: function() {
|
||||
return <div ref={() => {}} onClick={this.handleUserClick} className={this.state.clicked ? 'clicked' : ''}></div>;
|
||||
return (
|
||||
<div
|
||||
ref={() => {}}
|
||||
onClick={this.handleUserClick}
|
||||
className={this.state.clicked ? 'clicked' : ''}
|
||||
>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user