Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fat arrow + implicit return, no-return-assign bug #4743

Closed
Fenntasy opened this Issue Dec 18, 2015 · 9 comments

Comments

Projects
None yet
6 participants
@Fenntasy
Copy link

Fenntasy commented Dec 18, 2015

array.filter(a => a.test = value) does not trigger an error with no-return-assign activated.

eslint version : v1.10.3

.eslintrc.js

module.exports = {
    "ecmaFeatures": {
        "modules": true,
        "experimentalObjectRestSpread": true,
        "jsx": true
    },
    "env": {
        "browser": true,
        "es6": true,
        "node": true
    },
    "plugins": [
        "react"
    ],
    "rules": {
        "accessor-pairs": 2,
        "arrow-spacing": [2, { "before": true, "after": true }],
        "block-spacing": [2, "always"],
        "brace-style": [2, "1tbs", { "allowSingleLine": true }],
        "comma-dangle": [2, "never"],
        "comma-spacing": [2, { "before": false, "after": true }],
        "comma-style": [2, "last"],
        "constructor-super": 2,
        "curly": [2, "multi-line"],
        "dot-location": [2, "property"],
        "eol-last": 2,
        "eqeqeq": [1, "allow-null"],
        "generator-star-spacing": [2, { "before": true, "after": true }],
        "handle-callback-err": [2, "^(err|error)$" ],
        "indent": 2,
        "key-spacing": [2, { "beforeColon": false, "afterColon": true }],
        "new-cap": [2, { "newIsCap": true, "capIsNew": false }],
        "new-parens": 2,
        "no-array-constructor": 2,
        "no-caller": 2,
        "no-class-assign": 2,
        "no-cond-assign": 2,
        "no-const-assign": 2,
        "no-control-regex": 0,
        "no-debugger": 2,
        "no-delete-var": 2,
        "no-dupe-args": 2,
        "no-dupe-class-members": 2,
        "no-dupe-keys": 2,
        "no-duplicate-case": 2,
        "no-empty-character-class": 2,
        "no-empty-label": 2,
        "no-eval": 2,
        "no-ex-assign": 2,
        "no-extend-native": 2,
        "no-extra-bind": 2,
        "no-extra-boolean-cast": 2,
        "no-extra-parens": [2, "functions"],
        "no-fallthrough": 2,
        "no-floating-decimal": 2,
        "no-func-assign": 2,
        "no-implied-eval": 2,
        "no-inner-declarations": [2, "functions"],
        "no-invalid-regexp": 2,
        "no-irregular-whitespace": 2,
        "no-iterator": 2,
        "no-label-var": 2,
        "no-labels": 2,
        "no-lone-blocks": 2,
        "no-mixed-spaces-and-tabs": [2, "smart-tabs"],
        "no-multi-spaces": 2,
        "no-multi-str": 2,
        "no-multiple-empty-lines": [2, { "max": 1 }],
        "no-native-reassign": 2,
        "no-negated-in-lhs": 2,
        "no-new": 2,
        "no-new-func": 2,
        "no-new-object": 2,
        "no-new-require": 2,
        "no-new-wrappers": 2,
        "no-obj-calls": 2,
        "no-octal": 2,
        "no-octal-escape": 2,
        "no-proto": 2,
        "no-redeclare": 2,
        "no-regex-spaces": 2,
        "no-return-assign": 2,
        "no-self-compare": 2,
        "no-sequences": 2,
        "no-shadow-restricted-names": 2,
        "no-spaced-func": 2,
        "no-sparse-arrays": 2,
        "no-this-before-super": 2,
        "no-throw-literal": 2,
        "no-trailing-spaces": 2,
        "no-undef": 2,
        "no-undef-init": 2,
        "no-unexpected-multiline": 2,
        "no-unneeded-ternary": [2, { "defaultAssignment": false }],
        "no-unreachable": 2,
        "no-unused-vars": [2, { "vars": "all", "args": "none" }],
        "no-useless-call": 2,
        "no-with": 2,
        "one-var": [2, { "initialized": "never" }],
        "operator-linebreak": [2, "after", { "overrides": { "?": "before", ":": "before" } }],
        "padded-blocks": [2, "never"],
        "quotes": [2, "double", "avoid-escape"],
        "radix": 2,
        "semi": [2, "never"],
        "semi-spacing": [2, { "before": false, "after": true }],
        "space-after-keywords": [2, "always"],
        "space-before-blocks": [2, "always"],
        "space-before-function-paren": [2, "always"],
        "space-before-keywords": [2, "always"],
        "space-in-parens": 0,
        "space-infix-ops": 2,
        "space-return-throw-case": 2,
        "space-unary-ops": [2, { "words": true, "nonwords": false }],
        "spaced-comment": [2, "always", { "markers": ["global", "globals", "eslint", "eslint-disable", "*package", "!", ","] }],
        "use-isnan": 2,
        "valid-typeof": 2,
        "wrap-iife": [2, "any"],
        "yoda": [2, "never"],
        "react/display-name": 0,
        "react/forbid-prop-types": [1, {"forbid": ["any", "array"]}],
        "react/jsx-boolean-value": 0,
        "react/jsx-closing-bracket-location": 2,
        "react/jsx-curly-spacing": [2, "never"],
        "react/jsx-handler-names": 1,
        "react/jsx-indent-props": [2, 4],
        "react/jsx-key": 0,
        "react/jsx-max-props-per-line": 0,
        "react/jsx-no-bind": 1,
        "react/jsx-no-duplicate-props": 1,
        "react/jsx-no-literals": 0,
        "react/jsx-no-undef": 1,
        "react/jsx-pascal-case": 1,
        "react/jsx-quotes": 1,
        "react/jsx-sort-prop-types": 0,
        "react/jsx-sort-props": 0,
        "react/jsx-uses-react": 2,
        "react/jsx-uses-vars": 1,
        "react/no-danger": 0,
        "react/no-did-mount-set-state": 1,
        "react/no-did-update-set-state": 1,
        "react/no-direct-mutation-state": 1,
        "react/no-multi-comp": 0,
        "react/no-set-state": 0,
        "react/no-unknown-property": 1,
        "react/prefer-es6-class": 0,
        "react/prop-types": 1,
        "react/react-in-jsx-scope": 1,
        "react/require-extension": 1,
        "react/self-closing-comp": 1,
        "react/sort-comp": 1,
        "react/wrap-multilines": 1
    }
}
@eslintbot

This comment has been minimized.

Copy link

eslintbot commented Dec 18, 2015

@Fenntasy Thanks for the issue! If you're reporting a bug, please be sure to include:

  1. The version of ESLint you are using (run eslint -v)
  2. What you did (the source code and ESLint configuration)
  3. The actual ESLint output complete with numbers
  4. What you expected to happen instead

Requesting a new rule? Please see Proposing a New Rule for instructions.

@eslintbot eslintbot added the triage label Dec 18, 2015

@gyandeeps

This comment has been minimized.

Copy link
Member

gyandeeps commented Dec 18, 2015

Yeah, I dont think that rule currently checks for arrow-functions.

@alberto

This comment has been minimized.

Copy link
Member

alberto commented Dec 18, 2015

That is not a bug, you can't explicitly return when there is no block.

@nzakas

This comment has been minimized.

Copy link
Member

nzakas commented Dec 18, 2015

You can implicitly return, though, which is what that code is doing.

@Fenntasy

This comment has been minimized.

Copy link
Author

Fenntasy commented Dec 18, 2015

Just to be sure. It does not trigger anything either when I do these tests :
array.filter(a => { return a.test = value })
array.filter(a => ( a.test = value ))

@alberto

This comment has been minimized.

Copy link
Member

alberto commented Dec 18, 2015

Yeah, sorry, I misread what the rule was.

@alberto

This comment has been minimized.

Copy link
Member

alberto commented Dec 20, 2015

So, is this accepted?

@nzakas

This comment has been minimized.

Copy link
Member

nzakas commented Dec 21, 2015

Now it is

alberto added a commit that referenced this issue Dec 21, 2015

alberto added a commit that referenced this issue Dec 21, 2015

alberto added a commit that referenced this issue Dec 21, 2015

alberto added a commit that referenced this issue Dec 21, 2015

alberto added a commit that referenced this issue Dec 22, 2015

@alberto alberto closed this in edf89d3 Dec 22, 2015

nzakas added a commit that referenced this issue Dec 22, 2015

Merge pull request #4778 from eslint/issue4743
Fix: support arrow functions in no-return-assign (fixes #4743)
@pvdz

This comment has been minimized.

Copy link

pvdz commented Apr 7, 2016

Food for thought?

arr.forEach(obj => obj.foo = i);

now must be

arr.forEach(obj => (obj.foo = i));

to satisfy this rule with the paren exception, or

arr.forEach(obj => { obj.foo = i; });

with the strict rule in place. Unless you disable the rule altogether, of course.

The counter case is:

arr.filter(obj => obj.foo = i);

but the distinction between a forEach and filter (etc) is only checkable under certain assumptions, with hard edge cases.

Still, the initial case had me scratching my head and led me here.

@eslint eslint bot locked and limited conversation to collaborators Feb 6, 2018

@eslint eslint bot added the archived due to age label Feb 6, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.