Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

Incorrectly flags sticking of operator #373

Closed
rubenv opened this issue May 13, 2014 · 4 comments
Closed

Incorrectly flags sticking of operator #373

rubenv opened this issue May 13, 2014 · 4 comments

Comments

@rubenv
Copy link

rubenv commented May 13, 2014

I get the following:

Operator - should not stick to preceding expression at src/controllers/wizard.js :
    10 |
    11 |    // Convenience methods
    12 |    $scope.goBack = function () { Wizard.move(-1, 'goBack'); };
------------------------------------------------------^

Which I have to correct to Wizard.move( -1, 'goBack'); (note the space) before it validates.

This causes the following code to be "valid":

    $scope.goBack = function () { Wizard.move( -1, 'goBack'); };
    $scope.goNext = function () { Wizard.move(1, 'goNext'); };

I'd like it to enforce this:

    $scope.goBack = function () { Wizard.move(-1, 'goBack'); };
    $scope.goNext = function () { Wizard.move(1, 'goNext'); };

This feels like a bug to me, but it might just be a misconfiguration. Here's my config:

{
    "requireCurlyBraces": ["if", "else", "for", "while", "do", "try", "catch"],
    "requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch"],
    "requireParenthesesAroundIIFE": true,
    "requireSpacesInFunctionExpression": {
        "beforeOpeningCurlyBrace": true
    },
    "requireSpacesInAnonymousFunctionExpression": {
        "beforeOpeningRoundBrace": true
    },
    "disallowSpacesInNamedFunctionExpression": {
        "beforeOpeningRoundBrace": true
    },
    "disallowSpacesInFunctionDeclaration": {
        "beforeOpeningRoundBrace": true
    },
    "disallowMultipleVarDecl": true,
    "requireSpacesInsideObjectBrackets": "all",
    "disallowQuotedKeysInObjects": "allButReserved",
    "disallowSpaceAfterObjectKeys": true,
    "requireCommaBeforeLineBreak": true,
    "disallowLeftStickedOperators": ["?", "+", "-", "/", "*", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="],
    "requireRightStickedOperators": ["!"],
    "requireLeftStickedOperators": [","],
    "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"],
    "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"],
    "requireSpaceBeforeBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="],
    "requireSpaceAfterBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="],
    "validateQuoteMarks": true,
    "validateIndentation": 4,
    "disallowTrailingWhitespace": true,
    "disallowKeywordsOnNewLine": ["else"],
    "requireCapitalizedConstructors": true,
    "safeContextKeyword": "self",
    "requireDotNotation": true,
    "disallowYodaConditions": true
}
@markelog
Copy link
Member

*StickedOperators rules are deprecated now, use other rules for that

@rubenv
Copy link
Author

rubenv commented May 13, 2014

Is this documented somewhere? I built this config recently based on the README file in the master branch (which still lists them).

Which rules are meant to replace these?

@markelog
Copy link
Member

Not just yet sorry, but it will be, use *spaceBeforeBinaryOperators, *spacesInConditionalExpression and *unaryOperators, some of them not released yet, but we planning to do a new version of jscs today.

@rubenv
Copy link
Author

rubenv commented May 13, 2014

Cool, thanks a lot!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants