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
This commit is contained in:
Martin Pitt 2018-08-28 22:01:43 +02:00
parent f1bfdf8209
commit 1ab4dadd77
3 changed files with 46 additions and 9 deletions

View file

@ -3,7 +3,8 @@
"browser": true, "browser": true,
"es6": true "es6": true
}, },
"extends": "eslint:recommended", "extends": ["eslint:recommended", "standard", "standard-react"],
"parser": "babel-eslint",
"parserOptions": { "parserOptions": {
"ecmaFeatures": { "ecmaFeatures": {
"experimentalObjectRestSpread": true, "experimentalObjectRestSpread": true,
@ -11,11 +12,38 @@
}, },
"sourceType": "module" "sourceType": "module"
}, },
"plugins": ["react"], "plugins": ["flowtype", "react"],
"rules": { "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-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": { "globals": {
"require": false, "require": false,

View file

@ -11,6 +11,7 @@
}, },
"devDependencies": { "devDependencies": {
"babel-core": "^6.25.0", "babel-core": "^6.25.0",
"babel-eslint": "^9.0.0",
"babel-loader": "^7.0.0", "babel-loader": "^7.0.0",
"babel-plugin-transform-react-jsx": "^6.24.1", "babel-plugin-transform-react-jsx": "^6.24.1",
"babel-preset-env": "^1.5.2", "babel-preset-env": "^1.5.2",
@ -18,9 +19,16 @@
"compression-webpack-plugin": "~1.0.0", "compression-webpack-plugin": "~1.0.0",
"copy-webpack-plugin": "~3.0.1", "copy-webpack-plugin": "~3.0.1",
"css-loader": "^0.28.11", "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-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", "extract-text-webpack-plugin": "^2.1.0",
"htmlparser": "^1.7.7", "htmlparser": "^1.7.7",
"jed": "^1.1.1", "jed": "^1.1.1",

View file

@ -27,9 +27,10 @@ export class Application extends React.Component {
constructor() { constructor() {
super(); super();
cockpit.file('/etc/hostname').read().done((content) => { cockpit.file('/etc/hostname').read()
this.setState({ 'hostname': content.trim() }); .done((content) => {
}); this.setState({ 'hostname': content.trim() });
});
} }
render() { render() {