Skip to content

Commit

Permalink
use different eslint config for es6 and es5 (facebook#11794)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
ctxhou authored and gaearon committed Dec 11, 2017
1 parent a5025b1 commit e8e62eb
Show file tree
Hide file tree
Showing 45 changed files with 9,460 additions and 5,302 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"jest-jasmine2": "^21.3.0-beta.4",
"jest-runtime": "^21.3.0-beta.4",
"merge-stream": "^1.0.0",
"minimatch": "^3.0.4",
"minimist": "^1.2.0",
"mkdirp": "^0.5.1",
"ncp": "^2.0.0",
Expand Down
52 changes: 30 additions & 22 deletions packages/events/__tests__/ResponderEventPlugin-test.internal.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,16 @@ const _touchConfig = function(
) {
const allTouchObjects = allTouchHandles.map(touch);
const changedTouchObjects = subsequence(allTouchObjects, changedIndices);
const activeTouchObjects = topType === 'topTouchStart'
? allTouchObjects
: topType === 'topTouchMove'
const activeTouchObjects =
topType === 'topTouchStart'
? allTouchObjects
: topType === 'topTouchMove'
? allTouchObjects
: topType === 'topTouchEnd'
? antiSubsequence(allTouchObjects, changedIndices)
: topType === 'topTouchCancel'
? antiSubsequence(allTouchObjects, changedIndices)
: topType === 'topTouchCancel'
? antiSubsequence(allTouchObjects, changedIndices)
: null;
: null;

return {
nativeEvent: touchEvent(
Expand Down Expand Up @@ -234,19 +235,24 @@ const registerTestHandlers = function(eventTestConfig, readableIDToID) {
for (const readableID in eventTypeTestConfig) {
const nodeConfig = eventTypeTestConfig[readableID];
const id = readableIDToID[readableID];
const handler = nodeConfig.order === NA
? neverFire.bind(null, readableID, registrationName)
: // We partially apply readableID and nodeConfig, as they change in the
// parent closure across iterations.
function(rID, config, e) {
expect(
rID + '->' + registrationName + ' index:' + runs.dispatchCount++,
).toBe(rID + '->' + registrationName + ' index:' + config.order);
if (config.assertEvent) {
config.assertEvent(e);
}
return config.returnVal;
}.bind(null, readableID, nodeConfig);
const handler =
nodeConfig.order === NA
? neverFire.bind(null, readableID, registrationName)
: // We partially apply readableID and nodeConfig, as they change in the
// parent closure across iterations.
function(rID, config, e) {
expect(
rID +
'->' +
registrationName +
' index:' +
runs.dispatchCount++,
).toBe(rID + '->' + registrationName + ' index:' + config.order);
if (config.assertEvent) {
config.assertEvent(e);
}
return config.returnVal;
}.bind(null, readableID, nodeConfig);
putListener(getInstanceFromNode(id), registrationName, handler);
}
};
Expand Down Expand Up @@ -1362,7 +1368,7 @@ describe('ResponderEventPlugin', () => {
});

it('should determine the first common ancestor correctly', () => {
// This test was moved here from the ReactTreeTraversal test since only the
// This test was moved here from the ReactTreeTraversal test since only the
// ResponderEventPlugin uses `getLowestCommonAncestor`
const React = require('react');
const ReactTestUtils = require('react-dom/test-utils');
Expand All @@ -1379,7 +1385,7 @@ describe('ResponderEventPlugin', () => {
);
}
}

class ParentComponent extends React.Component {
render() {
return (
Expand Down Expand Up @@ -1443,7 +1449,9 @@ describe('ResponderEventPlugin', () => {
ReactDOMComponentTree.getInstanceFromNode(plan.one),
ReactDOMComponentTree.getInstanceFromNode(plan.two),
);
expect(firstCommon).toBe(ReactDOMComponentTree.getInstanceFromNode(plan.com));
expect(firstCommon).toBe(
ReactDOMComponentTree.getInstanceFromNode(plan.com),
);
}
});
});
2 changes: 1 addition & 1 deletion packages/react-art/npm/Wedge.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ var Wedge = createReactClass({
var startAngle = this.props.startAngle;
var endAngle = this.props.endAngle;
if (startAngle - endAngle === 0) {
return;
return null;
}

// radii are provided in pixels
Expand Down
16 changes: 8 additions & 8 deletions packages/react-dom/src/__tests__/ReactDOMComponent-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,10 +443,10 @@ describe('ReactDOMComponent', () => {
});

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

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

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

it('should not apply React-specific aliases to custom elements', () => {
var container = document.createElement('div');
const container = document.createElement('div');
ReactDOM.render(<some-custom-element arabicForm="foo" />, container);
var node = container.firstChild;
const node = container.firstChild;
// Should not get transformed to arabic-form as SVG would be.
expect(node.getAttribute('arabicForm')).toBe('foo');
expect(node.hasAttribute('arabic-form')).toBe(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ describe('ReactDOMServer', () => {
it('should not focus on either server or client with autofocus={false} even if there is a markup mismatch', () => {
spyOnDev(console, 'error');

var element = document.createElement('div');
const element = document.createElement('div');
element.innerHTML = ReactDOMServer.renderToString(
<button autoFocus={false}>server</button>,
);
Expand Down
4 changes: 2 additions & 2 deletions packages/react-dom/src/__tests__/validateDOMNesting-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

'use strict';

var React = require('react');
var ReactDOM = require('react-dom');
const React = require('react');
const ReactDOM = require('react-dom');

function normalizeCodeLocInfo(str) {
return str && str.replace(/at .+?:\d+/g, 'at **');
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/src/events/forks/EventListener-www.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @flow
*/

var EventListenerWWW = require('EventListener');
const EventListenerWWW = require('EventListener');

import typeof * as EventListenerType from '../EventListener';
import typeof * as EventListenerShimType from './EventListener-www';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';

describe('transform-prevent-infinite-loops', () => {
// Note: instead of testing the transform by applying it,
Expand Down
4 changes: 2 additions & 2 deletions scripts/babel/transform-object-assign-require.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ module.exports = function autoImporter(babel) {
CallExpression: function(path, file) {
if (path.get('callee').matchesPattern('Object.assign')) {
// generate identifier and require if it hasn't been already
var id = getAssignIdent(path, file, this);
const id = getAssignIdent(path, file, this);
path.node.callee = id;
}
},

MemberExpression: function(path, file) {
if (path.matchesPattern('Object.assign')) {
var id = getAssignIdent(path, file, this);
const id = getAssignIdent(path, file, this);
path.replaceWith(id);
}
},
Expand Down
Loading

0 comments on commit e8e62eb

Please sign in to comment.