Skip to content

Commit

Permalink
Revert "Revert "Optional Flow Support""
Browse files Browse the repository at this point in the history
  • Loading branch information
amilajack authored Sep 27, 2016
1 parent bbbc16b commit 2c24a7a
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 17 deletions.
4 changes: 1 addition & 3 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
"env": {
"production": {
"presets": ["react-optimize"],
"plugins": [
"babel-plugin-dev-expression"
]
"plugins": ["babel-plugin-dev-expression"]
},
"development": {
"presets": ["react-hmre"]
Expand Down
7 changes: 5 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@
"react/jsx-no-bind": "off",
"react/jsx-filename-extension": ["error", { "extensions": [".js", ".jsx"] }],
"react/prefer-stateless-function": "off",
"generator-star-spacing": "off"
"generator-star-spacing": "off",
"flowtype-errors/show-errors": 2
},
"plugins": [
"import",
"react"
"react",
"flowtype",
"flowtype-errors"
],
"settings": {
"import/resolver": {
Expand Down
17 changes: 17 additions & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[ignore]
.*/node_modules/fbjs/.*
.*/app/main.js
.*/app/dist/.*
.*/release/.*
.*/git/.*

[include]
./app/**/*.js
./node_modules/

[libs]

[options]
esproposal.class_static_fields=enable
esproposal.class_instance_fields=enable
esproposal.export_star_as=enable
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Make sure to list bootstrap in externals in `webpack.config.base.js` or the app
```js
externals: ['bootstrap']
```



## CSS Modules
Expand Down Expand Up @@ -173,6 +173,9 @@ Then, use git to merge some latest commits:
git pull upstream master
```

## Type Annotations
This project comes with Flow support out of the box! You can annotate your code with types, [get Flow errors as ESLint errors](https://github.com/amilajack/eslint-plugin-flowtype-errors), and get runtime errors of incorrect types with [tcomb. types](https://github.com/gcanti/babel-plugin-tcomb-boilerplate). Gradually add type annotations to function arguments and return values but if you don't want to add type checking, just don't add types. Type checks are turned off during production.

## Native-like UI

If you want to have native-like User Interface (OS X El Capitan and Windows 10), [react-desktop](https://github.com/gabrielbull/react-desktop) may perfect suit for you.
Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"babel-loader": "^6.2.5",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-dev-expression": "^0.2.1",
"babel-plugin-tcomb": "^0.3.14",
"babel-plugin-webpack-loaders": "^0.7.1",
"babel-polyfill": "^6.13.0",
"babel-preset-es2015": "^6.14.0",
Expand All @@ -77,8 +78,11 @@
"eslint": "^3.6.0",
"eslint-config-airbnb": "^12.0.0",
"eslint-import-resolver-webpack": "^0.6.0",
"eslint-plugin-flowtype": "^2.19.0",
"eslint-plugin-flowtype-errors": "^1.2.1",
"eslint-plugin-import": "^1.16.0",
"eslint-plugin-jsx-a11y": "^2.2.2",
"eslint-plugin-mocha": "^4.5.1",
"eslint-plugin-react": "^6.3.0",
"express": "^4.14.0",
"extract-text-webpack-plugin": "^1.0.1",
Expand All @@ -93,6 +97,7 @@
"sinon": "^1.17.6",
"spectron": "^3.3.0",
"style-loader": "^0.13.1",
"tcomb": "^3.2.15",
"webpack": "^1.13.2",
"webpack-dev-middleware": "^1.6.1",
"webpack-hot-middleware": "^2.12.2",
Expand Down
15 changes: 15 additions & 0 deletions test/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,22 @@
"env": {
"mocha": true
},
"plugins": [
"mocha"
],
"rules": {
"mocha/no-exclusive-tests": 2,
"mocha/no-skipped-tests": 0,
"mocha/no-pending-tests": 2,
"mocha/handle-done-callback": 2,
"mocha/no-synchronous-tests": 1,
"mocha/no-global-tests": 2,
"mocha/valid-test-description": 2,
"mocha/valid-suite-description": 2,
"mocha/no-sibling-hooks": 0,
"mocha/no-mocha-arrows": 0,
"mocha/no-hooks": 0,
"mocha/no-top-level-hooks": 0,
"no-unused-expressions": 0
}
}
10 changes: 5 additions & 5 deletions test/actions/counter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import * as actions from '../../app/actions/counter';


describe('actions', () => {
it('increment should create increment action', () => {
it('should increment should create increment action', () => {
expect(actions.increment()).to.deep.equal({ type: actions.INCREMENT_COUNTER });
});

it('decrement should create decrement action', () => {
it('should decrement should create decrement action', () => {
expect(actions.decrement()).to.deep.equal({ type: actions.DECREMENT_COUNTER });
});

it('incrementIfOdd should create increment action', () => {
it('should incrementIfOdd should create increment action', () => {
const fn = actions.incrementIfOdd();
expect(fn).to.be.a('function');
const dispatch = spy();
Expand All @@ -22,7 +22,7 @@ describe('actions', () => {
expect(dispatch.calledWith({ type: actions.INCREMENT_COUNTER })).to.be.true;
});

it('incrementIfOdd shouldnt create increment action if counter is even', () => {
it('should incrementIfOdd shouldnt create increment action if counter is even', () => {
const fn = actions.incrementIfOdd();
const dispatch = spy();
const getState = () => ({ counter: 2 });
Expand All @@ -31,7 +31,7 @@ describe('actions', () => {
});

// There's no nice way to test this at the moment...
it('incrementAsync', done => {
it('should incrementAsync', done => {
const fn = actions.incrementAsync(1);
expect(fn).to.be.a('function');
const dispatch = spy();
Expand Down
10 changes: 5 additions & 5 deletions test/components/Counter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,30 @@ function setup() {


describe('Counter component', () => {
it('should display count', () => {
it('should should display count', () => {
const { p } = setup();
expect(p.text()).to.match(/^1$/);
});

it('first button should call increment', () => {
it('should first button should call increment', () => {
const { buttons, actions } = setup();
buttons.at(0).simulate('click');
expect(actions.increment.called).to.be.true;
});

it('second button should call decrement', () => {
it('should second button should call decrement', () => {
const { buttons, actions } = setup();
buttons.at(1).simulate('click');
expect(actions.decrement.called).to.be.true;
});

it('third button should call incrementIfOdd', () => {
it('should third button should call incrementIfOdd', () => {
const { buttons, actions } = setup();
buttons.at(2).simulate('click');
expect(actions.incrementIfOdd.called).to.be.true;
});

it('fourth button should call incrementAsync', () => {
it('should fourth button should call incrementAsync', () => {
const { buttons, actions } = setup();
buttons.at(3).simulate('click');
expect(actions.incrementAsync.called).to.be.true;
Expand Down
2 changes: 1 addition & 1 deletion test/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { expect } from 'chai';


describe('description', () => {
it('description', () => {
it('should have description', () => {
expect(1 + 2).to.equal(3);
});
});

0 comments on commit 2c24a7a

Please sign in to comment.