diff --git a/.eslintrc b/.eslintrc index 8f6cd62a..4d30170d 100644 --- a/.eslintrc +++ b/.eslintrc @@ -3,7 +3,10 @@ env: es6: true parser: babel-eslint -plugins: [ "react" ] +plugins: [ + "react", + "class-property" +] rules: # Possible Errors @@ -97,6 +100,8 @@ rules: react/self-closing-comp: 1 react/sort-comp: 1 + class-property/class-property-semicolon: 2 + # Global scoped method and vars globals: netlify: true diff --git a/package.json b/package.json index 21d378f9..5c27e180 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "babel-runtime": "^6.5.0", "css-loader": "^0.23.1", "eslint": "^3.5.0", + "eslint-plugin-class-property": "^1.0.1", "eslint-plugin-react": "^5.1.1", "expect": "^1.20.2", "exports-loader": "^0.6.3", diff --git a/src/backends/github/AuthenticationPage.js b/src/backends/github/AuthenticationPage.js index c85dde2f..d744c8ea 100644 --- a/src/backends/github/AuthenticationPage.js +++ b/src/backends/github/AuthenticationPage.js @@ -6,13 +6,9 @@ export default class AuthenticationPage extends React.Component { onLogin: React.PropTypes.func.isRequired }; - constructor(props) { - super(props); - this.state = {}; - this.handleLogin = this.handleLogin.bind(this); - } + state = {}; - handleLogin(e) { + handleLogin = e => { e.preventDefault(); let auth; if (document.location.host.split(':')[0] === 'localhost') { @@ -28,7 +24,7 @@ export default class AuthenticationPage extends React.Component { } this.props.onLogin(data); }); - } + }; render() { const { loginError } = this.state; diff --git a/src/backends/netlify-git/AuthenticationPage.js b/src/backends/netlify-git/AuthenticationPage.js index 74e508c5..28333d33 100644 --- a/src/backends/netlify-git/AuthenticationPage.js +++ b/src/backends/netlify-git/AuthenticationPage.js @@ -5,13 +5,9 @@ export default class AuthenticationPage extends React.Component { onLogin: React.PropTypes.func.isRequired }; - constructor(props) { - super(props); - this.state = {}; - this.handleLogin = this.handleLogin.bind(this); - } + state = {}; - handleLogin(e) { + handleLogin = e => { e.preventDefault(); const { email, password } = this.state; this.setState({ authenticating: true }); @@ -33,7 +29,7 @@ export default class AuthenticationPage extends React.Component { this.setState({ loginError: data.msg }); }); }); - } + }; handleChange(key) { return (e) => { diff --git a/src/backends/test-repo/AuthenticationPage.js b/src/backends/test-repo/AuthenticationPage.js index ce20b0bf..a6f2e130 100644 --- a/src/backends/test-repo/AuthenticationPage.js +++ b/src/backends/test-repo/AuthenticationPage.js @@ -5,21 +5,16 @@ export default class AuthenticationPage extends React.Component { onLogin: React.PropTypes.func.isRequired }; - constructor(props) { - super(props); - this.state = { email: '' }; - this.handleLogin = this.handleLogin.bind(this); - this.handleEmailChange = this.handleEmailChange.bind(this); - } + state = { email: '' }; - handleLogin(e) { + handleLogin = e => { e.preventDefault(); this.props.onLogin(this.state); - } + }; - handleEmailChange(e) { + handleEmailChange = e => { this.setState({ email: e.target.value }); - } + }; render() { return