Skip to content

Commit

Permalink
Linting
Browse files Browse the repository at this point in the history
  • Loading branch information
ndelangen committed Nov 13, 2017
1 parent c3cfd7b commit 9cf2947
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 25 deletions.
2 changes: 0 additions & 2 deletions addons/a11y/register.js
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
// NOTE: loading addons using this file is deprecated!
// please use manager.js and preview.js files instead
require('./manager');
20 changes: 20 additions & 0 deletions addons/a11y/src/components/Report/Elements.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';

import Rules from './Rules';

Expand Down Expand Up @@ -27,13 +28,32 @@ function Element({ element, passes }) {
</li>
);
}
Element.propTypes = {
element: PropTypes.shape({
any: PropTypes.array.isRequired,
all: PropTypes.array.isRequired,
none: PropTypes.array.isRequired,
}).isRequired,
passes: PropTypes.bool.isRequired,
};

/* eslint-disable react/no-array-index-key */
function Elements({ elements, passes }) {
return (
<ol style={styles.element}>
{elements.map((element, index) => <Element passes={passes} element={element} key={index} />)}
</ol>
);
}
Elements.propTypes = {
elements: PropTypes.listOf(
PropTypes.shape({
any: PropTypes.array.isRequired,
all: PropTypes.array.isRequired,
none: PropTypes.array.isRequired,
})
).isRequired,
passes: PropTypes.bool.isRequired,
};

export default Elements;
5 changes: 4 additions & 1 deletion addons/a11y/src/components/Report/Info.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ function Info({ item }) {
}

Info.propTypes = {
item: PropTypes.object,
item: PropTypes.shape({
help: PropTypes.node,
helpUrl: PropTypes.string,
}).isRequired,
};

export default Info;
12 changes: 8 additions & 4 deletions addons/a11y/src/components/Report/Item.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ const styles = {

class Item extends Component {
static propTypes = {
item: PropTypes.object,
passes: PropTypes.bool,
item: PropTypes.shape({
description: PropTypes.string,
nodes: PropTypes.array,
tags: PropTypes.array,
}).isRequired,
passes: PropTypes.bool.isRequired,
};

constructor() {
Expand All @@ -43,9 +47,9 @@ class Item extends Component {

return (
<div style={styles.item}>
<div style={styles.headerBar} onClick={() => this.onToggle()}>
<button style={styles.hebuttonderBar} onClick={() => this.onToggle()}>
{item.description}
</div>
</button>
{open && <Info item={item} />}
{open && <Elements elements={item.nodes} passes={passes} />}
{open && <Tags tags={item.tags} />}
Expand Down
17 changes: 17 additions & 0 deletions addons/a11y/src/components/Report/Rules.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';

const impactColors = {
minor: '#f1c40f',
Expand Down Expand Up @@ -55,12 +56,28 @@ function Rule({ rule, passes }) {
);
}

Rule.propTypes = {
rule: PropTypes.shape({
message: PropTypes.node,
}).isRequired,
passes: PropTypes.bool.isRequired,
};

/* eslint-disable react/no-array-index-key */
function Rules({ rules, passes }) {
return (
<div style={styles.rules}>
{rules.map((rule, index) => <Rule passes={passes} rule={rule} key={index} />)}
</div>
);
}
Rules.propTypes = {
rules: PropTypes.listOf(
PropTypes.shape({
message: PropTypes.node,
})
).isRequired,
passes: PropTypes.bool.isRequired,
};

export default Rules;
4 changes: 4 additions & 0 deletions addons/a11y/src/components/Report/Tags.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';

const styles = {
tags: {
Expand Down Expand Up @@ -27,5 +28,8 @@ function Tags({ tags }) {
</div>
);
}
Tags.propTypes = {
tags: PropTypes.listOf(PropTypes.node).isRequired,
};

export default Tags;
15 changes: 9 additions & 6 deletions addons/a11y/src/components/Report/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@ import Item from './Item';

const styles = {
container: {
fontFamily:
'-apple-system, ".SFNSText-Regular", "San Francisco", Roboto, "Segoe UI", "Helvetica Neue", "Lucida Grande", sans-serif',
fontSize: '12px',
},
empty: {
fontFamily:
'-apple-system, ".SFNSText-Regular", "San Francisco", Roboto, "Segoe UI", "Helvetica Neue", "Lucida Grande", sans-serif',
fontSize: '11px',
padding: '20px 12px',
width: '100%',
Expand All @@ -34,8 +30,15 @@ function Report({ items, empty, passes }) {
}

Report.propTypes = {
items: PropTypes.array,
empty: PropTypes.string,
items: PropTypes.listOf(
PropTypes.shape({
description: PropTypes.string,
nodes: PropTypes.array,
tags: PropTypes.array,
})
).isRequired,
empty: PropTypes.string.isRequired,
passes: PropTypes.bool.isRequired,
};

export default Report;
19 changes: 10 additions & 9 deletions addons/a11y/src/components/Tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ const styles = {
display: 'flex',
},
tab: {
fontFamily:
'-apple-system, ".SFNSText-Regular", "San Francisco", Roboto, "Segoe UI", "Helvetica Neue", "Lucida Grande", sans-serif',
color: 'rgb(68, 68, 68)',
fontSize: '11px',
textDecoration: 'none',
Expand All @@ -29,6 +27,11 @@ const styles = {
},
};

const tabStyle = active => ({
...styles.tab,
...(active ? styles.tabActive : undefined),
});

class Tabs extends Component {
constructor(props) {
super(props);
Expand Down Expand Up @@ -59,19 +62,17 @@ class Tabs extends Component {
const { tabs } = this.props;
const { active } = this.state;

/* eslint-disable react/no-array-index-key */
return (
<div style={styles.tabs}>
{tabs.map((tab, index) => (
<div
<button
key={index}
style={{
...styles.tab,
...(index === active ? styles.tabActive : undefined),
}}
style={tabStyle(active === index)}
onClick={() => this.onToggle(index)}
>
{tab.label}
</div>
</button>
))}
</div>
);
Expand All @@ -93,7 +94,7 @@ Tabs.propTypes = {
label: PropTypes.node,
panel: PropTypes.node,
})
),
).isRequired,
};

export default Tabs;
12 changes: 9 additions & 3 deletions addons/a11y/src/components/WrapStory.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
import React, { Component } from 'react';
import { Component } from 'react';
import { findDOMNode } from 'react-dom';
import PropTypes from 'prop-types';
import axe from 'axe-core';

class WrapStory extends Component {
static propTypes = {
context: PropTypes.object,
context: PropTypes.shape({}),
storyFn: PropTypes.func,
channel: PropTypes.object,
channel: PropTypes.shape({}),
};
static defaultProps = {
context: {},
storyFn: () => {},
channel: {},
};

/* eslint-disable react/no-find-dom-node */
componentDidMount() {
const { channel } = this.props;
const wrapper = findDOMNode(this);
Expand Down

0 comments on commit 9cf2947

Please sign in to comment.