rwjblue / broccoli-jshint

MIT License
6 stars 30 forks source link

How to integrate into larger build process? #8

Open rickharrison opened 10 years ago

rickharrison commented 10 years ago

I am having trouble figuring out how to integrate this into a larger broccoli build process. Because it renames the files to have jshint.js, it breaks my browserify build step because all of the requires are now incorrect. Currently my build step is as follows:

If I just create a separate tree for the jshint, the errors are not reported. Any tips on what to do here?

jlgrall commented 9 years ago

I didn't test this, but could the broccoli-merge-trees be used after you worked on the separate tree ? See an example: https://github.com/mlunoe/react-bb-broccoli/blob/master/Brocfile.js#L57

Now, I don't know if it is the right way to fix this...

jlgrall commented 9 years ago

Currently, broccoli-jshint doesn't seem to jshint the files. Instead, it generates some test files that can probably be used by the "mocha" unit testing. Is this true ? Is it why you put the "ZOMG!!! TESTS?!?!!?" in the README.md ?

Anyway, the test does nothing useful, because it tests that trueis true... And if I disableTestGenerator it outputs "undefined" instead of the test.

That is what I understood from trying it and from reading some parts of its source code, so correct me where I am wrong.

So what is the idea here ? Is there a way to actually jshint my files ? What did I miss ?

rwjblue commented 9 years ago

@jlgrall:

Is it why you put the "ZOMG!!! TESTS?!?!!?" in the README.md ?

No, it is because at the time almost no Broccoli plugins had tests.

it generates some test files that can probably be used by the "mocha" unit testing. Is this true ?

The default tests are for QUnit actually, but there is a hook to implement any sort of test output that you would like.

So what is the idea here ?

The goal is to generate tests that fit into your normal CI testing environment. This ensures that your build fails properly when files do not pass JSHint.

Is there a way to actually jshint my files ?

Files are hinted and logs are made to the console immediately. Test files are also output so that your final build's normal test suite can run them and pass/fail your build in a single place.

jlgrall commented 9 years ago

Thanks. And that is exactly what should be written in the README.md ;) And good job for the plugin tests.

The next question is then: how can I run jsHintTree in such a way that:

Edit: it rewrote the question to make it clearer.

hhff commented 9 years ago

HI @rwjblue ! I'm attempting to do the same as @jlgrall (outside of an Ember CLI project).

I essentially just want to log the JSHint output to the console in the build process. I can only get it to do that if I merge the "hinted" tree into my application output, but that swallows my JS.

Is there anyway to do this? Thanks so much!

Keeo commented 9 years ago

I was able to do it by redirecting output to separate folder.

var babel = require('broccoli-babel-transpiler');
var jshint = require('broccoli-jshint');
var Funnel = require('broccoli-funnel');
var MergeTrees = require('broccoli-merge-trees');

const app = 'app';

var jshintTree = new Funnel(jshint(app), {
  destDir: 'jshint'
});

var es5Tree = new Funnel(babel(app), {
  destDir: 'dist'
});

module.exports = new MergeTrees([jshintTree, es5Tree]);