diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..f9a5062 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,37 @@ +{ + "rules": { + "indent": [ + 1, + "tab" + ], + "quotes": [ + 1, + "single" + ], + "linebreak-style": [ + 1, + "windows" + ], + "semi": [ + 1, + "never" + ] + }, + "env": { + "es6": true, + "browser": true, + "node" : true + }, + "extends": "eslint:recommended", + "ecmaFeatures": { + "jsx": true, + "experimentalObjectRestSpread": true, + "modules": true + }, + "plugins": [ + "react" + ], + "globals": { + "__DEBUG__": true + } +} \ No newline at end of file diff --git a/.gitignore b/.gitignore index bc52912..e2928ca 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ node_modules dist *.sublime-project -*.sublime-workspace \ No newline at end of file +*.sublime-workspace +npm-debug.log \ No newline at end of file diff --git a/package.json b/package.json index 2b2275d..bf8afc9 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,14 @@ { "name": "react-boilerplate", - "version": "0.1.2", + "version": "0.1.3", "description": "a react boilerplate", "main": "main.js", "dependencies": { "es5-shim": "^4.3.1", "es6-promise": "^3.0.2", "react": "^0.14.3", - "react-dom": "^0.14.3" + "react-dom": "^0.14.3", + "whatwg-fetch": "^0.10.1" }, "devDependencies": { "autoprefixer": "^6.1.1", @@ -15,9 +16,10 @@ "babel-loader": "^6.2.0", "babel-preset-es2015": "^6.1.18", "babel-preset-react": "^6.1.18", - "babel-preset-stage-2": "^6.1.18", "css-loader": "^0.23.0", "cssgrace": "^3.0.0", + "eslint": "^1.10.3", + "eslint-plugin-react": "^3.11.3", "exports-loader": "^0.6.2", "extract-text-webpack-plugin": "^0.9.1", "file-loader": "^0.8.5", @@ -36,6 +38,7 @@ }, "scripts": { "start": "node ./server.js", + "lint": "eslint ./src", "test": "echo \"Error: no test specified\" && exit 1", "deploy": "webpack --config webpack.config.js" }, diff --git a/src/scripts/components/app.js b/src/scripts/components/app.js index cb96121..55a3190 100644 --- a/src/scripts/components/app.js +++ b/src/scripts/components/app.js @@ -1,9 +1,9 @@ -import React from 'react'; +import React from 'react' export default class App extends React.Component { render() { return (
Hello,please enjoy it
- ); + ) } } diff --git a/src/scripts/main.js b/src/scripts/main.js index fe7dd68..28d3207 100644 --- a/src/scripts/main.js +++ b/src/scripts/main.js @@ -4,4 +4,8 @@ import ReactDom from 'react-dom' import React from 'react' import App from './components/app' +if (__DEBUG__ === true) { + console.log('this is debug model') +}; + ReactDom.render(, document.querySelector('#root')); diff --git a/webpack.config.js b/webpack.config.js index 43b3eff..9c14c28 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -30,6 +30,9 @@ module.exports = { new webpack.DefinePlugin({ __DEBUG__: false //true/false }), + new webpack.ProvidePlugin({ + 'fetch': 'imports?this=>global!exports?global.fetch!whatwg-fetch' + }), new webpack.optimize.CommonsChunkPlugin("commons", "commons.js"), new ExtractTextPlugin("[name].css",{allChunks: true}), new HtmlWebpackPlugin({ diff --git a/webpack.dev.config.js b/webpack.dev.config.js index d82d21f..47b58bb 100644 --- a/webpack.dev.config.js +++ b/webpack.dev.config.js @@ -31,6 +31,9 @@ module.exports = { new webpack.DefinePlugin({ __DEBUG__: true }), + new webpack.ProvidePlugin({ + 'fetch': 'imports?this=>global!exports?global.fetch!whatwg-fetch' + }), new webpack.optimize.CommonsChunkPlugin("commons", "commons.js"), new webpack.HotModuleReplacementPlugin(), new HtmlWebpackPlugin({