Skip to content

Commit

Permalink
Totally reorganize project structure
Browse files Browse the repository at this point in the history
Love it. Inspired by
https://gist.github.com/ryanflorence/110d4538bf98694538de

ESLint does not yet support glob-based rules, but likely will in v2:
eslint/eslint#3611
  • Loading branch information
cooperka committed Nov 14, 2015
1 parent c6407a2 commit 99b093f
Show file tree
Hide file tree
Showing 17 changed files with 70 additions and 67 deletions.
6 changes: 5 additions & 1 deletion .eslintrc
@@ -1,3 +1,7 @@
{
"extends": "airbnb"
"extends": "airbnb",

"env": {
"mocha": true
}
}
7 changes: 4 additions & 3 deletions karma.conf.js
@@ -1,20 +1,21 @@
const webpackConfig = require('./webpack.config');

module.exports = function(config) {
module.exports = (config) => {
config.set({
browsers: ['Chrome'],

frameworks: ['mocha'],

files: [
'tests.webpack.js',
'**/__tests__/*.js?',
],

preprocessors: {
'tests.webpack.js': ['webpack', 'sourcemap'],
'**/__tests__/*.js?': ['webpack', 'sourcemap'],
},

webpack: {
resolve: webpackConfig.resolve,
devtool: webpackConfig.devtool,
module: webpackConfig.module,
},
Expand Down
6 changes: 3 additions & 3 deletions package.json
@@ -1,10 +1,10 @@
{
"name": "react-simple-boilerplate",
"version": "0.0.1",
"description": "Boilerplate repo for starting ReactJS apps. Mostly for personal use and sandboxing.",
"main": "src/app.js",
"description": "Boilerplate repo for starting ReactJS apps.",
"main": "views",
"scripts": {
"lint": "eslint -c .eslintrc public src --ext .js,.jsx",
"lint": "eslint ./*.js? public views --ext .js,.jsx",
"build": "webpack --progress --colors",
"start": "webpack-dev-server --inline --hot --progress --colors --content-base public",
"test": "karma start"
Expand Down
2 changes: 1 addition & 1 deletion public/index.html
Expand Up @@ -5,7 +5,7 @@
<title>Hello React!</title>
</head>
<body>
<div id="app"></div>
<div id="appContainer"></div>
<script type="text/javascript" src="build/bundle.js"></script>
</body>
</html>
17 changes: 0 additions & 17 deletions src/app.js

This file was deleted.

5 changes: 0 additions & 5 deletions src/style/hello-world.scss

This file was deleted.

9 changes: 0 additions & 9 deletions test/.eslintrc

This file was deleted.

23 changes: 0 additions & 23 deletions test/components/hello-world.js

This file was deleted.

2 changes: 0 additions & 2 deletions tests.webpack.js

This file was deleted.

6 changes: 6 additions & 0 deletions src/style/app.scss → views/App/App.scss
@@ -1 +1,7 @@
@import '~normalize.css/normalize.css'; // Tilde resolves node modules

@import '../common/variables';

body {
background: $main-bkgd;
}
Empty file.
20 changes: 20 additions & 0 deletions views/App/HelloWorld/__tests__/HelloWorld.test.jsx
@@ -0,0 +1,20 @@
import React from 'react';
import ReactDOM from 'react-dom';
import TestUtils from 'react-addons-test-utils';
import { expect } from 'chai';

import HelloWorld from '../index';

describe('HelloWorld component', function() {
beforeEach(() => {
this.component = TestUtils.renderIntoDocument(<HelloWorld />);
this.renderedDOM = () => ReactDOM.findDOMNode(this.component);
});

it('says hello to the world', () => {
const helloWorldNode = this.renderedDOM();
const helloWorldText = helloWorldNode.innerHTML;
expect(helloWorldText).to.contain('Hello');
expect(helloWorldText).to.contain('world');
});
});
@@ -1,6 +1,6 @@
import React from 'react';

require('../style/hello-world.scss');
require('./HelloWorld.scss');

class HelloWorld extends React.Component {

Expand Down
17 changes: 17 additions & 0 deletions views/App/index.jsx
@@ -0,0 +1,17 @@
import React from 'react';

import HelloWorld from './HelloWorld';

require('./App.scss');

class App extends React.Component {

render() {
return (
<HelloWorld />
);
}

}

export default App;
1 change: 1 addition & 0 deletions views/common/variables.scss
@@ -0,0 +1 @@
$main-bkgd: lightgray;
6 changes: 6 additions & 0 deletions views/index.jsx
@@ -0,0 +1,6 @@
import React from 'react';
import ReactDOM from 'react-dom';

import App from './App';

ReactDOM.render(<App />, document.getElementById('appContainer'));
8 changes: 6 additions & 2 deletions webpack.config.js
Expand Up @@ -4,16 +4,20 @@ module.exports = {

entry: [
'webpack-hot-middleware/client',
'./src/app.js',
'./views',
],

resolve: {
extensions: ['', '.js', '.jsx'],
},

output: {
path: __dirname + '/build',
publicPath: '/build',
filename: 'bundle.js',
},

devtool: 'cheap-module-eval-source-map',
devtool: 'inline-source-map',

plugins: [
new webpack.NoErrorsPlugin(),
Expand Down

0 comments on commit 99b093f

Please sign in to comment.