Coder Social home page Coder Social logo

Using variable name _this. about tslint HOT 5 CLOSED

palantir avatar palantir commented on June 26, 2024
Using variable name _this.

from tslint.

Comments (5)

ashwinr avatar ashwinr commented on June 26, 2024

Sure, makes sense. I'll add an option.

On Aug 28, 2013, at 3:52 AM, osimicek [email protected]
wrote:

I´d like to use variable names that starts with underscore.

var _this;
But it causes "variable name must be in camelcase or uppercase" error.
I'm not sure if is it right or not.


Reply to this email directly or view it on GitHub.

from tslint.

ashwinr avatar ashwinr commented on June 26, 2024

Sorry, I don't see a convincing argument to be made for variables with leading underscores, especially since TypeScript has private modifiers. In the future, tslint will have the option to turn off rules for specific code-blocks, so you could do it then.

from tslint.

ashwinr avatar ashwinr commented on June 26, 2024

I can see an argument that getter methods are named with just the name and the underlying variable named as _name

from tslint.

osimicek avatar osimicek commented on June 26, 2024

Yes, getter and setter is one of the case.
I used it to instantiate object in static method.

class A {
...
    static create(param) {
        var _this = this;
        return new _this(param)
    }
}

from tslint.

ashwinr avatar ashwinr commented on June 26, 2024

leading underscores are now an option supplied to the varName rule

from tslint.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.