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

Fixes for watch mode of create-react-app #43

Merged
merged 10 commits into from Dec 16, 2016
Merged

Fixes for watch mode of create-react-app #43

merged 10 commits into from Dec 16, 2016

Conversation

karlhorky
Copy link
Contributor

I've added this plugin to create-react-app in facebook/create-react-app#1216. This pull request improves the display of the warnings / errors and makes them appear in watch mode too.

@JaKXz
Copy link
Contributor

JaKXz commented Dec 9, 2016

@karlhorky thanks for the PR! on first glance it looks good, once CI passes I'll take a closer look :)

@karlhorky
Copy link
Contributor Author

Hm, ok I'm getting this now:

failing
1) stylelint-webpack-plugin works with multiple source files:
  AssertionError: expected [ Array(1) ] to have a length of 2 but got 1
    at /home/travis/build/vieron/stylelint-webpack-plugin/test/index.js:73:50

I think this is because I'm adding only one array item to warnings with the formatted error. Should I just update the test to check for one? And maybe parse the output to check if there are really two errors reported?

@karlhorky
Copy link
Contributor Author

I've done it the way I described. Let me know if you'd like this improved.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 95.238% when pulling 69fc5c7 on karlhorky:create-react-app-fixes into dc97d01 on vieron:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 95.238% when pulling 69fc5c7 on karlhorky:create-react-app-fixes into dc97d01 on vieron:master.

Copy link
Contributor

@JaKXz JaKXz left a comment

Choose a reason for hiding this comment

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

Thanks again, I think this looks like a great improvement. I'd just like to test it more throughly so we can release it as a patch rather than a new minor version since it brings lots of improvements for everyone without breaking changes (afaict)

compilation.plugin && compilation.plugin('compilation', function (compilation) {
compilation.errors = compilation.errors.concat(errors);
compilation.warnings = compilation.warnings.concat(warnings);
compiler.plugin('compilation', function (compilation) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If removing the guard for compilation.plugin you can remove the eslint comment above.

I guess in more recent versions of webpack the race? condition for plugin being defined have been fixed? ie. Has this been verified to work consistently?

Copy link
Contributor Author

@karlhorky karlhorky Dec 12, 2016

Choose a reason for hiding this comment

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

This is done.

I wasn't sure why this guard was there - what race condition do you mean? In my tests in watch mode, it was working correctly.

I thought it was mainly there because the parameter being passed to the watch function was actually a watcher and not a compiler.

expect(stats.compilation.errors).to.have.length(2);
expect(stats.compilation.errors).to.have.length(1);
expect(stats.compilation.errors[0]).to.contain('test/fixtures/test7/_second.scss');
expect(stats.compilation.errors[0]).to.contain('test/fixtures/test7/test.scss');
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: chai's .to.contain matchers work on arrays so since you're asserting on the length above I think you can remove the index

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm, that doesn't work, since that's not the full content of the string:

1) stylelint-webpack-plugin works with multiple source files:
     AssertionError: expected [ Array(1) ] to include 'test/fixtures/test7/_second.scss'
      at ~/projects/stylelint-webpack-plugin/test/index.js:74:45

@coveralls
Copy link

coveralls commented Dec 12, 2016

Coverage Status

Coverage increased (+0.2%) to 95.238% when pulling 0eaa431 on karlhorky:create-react-app-fixes into dc97d01 on vieron:master.

@karlhorky
Copy link
Contributor Author

@JaKXz any further feedback? Or can this be merged?

compilation.plugin && compilation.plugin('compilation', function (compilation) {
compilation.errors = compilation.errors.concat(errors);
compilation.warnings = compilation.warnings.concat(warnings);
compiler.plugin('compilation', function (compilation) {
Copy link
Contributor

@JaKXz JaKXz Dec 15, 2016

Choose a reason for hiding this comment

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

Sorry for the delayed response @karlhorky -

Please make this (and other anonymous fns) a named function [because if somehow there's some error thrown it will provide better feedback in the stack trace about where it's coming from]. I should really have a lint rule for this.

@JaKXz
Copy link
Contributor

JaKXz commented Dec 15, 2016

@karlhorky other than one minor comment in those two places, I think this is good to go! Just curious if you've tested this outside create-react-app in a trivial and / or non-trivial codebase. Thanks!

@karlhorky
Copy link
Contributor Author

karlhorky commented Dec 15, 2016

@JaKXz fixed.

As for your question regarding where this is being used, I have my own fork of create-react-app, which I am currently in the process of switching over to with my portfolio website. It is also the basis for new projects that we're doing at @kununu (including the kununu.com website).

@karlhorky
Copy link
Contributor Author

Ah sorry, missed the eslint warnings. I'll fix the last few.

@coveralls
Copy link

coveralls commented Dec 16, 2016

Coverage Status

Coverage increased (+0.2%) to 95.238% when pulling b4e6f2b on karlhorky:create-react-app-fixes into dc97d01 on vieron:master.

@JaKXz JaKXz merged commit 996eb21 into webpack-contrib:master Dec 16, 2016
@karlhorky
Copy link
Contributor Author

Awesome, thanks @JaKXz!

@JaKXz
Copy link
Contributor

JaKXz commented Dec 16, 2016

No worries! will get this released soon (before the end of Sunday)! Thanks for your patience @karlhorky

@JaKXz
Copy link
Contributor

JaKXz commented Dec 18, 2016

+ stylelint-webpack-plugin@0.4.1 published!

@karlhorky
Copy link
Contributor Author

Thanks! Upgraded in my create-react-app PR.

I noticed that the tests were breaking because stylelint released version 7.7.0 (breaking paths with stylelint/stylelint#2134). I've opened #49 for this.

@karlhorky karlhorky deleted the create-react-app-fixes branch December 18, 2016 15:18
joshwiens pushed a commit that referenced this pull request Mar 31, 2018
* Pass in compiler to 'watch-run' plugin

* Fix incorrect variable name

* Display formatted warnings and errors

* Fix linting error

* Fix test

* Remove unnecessary eslint configuration

* Name anonymous functions

* correct style nits

* fixes eslint nit

* Fix linting errors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants