From 1ab4dadd77a9ee3f554979bd2281514a75e4d30c Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Tue, 28 Aug 2018 22:01:43 +0200 Subject: [PATCH] Enable a lot of eslint options and plugins Taken rules from Cockpit, which have been proven to be effective for finding bugs and keeping clean code, and sensible (not taking unreasonable effort to satisfy). Fix code layout in app.jsx accordingly. Closes #39 --- .eslintrc.json | 36 ++++++++++++++++++++++++++++++++---- package.json | 12 ++++++++++-- src/app.jsx | 7 ++++--- 3 files changed, 46 insertions(+), 9 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 71c0e41..3b7538e 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -3,7 +3,8 @@ "browser": true, "es6": true }, - "extends": "eslint:recommended", + "extends": ["eslint:recommended", "standard", "standard-react"], + "parser": "babel-eslint", "parserOptions": { "ecmaFeatures": { "experimentalObjectRestSpread": true, @@ -11,11 +12,38 @@ }, "sourceType": "module" }, - "plugins": ["react"], + "plugins": ["flowtype", "react"], "rules": { - "react/jsx-uses-vars": "error", + "indent": ["error", 4, + { + "ObjectExpression": "first", + "CallExpression": {"arguments": "first"}, + "MemberExpression": 2, + "ignoredNodes": [ "JSXAttribute" ] + }], + "newline-per-chained-call": ["error", { "ignoreChainWithDepth": 2 }], + "lines-between-class-members": ["error", "always", { "exceptAfterSingleLine": true }], + "prefer-promise-reject-errors": ["error", { "allowEmptyReject": true }], + "react/jsx-indent": ["error", 4], + "semi": ["error", "always", { "omitLastInOneLineBlock": true }], + + "camelcase": "off", + "comma-dangle": "off", + "curly": "off", + "jsx-quotes": "off", + "key-spacing": "off", "no-console": "off", - "no-undef": "error" + "quotes": "off", + "react/jsx-curly-spacing": "off", + "react/jsx-indent-props": "off", + "react/prop-types": "off", + "space-before-function-paren": "off", + "standard/no-callback-literal": "off", + + "eqeqeq": "off", + "import/no-webpack-loader-syntax": "off", + "object-property-newline": "off", + "react/jsx-no-bind": "off" }, "globals": { "require": false, diff --git a/package.json b/package.json index 74b2c11..28c1357 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ }, "devDependencies": { "babel-core": "^6.25.0", + "babel-eslint": "^9.0.0", "babel-loader": "^7.0.0", "babel-plugin-transform-react-jsx": "^6.24.1", "babel-preset-env": "^1.5.2", @@ -18,9 +19,16 @@ "compression-webpack-plugin": "~1.0.0", "copy-webpack-plugin": "~3.0.1", "css-loader": "^0.28.11", - "eslint": "^3.0.0", + "eslint": "^5.4.0", + "eslint-config-standard": "^11.0.0", + "eslint-config-standard-react": "^6.0.0", "eslint-loader": "~1.6.1", - "eslint-plugin-react": "~6.9.0", + "eslint-plugin-flowtype": "^2.50.0", + "eslint-plugin-import": "^2.14.0", + "eslint-plugin-node": "^7.0.1", + "eslint-plugin-promise": "^4.0.0", + "eslint-plugin-react": "^6.9.0", + "eslint-plugin-standard": "^3.1.0", "extract-text-webpack-plugin": "^2.1.0", "htmlparser": "^1.7.7", "jed": "^1.1.1", diff --git a/src/app.jsx b/src/app.jsx index f688c84..915eab5 100644 --- a/src/app.jsx +++ b/src/app.jsx @@ -27,9 +27,10 @@ export class Application extends React.Component { constructor() { super(); - cockpit.file('/etc/hostname').read().done((content) => { - this.setState({ 'hostname': content.trim() }); - }); + cockpit.file('/etc/hostname').read() + .done((content) => { + this.setState({ 'hostname': content.trim() }); + }); } render() {