From 32ef8ff301f03c1132fea38db23303aede7ef75d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Fri, 5 Jul 2019 04:14:15 +0200 Subject: [PATCH] Unify Ruby and ERB Rubocop rules So now we remove duplication between .rubocop.yml and the rubocop rules defined for erblint. Having the rules in two places led to some mistakes, like renaming Layout/Tab to Layout/IndentationStyle in `.rubocop.yml` but forgetting to do so in `.erb-lint.yml`. This also means we can use the EnforcedStyle options for Layout/SpaceInsideHashLiteralBraces in views as well. We couldn't implement this feature earlier because it required Ruby 2.4 and due to incompatibilities between versions of erb_lint and versions of rubocop. There are some rules which do not apply to ERB files and so we're disabling them. * Layout/LineLength, Layout/TrailingEmptyLines and Lint/UselssAssignment generate false positives * Rails/OutputSafety is redundant since its functionality is already covered by ERB Lint ErbSafety linter --- .erb-lint.yml | 37 +++++++++++-------------------------- 1 file changed, 11 insertions(+), 26 deletions(-) diff --git a/.erb-lint.yml b/.erb-lint.yml index 6f3ce44df..ec457aa0c 100644 --- a/.erb-lint.yml +++ b/.erb-lint.yml @@ -20,29 +20,14 @@ linters: enabled: true Rubocop: enabled: true - only: - - Layout/EndOfLine - - Layout/SpaceAfterColon - - Layout/SpaceAfterComma - - Layout/SpaceAfterMethodName - - Layout/SpaceAfterNot - - Layout/SpaceAfterSemicolon - - Layout/SpaceAroundBlockParameters - - Layout/SpaceAroundOperators - - Layout/SpaceBeforeBlockBraces - - Layout/SpaceBeforeComma - - Layout/SpaceBeforeComment - - Layout/SpaceBeforeFirstArg - - Layout/SpaceBeforeSemicolon - - Layout/SpaceInsideArrayLiteralBrackets - - Layout/SpaceInsideArrayPercentLiteral - - Layout/SpaceInsideBlockBraces - - Layout/SpaceInsideHashLiteralBraces - - Layout/SpaceInsideParens - - Layout/SpaceInsidePercentLiteralDelimiters - - Layout/SpaceInsideRangeLiteral - - Layout/SpaceInsideReferenceBrackets - - Layout/SpaceInsideStringInterpolation - - Layout/Tab - - Lint/LiteralAsCondition - - Style/PercentLiteralDelimiters + rubocop_config: + inherit_from: + - .rubocop.yml + Layout/LineLength: + Enabled: false + Layout/TrailingEmptyLines: + Enabled: false + Lint/UselessAssignment: + Enabled: false + Rails/OutputSafety: + Enabled: false