putout

🐊 Pluggable and configurable JavaScript Linter, code transformer and formatter with built-in ESLint and Babel support for js, jsx typescript, flow, markdown, yaml and json. Write declarative codemods in a simplest possible way 😏

MIT License

Downloads
3.6M
Stars
646
Committers
23

Bot releases are hidden (Show)

putout - putout v29.0.8

Published by coderaiser over 1 year ago

🐞 fix

  • 919290247 @putout/operator-declare: report

πŸ”₯ feature

  • 16db04f0b package: @putout/plugin-remove-iife v4.0.0
  • e0b3f0e61 @putout/plugin-remove-iife: exclude VariableDeclarator (#133)
putout - putout v29.0.7

Published by coderaiser over 1 year ago

🐞 fix

  • 39a973e5c @putout/plugin-declare-before-reference: exclude ExportNamedDeclaration (#134)

πŸ”₯ feature

  • 9eca8816c package: @putout/plugin-declare-before-reference v2.0.0
  • aff993608 @putout/plugin-declare-before-reference: drop support of 🐊 < 29
  • d1743b555 @putout/plugin-declare-before-reference: drop support of node < 16
putout - putout v29.0.6

Published by coderaiser over 1 year ago

πŸ”₯ feature

  • 0af80e51a package: @putout/operator-declare v5.0.0
  • b306cf6fe package: @putout/operator-declare v5.0.0
  • 62f3355ae package: @putout/engine-loader v8.0.0
  • 3a4a99b07 package: @putout/engine-runner v15.0.0
  • 017bb3ba0 package: @putout/test v6.0.0
  • f89823aab @putout/plugin-declare: convert to Declarator
  • a0c7d1682 @putout/types: add
  • 39901c763 @putout/test: add support of Declarator
  • b5b4d0001 @putout/plugin-declare: move out is-type to types/declare
  • 9fb14536d @putout/operator-declare: require: putout -> @putout/engine-parser, @babel/types
  • d15347e94 @putout/engine-loader: add support of Declarator
  • 3ded80721 @putout/engine-runner: add support of Declarator
putout - putout v29.0.5

Published by coderaiser over 1 year ago

πŸ”₯ feature

  • f8d2d4a61 @putout/plugin-apply-at: renamed from @putout/plugin-apply-array-at
  • f1e893dd5 @putout/plugin-declare: move maybe to @putout/plugin-maybe
  • 5a9d4720d @putout/plugin-maybe: add declare
  • f06ae34bc (package) @putout/plugin-math v2.0.0
  • f4f5b8850 @putout/plugin-math: drop support of 🐊 < 29
  • f75bf9d5e @putout/plugin-math: apply-numeric-separators: exclude octal
  • 627f861f6 (package) @putout/plugin-package-json v5.0.0
  • 917b39038 @putout/plugin-package-json: drop support of 🐊 < 29
  • 05b0fd7a8 @putout/plugin-package-json: remove-commit-type: add
putout - putout v29.0.4

Published by coderaiser over 1 year ago

πŸ”₯ feature

  • 5492a6459 (package) @putout/plugin-math v2.0.0
  • d46d5778a @putout/plugin-math: drop support of 🐊 < 29
  • 0e789e6d9 @putout/plugin-math: apply-numeric-separators: exclude octal
putout - putout v29.0.3

Published by coderaiser over 1 year ago

πŸ”₯ feature

  • 61ffcfb57 (package) @putout/plugin-package-json v5.0.0
  • 54f52f4cf @putout/plugin-package-json: drop support of 🐊 < 29
  • f6dbfeac3 @putout/plugin-package-json: remove-commit-type: add
putout - putout v29.0.2

Published by coderaiser over 1 year ago

πŸ”₯ feature

  • e4e4435b3 @putout/plugin-maybe: renamed from @putout/plugin-apply-maybe
  • be39dd68a eslint-plugin-putout: array-element-newline: exclude arrays with string and number
putout - putout v29.0.1

Published by coderaiser over 1 year ago

πŸ”₯ feature

  • eslint-plugin-putout: single-property-destructuring: exclude AssignmentPattern used as value of ObjectPatterns Property
  • package: @putout/plugin-putout v12.0.0
  • @putout/plugin-putout: drop support of 🐊 < 29
  • @putout/plugin-declare: renamed from @putout/plugin-declare-undefined-variables
putout - 🐊 Putout v29

Published by coderaiser over 1 year ago

image

β€œIf a warrior is not unattached to life and death, he will be of no use whatsoever. The saying that β€œAll abilities come from one mind” sounds as though it has to do with sentient matters, but it is in fact a matter of being unattached to life and death. With such non-attachment one can accomplish any feat.”

― Yamamoto Tsunetomo, Hagakure: The Book of the Samurai

Hi folks, the time is come for next major release of 🐊Putout.
The changes are small, but important:

πŸ“›@putout/plugin-declare

The name of declare-undefined-variables was to long and not informative:

  • it declares constants and imports;
  • with defined values;

So it was shorten, please change your .putout.json, if you disabled or used in any way:

{
    "rules": {
-       "declare-undefined-variables": "off" ,
+       "declare": "off",
  }
}

Such useful plugin can declare variables for you on top of a file when you use it,
so you better keep it on ;).

For example if you use:

assign(obj, {
    hello: 'world',
});

@putout/plugin-declare will transform it to:

const {assign} = Object;
assign(obj, {
    hello: 'world',
});

Ability to declare variable becomes so simple because of @putout/operator-declare:

const {operator} = require('putout');
const {declare} = operator;

module.exports = declare({
    readFile: `import {readFile} from 'fs/promises'`,
});

You can even declare any variable you need in your project adding couple lines to .putout.json:

{
    "rules": {
        "putout/declare": ["on", {
            "declarations": {
                "fs": "import fs from 'fs/promises'"
            }
        }]
    }
}

Declarator

image

You can also use a new type of plugin Declarator, in this case code will be even simpler (checkout in 🐊Putout Editor):

module.exports.declare = () => ({
    readFile: `import {readFile} from 'fs/promises'`,
});

putout/apply-declare from @putout/plugin-putout will help you migrate to a new plugin type.

There is also rules that benefits from this feature in a couple other plugins:

You can do even more with putout/evaluate ESLint rule:

-import {readFile} from '__putout_evaluate: `./` + basename(__filename).replace(`.spec.js`, `.js`)';
+import {readFile} from './hello.js';

πŸ“›@putout/plugin-maybe

Renamed from @putout/plugin-apply-maybe.
Please change your .putout.json, if you disabled or used in any way:

{
    "rules": {
-       "apply-maybe": "off" ,
+       "maybe": "off",
  }
}

πŸ“›@putout/plugin-apply-at

Renamed from @putout/plugin-apply-array-at, since same method exists not only in prototype of Array

The at() method takes an integer value and returns the item at that index, allowing for positive and negative integers. Negative integers count back from the last item in the array.

(c) MDN: Array.prototype.at()

But also in String.prototype:

The at() method takes an integer value and returns a new String consisting of the single UTF-16 code unit located at the specified offset. This method allows for positive and negative integers. Negative integers count back from the last string character.

(c) MDN: String.prototype.at()

Please change your .putout.json, if you disabled or used in any way:

{
    "rules": {
-       "apply-array-at": "off" ,
+       "apply-at": "off",
  }
}

πŸ“›@putout/plugin-types

A brand new plugin types merged to itself part of declare, and a couple other plugins, so update .putout.json:

{
    "rules": {
-       "convert-typeof-to-is-type": "off" ,
-       "remove-useless-type-conversions": "off",
-       "remove-useless-typeof": "off",
-       "apply-is-array": "off",
-       "remove-useless-type-conversion/with-double-negations": "off",
+       "types/convert-typeof-to-is-type": "off",
+       "types/remove-useless-conversion": "off",
+       "types/remove-double-negations": "off",
+       "types/remove-useless-typeof": "off",
+       "types/apply-is-array": "off",
+       "types/remove-double-negations": "off"
  }
}

πŸ“›@putout/plugin-conditions

A brand new plugin conditions merged couple other plugins to speed up install, so update .putout.json:

{
    "rules": {
-       "apply-comparison-order": "off" ,
-       "apply-if-condition": "off",
-       "convert-comparison-to-boolean": "off",
-       "convert-equal-to-strict-equal": "off",
-       "remove-useless-conditions/evaluate": "off",
-       "remove-useless-conditions/simplify": "off",
-       "convert-comparison-to-boolean": "off",
-       "remove-constant-conditions": "off",
-       "remove-boolean-from-assertions": "off",
+       "conditions/apply-comparison-order": "off",
+       "conditions/apply-if": "off",
+       "conditions/convert-comparison-to-boolean": "off",
+       "conditions/convert-equal-to-strict-equal": "off",
+       "conditions/evaluate": "off"
+       "conditions/simplify": "off",
+       "conditions/convert-comparison-to-boolean": "off",
+       "conditions/remove-constant": "off",
+       "conditions/remove-boolean": "off"
  }
}

πŸ“›@putout/plugin-for-of

A brand new plugin for-of merged couple other plugins to speed up install, so update .putout.json:

{
    "rules": {
-       "convert-for-for-of": "off" ,
-       "convert-for-each-for-of": "off",
-       "convert-for-in-to-for-of": "off",
-       "convert-map-to-for-of": "off",
-       "remove-useless-for-of": "off",
-       "remove-unused-for-of-variables": "off",
-       "remove-useless-array-from": "off",
-       "remove-useless-variables/for-of": "off"
-       "convert-reduce-to-for-of": "off",
+       "for-of/for": "off",
+       "for-of/for-each": "off",
+       "for-of/for-in": "off",
+       "for-of/map": "off",
+       "for-of/remove-useless": "off"
+       "for-of/remove-unused-variables": "off",
+       "for-of/remove-useless-array-from": "off",
+       "for-of/remove-useless-variables": "off",
+       "for-of/reduce": "off"
    }
}

eslint-plugin-putout v17

Update ESLint plugin, to have support of for-of rules 😏.

πŸŽ‰ @putout/plugin-package-json

With release of 🎁Wisdom v14 commitType defaults to colon so there is no need to set it if it OK for you it was colon rule package-json/remove-commit-type handles such cases 😏. So we have less bytes to download while install 🎈.

Here is package.json:

{
    "name: "putout",
    "version": "29.0.0",
-   "commitType": "colon"
}

Same with nupdate v11 it uses colon by default.

Printer

Now you have ability to define printer you want, it can be:

If you want to try brand new @putout/printer update .putout.json with:

{
    "printer": "putout"
}

When you need to customize options, use:

{
    "printer": ["putout", {
        "format": {
            "indent": "    "
        }
    }]
}

Same with tests:

const test = require('@putout/test');
const rm = require('..');

const test = createTest({
    printer: "putout",
    plugins: [
        ['remove-unused-variables', rm],
   ]
});

New printer is:

  • βœ… much simpler in support then recast;
  • βœ… opinionated and has good defaults;
  • βœ… produces code like it was processed by ESLint without involving ESLint at all;
  • πŸŽ‰ Twice faster then Recast;

About speed, for file speed.js:

const putout = require('putout');
const {readFileSync} = require('fs');
const parser = require('@babel/parser');

const code = readFileSync('./lib/tokenize/tokenize.js', 'utf8');
const ast = parser.parse(code);

speed('recast');
speed('putout');

function speed(printer) {
    console.time(printer);

    for (let i = 0; i < 1000; i++) {
        putout(code, {
            printer,
            plugins: [
                'remove-unused-variables',
            ],
        });
    }

    console.timeEnd(printer);
}

With contents of tokenize.js from @putout/printer, we have:

image

That's all for for now, have a good day 🦏!

πŸ”₯ feature

  • f8d2d4a @putout/plugin-apply-at: renamed from @putout/plugin-apply-array-at
  • f1e893d @putout/plugin-declare: move maybe to @putout/plugin-maybe
  • a1d0d14 @putout/plugin-declare: renamed from @putout/plugin-declare-undefined-variables
  • d15347e @putout/engine-loader: add support of Declarator
  • 3ded807 @putout/engine-runner: add support of Declarator
  • 39901c7 @putout/test: add support of Declarator
  • e4e4435 @putout/plugin-maybe: renamed from @putout/plugin-apply-maybe
  • f8d2d4a feature: @putout/plugin-apply-at: renamed from @putout/plugin-apply-array-at
  • b5b4d00 @putout/plugin-declare: move out is-type to types/declare
  • 447110c @putout/plugin-types: merge apply-is-array
  • 091532b @putout/plugin-types: merge remove-useless-typeof
  • 33d82db @putout/plugin-types: merge remove-useless-type-conversion
  • 98a95d1 @putout/plugin-types: merge convert-typeof-to-is-type
  • 94706ee @putout/plugin-conditions: add
  • a660083 @putout/plugin-for-of: add
  • 9f0b4d2 @putout/for-of: add for-of from remove-useless-variables
  • 2590ee0 @putout/plugin-for-of: merge remove-useless-array-from
  • 05b0fd7 @putout/plugin-package-json: remove-commit-type: add
putout - putout v28.19.2

Published by coderaiser over 1 year ago

πŸ”₯ feature

  • package: @putout/plugin-remove-useless-type-conversion v3.0.0
  • @putout/plugin-remove-useless-type-conversion: drop support of 🐊 < 28
  • @putout/plugin-remove-useless-type-conversion: with-double-negations: exclude jsx expressions
  • eslint-plugin-putout: array-element-newline: 30 characters -> includes ","
  • eslint-plugin-putout: array-element-newline: exclude to long lines with lots of spaces
  • @putout/plugin-apply-maybe: avoid transforming declarations
putout - putout v28.19.1

Published by coderaiser over 1 year ago

🐞 fix

  • RECAST instead of --recast
putout - putout v28.19.0

Published by coderaiser over 1 year ago

🐞 fix

  • @putout/formatter-memory: add one more \n to output
  • @putout/formatter-memory: add \n in output
  • @putout/formatter-memory: drop comma
  • @putout/plugin-math: apply-numeric-separators: get back 5 digits min
  • @putout/engine-parser: print: switch to babel/generate only when recast break code
  • @putout/plugin-split-nested-destructuring: property instead of source

πŸ”₯ feature

  • putout: add --recast option
  • putout: add ability to avoid using recast when fix false
  • @putout/engine-parser: add ability to disable recast
  • eslint-plugin-putout: add-newline-before-function-call: add support of Program body
  • @putout/eslint: createPlugin: improve getSpacesBeforeNode: first node in Program body
  • @putout/test: processor: improve support of UPDATE
  • eslint-plugin-putout: add support of jsx
  • eslint-plugin-putout: array-element-newline: improve support of ArrayExpressions full of Literals with length < 5
  • @putout/test: formatMany: when UPDATE used pass
  • @putout/operate: replaceWith, replaceWithMultiple: improve handling of BlockStatement
  • @putout/formatter-memory: move out maybeZero
  • @putout/engine-parser: switch balanced brackets check to parse
  • @putout/test: when format used with UPDATE pass
  • @putout/formatter-memory: add support of time
  • @putout/plugin-math: apply-numeric-separators: exclude 1e9
  • @putout/engine-parser: try to use babel/generate, when recast produces broken code with additional brace (https://github.com/benjamn/recast/issues/1248)
  • @putout/operator-declare: rm dead code
  • @putout/plugin-promises: remove-useless-await: exclude optional chaining call
  • @putout/plugin-split-nested-destructuring: exclude cases where couple properties used
putout - putout v28.18.0

Published by coderaiser over 1 year ago

πŸ”₯ feature

putout - putout v28.17.0

Published by coderaiser over 1 year ago

πŸ”₯ feature

  • package: @putout/plugin-apply-destructuring v6.0.0
  • @putout/plugin-apply-destructuring: drop support of 🐊 < 28
  • @putout/plugin-apply-destructuring: drop support of node < 16
  • @putout/plugin-apply-destructuring: object: get rid off const a = b.a || c -> const {a = c} = b since it works only for b.a = undefined not for: 0, null, undefined, '', etc
  • eslint-plugin-putout: add remove-empty-newline-between-declarations
  • @putout/plugin-split-nested-destructuring: add support of rename
  • @putout/engine-loader: is-enabled: improve handling of disabled rules of Multirule Plugin
  • package: @putout/recast v1.12.1 (#129)
putout - putout v28.16.0

Published by coderaiser over 1 year ago

🐞 fix

  • @putout/plugin-regexp: remove-useless-group: report after transform

πŸ”₯ feature

  • @putout/plugin-apply-maybe: add
  • @putout/plugin-regexp: apply-literal-notation: report: message
  • @putout/plugin-regexp: apply-literal-notation: improve support of @putout/plugin-remove-useless-escape
  • @putout/plugin-regexp: remove-useless-group: improve support of apply-literal-notation
putout - putout v28.15.0

Published by coderaiser over 1 year ago

πŸ”₯ feature

  • package: @putout/plugin-promises v9.0.0
  • @putout/plugin-promises: drop support of 🐊 < 28
  • @putout/plugin-promises: apply-top-level-await: report: improve message
  • @putout/plugin-promises: apply-top-level-await: exclude not async parent functions
putout - putout v28.14.0

Published by coderaiser over 1 year ago

πŸ”₯ feature

  • package: @putout/plugin-split-nested-destructuring v2.0.0
  • @putout/plugin-split-nested-destructuring: drup support of 🐊 < 28
  • @putout/plugin-split-nested-destructuring: drup support of node < 16
  • @putout/plugin-split-nested-destructuring: exclude declared variables
  • @putout/eslint: add ability to ignore ESLint warnings with NO_ESLINT_WARNINGS
  • @putout/operate: replace, replaceWith: check if node is statement
  • @putout/plugin-convert-for-each-to-for-of: simplify: use default behaviour of replaceWith instead of maybeBody
  • @putout/operate: replaceWithMultiple: add ability to replace Expression with Statement when body of ArrowFunctionExpression is Expression
  • @putout/operate: replaceWith: add ability to replace Expression with Statement when body of ArrowFunctionExpression is Expression
putout - putout v28.13.0

Published by coderaiser over 1 year ago

πŸ”₯ feature

  • @putout/plugin-convert-for-each-to-for-of: package: description
  • @putout/plugin-convert-for-each-to-for-of: drop support of 🐊 < 28
  • @putout/plugin-convert-for-each-to-for-of: drop support of node < 16
  • @putout/plugin-convert-for-each-to-for-of: improve support of 'forEach' used as body of arrow function
putout - putout v28.12.0

Published by coderaiser over 1 year ago

πŸ”₯ feature

  • package: @putout/plugin-remove-useless-continue v2.0.0
  • @putout/plugin-remove-useless-continue: drop support of 🐊 < 28
  • @putout/plugin-remove-useless-continue: drop support of node < 16
  • @putout/plugin-remove-useless-contiue: remove only ContinueStatement
putout - putout v28.11.0

Published by coderaiser over 1 year ago

πŸ”₯ feature

  • package: @putout/plugin-apply-flat-map v2.0.0
  • @putout/plugin-apply-template-literals: add
  • @putout/plugin-putout: check-replace-code: add support of __identifier__a
  • @putout/compare: comparators: add support of TemplateElements
  • @putout/compare: improve compare of template literals
  • @putout/plugin-apply-flat-map: drop support of 🐊 < 28
  • @putout/compare: improve support of template literals
Package Rankings
Top 1.65% on Npmjs.org
Badges
Extracted from project README
NPM version Build Status Coverage Status DeepScan putout npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm npm