Skip to content

Commit

Permalink
Include more paths into linting
Browse files Browse the repository at this point in the history
  • Loading branch information
Hypnosphi committed Feb 17, 2018
1 parent e5b73a3 commit 1a550e9
Show file tree
Hide file tree
Showing 64 changed files with 283 additions and 321 deletions.
4 changes: 2 additions & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ dist
build
coverage
node_modules
addons/**/example/**
app/**/demo/**
#addons/**/example/**
docs/public
lib/cli/test
*.bundle.js
Expand All @@ -13,3 +12,4 @@ lib/cli/test
!.eslintrc.js
!.eslintrc-markdown.js
!.jest.config.js
!.storybook
7 changes: 7 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ module.exports = {
'**/scripts/*.js',
'**/stories/**/*.js',
'**/__tests__/**/*.js',
'**/.storybook/**/*.js',
],
peerDependencies: true,
},
Expand Down Expand Up @@ -101,5 +102,11 @@ module.exports = {
'jsx-a11y/accessible-emoji': ignore,
},
},
{
files: '**/.storybook/config.js',
rules: {
'global-require': ignore,
},
},
],
};
14 changes: 7 additions & 7 deletions addons/a11y/.storybook/components/Button/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ const styles = {
wrong: {
color: '#ffffff',
backgroundColor: '#4caf50',
}
}
},
};

function Button({ label, content, disabled, contrast }) {
function Button({ content, disabled, contrast }) {
return (
<button
style={{
Expand All @@ -27,19 +27,19 @@ function Button({ label, content, disabled, contrast }) {
}}
disabled={disabled}
>
{ content }
{content}
</button>
)
);
}

Button.propTypes = {
label: PropTypes.string,
content: PropTypes.string,
disabled: PropTypes.bool,
contrast: PropTypes.oneOf(['ok', 'wrong'])
contrast: PropTypes.oneOf(['ok', 'wrong']),
};

Button.defaultProps = {
content: 'null',
disabled: false,
contrast: 'ok',
};
Expand Down
29 changes: 6 additions & 23 deletions addons/a11y/.storybook/components/Button/stories.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,17 @@
import React from 'react';
import { storiesOf } from '@storybook/react';
import Faker from 'faker';

import { checkA11y } from './../../../src';

import Button from './component';

import Faker from 'faker';

const text = Faker.lorem.words();

storiesOf('<Button />', module)
.addDecorator(checkA11y)
.add('Default', () => (
<Button />
))
.add('Content', () => (
<Button content={text} />
))
.add('Label', () => (
<Button label={text} />
))
.add('Disabled', () => (
<Button
disabled
content={text}
/>
))
.add('Invalid contrast', () => (
<Button
contrast="wrong"
content={Faker.lorem.words()}
/>
));
.add('Default', () => <Button />)
.add('Content', () => <Button content={text} />)
.add('Label', () => <Button label={text} />)
.add('Disabled', () => <Button disabled content={text} />)
.add('Invalid contrast', () => <Button contrast="wrong" content={Faker.lorem.words()} />);
18 changes: 9 additions & 9 deletions addons/a11y/.storybook/components/Form/components/Input.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ import React from 'react';
import PropTypes from 'prop-types';

function Input({ id, value, type, placeholder }) {
return (
<input
id={id}
value={value}
placeholder={placeholder}
type={type}
/>
);
return <input id={id} value={value} placeholder={placeholder} type={type} />;
}

Input.propTypes = {
type: PropTypes.oneOf(['text', 'password']),
id: PropTypes.string,
value: PropTypes.string,
placeholder: PropTypes.string,
}
};

Input.defaultProps = {
type: null,
id: null,
value: null,
placeholder: null,
};

export default Input;
15 changes: 6 additions & 9 deletions addons/a11y/.storybook/components/Form/components/Label.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,19 @@ const styles = {
label: {
padding: '0 6px',
},
}
};

function Label({ id, content }) {
return (
<label
style={styles.label}
htmlFor={id}
>
{ content }
<label style={styles.label} htmlFor={id}>
{content}
</label>
)
);
}

Label.propTypes = {
content: PropTypes.string,
id: PropTypes.string,
content: PropTypes.string.isRequired,
id: PropTypes.string.isRequired,
};

export default Label;
8 changes: 6 additions & 2 deletions addons/a11y/.storybook/components/Form/components/Row.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ function Row({ label, input }) {

Row.propTypes = {
label: PropTypes.instanceOf(Label),
input: PropTypes.instanceOf(Input),
}
input: PropTypes.instanceOf(Input).isRequired,
};

Row.defaultProps = {
label: null,
};

export default Row;
6 changes: 1 addition & 5 deletions addons/a11y/.storybook/components/Form/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,4 @@ import Input from './Input';
import Label from './Label';
import Row from './Row';

export {
Input,
Label,
Row,
};
export { Input, Label, Row };
32 changes: 8 additions & 24 deletions addons/a11y/.storybook/components/Form/stories.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,20 @@
import React from 'react';
import { storiesOf } from '@storybook/react';
import Faker from 'faker';

import * as Form from './components';

import { storiesOf } from '@storybook/react';
import { checkA11y } from './../../../src';

import Faker from 'faker';

const label = Faker.lorem.word();
const placeholder = Faker.lorem.word();

storiesOf('<Form />', module)
.addDecorator(checkA11y)
.add('Without Label', () => (
<Form.Row
input={<Form.Input />}
/>
))
.add ('With label', () => (
<Form.Row
label={<Form.Label
content={label}
id="1"
/>}
input={<Form.Input id="1" />}
/>
))
.add ('With placeholder', () => (
<Form.Row
input={<Form.Input
id="1"
placeholder={placeholder}
/>}
/>
.add('Without Label', () => <Form.Row input={<Form.Input />} />)
.add('With label', () => (
<Form.Row label={<Form.Label content={label} id="1" />} input={<Form.Input id="1" />} />
))
.add('With placeholder', () => (
<Form.Row input={<Form.Input id="1" placeholder={placeholder} />} />
));
13 changes: 6 additions & 7 deletions addons/a11y/.storybook/components/Image/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';

function Image({ src, alt, presentation }) {
return (
<img
src={src}
alt={alt}
role={presentation && 'presentation'}
/>
);
return <img src={src} alt={alt} role={presentation && 'presentation'} />;
}

Image.propTypes = {
Expand All @@ -17,4 +11,9 @@ Image.propTypes = {
presentation: PropTypes.bool,
};

Image.defaultProps = {
alt: null,
presentation: false,
};

export default Image;
21 changes: 4 additions & 17 deletions addons/a11y/.storybook/components/Image/stories.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,16 @@
import React from 'react';
import { storiesOf } from '@storybook/react';
import Faker from 'faker';

import { checkA11y } from './../../../src';

import Image from './component';

import Faker from 'faker';

const image = Faker.image.animals();
const alt = Faker.lorem.words();

storiesOf('<Image />', module)
.addDecorator(checkA11y)
.add('Without alt', () => (
<Image src={image} />
))
.add('With alt', () => (
<Image
src={image}
alt={alt}
/>
))
.add('Presentation', () => (
<Image
presentation
src={image}
/>
));
.add('Without alt', () => <Image src={image} />)
.add('With alt', () => <Image src={image} alt={alt} />)
.add('Presentation', () => <Image presentation src={image} />);
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import React, { cloneElement } from 'react';
import { createElement } from 'react';
import PropTypes from 'prop-types';

const headings = {
1: (<h1 />),
2: (<h2 />),
3: (<h3 />),
4: (<h4 />),
1: 'h1',
2: 'h2',
3: 'h3',
4: 'h4',
};

function Heading({ level, children }) {
return cloneElement(headings[level], {}, children)
return createElement(headings[level], {}, children);
}

Heading.propTypes = {
level: PropTypes.oneOf([1, 2, 3, 4]),
children: PropTypes.any,
children: PropTypes.node,
};

Heading.defaultProps = {
Expand Down
10 changes: 3 additions & 7 deletions addons/a11y/.storybook/components/Typography/components/Link.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@ import React from 'react';
import PropTypes from 'prop-types';

function Link({ href, content }) {
return (
<a href={href}>
{ content }
</a>
);
return <a href={href}>{content}</a>;
}

Link.propTypes = {
href: PropTypes.string,
content: PropTypes.string,
href: PropTypes.string.isRequired,
content: PropTypes.string.isRequired,
};

export default Link;
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@ import React from 'react';
import PropTypes from 'prop-types';

function Text({ children }) {
return (
<p>
{children}
</p>
);
return <p>{children}</p>;
}

Text.propTypes = {
children: PropTypes.any,
children: PropTypes.node.isRequired,
};

export default Text;
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,4 @@ import Heading from './Heading';
import Link from './Link';
import Text from './Text';

export {
Heading,
Link,
Text,
};
export { Heading, Link, Text };
Loading

0 comments on commit 1a550e9

Please sign in to comment.