octoblu/zooid-toast

View on GitHub

Showing 7 of 7 total issues

'timeout' PropType is defined but prop is never used
Open

  timeout: PropTypes.number,
Severity: Minor
Found in src/Toast/index.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Expected 'this' to be used by class method 'willLeave'.
Open

  willLeave() {
Severity: Minor
Found in src/Toast/index.js by eslint

Enforce that class methods utilize this (class-methods-use-this)

If a class method does not use this, it can safely be made a static function.

It's possible to have a class method which doesn't use this, such as:

class A {
    constructor() {
        this.a = "hi";
    }

    print() {
        console.log(this.a);
    }

    sayHi() {
        console.log("hi");
    }
}

let a = new A();
a.sayHi(); // => "hi"

In the example above, the sayHi method doesn't use this, so we can make it a static method:

class A {
    constructor() {
        this.a = "hi";
    }

    print() {
        console.log(this.a);
    }

    static sayHi() {
        console.log("hi");
    }
}

A.sayHi(); // => "hi"

Also note in the above examples that the code calling the function on an instance of the class (let a = new A(); a.sayHi();) changes to calling it on the class itself (A.sayHi();).

Rule Details

This rule is aimed to flag class methods that do not use this.

Examples of incorrect code for this rule:

/*eslint class-methods-use-this: "error"*/
/*eslint-env es6*/

class A {
    foo() {
        console.log("Hello World");     /*error Expected 'this' to be used by class method 'foo'.*/
    }
}

Examples of correct code for this rule:

/*eslint class-methods-use-this: "error"*/
/*eslint-env es6*/
class A {
    foo() {
        this.bar = "Hello World"; // OK, this is used
    }
}

class A {
    constructor() {
        // OK. constructor is exempt
    }
}

class A {
    static foo() {
        // OK. static methods aren't expected to use this.
    }
}

Options

Exceptions

"class-methods-use-this": [<enabled>, { "exceptMethods": [&lt;...exceptions&gt;] }]</enabled>

The exceptMethods option allows you to pass an array of method names for which you would like to ignore warnings.

Examples of incorrect code for this rule when used without exceptMethods:

/*eslint class-methods-use-this: "error"*/

class A {
    foo() {
    }
}

Examples of correct code for this rule when used with exceptMethods:

/*eslint class-methods-use-this: ["error", { "exceptMethods": ["foo"] }] */

class A {
    foo() {
    }
}

Source: http://eslint.org/docs/rules/

propType "message" is not required, but has no corresponding defaultProp declaration.
Open

  message: PropTypes.string,
Severity: Minor
Found in src/Toast/index.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

JSX not allowed in files with extension '.js'
Open

      <Transition component={false} enter={this.willEnter()} leave={this.willLeave()}>
Severity: Minor
Found in src/Toast/index.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

propType "className" is not required, but has no corresponding defaultProp declaration.
Open

  className: PropTypes.string,
Severity: Minor
Found in src/Toast/index.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Expected empty line after import statement not followed by another import.
Open

import Toast from './Toast'
Severity: Minor
Found in src/index.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Expected 'this' to be used by class method 'willEnter'.
Open

  willEnter() {
Severity: Minor
Found in src/Toast/index.js by eslint

Enforce that class methods utilize this (class-methods-use-this)

If a class method does not use this, it can safely be made a static function.

It's possible to have a class method which doesn't use this, such as:

class A {
    constructor() {
        this.a = "hi";
    }

    print() {
        console.log(this.a);
    }

    sayHi() {
        console.log("hi");
    }
}

let a = new A();
a.sayHi(); // => "hi"

In the example above, the sayHi method doesn't use this, so we can make it a static method:

class A {
    constructor() {
        this.a = "hi";
    }

    print() {
        console.log(this.a);
    }

    static sayHi() {
        console.log("hi");
    }
}

A.sayHi(); // => "hi"

Also note in the above examples that the code calling the function on an instance of the class (let a = new A(); a.sayHi();) changes to calling it on the class itself (A.sayHi();).

Rule Details

This rule is aimed to flag class methods that do not use this.

Examples of incorrect code for this rule:

/*eslint class-methods-use-this: "error"*/
/*eslint-env es6*/

class A {
    foo() {
        console.log("Hello World");     /*error Expected 'this' to be used by class method 'foo'.*/
    }
}

Examples of correct code for this rule:

/*eslint class-methods-use-this: "error"*/
/*eslint-env es6*/
class A {
    foo() {
        this.bar = "Hello World"; // OK, this is used
    }
}

class A {
    constructor() {
        // OK. constructor is exempt
    }
}

class A {
    static foo() {
        // OK. static methods aren't expected to use this.
    }
}

Options

Exceptions

"class-methods-use-this": [<enabled>, { "exceptMethods": [&lt;...exceptions&gt;] }]</enabled>

The exceptMethods option allows you to pass an array of method names for which you would like to ignore warnings.

Examples of incorrect code for this rule when used without exceptMethods:

/*eslint class-methods-use-this: "error"*/

class A {
    foo() {
    }
}

Examples of correct code for this rule when used with exceptMethods:

/*eslint class-methods-use-this: ["error", { "exceptMethods": ["foo"] }] */

class A {
    foo() {
    }
}

Source: http://eslint.org/docs/rules/

Severity
Category
Status
Source
Language