Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set ESlint rules more strict 🚑 #911

Merged
merged 71 commits into from
Jun 6, 2017
Merged

Set ESlint rules more strict 🚑 #911

merged 71 commits into from
Jun 6, 2017

Conversation

ndelangen
Copy link
Member

@ndelangen ndelangen commented Apr 17, 2017

Issue: eslint rules are too loose, errors are passing though.

What I did

As described in review comments #904 linting is rather non-strict right now.
Though I'm personally of the opinion too strict linting can be harmful, I agree, we could make it a bit more strict to weed out some bad code we have and prevent bad come from getting pushed to master.

  • use eslint to lint all .js & .jsx files
  • use eslint to lint all .json files
  • sort all package.json using sort-package-json (single time).
  • set rules to a much much much stricter set
  • fix all js-files errors
  • fix all json-files errors
  • use remark-lint to lint all .md files
  • use remark-lint-code-eslint to lint all code-samples inside markdown files
  • use prettier
  • fix all markdown-files errors
  • setup lint-staged
  • test lint-staged
  • fix any regressions
  • more covfefe

How to test

run npm run lint

@ndelangen ndelangen changed the title Eslint strict Set ESlint rules more strict Apr 17, 2017
@ndelangen ndelangen force-pushed the eslint-strict branch 5 times, most recently from 8e19de8 to c241677 Compare April 18, 2017 20:51
@@ -107,7 +107,7 @@ function previewProp(val) {
}

if (!braceWrap) return content;
return <span>{{ content }}</span>;
return <span>{`{ ${content} }`}</span>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

# Conflicts:
#	packages/addon-graphql/package.json
#	packages/addon-info/package.json
#	packages/addon-info/src/components/Node.js
#	packages/addon-knobs/package.json
#	packages/addon-notes/package.json
#	packages/channel-postmessage/package.json
#	packages/channel-websocket/package.json
#	packages/decorator-centered/package.json
#	packages/react-native-storybook/package.json
#	packages/react-storybook/src/server/config.js
#	packages/storybook-ui/package.json
#	packages/storybook-ui/src/modules/ui/components/layout/index.js
@codecov
Copy link

codecov bot commented Apr 28, 2017

Codecov Report

Merging #911 into master will increase coverage by 0.76%.
The diff coverage is 15.24%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #911      +/-   ##
==========================================
+ Coverage   13.31%   14.07%   +0.76%     
==========================================
  Files         199      200       +1     
  Lines        4589     4497      -92     
  Branches      534      616      +82     
==========================================
+ Hits          611      633      +22     
+ Misses       3503     3333     -170     
- Partials      475      531      +56
Impacted Files Coverage Δ
addons/knobs/src/components/Panel.js 88% <ø> (ø) ⬆️
lib/ui/src/modules/ui/containers/shortcuts_help.js 100% <ø> (ø) ⬆️
...ct-native/src/server/config/webpack.config.prod.js 0% <ø> (ø) ⬆️
addons/options/preview.js 0% <ø> (ø) ⬆️
...p/react-native/src/server/config/webpack.config.js 0% <ø> (ø) ⬆️
addons/options/src/manager/index.js 0% <ø> (ø) ⬆️
lib/ui/src/modules/ui/configs/handle_keyevents.js 33.33% <ø> (ø) ⬆️
addons/info/src/index.js 0% <ø> (ø) ⬆️
addons/comments/manager.js 0% <ø> (ø) ⬆️
addons/options/manager.js 0% <ø> (ø) ⬆️
... and 143 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a5de77a...432c371. Read the comment docs.

@ndelangen ndelangen changed the title Set ESlint rules more strict Set ESlint rules more strict 🚑 Apr 28, 2017
@theinterned
Copy link
Member

@ndelangen I'm working on this and I just want to make sure this is right: I'm working directly off your branch -- not from my fork

@theinterned
Copy link
Member

theinterned commented Apr 28, 2017

question: I've got this error:

/Users/user/src/theinterned-storybook/packages/storybook-ui/src/modules/ui/components/left_panel/text_filter.test.js
  1:1  error  'enzyme' should be listed in the project's dependencies. Run 'npm i -S enzyme' to add it  import/no-extraneous-dependencies

this is due to enzyme being in the root package.json is it appropriate just add an eslint-disable-line or should we modify the eslintrc?

notes:

1. did not resolve `jsx-a11y` errors as that would require closer
attention to the browser
2. did not resolve any `'enzyme' should be listed in the project's
dependencies. Run 'npm i -S enzyme' to add it
import/no-extraneous-dependencies` see note:
#911 (comment)
adds `global` as the  dep was missing in add-on-knobs
didn’t resolve jsx-a11y linting in this pass
uses `toMatchObject` rather than `toEqual` to be more lenient about
what props are present
Copy link
Member

@shilman shilman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey this looks great but I think we should get it merged and then do refinements on the merged version. I think this PR is getting out of control?

.remarkrc Outdated
@@ -5,7 +5,8 @@
["remark-lint-code", {"js": {
"module": "node_modules/remark-lint-code-eslint",
"options": {
"fix": true
"fix": true,
"configFile": "/Users/dev/Projects/GitHub/storybook/react-storybook/.eslintrc-markdown.js"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fix this

@@ -26,7 +26,7 @@ See how we can use this:

```js
// Register the addon with a unique name.
addonAPI.register('kadira/notes', (storybookAPI) => {
addonAPI.register('my-organisation/my-addon', (storybookAPI) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ndelangen can we put this in a different PR? i think it is unrelated to eslint?

+ make listing more specific
Copy link
Member

@shilman shilman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ndelangen I am seeing an error trying to run gatsby in the docs

npm run dev

Huge string of errors:

ERROR in ./~/css-loader!./~/postcss-loader/lib!./components/Docs/Content/style.css
Module build failed: Error: No PostCSS Config found in: /Users/shilman/projects/storybook/new/storybook/docs/components/Docs/Content
    at Error (native)
    at /Users/shilman/projects/storybook/new/storybook/docs/node_modules/postcss-load-config/index.js:51:26

 @ ./components/Docs/Content/style.css 4:14-130 18:2-22:4 19:20-136
...

@ndelangen
Copy link
Member Author

It's fixed @shilman !

@ndelangen
Copy link
Member Author

I'm ready to merge this, who can test locally and approve?

@ndelangen ndelangen added this to the v3.0.2 milestone Jun 6, 2017
@ndelangen ndelangen self-assigned this Jun 6, 2017
@ndelangen ndelangen added maintenance User-facing maintenance tasks and removed ci: do not merge in progress labels Jun 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance User-facing maintenance tasks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants