Adjust code to airbnb style guide, including eslint rules and prettier configuration for code base

This commit is contained in:
Victor Hagelbäck 2021-01-22 15:49:02 +01:00
parent 1b55cabf63
commit 281acd6ad8
23 changed files with 919 additions and 2225 deletions

39
plejd/.eslintrc.js Normal file
View file

@ -0,0 +1,39 @@
// const path = require('path');
// {
// "extends": ["airbnb-base", "plugin:prettier/recommended"],
// "plugins": ["prettier"],
// "rules": {
// "prettier/prettier": "error"
// }
// }
// eslint-disable-next-line no-undef
module.exports = {
root: true,
extends: [
'airbnb-base',
// 'prettier',
// 'plugin:prettier/recommended'
],
parser: 'babel-eslint',
// plugins: ['prettier'],
rules: getRules(),
};
function getRules() {
return {
// Allows modification of properties passed to functions.
// Notably used in array.forEach(e => {e.prop = val;})
'no-param-reassign': ['error', { props: false }],
// ++ operator widely used
'no-plusplus': ['off'],
// Hassio-Plejd team feals _ prefix is great for "private" variables.
// They will still be available for use from the outside
'no-underscore-dangle': ['off'],
// Allow function hoisting to improve code readability
'no-use-before-define': ['error', { functions: false, classes: true, variables: true }],
// Allow direct indexing of arrays only (array[0])
'prefer-destructuring': ['error', { array: false, object: true }],
};
}