segmentio/analytics.js-integrations — pull request #128 by ianstormtaylor (2014-04-30 06:25:25+00:00)
Title: Cleanup/structure

cc @yields @realyze

This is a biiiigggg diff, because a lot of this was cleaning up styles everywhere, so it's more useful to just [browse the actual source](https://github.com/segmentio/analytics.js-integrations/tree/cleanup/structure). One of the things we want to do is get the existing code quality to be as high as possible, and stay high over time, so this PR does:

1. **Moves tests right next to the integration source files.** That way it's way more obvious how the two match together, and it means we can have them be automatically generated with [Khaos](https://github.com/segmentio/khaos) from [a standard template](https://github.com/segmentio/khaos-analytics.js-integration) to start with. (I'm planning to write up more Readme content about that if you guys think it's a good idea.)

2. **Cleans up random parts, like Makefile and test runners.** This was just random cleaning. One thing, was that I moved `slugs.json` to the top-level directory as `integrations.json` for clarity, since it gets lost otherwise. @yields not sure exactly how that's used, whether it's access directly or just internal here, so we might need to make some adjustments somewhere, or we can revert it if you think it's bad to move. Ideally we could remove it all together.

3. **Adds a style checker to the tests.** Using [jscs](https://github.com/mdevils/node-jscs) to run all of the source files through a linter with [some rules](https://github.com/segmentio/analytics.js-integrations/blob/cleanup/structure/test/style.json), that will fail the tests if the styles don't match up. For example, function declarations look like `function(){` not `function () {`. So that will show up in Travis CI too which is cool, so PRs will automatically check for style now.

This PR isn't super on fire for timing, but if we like the direction, we should generally try to merge it somewhat soon so it doesn't diverge too much.

Let me know!