From 47eb406eb84b60dcf82be5e2d273cb695a890607 Mon Sep 17 00:00:00 2001 From: OleksandrNechai Date: Wed, 13 Nov 2019 15:46:11 +0200 Subject: [PATCH] chore(lint): add complexity rules to picasso n --- .eslintrc | 53 +++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 41 insertions(+), 12 deletions(-) diff --git a/.eslintrc b/.eslintrc index a8a20a8df98..2a900028d55 100644 --- a/.eslintrc +++ b/.eslintrc @@ -121,9 +121,38 @@ "@typescript-eslint/no-non-null-assertion": 1, "@typescript-eslint/explicit-member-accessibility": 0, "@typescript-eslint/no-var-requires": 0, - "@typescript-eslint/no-use-before-define": [2, { "functions": false, "classes": false, "variables": false, "typedefs": false }], + "@typescript-eslint/no-use-before-define": [ + 2, + { + "functions": false, + "classes": false, + "variables": false, + "typedefs": false + } + ], "@typescript-eslint/no-explicit-any": 1, - "@typescript-eslint/ban-ts-ignore": 1 + "@typescript-eslint/ban-ts-ignore": 1, + + /** + * COMPLEXITY + * Ensure small functions and no nested/callback hell. + * If you need more, consider extracting some logic. + * Also you have cool destructuring feature, use it. + */ + "complexity": ["error", { "max": 11 }], + "max-params": ["error", 3], + "max-statements": ["error", 10], + "max-statements-per-line": ["error", { "max": 1 }], + "max-nested-callbacks": ["error", { "max": 2 }], + "max-depth": ["error", { "max": 3 }], + "max-lines": [ + "error", + { + "max": 150, + "skipBlankLines": true, + "skipComments": true + } + ] }, "env": { "jest": true @@ -133,21 +162,21 @@ "fetch": true }, - "overrides": [ - { - "files": ["*.example.jsx"], - "rules": { + "overrides": [ + { + "files": ["*.example.jsx"], + "rules": { "react/no-multi-comp": 0, "react/require-optimization": 0, "import/no-named-default": 0, "no-console": 0 - } - }, - { - "files": ["src/components/**/*.tsx"], - "rules": { + } + }, + { + "files": ["src/components/**/*.tsx"], + "rules": { "no-restricted-imports": [2, "styled-components"] - } + } } ] }