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

constructor-super issue with constructors that use return and finally #11092

Closed
Neuroboy23 opened this issue Nov 16, 2018 · 4 comments
Closed
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion auto closed The bot closed this issue bug ESLint is working incorrectly evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion rule Relates to ESLint's core rules

Comments

@Neuroboy23
Copy link

The code below triggers the constructor-super rule, but I believe it should not. The only paths through this code either always call super and/or always exception out.

class A {}

class B extends A {
    constructor() {
        try {
            const result = super();
            return result;
        }
        finally {
        }
    }
}
// error  Lacked a call of 'super()' in some code paths  constructor-super

It also happens if there is a re-throwing catch clause and a finally.

class A {}

class B extends A {
    constructor() {
        try {
            const result = super();
            return result;
        }
        catch (e) {
            throw e;
        }
        finally {
        }
    }
}
// error  Lacked a call of 'super()' in some code paths  constructor-super

It does NOT happen if the finally clause isn't present.

class A {}

class B extends A {
    constructor() {
        try {
            const result = super();
            return result;
        }
        catch (e) {
            throw e;
        }
    }
}
// OK

It also does NOT happen if there's no return statement.

class A {}

class B extends A {
    constructor() {
        try {
            super();
        }
        finally {
        }
    }
}
// OK

Environment:

  • OS: Windows 10
  • Node: v10.11.0
  • ESLint: v5.9.0
  • NPM: v6.4.1
  • Parser: eslint
  • Configuration:
module.exports = {
    "root": true,
    "env": {
        "amd": true,
        "es6": true
    },
    "globals": {
        "define": true,
        "asyncDefine": true
    },
    "parserOptions": {
        "ecmaVersion": 2015,
        "ecmaFeatures": {
            "impliedStrict": true
        }
    },
    "extends": "eslint:recommended",
    "rules": {

        "for-direction": "error",
        "getter-return": "error",
        "no-constant-condition": ["error", { "checkLoops": false }],
        "no-extra-parens": "off",

        "accessor-pairs": "error",
        "array-callback-return": "error",
        "class-methods-use-this": "error",
        "complexity": ["error", 20],
        "consistent-return": "error",
        "curly": "error",
        "default-case": "error",
        "dot-location": ["error", "property"],
        "eqeqeq": "error",
        "no-alert": "error",
        "no-caller": "error",
        "no-div-regex": "error",
        "no-else-return": "error",
        "no-eq-null": "error",
        "no-eval": "error",
        "no-extend-native": "error",
        "no-extra-label": "error",
        "no-floating-decimal": "error",
        "no-implicit-globals": "error",
        "no-implied-eval": "error",
        "no-iterator": "error",
        "no-labels": "error",
        "no-loop-func": "error",
        "no-new": "error",
        "no-new-wrappers": "error",
        "no-octal-escape": "error",
        "no-redeclare": "off",
        "no-return-assign": ["error", "always"],
        "no-return-await": "error",
        "no-script-url": "error",
        "no-self-assign": "error",
        "no-self-compare": "error",
        "no-sequences": "error",
        "no-throw-literal": "error",
        "no-unmodified-loop-condition": "error",
        "no-unused-expressions": "error",
        "no-useless-call": "error",
        "no-useless-concat": "error",
        "no-useless-return": "error",
        "no-void": "error",
        "no-with": "error",
        "prefer-promise-reject-errors": "error",
        "require-await": "error",
        "wrap-iife": ["error", "any"],
        "yoda": "error",
        "strict": ["error", "never"],

        "no-shadow-restricted-names": "error",
        "no-undef-init": "error",
        "no-unused-vars": ["error", { "args": "none", "varsIgnorePattern": "^logger$" }],

        "brace-style": ["error", "stroustrup", { "allowSingleLine": true }],
        "comma-dangle": ["error", "only-multiline"],
        "comma-spacing": "error",
        "comma-style": "error",
        "computed-property-spacing": "error",
        "func-call-spacing": "error",
        "keyword-spacing": "error",
        "max-depth": ["error", 5],
        "max-len": ["error", 100 , { "ignoreComments": true, "ignoreUrls": true, "ignoreStrings": true }],
        "max-statements": "off",
        "max-statements-per-line": "error",
        "new-cap": ["error", { "capIsNewExceptionPattern": "^[A-Z0-9_]+$", "properties": false }],
        "new-parens": "error",
        "no-array-constructor": "error",

        "no-multiple-empty-lines": "error",
        "no-nested-ternary": "error",
        "no-new-object": "error",
        "no-tabs": "error",
        "no-trailing-spaces": "warn",
        "no-whitespace-before-property": "error",
        "object-curly-newline": ["error", { "consistent": true }],
        "operator-linebreak": ["error", "after", { "overrides": { "?": "after", ":": "after" } }],

        "quotes": ["error", "double"],
        "no-extra-semi": ["warn"],
        "semi": ["error", "always"],
        "semi-spacing": "error",
        "semi-style": "error",
        "space-before-blocks": "error",
        "space-in-parens": ["error", "never"],
        "space-infix-ops": ["error", { "int32Hint": true }],
        "space-unary-ops": "error",
        "switch-colon-spacing": "error",
        "template-tag-spacing": "error",

        "space-before-function-paren": ["error", {
            "anonymous": "ignore",
            "asyncArrow": "ignore",
            "named": "never",
        }],

        "spaced-comment": ["error", "always", {
            "markers": ["/"],
            "exceptions": ["/", "-", "=", "#"]
        }],
    }
};
@eslint-deprecated eslint-deprecated bot added the triage An ESLint team member will look at this issue soon label Nov 16, 2018
@aladdin-add aladdin-add added bug ESLint is working incorrectly rule Relates to ESLint's core rules evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Nov 19, 2018
@aladdin-add
Copy link
Member

Thanks for the report!
seems a bug to me. Are you willing to submit a pull request to fix it? 😄

@Neuroboy23
Copy link
Author

@aladdin-add I am willing to work on this, but I'm awaiting approval from my company. I will claim this issue when that approval happens, unless someone claims in first.

@not-an-aardvark
Copy link
Member

This seems related to #7481.

@eslint-deprecated eslint-deprecated bot added the auto closed The bot closed this issue label Jan 19, 2019
@eslint-deprecated
Copy link

Unfortunately, it looks like there wasn't enough interest from the team
or community to implement this change. While we wish we'd be able to
accommodate everyone's requests, we do need to prioritize. We've found
that issues failing to reach accepted status after 21 days tend to
never be accepted, and as such, we close those issues.
This doesn't mean the idea isn't interesting or useful, just that it's
not something the team can commit to.

Thanks for contributing to ESLint and we appreciate your understanding.

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Jul 19, 2019
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Jul 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion auto closed The bot closed this issue bug ESLint is working incorrectly evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion rule Relates to ESLint's core rules
Projects
None yet
Development

No branches or pull requests

3 participants