Skip to content

Commit

Permalink
fix #11 Support eslint-config-airbnb
Browse files Browse the repository at this point in the history
Signed-off-by: Bo-Yi Wu <[email protected]>
  • Loading branch information
appleboy committed Oct 10, 2015
1 parent 3d3496d commit 5feb525
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 29 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"stage": 0
}
10 changes: 10 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "airbnb",
"globals": {
"grecaptcha": true,
"console": true
},
"rules": {
"no-console": 0
}
}
10 changes: 5 additions & 5 deletions example/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ import React from 'react';
import Recaptcha from '../src';

// site key
let sitekey = 'xxxxxxxx';
const sitekey = 'xxxxxxxx';

// specifying your onload callback function
let callback = () => {
const callback = () => {
console.log('Done!!!!');
};

let verifyCallback = (response) => {
const verifyCallback = (response) => {
console.log(response);
};

let App = React.createClass({
class App extends React.Component {
render() {
return (
<div>
Expand All @@ -27,6 +27,6 @@ let App = React.createClass({
</div>
);
}
});
}

React.render(<App />, document.getElementById('app'));
24 changes: 12 additions & 12 deletions example/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,42 +14,42 @@ const port = process.env.PORT || 3000;
module.exports = {

// Efficiently evaluate modules with source maps
devtool: "eval",
devtool: 'eval',

// Set entry point to ./example/main and include necessary files for hot load
entry: [
entry: [
`webpack-dev-server/client?http://localhost:${port}`,
"webpack/hot/only-dev-server",
"./example/main"
'webpack/hot/only-dev-server',
'./example/main',
],

// This will not actually create a bundle.js file in ./build. It is used
// by the dev server for dynamic hot loading.
output: {
path: `${__dirname}/build/`,
filename: "app.js",
publicPath: `http://localhost:${port}/build/`
filename: 'app.js',
publicPath: `http://localhost:${port}/build/`,
},

// Necessary plugins for hot load
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
new webpack.NoErrorsPlugin(),
],

// Transform source code using Babel and React Hot Loader
module: {
loaders: [{
test: /\.jsx?$/,
exclude: /node_modules/,
loaders: ["react-hot", "babel-loader"]
}]
loaders: ['react-hot', 'babel-loader'],
}],
},

// Automatically transform files with these extensions
resolve: {
extensions: ['', '.js', '.jsx']
extensions: ['', '.js', '.jsx'],
},

port: port
}
port,
};
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"start": "babel-node example/server.js",
"prebuild": "rm -rf dist",
"build": "webpack -p --config webpack.production.config.js",
"lint": "eslint src example",
"test": "jest"
},
"repository": {
Expand All @@ -30,8 +31,12 @@
},
"devDependencies": {
"babel-core": "^5.8.25",
"babel-eslint": "^4.1.3",
"babel-jest": "^5.3.0",
"babel-loader": "^5.3.2",
"eslint": "^1.6.0",
"eslint-config-airbnb": "^0.1.0",
"eslint-plugin-react": "^3.5.1",
"jest": "^0.1.40",
"jest-cli": "^0.5.4",
"react-hot-loader": "^1.3.0",
Expand Down
4 changes: 1 addition & 3 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict';

import React from 'react';

const propTypes = {
Expand Down Expand Up @@ -35,7 +33,7 @@ export default class Recaptcha extends React.Component {
sitekey: this.props.sitekey,
callback: (this.props.verifyCallback) ? this.props.verifyCallback : undefined,
theme: this.props.theme,
type: this.props.type
type: this.props.type,
});

if (this.props.onloadCallback) {
Expand Down
18 changes: 9 additions & 9 deletions webpack.production.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@ var webpack = require('webpack');
* This is the Webpack configuration file for production.
*/
module.exports = {
entry: "./src/index",
entry: './src/index',

output: {
library: 'ReactRecaptcha',
libraryTarget: 'umd',
path: __dirname + "/dist/",
filename: "react-recaptcha.js"
path: __dirname + '/dist/',
filename: 'react-recaptcha.js'
},

externals: [{
"react": {
root: "React",
commonjs2: "react",
commonjs: "react",
amd: "react"
'react': {
root: 'React',
commonjs2: 'react',
commonjs: 'react',
amd: 'react'
}
}],

module: {
loaders: [
{ test: /\.jsx?$/, exclude: /node_modules/, loader: "babel-loader" }
{ test: /\.jsx?$/, exclude: /node_modules/, loader: 'babel-loader' }
]
},

Expand Down

0 comments on commit 5feb525

Please sign in to comment.