Skip to content

Commit e8e62eb

Browse files
ctxhougaearon
authored andcommitted
use different eslint config for es6 and es5 (#11794)
* use different eslint config for es6 and es5 * remove confusing eslint/baseConfig.js & add more eslint setting for es5, es6 * more clear way to run eslint on es5 & es6 file * seperate ESNext, ES6, ES6 path, and use different lint config * rename eslint config file & update eslint rules * Undo yarn.lock changes * Rename a file * Remove unnecessary exceptions * Refactor a little bit * Refactor and tweak the logic * Minor issues
1 parent a5025b1 commit e8e62eb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+9460
-5302
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
"jest-jasmine2": "^21.3.0-beta.4",
7373
"jest-runtime": "^21.3.0-beta.4",
7474
"merge-stream": "^1.0.0",
75+
"minimatch": "^3.0.4",
7576
"minimist": "^1.2.0",
7677
"mkdirp": "^0.5.1",
7778
"ncp": "^2.0.0",

packages/events/__tests__/ResponderEventPlugin-test.internal.js

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,16 @@ const _touchConfig = function(
6565
) {
6666
const allTouchObjects = allTouchHandles.map(touch);
6767
const changedTouchObjects = subsequence(allTouchObjects, changedIndices);
68-
const activeTouchObjects = topType === 'topTouchStart'
69-
? allTouchObjects
70-
: topType === 'topTouchMove'
68+
const activeTouchObjects =
69+
topType === 'topTouchStart'
70+
? allTouchObjects
71+
: topType === 'topTouchMove'
7172
? allTouchObjects
7273
: topType === 'topTouchEnd'
74+
? antiSubsequence(allTouchObjects, changedIndices)
75+
: topType === 'topTouchCancel'
7376
? antiSubsequence(allTouchObjects, changedIndices)
74-
: topType === 'topTouchCancel'
75-
? antiSubsequence(allTouchObjects, changedIndices)
76-
: null;
77+
: null;
7778

7879
return {
7980
nativeEvent: touchEvent(
@@ -234,19 +235,24 @@ const registerTestHandlers = function(eventTestConfig, readableIDToID) {
234235
for (const readableID in eventTypeTestConfig) {
235236
const nodeConfig = eventTypeTestConfig[readableID];
236237
const id = readableIDToID[readableID];
237-
const handler = nodeConfig.order === NA
238-
? neverFire.bind(null, readableID, registrationName)
239-
: // We partially apply readableID and nodeConfig, as they change in the
240-
// parent closure across iterations.
241-
function(rID, config, e) {
242-
expect(
243-
rID + '->' + registrationName + ' index:' + runs.dispatchCount++,
244-
).toBe(rID + '->' + registrationName + ' index:' + config.order);
245-
if (config.assertEvent) {
246-
config.assertEvent(e);
247-
}
248-
return config.returnVal;
249-
}.bind(null, readableID, nodeConfig);
238+
const handler =
239+
nodeConfig.order === NA
240+
? neverFire.bind(null, readableID, registrationName)
241+
: // We partially apply readableID and nodeConfig, as they change in the
242+
// parent closure across iterations.
243+
function(rID, config, e) {
244+
expect(
245+
rID +
246+
'->' +
247+
registrationName +
248+
' index:' +
249+
runs.dispatchCount++,
250+
).toBe(rID + '->' + registrationName + ' index:' + config.order);
251+
if (config.assertEvent) {
252+
config.assertEvent(e);
253+
}
254+
return config.returnVal;
255+
}.bind(null, readableID, nodeConfig);
250256
putListener(getInstanceFromNode(id), registrationName, handler);
251257
}
252258
};
@@ -1362,7 +1368,7 @@ describe('ResponderEventPlugin', () => {
13621368
});
13631369

13641370
it('should determine the first common ancestor correctly', () => {
1365-
// This test was moved here from the ReactTreeTraversal test since only the
1371+
// This test was moved here from the ReactTreeTraversal test since only the
13661372
// ResponderEventPlugin uses `getLowestCommonAncestor`
13671373
const React = require('react');
13681374
const ReactTestUtils = require('react-dom/test-utils');
@@ -1379,7 +1385,7 @@ describe('ResponderEventPlugin', () => {
13791385
);
13801386
}
13811387
}
1382-
1388+
13831389
class ParentComponent extends React.Component {
13841390
render() {
13851391
return (
@@ -1443,7 +1449,9 @@ describe('ResponderEventPlugin', () => {
14431449
ReactDOMComponentTree.getInstanceFromNode(plan.one),
14441450
ReactDOMComponentTree.getInstanceFromNode(plan.two),
14451451
);
1446-
expect(firstCommon).toBe(ReactDOMComponentTree.getInstanceFromNode(plan.com));
1452+
expect(firstCommon).toBe(
1453+
ReactDOMComponentTree.getInstanceFromNode(plan.com),
1454+
);
14471455
}
14481456
});
14491457
});

packages/react-art/npm/Wedge.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ var Wedge = createReactClass({
163163
var startAngle = this.props.startAngle;
164164
var endAngle = this.props.endAngle;
165165
if (startAngle - endAngle === 0) {
166-
return;
166+
return null;
167167
}
168168

169169
// radii are provided in pixels

packages/react-dom/src/__tests__/ReactDOMComponent-test.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -443,10 +443,10 @@ describe('ReactDOMComponent', () => {
443443
});
444444

445445
it('should not set null/undefined attributes', () => {
446-
var container = document.createElement('div');
446+
const container = document.createElement('div');
447447
// Initial render.
448448
ReactDOM.render(<img src={null} data-foo={undefined} />, container);
449-
var node = container.firstChild;
449+
const node = container.firstChild;
450450
expect(node.hasAttribute('src')).toBe(false);
451451
expect(node.hasAttribute('data-foo')).toBe(false);
452452
// Update in one direction.
@@ -468,9 +468,9 @@ describe('ReactDOMComponent', () => {
468468
});
469469

470470
it('should apply React-specific aliases to HTML elements', () => {
471-
var container = document.createElement('div');
471+
const container = document.createElement('div');
472472
ReactDOM.render(<form acceptCharset="foo" />, container);
473-
var node = container.firstChild;
473+
const node = container.firstChild;
474474
// Test attribute initialization.
475475
expect(node.getAttribute('accept-charset')).toBe('foo');
476476
expect(node.hasAttribute('acceptCharset')).toBe(false);
@@ -501,9 +501,9 @@ describe('ReactDOMComponent', () => {
501501
});
502502

503503
it('should apply React-specific aliases to SVG elements', () => {
504-
var container = document.createElement('div');
504+
const container = document.createElement('div');
505505
ReactDOM.render(<svg arabicForm="foo" />, container);
506-
var node = container.firstChild;
506+
const node = container.firstChild;
507507
// Test attribute initialization.
508508
expect(node.getAttribute('arabic-form')).toBe('foo');
509509
expect(node.hasAttribute('arabicForm')).toBe(false);
@@ -543,9 +543,9 @@ describe('ReactDOMComponent', () => {
543543
});
544544

545545
it('should not apply React-specific aliases to custom elements', () => {
546-
var container = document.createElement('div');
546+
const container = document.createElement('div');
547547
ReactDOM.render(<some-custom-element arabicForm="foo" />, container);
548-
var node = container.firstChild;
548+
const node = container.firstChild;
549549
// Should not get transformed to arabic-form as SVG would be.
550550
expect(node.getAttribute('arabicForm')).toBe('foo');
551551
expect(node.hasAttribute('arabic-form')).toBe(false);

packages/react-dom/src/__tests__/ReactServerRendering-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ describe('ReactDOMServer', () => {
376376
it('should not focus on either server or client with autofocus={false} even if there is a markup mismatch', () => {
377377
spyOnDev(console, 'error');
378378

379-
var element = document.createElement('div');
379+
const element = document.createElement('div');
380380
element.innerHTML = ReactDOMServer.renderToString(
381381
<button autoFocus={false}>server</button>,
382382
);

packages/react-dom/src/__tests__/validateDOMNesting-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
'use strict';
1111

12-
var React = require('react');
13-
var ReactDOM = require('react-dom');
12+
const React = require('react');
13+
const ReactDOM = require('react-dom');
1414

1515
function normalizeCodeLocInfo(str) {
1616
return str && str.replace(/at .+?:\d+/g, 'at **');

packages/react-dom/src/events/forks/EventListener-www.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @flow
88
*/
99

10-
var EventListenerWWW = require('EventListener');
10+
const EventListenerWWW = require('EventListener');
1111

1212
import typeof * as EventListenerType from '../EventListener';
1313
import typeof * as EventListenerShimType from './EventListener-www';

scripts/babel/__tests__/transform-prevent-infinite-loops-test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*/
7+
'use strict';
78

89
describe('transform-prevent-infinite-loops', () => {
910
// Note: instead of testing the transform by applying it,

scripts/babel/transform-object-assign-require.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ module.exports = function autoImporter(babel) {
2626
CallExpression: function(path, file) {
2727
if (path.get('callee').matchesPattern('Object.assign')) {
2828
// generate identifier and require if it hasn't been already
29-
var id = getAssignIdent(path, file, this);
29+
const id = getAssignIdent(path, file, this);
3030
path.node.callee = id;
3131
}
3232
},
3333

3434
MemberExpression: function(path, file) {
3535
if (path.matchesPattern('Object.assign')) {
36-
var id = getAssignIdent(path, file, this);
36+
const id = getAssignIdent(path, file, this);
3737
path.replaceWith(id);
3838
}
3939
},

0 commit comments

Comments
 (0)