Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eslint-plugin-classes

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-classes

custom ESLint rule, ckecks class style.

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6.1K
increased by362.47%
Maintainers
1
Weekly downloads
 
Created
Source

eslint-plugin-classes

custom ESLint rule, checks class style. (will adding more rules for class)

Rule Details

space

should no space between method name and parens.

The following patterns are considered warnings:

class Foo {
  bar () {
  }
}

class Foo {
  static bar () {
  }
}

class Foo {
  bar () {
  }

  buz() {
  }
}

The following patterns are not warnings:

class Foo {
  bar() {
  }
}

class Foo {
  static bar() {
  }
}

class Foo {
  bar() {
  }

  buz() {
  }
}

name

  • class name should start with upper case.
  • method name should start with lower case.

The following patterns are considered warnings:

class foo {
}

class Foo {
  Bar () {
  }
}

The following patterns are not warnings:

class Foo {
}

class Foo {
  bar () {
  }
}

constructor

class should have constructor always even if empty body.

The following patterns are considered warnings:

class Foo {
}

class Foo {
  bar() {
  }
}

The following patterns are not warnings:

class Foo {
  constructor() {
    console.log('test');
  }
}

class Foo {
  constructor() {
  }

  bar() {
  }
}

super

extended class should call super() at the top of constructor.

The following patterns are considered warnings:

class Foo extends A {
  bar() {
  }
}

class Foo extends A {
  constructor() {
    this.bar();
  }
  bar() {
  }
}

The following patterns are not warnings:

class Foo extends A {
  constructor() {
    super();
    this.a = 10;
  }
  bar() {
  }
}

class Foo extends A {
  bar() {
  }
  constructor() {
    super();
    this.a = 10;
  }
}

class Foo extends A {
  constructor() {
    // comments
    super();
    this.a = 10;
  }
}

Style

enforce order of definition of method in order of static method => constructor => instance methods.

The following patterns are considered warnings:

class Foo {
    constructor() {}
    static bar() {}
}


class Foo {
    baz() {}
    static bar() {}
    constructor() {}
    baz() {}
}

The following patterns are not warnings:

class Foo {
    static bar() {}
    static bal() {}
    constructor() {}
    baz() {}
    biz() {}
    bez() {}
}

Usage

plugins:
  - classes

rules:
  # Plugins
  classes/space  : 2
  classes/name   : [2, "class", "method"]
  classes/constructor : 2
  classes/super  : 2
  classes/style  : 2

License

MIT

Keywords

FAQs

Package last updated on 16 Nov 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc