Skip to content

Commit

Permalink
[Dev Deps] update babel-preset-airbnb, eslint, `eslint-config-air…
Browse files Browse the repository at this point in the history
…bnb`, `eslint-plugin-import`, `mocha`
  • Loading branch information
ljharb committed Sep 30, 2016
1 parent c07e61f commit 9b56f2a
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 81 deletions.
10 changes: 5 additions & 5 deletions package.json
Expand Up @@ -64,7 +64,7 @@
"babel-core": "^6.14.0",
"babel-eslint": "^6.1.2",
"babel-loader": "^6.2.5",
"babel-preset-airbnb": "^2.0.0",
"babel-preset-airbnb": "^2.1.0",
"babel-register": "^6.14.0",
"chai": "^3.5.0",
"coveralls": "^2.11.14",
Expand All @@ -73,9 +73,9 @@
"enzyme-example-karma-webpack": "^0.1.4",
"enzyme-example-mocha": "^0.1.0",
"enzyme-example-react-native": "^0.1.0",
"eslint": "^3.5.0",
"eslint-config-airbnb": "^10.0.1",
"eslint-plugin-import": "^1.15.0",
"eslint": "^3.6.1",
"eslint-config-airbnb": "^12.0.0",
"eslint-plugin-import": "^1.16.0",
"eslint-plugin-jsx-a11y": "^2.2.2",
"eslint-plugin-react": "^6.3.0",
"gitbook-cli": "^1.0.1",
Expand All @@ -88,7 +88,7 @@
"karma-mocha": "^1.1.1",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^1.7.0",
"mocha": "^3.0.2",
"mocha": "^3.1.0",
"rimraf": "^2.5.4",
"sinon": "^1.17.6",
"webpack": "^1.13.2"
Expand Down
36 changes: 12 additions & 24 deletions src/ComplexSelector.js
Expand Up @@ -7,17 +7,15 @@ export default class ComplexSelector {
this.childrenOfNode = childrenOfNode;
}

getSelectors(selector) {
getSelectors(selector) { // eslint-disable-line class-methods-use-this
const selectors = split(selector, / (?=(?:(?:[^"]*"){2})*[^"]*$)/);
return selectors.reduce((list, sel) => {
if (sel === '+' || sel === '~') {
const temp = list.pop();
list.push(sel, temp);
return list;
return list.concat(sel, temp);
}

list.push(sel);
return list;
return list.concat(sel);
}, []);
}

Expand All @@ -35,7 +33,7 @@ export default class ComplexSelector {

return (child) => {
if (firstPredicate(child)) {
return (sibling) => secondPredicate(sibling);
return sibling => secondPredicate(sibling);
}

return false;
Expand Down Expand Up @@ -85,33 +83,23 @@ export default class ComplexSelector {
}

treeFilterDirect() {
return (tree, fn) => {
const results = [];
this.childrenOfNode(tree).forEach(child => {
if (fn(child)) {
results.push(child);
}
});

return results;
};
return (tree, fn) => this.childrenOfNode(tree).filter(child => fn(child));
}

treeFindSiblings(selectSiblings) {
return (tree, fn) => {
const results = [];
const list = [this.childrenOfNode(tree)];

const traverseChildren = (children) =>
children.forEach((child, i) => {
const secondPredicate = fn(child);
const traverseChildren = children => children.forEach((child, i) => {
const secondPredicate = fn(child);

list.push(this.childrenOfNode(child));
list.push(this.childrenOfNode(child));

if (secondPredicate) {
selectSiblings(children, secondPredicate, results, i);
}
});
if (secondPredicate) {
selectSiblings(children, secondPredicate, results, i);
}
});

while (list.length) {
traverseChildren(list.shift());
Expand Down
2 changes: 1 addition & 1 deletion src/MountedTraversal.js
Expand Up @@ -117,7 +117,7 @@ export function childrenOfInstInternal(inst) {
return false;
}
return true;
}).map(key => {
}).map((key) => {
if (!REACT013 && typeof renderedChildren[key]._currentElement.type === 'function') {
return renderedChildren[key]._instance;
}
Expand Down
13 changes: 3 additions & 10 deletions src/ReactWrapper.jsx
Expand Up @@ -360,14 +360,7 @@ export default class ReactWrapper {
* @returns {Boolean}
*/
containsAnyMatchingElements(nodes) {
if (!Array.isArray(nodes)) return false;
if (nodes.length <= 0) return false;
for (let i = 0; i < nodes.length; i++) {
if (this.containsMatchingElement(nodes[i])) {
return true;
}
}
return false;
return Array.isArray(nodes) && nodes.some(node => this.containsMatchingElement(node));
}

/**
Expand Down Expand Up @@ -467,7 +460,7 @@ export default class ReactWrapper {
* @returns {String}
*/
html() {
return this.single('html', n => {
return this.single('html', (n) => {
const node = findDOMNode(n);
return node === null ? null :
node.outerHTML.replace(/\sdata-(reactid|reactroot)+="([^"]*)+"/g, '');
Expand Down Expand Up @@ -495,7 +488,7 @@ export default class ReactWrapper {
* @returns {ReactWrapper}
*/
simulate(event, mock = {}) {
this.single('simulate', n => {
this.single('simulate', (n) => {
const mappedEvent = mapNativeEventNames(event);
const eventFn = Simulate[mappedEvent];
if (!eventFn) {
Expand Down
2 changes: 2 additions & 0 deletions src/ReactWrapperComponent.jsx
@@ -1,6 +1,8 @@
import React, { PropTypes } from 'react';
import objectAssign from 'object.assign';

/* eslint react/forbid-prop-types: 0 */

/**
* This is a utility component to wrap around the nodes we are
* passing in to `mount()`. Theoretically, you could do everything
Expand Down
6 changes: 3 additions & 3 deletions src/ShallowTraversal.js
Expand Up @@ -17,7 +17,7 @@ export function childrenOfNode(node) {
if (!node) return [];
const maybeArray = propsOfNode(node).children;
const result = [];
React.Children.forEach(maybeArray, child => {
React.Children.forEach(maybeArray, (child) => {
if (child !== null && child !== false && typeof child !== 'undefined') {
result.push(child);
}
Expand All @@ -40,7 +40,7 @@ export function treeForEach(tree, fn) {

export function treeFilter(tree, fn) {
const results = [];
treeForEach(tree, node => {
treeForEach(tree, (node) => {
if (fn(node)) {
results.push(node);
}
Expand All @@ -56,7 +56,7 @@ export function pathToNode(node, root) {
const queue = [root];
const path = [];

const hasNode = (testNode) => node === testNode;
const hasNode = testNode => node === testNode;

while (queue.length) {
const current = queue.pop();
Expand Down
15 changes: 2 additions & 13 deletions src/ShallowWrapper.js
Expand Up @@ -376,14 +376,7 @@ export default class ShallowWrapper {
* @returns {Boolean}
*/
containsAnyMatchingElements(nodes) {
if (!Array.isArray(nodes)) return false;
if (nodes.length <= 0) return false;
for (let i = 0; i < nodes.length; i++) {
if (this.containsMatchingElement(nodes[i])) {
return true;
}
}
return false;
return Array.isArray(nodes) && nodes.some(node => this.containsMatchingElement(node));
}

/**
Expand Down Expand Up @@ -512,11 +505,7 @@ export default class ShallowWrapper {
* @returns {String}
*/
html() {
return this.single('html', n => {
// NOTE: splitting this into two statements is required to make the linter happy.
const isNull = this.type() === null;
return isNull ? null : renderToStaticMarkup(n);
});
return this.single('html', n => (this.type() === null ? null : renderToStaticMarkup(n)));
}

/**
Expand Down
13 changes: 4 additions & 9 deletions src/Utils.js
Expand Up @@ -67,7 +67,7 @@ export function childrenEqual(a, b, lenComp) {
if (!a && !b) return true;
if (a.length !== b.length) return false;
if (a.length === 0 && b.length === 0) return true;
for (let i = 0; i < a.length; i++) {
for (let i = 0; i < a.length; i += 1) {
if (!nodeEqual(a[i], b[i], lenComp)) return false;
}
return true;
Expand All @@ -80,7 +80,7 @@ export function nodeEqual(a, b, lenComp = is) {
const left = propsOfNode(a);
const leftKeys = Object.keys(left);
const right = propsOfNode(b);
for (let i = 0; i < leftKeys.length; i++) {
for (let i = 0; i < leftKeys.length; i += 1) {
const prop = leftKeys[i];
// we will check children later
if (prop === 'children') {
Expand Down Expand Up @@ -214,13 +214,8 @@ export function selectorType(selector) {
}

export function AND(fns) {
return x => {
let i = fns.length;
while (i--) {
if (!fns[i](x)) return false;
}
return true;
};
const fnsReversed = fns.slice().reverse();
return x => fnsReversed.every(fn => fn(x));
}

export function coercePropValue(propName, propValue) {
Expand Down
2 changes: 2 additions & 0 deletions test/.eslintrc
Expand Up @@ -11,5 +11,7 @@
"import/no-extraneous-dependencies": [2, {
"devDependencies": true
}],
"jsx-a11y/no-static-element-interactions": 0,
"jsx-a11y/anchor-has-content": 0
}
}
2 changes: 1 addition & 1 deletion test/Debug-spec.jsx
Expand Up @@ -417,7 +417,7 @@ describe('debug', () => {
});

it('renders passed children properly', () => {
const Foo = (props) => (
const Foo = props => (
<div className="foo">
<span>From Foo</span>
{props.children}
Expand Down
8 changes: 4 additions & 4 deletions test/ReactWrapper-spec.jsx
Expand Up @@ -970,7 +970,7 @@ describeWithDOM('mount', () => {

describeIf(!REACT013, 'stateless function components', () => {
it('should set props for a component multiple times', () => {
const Foo = (props) => (
const Foo = props => (
<div className={props.id}>
{props.id}
</div>
Expand All @@ -983,7 +983,7 @@ describeWithDOM('mount', () => {
});

it('should merge newProps with oldProps', () => {
const Foo = (props) => (
const Foo = props => (
<Bar {...props} />
);
const Bar = () => (
Expand Down Expand Up @@ -1544,7 +1544,7 @@ describeWithDOM('mount', () => {

describeIf(!REACT013, 'stateless function components', () => {
it('should handle nodes with mapped children', () => {
const Foo = (props) => (
const Foo = props => (
<div>{props.items.map(x => x)}</div>
);
matchesRender(<Foo items={['abc', 'def', 'hij']} />);
Expand Down Expand Up @@ -1809,7 +1809,7 @@ describeWithDOM('mount', () => {

describeIf(!REACT013, 'stateless function components', () => {
it('should handle mixed children with and without arrays', () => {
const Foo = (props) => (
const Foo = props => (
<div>
<span className="foo" />
{props.items.map(x => x)}
Expand Down
12 changes: 6 additions & 6 deletions test/ShallowWrapper-spec.jsx
Expand Up @@ -825,7 +825,7 @@ describe('shallow', () => {

describeIf(!REACT013, 'stateless function components', () => {
it('should set props for a component multiple times', () => {
const Foo = (props) => (
const Foo = props => (
<div className={props.id}>
{props.id}
</div>
Expand All @@ -838,7 +838,7 @@ describe('shallow', () => {
});

it('should merge newProps with oldProps', () => {
const Foo = (props) => (
const Foo = props => (
<Bar {...props} />
);
const Bar = () => (
Expand Down Expand Up @@ -981,7 +981,7 @@ describe('shallow', () => {
describeIf(!REACT013, 'stateless function components', () => {
it('should simulate events', () => {
const spy = sinon.spy();
const Foo = (props) => (
const Foo = props => (
<a onClick={props.onClick}>foo</a>
);

Expand Down Expand Up @@ -1076,7 +1076,7 @@ describe('shallow', () => {
this.setState({ count: this.state.count + 1 });
}
render() {
++renderCount;
renderCount += 1;
return (
<a onClick={this.onClick}>{this.state.count}</a>
);
Expand Down Expand Up @@ -1363,7 +1363,7 @@ describe('shallow', () => {

describeIf(!REACT013, 'stateless function components', () => {
it('should handle nodes with mapped children', () => {
const Foo = (props) => (
const Foo = props => (
<div>
{props.items.map(x => x)}
</div>
Expand Down Expand Up @@ -1657,7 +1657,7 @@ describe('shallow', () => {

describeIf(!REACT013, 'stateless function components', () => {
it('should handle mixed children with and without arrays', () => {
const Foo = (props) => (
const Foo = props => (
<div>
<span className="foo" />
{props.items.map(x => x)}
Expand Down
10 changes: 5 additions & 5 deletions test/Utils-spec.jsx
Expand Up @@ -201,8 +201,8 @@ describe('Utils', () => {
)).to.equal(false);

expect(nodeEqual(
<div children="child" className="foo" />,
<div children="child" className="bar" />
<div className="foo">child</div>,
<div className="bar">child</div>,
)).to.equal(false);
});

Expand All @@ -213,8 +213,8 @@ describe('Utils', () => {
)).to.equal(false);

expect(nodeEqual(
<div children="child" className="foo" />,
<div children="other child" className="foo" />
<div className="foo">child</div>,
<div className="foo">other child</div>,
)).to.equal(false);
});

Expand All @@ -225,7 +225,7 @@ describe('Utils', () => {
)).to.equal(true);

expect(nodeEqual(
<div children={null} className="foo" />,
<div children={null} className="foo" />, // eslint-disable-line react/no-children-prop
<div className="foo" />
)).to.equal(true);
});
Expand Down

0 comments on commit 9b56f2a

Please sign in to comment.