@putout/plugin-apply-starts-with

1.1.0 • Public • Published

@putout/plugin-apply-starts-with NPM version

The startsWith() method determines whether a string begins with the characters of a specified string, returning true or false as appropriate.

(c) MDN

🐊Putout plugin adds ability to apply .startsWith().

Install

npm i @putout/plugin-apply-starts-with

Rule

{
    "rules": {
        "apply-starts-with": "on"
    }
}

Example of incorrect code

function x(a = '') {
    if (!a.indexOf('1'))
        return false;
}

function x1({a = ''}) {
    return !a.indexOf('1');
}

function x2() {
    const {a = ''} = z;
    return !a.indexOf('1');
}

Example of correct code

function x(a = '') {
    return a.startsWith('1');
}

function x1({a = ''}) {
    return a.startsWith('1');
}

function x2() {
    const {a = ''} = z;
    return a.startsWith('1');
}

License

MIT

Package Sidebar

Install

npm i @putout/plugin-apply-starts-with

Weekly Downloads

3,271

Version

1.1.0

License

MIT

Unpacked Size

5.02 kB

Total Files

4

Last publish

Collaborators

  • coderaiser