From 7f76c79319bf0817222fc88011fd870d97648963 Mon Sep 17 00:00:00 2001 From: Anike Arni Date: Tue, 7 Feb 2017 19:46:45 -0200 Subject: [#922] Adds eslint for react and es6 files --- web-ui/.eslintrc.json | 18 ++++++++++++++++++ web-ui/package.json | 9 ++++++++- web-ui/src/account_recovery/account_recovery.js | 14 +++++++------- web-ui/src/account_recovery/page.js | 8 ++++++-- web-ui/src/common/input_field/input_field.js | 5 +++++ web-ui/src/common/submit_button/submit_button.js | 4 ++++ web-ui/src/i18n.js | 18 +++++++++--------- web-ui/test/unit/account_recovery/page.spec.js | 7 ++++--- 8 files changed, 61 insertions(+), 22 deletions(-) create mode 100644 web-ui/.eslintrc.json (limited to 'web-ui') diff --git a/web-ui/.eslintrc.json b/web-ui/.eslintrc.json new file mode 100644 index 00000000..4828136e --- /dev/null +++ b/web-ui/.eslintrc.json @@ -0,0 +1,18 @@ +{ + "extends": "airbnb", + "plugins": [ + "react", + "jsx-a11y", + "import" + ], + "rules": { + "import/no-extraneous-dependencies": ["off"], + "import/extensions": ["off"], + "import/no-unresolved": ["off"], + "react/jsx-filename-extension": ["off"], + "jsx-quotes": ["error", "prefer-single"], + "no-undef": ["off"], + "comma-dangle": ["off"], + "semi": ["error", "never"] + } +} diff --git a/web-ui/package.json b/web-ui/package.json index dba34e97..ab5d1b24 100644 --- a/web-ui/package.json +++ b/web-ui/package.json @@ -16,6 +16,11 @@ "css-loader": "^0.26.1", "dompurify": "^0.8.4", "enzyme": "^2.7.1", + "eslint": "^3.15.0", + "eslint-config-airbnb": "^14.1.0", + "eslint-plugin-import": "^2.2.0", + "eslint-plugin-jsx-a11y": "^4.0.0", + "eslint-plugin-react": "^6.9.0", "expect": "^1.20.2", "file-loader": "^0.10.0", "font-awesome": "^4.7.0", @@ -64,7 +69,7 @@ "webpack": "^1.14.0" }, "scripts": { - "test": "npm run jshint --silent && npm run build-statics --silent && npm run mocha-test && npm run karma-test", + "test": "npm run lint --silent && npm run build-statics --silent && npm run mocha-test && npm run karma-test", "mocha-test": "mocha-webpack --webpack-config webpack.test.config.js \"test/unit/**/*.spec.js\"", "mocha-watch": "mocha-webpack --watch --webpack-config webpack.test.config.js \"test/unit/**/*.spec.js\"", "karma-test": "karma start --single-run $GRUNT_OPTS", @@ -80,7 +85,9 @@ "build-prod": "npm run build-statics && webpack -p --config ./webpack.production.config.js", "build-js": "webpack --colors --progress", "build-js-watch": "webpack --colors --progress --watch", + "lint": "npm run jshint && npm run eslint", "jshint": "jshint --config=.jshintrc app test", + "eslint": "eslint src test/unit", "clean": "rm -rf dist/ app/js/generated/hbs/* app/css/*", "package": "PIXELATED_BUILD='package' npm run build-prod && npm run imagemin", "imagemin": "node config/imagemin.js", diff --git a/web-ui/src/account_recovery/account_recovery.js b/web-ui/src/account_recovery/account_recovery.js index 6c12e326..eac14bf7 100644 --- a/web-ui/src/account_recovery/account_recovery.js +++ b/web-ui/src/account_recovery/account_recovery.js @@ -20,16 +20,16 @@ import { render } from 'react-dom' import a11y from 'react-a11y' import { I18nextProvider } from 'react-i18next' -import Page from './page' -import i18n from '../i18n' - import 'font-awesome/scss/font-awesome.scss' -if(process.env.NODE_ENV === 'development') a11y(React); +import PageWrapper from './page' +import i18n from '../i18n' + +if (process.env.NODE_ENV === 'development') a11y(React) render( - - + + , document.getElementById('root') -); +) diff --git a/web-ui/src/account_recovery/page.js b/web-ui/src/account_recovery/page.js index d1bcb464..396788e7 100644 --- a/web-ui/src/account_recovery/page.js +++ b/web-ui/src/account_recovery/page.js @@ -32,8 +32,8 @@ export const Page = ({ t }) => (