Skip to content

Commit

Permalink
Merge pull request #3011 from storybooks/eliminate-lint-warnings
Browse files Browse the repository at this point in the history
Improve linting
  • Loading branch information
Hypnosphi authored Feb 18, 2018
2 parents 82969cd + d68b5d1 commit abdd351
Show file tree
Hide file tree
Showing 144 changed files with 579 additions and 707 deletions.
3 changes: 1 addition & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ dist
build
coverage
node_modules
addons/**/example/**
app/**/demo/**
docs/public
lib/cli/test
*.bundle.js
Expand All @@ -13,3 +11,4 @@ lib/cli/test
!.eslintrc.js
!.eslintrc-markdown.js
!.jest.config.js
!.storybook
58 changes: 39 additions & 19 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ const ignore = 0;

module.exports = {
root: true,
extends: ['eslint-config-airbnb', 'plugin:jest/recommended', 'prettier'],
extends: [
'eslint-config-airbnb',
'plugin:jest/recommended',
'plugin:import/react-native',
'prettier',
'prettier/react',
],
plugins: ['prettier', 'jest', 'react', 'json'],
parser: 'babel-eslint',
parserOptions: {
Expand All @@ -25,7 +31,6 @@ module.exports = {
},
},
rules: {
strict: [error, 'never'],
'prettier/prettier': [
warn,
{
Expand All @@ -37,16 +42,13 @@ module.exports = {
},
],
'no-debugger': process.env.NODE_ENV === 'production' ? error : ignore,
quotes: [warn, 'single', { avoidEscape: true }],
'class-methods-use-this': ignore,
'arrow-parens': [warn, 'as-needed'],
'space-before-function-paren': ignore,
'import/no-unresolved': error,
'import/extensions': [
error,
'always',
{
js: 'never',
json: 'always',
ts: 'never',
},
],
'import/no-extraneous-dependencies': [
Expand All @@ -61,6 +63,7 @@ module.exports = {
'**/scripts/*.js',
'**/stories/**/*.js',
'**/__tests__/**/*.js',
'**/.storybook/**/*.js',
],
peerDependencies: true,
},
Expand All @@ -69,24 +72,41 @@ module.exports = {
'import/default': error,
'import/named': error,
'import/namespace': error,
'react/jsx-wrap-multilines': ignore,
'react/jsx-indent': ignore,
'react/jsx-indent-props': ignore,
'react/jsx-closing-bracket-location': ignore,
'react/jsx-uses-react': error,
'react/jsx-uses-vars': error,
'react/react-in-jsx-scope': error,
'react/jsx-filename-extension': [
warn,
{
extensions: ['.js', '.jsx'],
},
],
'jsx-a11y/accessible-emoji': ignore,
'jsx-a11y/href-no-hash': ignore,
'jsx-a11y/label-has-for': ignore,
'jsx-a11y/click-events-have-key-events': error,
'jsx-a11y/anchor-is-valid': [warn, { aspects: ['invalidHref'] }],
'react/no-unescaped-entities': ignore,
'jsx-a11y/label-has-for': [
error,
{
required: {
some: ['nesting', 'id'],
},
},
],
'jsx-a11y/anchor-is-valid': [
error,
{
components: ['RoutedLink', 'MenuLink', 'LinkTo', 'Link'],
specialLink: ['overrideParams', 'kind', 'story', 'to'],
},
],
},
overrides: [
{
files: ['**/react-native*/**', '**/REACT_NATIVE*/**', '**/crna*/**'],
rules: {
'jsx-a11y/accessible-emoji': ignore,
},
},
{
files: '**/.storybook/config.js',
rules: {
'global-require': ignore,
},
},
],
};
10 changes: 5 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@ In addition to the changes listed here, also contains fixes from [3.3.5](#335) a

#### Bug Fixes

- [app:angular] Fixed dependency injection for components [#2566](https://github.com/storybooks/storybook/pull/2566)
- `app:angular` Fixed dependency injection for components [#2566](https://github.com/storybooks/storybook/pull/2566)
- Revert "Move everything from lodash to lodash-es" [#2591](https://github.com/storybooks/storybook/pull/2591)

#### Maintenance
Expand Down Expand Up @@ -1037,7 +1037,7 @@ We'll do a better job of getting out smaller releases next time around. ;-)
- Added type annotation to helpers, added ts declaration files for angu… [#2459](https://github.com/storybooks/storybook/pull/2459)
- Adding extra metadata to module/components [#2526](https://github.com/storybooks/storybook/pull/2526)
- Fix ng component prop output override [#2456](https://github.com/storybooks/storybook/pull/2456)
- [WIP] Angular versions support [#2467](https://github.com/storybooks/storybook/pull/2467)
- `WIP` Angular versions support [#2467](https://github.com/storybooks/storybook/pull/2467)
- Angular Add custom pipes support [#2518](https://github.com/storybooks/storybook/pull/2518)
- Add angular support: Storybook for Angular [#1474](https://github.com/storybooks/storybook/pull/1474)
- Fix addon Knobs: add array in Object PropTypes [#2227](https://github.com/storybooks/storybook/pull/2227)
Expand Down Expand Up @@ -1294,7 +1294,7 @@ We'll do a better job of getting out smaller releases next time around. ;-)
- Added type annotation to helpers, added ts declaration files for angu… [#2459](https://github.com/storybooks/storybook/pull/2459)
- Adding extra metadata to module/components [#2526](https://github.com/storybooks/storybook/pull/2526)
- Fix ng component prop output override [#2456](https://github.com/storybooks/storybook/pull/2456)
- [WIP] Angular versions support [#2467](https://github.com/storybooks/storybook/pull/2467)
- `WIP` Angular versions support [#2467](https://github.com/storybooks/storybook/pull/2467)
- Angular Add custom pipes support [#2518](https://github.com/storybooks/storybook/pull/2518)

#### Bug Fixes
Expand Down Expand Up @@ -1610,7 +1610,7 @@ We'll do a better job of getting out smaller releases next time around. ;-)
#### Bug Fixes

- Number knob: apply default min/max/step values only in range mode [#2437](https://github.com/storybooks/storybook/pull/2437)
- [addon-actions] Check result of getPropertyDescriptor for IE11 [#2428](https://github.com/storybooks/storybook/pull/2428)
- `addon-actions` Check result of getPropertyDescriptor for IE11 [#2428](https://github.com/storybooks/storybook/pull/2428)
- Edited template of search box result item to fix overflow text in row [#2419](https://github.com/storybooks/storybook/pull/2419)
- Fix missing supported extension check in case when asset is a string [#2468](https://github.com/storybooks/storybook/pull/2468)

Expand Down Expand Up @@ -2654,7 +2654,7 @@ Minor bug fixes and documentation updates post 3.0.0 release.

- Fixed typo in react-native browser instructions [#1189](https://github.com/storybooks/storybook/pull/1189)
- Add instruction for npm install with -D for development dependency [#1168](https://github.com/storybooks/storybook/pull/1168)
- Fix broken link for [addons] in README [#1167](https://github.com/storybooks/storybook/pull/1167)
- Fix broken link for `addons` in README [#1167](https://github.com/storybooks/storybook/pull/1167)
- Refreshed logo in docs [#1149](https://github.com/storybooks/storybook/pull/1149)
- fix addon broken links in documentation [#1165](https://github.com/storybooks/storybook/pull/1165)
- start-storybook cli - expand commands descriptions [#1161](https://github.com/storybooks/storybook/pull/1161)
Expand Down
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;
Loading

0 comments on commit abdd351

Please sign in to comment.