Skip to content

Commit

Permalink
Merge pull request #988 from airbnb/eslint-markdown
Browse files Browse the repository at this point in the history
lint our markdown
  • Loading branch information
ljharb authored Jun 17, 2017
2 parents 0d1936a + 4e32297 commit 4871201
Show file tree
Hide file tree
Showing 97 changed files with 587 additions and 592 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
_book/
build/
21 changes: 21 additions & 0 deletions .eslintrc-markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"extends": "./.eslintrc",
"root": true,
"plugins": [
"markdown"
],
"rules": {
"class-methods-use-this": 0,
"import/no-unresolved": 0,
"import/no-extraneous-dependencies": 0,
"import/extensions": 0,
"max-len": 0,
"no-unused-vars": 0,
"no-console": 0,
"no-undef": 0,
"react/react-in-jsx-scope": 0,
"react/jsx-filename-extension": 0,
"react/jsx-no-undef": 0,
"react/no-multi-comp": 0,
},
}
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,19 @@ describe('<MyComponent />', () => {
});

it('renders children when passed in', () => {
const wrapper = shallow(
const wrapper = shallow((
<MyComponent>
<div className="unique" />
</MyComponent>
);
));
expect(wrapper.contains(<div className="unique" />)).to.equal(true);
});

it('simulates click events', () => {
const onButtonClick = sinon.spy();
const wrapper = shallow(
const wrapper = shallow((
<Foo onButtonClick={onButtonClick} />
);
));
wrapper.find('button').simulate('click');
expect(onButtonClick).to.have.property('callCount', 1);
});
Expand Down Expand Up @@ -144,9 +144,9 @@ describe('<Foo />', () => {

it('simulates click events', () => {
const onButtonClick = sinon.spy();
const wrapper = mount(
const wrapper = mount((
<Foo onButtonClick={onButtonClick} />
);
));
wrapper.find('button').simulate('click');
expect(onButtonClick).to.have.property('callCount', 1);
});
Expand Down
2 changes: 1 addition & 1 deletion docs/api/ReactWrapper/at.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Returns a wrapper around the node at a given index of the current wrapper.

```jsx
const wrapper = mount(<MyComponent />);
expect(wrapper.find(Foo).at(0).props().foo).to.equal("bar");
expect(wrapper.find(Foo).at(0).props().foo).to.equal('bar');
```


Expand Down
8 changes: 4 additions & 4 deletions docs/api/ReactWrapper/contains.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ the ones passed in.


```jsx
const wrapper = mount(
const wrapper = mount((
<div>
<div data-foo="foo" data-bar="bar">Hello</div>
</div>
);
));

expect(wrapper.contains(<div data-foo="foo" data-bar="bar">Hello</div>)).to.equal(true);

Expand All @@ -37,13 +37,13 @@ expect(wrapper.contains(<div data-foo="foo" data-bar="bar" />)).to.equal(false);
```

```jsx
const wrapper = mount(
const wrapper = mount((
<div>
<span>Hello</span>
<div>Goodbye</div>
<span>Again</span>
</div>
);
));

expect(wrapper.contains([
<span>Hello</span>,
Expand Down
4 changes: 2 additions & 2 deletions docs/api/ReactWrapper/containsAllMatchingElements.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ like the nodes passed in.


```jsx
const wrapper = mount(
const wrapper = mount((
<div>
<span className="foo">Hello</span>
<div style={{ fontSize: 13 }}>Goodbye</div>
<span>Again</span>
</div>
);
));

expect(wrapper.containsAllMatchingElements([
<span>Hello</span>,
Expand Down
4 changes: 2 additions & 2 deletions docs/api/ReactWrapper/containsAnyMatchingElements.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ like one of the array passed in.


```jsx
const wrapper = mount(
const wrapper = mount((
<div>
<span className="foo">Hello</span>
<div style={{ fontSize: 13 }}>Goodbye</div>
<span>Again</span>
</div>
);
));

expect(wrapper.containsAnyMatchingElements([
<span>Bonjour</span>,
Expand Down
28 changes: 9 additions & 19 deletions docs/api/ReactWrapper/containsMatchingElement.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,18 @@ the one passed in.


```jsx
const wrapper = mount(
const wrapper = mount((
<div>
<div data-foo="foo" data-bar="bar">Hello</div>
</div>
);

expect(wrapper.containsMatchingElement(
<div data-foo="foo" data-bar="bar">Hello</div>
)).to.equal(true);
expect(wrapper.containsMatchingElement(
<div data-foo="foo">Hello</div>
)).to.equal(true);

expect(wrapper.containsMatchingElement(
<div data-foo="foo" data-bar="bar" data-baz="baz">Hello</div>
)).to.equal(false);
expect(wrapper.containsMatchingElement(
<div data-foo="foo" data-bar="Hello">Hello</div>
)).to.equal(false);
expect(wrapper.containsMatchingElement(
<div data-foo="foo" data-bar="bar" />
)).to.equal(false);
));

expect(wrapper.containsMatchingElement(<div data-foo="foo" data-bar="bar">Hello</div>)).to.equal(true);
expect(wrapper.containsMatchingElement(<div data-foo="foo">Hello</div>)).to.equal(true);

expect(wrapper.containsMatchingElement(<div data-foo="foo" data-bar="bar" data-baz="baz">Hello</div>)).to.equal(false);
expect(wrapper.containsMatchingElement(<div data-foo="foo" data-bar="Hello">Hello</div>)).to.equal(false);
expect(wrapper.containsMatchingElement(<div data-foo="foo" data-bar="bar" />)).to.equal(false);
```

#### Common Gotchas
Expand Down
2 changes: 1 addition & 1 deletion docs/api/ReactWrapper/context.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ root component instance.
```jsx
const wrapper = mount(
<MyComponent />,
{ context: { foo: 10 } }
{ context: { foo: 10 } },
);

expect(wrapper.context().foo).to.equal(10);
Expand Down
32 changes: 15 additions & 17 deletions docs/api/ReactWrapper/debug.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,21 @@ console when tests are not passing when you expect them to.

Say we have the following components:
```jsx
class Foo extends React.Component {
render() {
return (
<div className="foo">
<span>Foo</span>
</div>
);
}
function Foo() {
return (
<div className="foo">
<span>Foo</span>
</div>
);
}

class Bar extends React.Component {
render() {
return (
<div className="bar">
<span>Non-Foo</span>
<Foo baz="bax" />
</div>
);
}
function Bar() {
return (
<div className="bar">
<span>Non-Foo</span>
<Foo baz="bax" />
</div>
);
}
```

Expand All @@ -42,6 +38,7 @@ console.log(mount(<Bar id="2" />).debug());
```

Would output the following to the console:
<!-- eslint-disable -->
```jsx
<Bar id="2">
<div className="bar">
Expand All @@ -65,6 +62,7 @@ Likewise, running:
console.log(mount(<Bar id="2" />).find(Foo).debug());
```
Would output the following to the console:
<!-- eslint-disable -->
```jsx
<Foo baz="bax">
<div className="foo">
Expand Down
4 changes: 2 additions & 2 deletions docs/api/ReactWrapper/every.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ Returns whether or not all of the nodes in the wrapper match the provided select
#### Examples

```jsx
const wrapper = mount(
const wrapper = mount((
<div>
<div className="foo qoo" />
<div className="foo boo" />
<div className="foo hoo" />
</div>
);
));
expect(wrapper.find('.foo').every('.foo')).to.equal(true);
expect(wrapper.find('.foo').every('.qoo')).to.equal(false);
expect(wrapper.find('.foo').every('.bar')).to.equal(false);
Expand Down
4 changes: 2 additions & 2 deletions docs/api/ReactWrapper/everyWhere.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ Returns whether or not all of the nodes in the wrapper pass the provided predica
#### Example

```jsx
const wrapper = mount(
const wrapper = mount((
<div>
<div className="foo qoo" />
<div className="foo boo" />
<div className="foo hoo" />
</div>
);
));
expect(wrapper.find('.foo').everyWhere(n => n.hasClass('foo'))).to.equal(true);
expect(wrapper.find('.foo').everyWhere(n => n.hasClass('qoo'))).to.equal(false);
expect(wrapper.find('.foo').everyWhere(n => n.hasClass('bar'))).to.equal(false);
Expand Down
2 changes: 1 addition & 1 deletion docs/api/ReactWrapper/find.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ expect(wrapper.find('Foo')).to.have.length(1);
Object Property Selector:
```jsx
const wrapper = mount(<MyComponent />);
expect(wrapper.find({prop: 'value'})).to.have.length(1);
expect(wrapper.find({ prop: 'value' })).to.have.length(1);
```

#### Related Methods
Expand Down
2 changes: 1 addition & 1 deletion docs/api/ReactWrapper/first.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ Reduce the set of matched nodes to the first in the set.

```jsx
const wrapper = mount(<MyComponent />);
expect(wrapper.find(Foo).first().props().foo).to.equal("bar");
expect(wrapper.find(Foo).first().props().foo).to.equal('bar');
```
6 changes: 3 additions & 3 deletions docs/api/ReactWrapper/forEach.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ instance.
#### Example

```jsx
const wrapper = mount(
const wrapper = mount((
<div>
<div className="foo bax" />
<div className="foo bar" />
<div className="foo baz" />
</div>
);
));

wrapper.find('.foo').forEach(function (node) {
wrapper.find('.foo').forEach((node) => {
expect(node.hasClass('foo')).to.equal(true);
});
```
Expand Down
2 changes: 1 addition & 1 deletion docs/api/ReactWrapper/get.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Returns the node at a given index of the current wrapper.

```jsx
const wrapper = mount(<MyComponent />);
expect(wrapper.find(Foo).get(0).props.foo).to.equal("bar");
expect(wrapper.find(Foo).get(0).props.foo).to.equal('bar');
```


Expand Down
2 changes: 1 addition & 1 deletion docs/api/ReactWrapper/getDOMNode.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ Notes:

```jsx
const wrapper = mount(<MyComponent />);
expect(wrapper.getDOMNode()).to.have.property("className");
expect(wrapper.getDOMNode()).to.have.property('className');
```
16 changes: 7 additions & 9 deletions docs/api/ReactWrapper/getNode.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@ Returns the wrapper's underlying node.
#### Examples

```jsx
class Test extends React.Component {
render() {
return (
<div>
<span />
<span />
</div>
);
}
function Test() {
return (
<div>
<span />
<span />
</div>
);
}

const wrapper = mount(<Test />);
Expand Down
16 changes: 7 additions & 9 deletions docs/api/ReactWrapper/getNodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@ Returns the wrapper's underlying nodes.
#### Examples

```jsx
class Test extends React.Component {
render() {
return (
<div>
<span />
<span />
</div>
);
}
function Test() {
return (
<div>
<span />
<span />
</div>
);
}

const wrapper = mount(<Test />);
Expand Down
Loading

0 comments on commit 4871201

Please sign in to comment.