@putout/plugin-parens
🐊Putout plugin adds missing and remove useless parens
Last updated a year ago by coderaiser .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @putout/plugin-parens 
SYNC missed versions from official npm registry.

@putout/plugin-parens NPM version

????Putout plugin adds ability to add missing parens. Check out in ????Putout Editor.

Install

npm i @putout/plugin-parens

Rules

Config

Short:

{
    "rules": {
        "parens/add-missing": "on",
        "parens/remove-useless": "on"
    }
}

Full:

{
    "rules": {
        "parens/add-missing-for-await": "on",
        "parens/add-missing-for-template": "on",
        "parens/add-missing-for-assign": "on",
        "parens/remove-useless-for-await": "on",
        "parens/remove-useless-for-params": "on"
    }
}

add-missing-for-assign

The JavaScript exception "invalid assignment left-hand side" occurs when there was an unexpected assignment somewhere. It may be triggered when a single = sign was used instead of == or ===.

(c) MDN

To disable use:

{
    "rules": {
        "parens/add-missing-for-assign": "off"
    }
}
-a && b = a;
+a && (b = a);

add-missing-for-await

❌ Example of incorrect code

await asyncFn().filter(Boolean);

βœ… Example of correct code

(await asyncFn()).filter(Boolean);

add-missing-for-template

The JavaScript exception "tagged template cannot be used with optional chain" occurs when the tag expression of a tagged template literal is an optional chain, or if there's an optional chain between the tag and the template.

(c) MDN

Checkout in ????Putout Editor.

{
    "rules": {
        "parens/add-missing-for-template": "off"
    }
}

❌ Example of incorrect code

getConsoleLog?.()``;
String?.raw``;
String?.raw!``;

βœ… Example of correct code

(getConsoleLog?.())``;
(String?.raw)``;
(String?.raw)!``;

remove-useless-for-await

Checkout in ????Putout Editor.

❌ Example of incorrect code

const s = (await m());

βœ… Example of correct code

const s = await m();

remove-useless-for-params

Uncaught SyntaxError: Invalid destructuring assignment target

(c) Chrome

Checkout in ????Putout Editor.

❌ Example of incorrect code

const a = ((b)) => c;

βœ… Example of correct code

const a = (b) => c;

License

MIT

Current Tags

  • 5.1.0                                ...           latest (2 months ago)

11 Versions

  • 5.1.0                                ...           2 months ago
  • 5.0.0                                ...           2 months ago
  • 4.0.0                                ...           9 months ago
  • 3.0.0                                ...           a year ago
  • 2.1.0                                ...           a year ago
  • 2.0.0                                ...           a year ago
  • 1.1.3                                ...           a year ago
  • 1.1.2                                ...           a year ago
  • 1.1.1                                ...           a year ago
  • 1.1.0                                ...           a year ago
  • 1.0.0                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 0
Dependencies (0)
None
Dev Dependencies (8)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |