Skip to content

Commit 67d6af3

Browse files
authored
Merge pull request #911 from storybooks/eslint-strict
Set ESlint rules more strict 🚑
2 parents a5de77a + 432c371 commit 67d6af3

254 files changed

Lines changed: 2865 additions & 1998 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,11 @@ dist
22
build
33
coverage
44
node_modules
5+
**/example/**
6+
**/demo/**
57
docs/public
8+
9+
!.remarkrc.js
10+
!.eslintrc.js
11+
!.eslintrc-markdown.js
12+
!.jest.config.js

.eslintrc-markdown.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
const error = 2;
2+
const warn = 1;
3+
const ignore = 0;
4+
5+
module.exports = {
6+
root: true,
7+
extends: ['eslint-config-airbnb', 'plugin:jest/recommended', 'prettier'],
8+
plugins: ['prettier', 'jest', 'react'],
9+
parser: 'babel-eslint',
10+
parserOptions: {
11+
sourceType: 'module',
12+
},
13+
env: {
14+
es6: true,
15+
node: true,
16+
'jest/globals': true,
17+
},
18+
globals: {
19+
storiesOf: true,
20+
addonAPI: true,
21+
__DEV__: true,
22+
fetch: true,
23+
},
24+
rules: {
25+
strict: [error, 'never'],
26+
'prettier/prettier': [
27+
warn,
28+
{
29+
printWidth: 100,
30+
tabWidth: 2,
31+
bracketSpacing: true,
32+
trailingComma: 'es5',
33+
singleQuote: true,
34+
},
35+
],
36+
'no-console': ignore,
37+
'global-require': ignore,
38+
quotes: [warn, 'single'],
39+
'no-unused-vars': ignore,
40+
'class-methods-use-this': ignore,
41+
'arrow-parens': [warn, 'as-needed'],
42+
'space-before-function-paren': ignore,
43+
'import/no-unresolved': ignore,
44+
'import/extensions': ignore,
45+
'import/no-extraneous-dependencies': ignore,
46+
'import/prefer-default-export': ignore,
47+
'react/prop-types': ignore,
48+
'react/jsx-wrap-multilines': ignore,
49+
'react/jsx-uses-react': error,
50+
'react/jsx-uses-vars': error,
51+
'react/react-in-jsx-scope': ignore,
52+
'react/jsx-filename-extension': ignore,
53+
'jsx-a11y/accessible-emoji': ignore,
54+
'react/no-unescaped-entities': ignore,
55+
},
56+
};

.eslintrc.js

Lines changed: 56 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,68 @@
1+
const error = 2;
2+
const warn = 1;
3+
const ignore = 0;
4+
15
module.exports = {
26
root: true,
3-
extends: [
4-
'./node_modules/eslint-config-airbnb-base/rules/es6.js',
5-
],
6-
plugins: [
7-
'prettier',
8-
],
7+
extends: ['eslint-config-airbnb', 'plugin:jest/recommended', 'prettier'],
8+
plugins: ['prettier', 'jest', 'react', 'json'],
99
parser: 'babel-eslint',
1010
parserOptions: {
1111
sourceType: 'module',
1212
},
1313
env: {
1414
es6: true,
1515
node: true,
16+
'jest/globals': true,
1617
},
1718
rules: {
18-
strict: 0,
19-
'prettier/prettier': ['warn', {
20-
printWidth: 100,
21-
tabWidth: 2,
22-
bracketSpacing: true,
23-
trailingComma: 'es5',
24-
singleQuote: true,
25-
}],
26-
quotes: ['warn', 'single'],
27-
'arrow-parens': ['warn', 'as-needed'],
19+
strict: [error, 'never'],
20+
'prettier/prettier': [
21+
warn,
22+
{
23+
printWidth: 100,
24+
tabWidth: 2,
25+
bracketSpacing: true,
26+
trailingComma: 'es5',
27+
singleQuote: true,
28+
},
29+
],
30+
quotes: [warn, 'single'],
31+
'class-methods-use-this': ignore,
32+
'arrow-parens': [warn, 'as-needed'],
33+
'space-before-function-paren': ignore,
34+
'import/no-unresolved': warn,
35+
'import/extensions': [
36+
warn,
37+
{
38+
js: 'never',
39+
json: 'always',
40+
},
41+
],
42+
'import/no-extraneous-dependencies': [
43+
warn,
44+
{
45+
devDependencies: [
46+
'**/*.test.js',
47+
'**/scripts/*.js',
48+
'**/stories/*.js',
49+
'**/__tests__/*.js',
50+
],
51+
peerDependencies: true,
52+
},
53+
],
54+
'import/prefer-default-export': ignore,
55+
'react/jsx-wrap-multilines': ignore,
56+
'react/jsx-uses-react': error,
57+
'react/jsx-uses-vars': error,
58+
'react/react-in-jsx-scope': error,
59+
'react/jsx-filename-extension': [
60+
warn,
61+
{
62+
extensions: ['.js', '.jsx'],
63+
},
64+
],
65+
'jsx-a11y/accessible-emoji': ignore,
66+
'react/no-unescaped-entities': ignore,
2867
},
29-
}
68+
};

.remarkrc

Lines changed: 0 additions & 16 deletions
This file was deleted.

.remarkrc.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
module.exports = {
2+
plugins: [
3+
'remark-preset-lint-recommended',
4+
['remark-lint-list-item-indent', false],
5+
[
6+
'remark-lint-code',
7+
{
8+
js: {
9+
module: 'node_modules/remark-lint-code-eslint',
10+
options: {
11+
fix: true,
12+
configFile: '.eslintrc-markdown.js',
13+
},
14+
},
15+
},
16+
],
17+
[
18+
'remark-toc',
19+
{
20+
tight: true,
21+
maxDepth: 3,
22+
},
23+
],
24+
],
25+
};

CHANGELOG.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Storybook 3.0 is our first fully community-driven release! Notable changes:
5757
- FIX addon info and addon storyshots incompatibility [#1129](https://github.com/storybooks/storybook/pull/1129)
5858
- FIX postcss options missing in default webpack config && UPDATE dependencies [#1087](https://github.com/storybooks/storybook/pull/1087)
5959
- Fix CLI had a package version from storybook hardcoded - now queries npm registry [#1079](https://github.com/storybooks/storybook/pull/1079)
60-
- Fix semi broken __docgenInfo integration in addon info [#1030](https://github.com/storybooks/storybook/pull/1030)
60+
- Fix semi broken \_\_docgenInfo integration in addon info [#1030](https://github.com/storybooks/storybook/pull/1030)
6161
- Fix: build-storybook no longer supports relative paths [#1058](https://github.com/storybooks/storybook/pull/1058)
6262
- Fix for types `number` for addon knobs [#1001](https://github.com/storybooks/storybook/pull/1001)
6363
- Fix webpack overriding && Add an example with local file dependencies [#965](https://github.com/storybooks/storybook/pull/965)
@@ -116,12 +116,12 @@ Storybook 3.0 is our first fully community-driven release! Notable changes:
116116
- Added an upgrade mode to getstorybook [#1146](https://github.com/storybooks/storybook/pull/1146)
117117
- Update link to Storyshots addon [#1074](https://github.com/storybooks/storybook/pull/1074)
118118
- Added error message for missing or invalid storyName [#747](https://github.com/storybooks/storybook/pull/747)
119-
- Opened an Open Collective Account https://opencollective.com/storybook [#1065](https://github.com/storybooks/storybook/pull/1065)
119+
- Opened an Open Collective Account <https://opencollective.com/storybook> [#1065](https://github.com/storybooks/storybook/pull/1065)
120120
- Add propTablesExclude option [#924](https://github.com/storybooks/storybook/pull/924)
121121
- addon-info: make the info overlay be fixed [#914](https://github.com/storybooks/storybook/pull/914)
122122
- Handle null elements in getData [#926](https://github.com/storybooks/storybook/pull/926)
123-
- add description field from __docgenInfo for prop table for info plugin [#929](https://github.com/storybooks/storybook/pull/929)
124-
- #959 add a max-height and center element with alignItems: center [#961](https://github.com/storybooks/storybook/pull/961)
123+
- add description field from \_\_docgenInfo for prop table for info plugin [#929](https://github.com/storybooks/storybook/pull/929)
124+
- \#959 add a max-height and center element with alignItems: center [#961](https://github.com/storybooks/storybook/pull/961)
125125
- Switch to the only prepublish script [#903](https://github.com/storybooks/storybook/pull/903)
126126
- PR review policy [#923](https://github.com/storybooks/storybook/pull/923)
127127
- Add typescript definitions for getStorybook() [#753](https://github.com/storybooks/storybook/pull/753)

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ We welcome contributions to Storybook!
9393
> boolean check if code conforms to linting rules - uses remark & eslint
9494
9595
- `npm run lint:js` - will check js
96-
- `npm run lint:markdown` - will check markdown + code samples
96+
- `npm run lint:md` - will check markdown + code samples
9797

9898
- `npm run lint:js -- --fix` - will automatically fix js
99-
- `npm run lint:markdown -- -o` - will automatically fix markdown
99+
- `npm run lint:md -- -o` - will automatically fix markdown
100100

101101
#### `npm run test`
102102

addons/actions/README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ This addon works with Storybook for:
1818
## Getting Started
1919

2020
Install:
21+
2122
```sh
2223
npm i -D @storybook/addon-actions
2324
```
@@ -27,8 +28,10 @@ Import the `action` function and use it to create actions handlers. When creatin
2728
> _Note: Make sure NOT to use reserved words as function names. [issues#29](https://github.com/storybooks/storybook-addon-actions/issues/29#issuecomment-288274794)_
2829
2930
```js
30-
import { storiesOf } from '@storybook/react'
31-
import { action } from '@storybook/addon-actions'
31+
import { storiesOf } from '@storybook/react';
32+
import { action } from '@storybook/addon-actions';
33+
34+
import Button from './button';
3235

3336
storiesOf('Button', module)
3437
.add('default view', () => (
@@ -47,6 +50,8 @@ If you wish to process action data before sending them over to the logger, you c
4750
```js
4851
import { action, decorateAction } from '@storybook/addon-actions'
4952

53+
import Button from './button';
54+
5055
const firstArgAction = decorateAction([
5156
args => args.slice(0, 1)
5257
]);

addons/actions/package.json

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,23 @@
22
"name": "@storybook/addon-actions",
33
"version": "3.0.1",
44
"description": "Action Logger addon for storybook",
5-
"main": "dist/index.js",
6-
"scripts": {
7-
"deploy-storybook": "storybook-to-ghpages",
8-
"prepublish": "node ../../scripts/prepublish.js",
9-
"storybook": "start-storybook -p 9001"
10-
},
11-
"repository": {
12-
"type": "git",
13-
"url": "https://github.com/storybooks/storybook.git"
14-
},
155
"keywords": [
166
"storybook"
177
],
18-
"license": "MIT",
8+
"homepage": "https://github.com/storybooks/storybook/tree/master/addons/actions",
199
"bugs": {
2010
"url": "https://github.com/storybooks/storybook/issues"
2111
},
22-
"homepage": "https://github.com/storybooks/storybook/tree/master/addons/actions",
23-
"devDependencies": {
24-
"react": "^15.5.4",
25-
"react-dom": "^15.5.4",
26-
"react-test-renderer": "^15.5.4",
27-
"shelljs": "^0.7.7"
12+
"license": "MIT",
13+
"main": "dist/index.js",
14+
"repository": {
15+
"type": "git",
16+
"url": "https://github.com/storybooks/storybook.git"
17+
},
18+
"scripts": {
19+
"deploy-storybook": "storybook-to-ghpages",
20+
"prepublish": "node ../../scripts/prepublish.js",
21+
"storybook": "start-storybook -p 9001"
2822
},
2923
"dependencies": {
3024
"@storybook/addons": "^3.0.0",
@@ -33,6 +27,12 @@
3327
"prop-types": "^15.5.8",
3428
"react-inspector": "^2.0.0"
3529
},
30+
"devDependencies": {
31+
"react": "^15.5.4",
32+
"react-dom": "^15.5.4",
33+
"react-test-renderer": "^15.5.4",
34+
"shelljs": "^0.7.7"
35+
},
3636
"peerDependencies": {
3737
"react": "*",
3838
"react-dom": "*"

addons/actions/src/components/ActionLogger/index.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import style from './style';
55

66
class ActionLogger extends Component {
77
componentDidUpdate() {
8-
const latest = this.refs.latest;
8+
const latest = this.ref.latest;
99
if (latest) {
1010
const borderLeft = style.action.borderLeft;
1111
latest.style.borderLeft = 'solid 5px #aaa';
@@ -15,8 +15,12 @@ class ActionLogger extends Component {
1515
}
1616
}
1717

18+
getActionData() {
19+
return this.props.actions.map((action, i) => this.renderAction(action, i));
20+
}
21+
1822
renderAction(action, i) {
19-
const ref = i ? '' : 'latest';
23+
const ref = () => (this.ref = i ? '' : 'latest');
2024
const counter = <div style={style.counter}>{action.count}</div>;
2125
return (
2226
<div ref={ref} key={action.id} style={style.action}>
@@ -34,10 +38,6 @@ class ActionLogger extends Component {
3438
);
3539
}
3640

37-
getActionData() {
38-
return this.props.actions.map((action, i) => this.renderAction(action, i));
39-
}
40-
4141
render() {
4242
return (
4343
<div style={style.wrapper}>
@@ -50,7 +50,11 @@ class ActionLogger extends Component {
5050

5151
ActionLogger.propTypes = {
5252
onClear: PropTypes.func,
53-
actions: PropTypes.array,
53+
actions: PropTypes.array, // eslint-disable-line react/forbid-prop-types
54+
};
55+
ActionLogger.defaultProps = {
56+
onClear: () => {},
57+
actions: [],
5458
};
5559

5660
export default ActionLogger;

0 commit comments

Comments
 (0)