Skip to content
This repository has been archived by the owner on Aug 4, 2020. It is now read-only.

eslint prefer static class properties #128

Closed
graingert opened this issue Jul 31, 2017 · 2 comments
Closed

eslint prefer static class properties #128

graingert opened this issue Jul 31, 2017 · 2 comments

Comments

@graingert
Copy link

graingert commented Jul 31, 2017

Please describe what the rule should do:
Move static class properties into the class body.

What category of rule is this? (place an "X" next to just one item)

[x] Enforces code style
[ ] Warns about a potential error
[x] Suggests an alternate way of doing something
[ ] Other (please specify:)

Provide 2-3 code examples that this rule will warn about:

// bad
class Foo {}
Foo.bar = 3;

// good

class Foo {
  static bar = 3;
}
@graingert
Copy link
Author

would also be good to disallow this. assignments that are not dependent on constructor arguments.

//bad

class Foo {
    constructor(ham) {
        this.foo = 4;
    }
}

// good

class Foo {
    constructor(ham) {
        this.foo = ham;
    }
}

disallow class assignments.

//bad

class Foo {
}

Foo.bar = 3;

// good

class Foo {
    static bar = 3;
}

@kaicataldo
Copy link
Member

Thank you for the issue. Now that @babel/eslint-plugin has been released, we are making this repository read-only. If this is a change you would still like to advocate for, please reopen this in the babel/babel monorepo.

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