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
putout - putout v19.7.1

Published by coderaiser about 3 years ago

๐Ÿž fix

  • (@putout/cli-validate-args) quote -> back quote
  • (putout) cli: --disable-all + --quotes

๐Ÿ”ฅ feature

  • (@putout/plugin-apply-montag) improve support of newlines
putout - putout v19.7.0

Published by coderaiser about 3 years ago

๐Ÿž fix

  • (@putout/cli-ruler) export: named -> default

๐Ÿ”ฅ feature

  • (@putout/plugin-tape) add convert-ok-to-called-with
  • (package) find-up v6.0.0
  • (@putout/plugin-apply-montag) add
putout - putout v19.6.0

Published by coderaiser about 3 years ago

๐Ÿ”ฅ feature

  • (package) @putout/plugin-declare-undefined-variables v2.0.0
  • (@putout/plugin-declare-undefined-variables) drop support of putout < 19
  • (@putout/plugin-declare-undefined-variables) report: change
  • (@putout/plugin-declare-undefined-variables) add support of montag
  • (@putout/compare) isTemplate: add support of "."
  • (package) @putout/plugin-remove-empty v6.0.0
  • (@putout/plugin-remove-empty) drop suppot of putout < 19
  • (package) @putout/plugin-remove-empty-pattern v4.0.0
  • (@putout/plugin-remove-empty-pattern) drop support of node < 14
  • (@putout/plugin-remove-empty-pattern) add support of let declaration and assignment
  • (@putout/plugin-putout) check-replace-code: generate code: __array: add support of AssignmentPattern
  • (@putout/plugin-remove-empty-pattern) add support of ArrayPattern full of empty elements
  • (@putout/plugin-putout) check-replace-code: add support of ArrayPattern used as function argument
putout - putout v19.5.0

Published by coderaiser about 3 years ago

๐Ÿž fix

  • (@putout/plugin-remove-useless-return) exclude CallExpression

๐Ÿ”ฅ feature

  • (@putout/plugin-remove-useless-return) add support of LogicalExpression
  • (@putout/plugin-remove-useless-return) excludew TemplateLiteral
  • (@putout/plugin-remove-useless-return) excludew NewExpression
  • (package) @putout/plugin-remove-useless-return v3.0.0
  • (@putout/plugin-remove-useless-return) drop support of putout < 19
  • (@putout/plugin-remove-useless-return) add support of const declaration
putout - putout v19.4.0

Published by coderaiser about 3 years ago

๐Ÿ”ฅ feature

  • (@putout/cli-ruler) move out from putout
putout - putout v19.3.1

Published by coderaiser about 3 years ago

๐Ÿž fix

  • (putout) cli: error message correction: --fix + --disable
putout - putout v19.3.0

Published by coderaiser about 3 years ago

--fix cannot be used with Ruler toggler

Just landed additional check of user input when running command to set baseline disabling all found rules --disable-all and other ruler options.

image

๐Ÿคทโ€โ™‚๏ธ What is Ruler?

When you need to change .putout.json you can do it not only manually editing the file in an editor, but with help of Ruler as well.

Ruler can enable one rule with putout --enable convert-commonjs-to-esm or disable all rules with putout --disable-all. But it should never be used with --fix, because it's not clear what should be done. Actually what is done is changes made to .putout.json but putout doesn't see them and works with older version of config what can be confusing.

Of course this should be documented. But much better way would be to help user with detailed explanation from used application, so there was no need to read the documentation :).

๐Ÿคทโ€โ™‚๏ธ How ruler can be helpful to me?

You may want to convert your CommonJS module into Ecma Script Modules. Right now this is a trend started by @sindresorhus.

Convert CommonJS to ESM

Let's suppose you have a file called index.js:

const unused = 5;

module.exports = function() {
    return promise();
}

async function promise(a) {
    return Promise.reject(Error('x'));
}

You want to convert it to ESM, and everything else keep untouched. You can do this with a Ruler. So you disable all rules that Putout can find right now.

putout index.js --disable-all will find next errors:

 1:4   error   "unused" is defined but never used                        remove-unused-variables
 7:23  error   "a" is defined but never used                             remove-unused-variables
 3:0   error   Arrow functions should be used                            convert-to-arrow-function
 1:0   error   "use strict" directive should be on top of commonjs file  strict-mode/add
 8:4   error   Reject is useless in async functions, use throw instead   promises/convert-reject-to-throw
 4:11  error   Async functions should be called using await              promises/add-missing-await
 7:0   error   Useless async should be avoided                           promises/remove-useless-async

And create config file .putout.json with:

{
    "rules": {
        "remove-unused-variables": "off",
        "convert-to-arrow-function": "off",
        "strict-mode/add": "off",
        "promises/convert-reject-to-throw": "off",
        "promises/add-missing-await": "off",
        "promises/remove-useless-async": "off"
    }
}

Then running putout index.js --enable convert-commonjs-to-esm will update config with:

{
    "rules": {
        "remove-unused-variables": "off",
        "convert-to-arrow-function": "off",
        "strict-mode/add": "off",
        "promises/convert-reject-to-throw": "off",
        "promises/add-missing-await": "off",
-       "promises/remove-useless-async": "off"
+       "promises/remove-useless-async": "off",
+       "convert-commonjs-to-esm": "on"
    }
}

Then putout --fix index.js will do the thing and update index.js with:

const unused = 5;

export default function() {
    return promise();
};

async function promise(a) {
    return Promise.reject(Error('x'));
}

So in case of src directory, it will look like:

putout src --disable-all && putout src --enable convert-commonjs-to-esm && putout src --fix

This command will disable all rules that Putout can find right now and enable single rule. All Putout rules made for good and highly suggested to be used, they all enabled in this and all my other repositories. Anyways you can always disable what you don't need.
Happy coding ๐ŸŽˆ!

๐Ÿž fix

  • (@putout/plugin-declare-undefined-variables) mockImport: multiple declarations

๐Ÿ”ฅ feature

  • (putout) exit with error when "--fix" used with "--enable(-all)" or "--diable(-all)" (#77)
  • (@putout/plugin-regexp) remove-useless-group: allow only test, search match (#74)
  • (@putout/plugin-apply-filter-boolean) add
  • (eslint-plugin-putout) rm category (https://eslint.org/blog/2021/08/eslint-v8.0.0-beta.1-released)
putout - putout v19.2.0

Published by coderaiser about 3 years ago

๐Ÿ”ฅ feature

putout - putout v19.1.0

Published by coderaiser about 3 years ago

๐Ÿž fix

  • (@putout/plugin-remove-nested-blocks) declared

๐Ÿ”ฅ feature

  • (package) @putout/plugin-remove-useless-variables v5.0.0
  • (package) @putout/plugin-remove-nested-blocks v4.0.0
  • (package) @putout/plugin-tape v3.0.0
  • (package) @putout/engine-runner v11.0.0
  • (@putout/plugin-remove-useless-variables) drop support of putout < 19
  • (@putout/plugin-remove-nested-blocks) drop support of putout < 19
  • (@putout/plugin-tape) drop support of putout < 19
  • (@putout/plugin-tape) simplify according to @putout/engine-runner crawling
  • (@putout/plugin-remove-useless-variables) rm binding check
  • (@putout/engine-runner) replace: add crawl
  • (@putout/plugin-declare-undefined-variables) add support of mockImport (https://github.com/coderaiser/mock-import)
putout - putout v19.0.2

Published by coderaiser about 3 years ago

๐Ÿž fix

  • (putout) remove-useless-await -> promises/remove-useless-await

๐Ÿ”ฅ feature

  • (@putout/plugin-promises) add @putout/plugin-remove-useless-await
  • (@putout/plugin-convert-commonjs-to-esm) require: add support of chaining
  • (@putout/plugin-convert-commonjs-to-esm) commons: add support of top-level-require
  • (@putout/plugin-convert-commonjs-to-esm) add support of declared require
  • (@putout/plugin-convert-commonjs-to-esm) require: excluded binded
  • (@putout/plugin-convert-commonjs-to-esm) require: add support of kebab-case
  • (@putout/plugin-convert-commonjs-to-esm) add support of const __a = require("__b")(__args)
putout - putout v19.0.1

Published by coderaiser about 3 years ago

๐Ÿž fix

  • (@putout/plugin-apply-top-level-await) add to @putout/plugin-promises

๐Ÿ”ฅ feature

  • (@putout/plugin-regexp) remove-useless-group: add support of replaceAll (#74)
  • (@putout/plugin-regexp) remove-useless-group: exclude exec (#74)
  • (@putout/plugin-regexp) remove-useless-group: exclude VariableDeclaration (#74)
  • (@putout/plugin-regexp) remove-useless-group: exclude split, replace (#74)
putout - putout v19.0.0

Published by coderaiser about 3 years ago

๐Ÿฅš Never put all eggs in one basket ๐Ÿงบ

But I will, and the time is came to group all rules related to promises together. And this is a...

โš  ... a breaking change

But this is for good! Right now Putout has a lot of rules, and would be a little bit more pleasant to use it if will be less rules, but more categories.

Closer to point, next rules now bundled into @putout/plugin-promises ๐ŸŽ‰ :

-const show = async () => {
+const show = () => {
    console.log('hello');
};
-   await await Promise.resolve('hello');
+   await Promise.resolve('hello');
import fs from 'fs';

-(async () => {
-    const data = await fs.promises.readFile('hello.txt');
-})();
+const data = await fs.promises.readFile('hello.txt');

All of them enabled by default, if you disabled some of them before consider updating .putout.json:

{
    "rules": {
-      "remove-useless-async": "off",
-      "remove-useless-await": "off",
-      "apply-top-level-await: "off"
+      "promises/remove-useless-async": "off",
+      "promises/remove-useless-await": "off",
+      "promises/apply-top-level-await": "off"
    },
    "plugins": [
-      "remove-useless-async",
-      "remove-useless-await",
-      "apply-top-level-await"
    ]
}

Same for match:

{
    "match": {
         "*.md": {
-           "remove-useless-async": "off",
-           "remove-useless-await": "off",
-           "apply-top-level-await": "off"
+           "promises/remove-useless-async": "off",
+           "promises/remove-useless-await": "off",
+           "promises/apply-top-level-await": "off"
        }
    },

Otherwise if you didn't disable any of mentioned rules, that's awesome have a party ๐ŸŽˆ!

๐Ÿž fix

  • (@putout/cli-validate-args) switch to dinymic import
  • (@putout/plugin-regexp) convert-to-string: false possitive with Char of kind meta: \d
  • (@putout/eslint-config) peerDependency
  • (eslint-plugin-putout) peerDependencies: eslint

๐Ÿ”ฅ feature

  • (package) @putout/plugin-promises v6.0.0
  • (@putout/operate) extract: add support of ClassMethod
  • (putout) remove-useless-async -> promises/remove-useless-async
  • (@putout/plugin-promises) add @putout/plugin-remove-useless-async
  • (@putout/plugin-remove-useless-async) add support of functions with return
  • (@putout/plugin-madrun) add remove-check-duplicates-from-test
putout - putout v18.16.0

Published by coderaiser about 3 years ago

๐Ÿ”ฅ feature

  • (package) supertape v6.0.1
  • (putout) disable remove-unreachable-code for markdown
  • (eslint-plugin-putout) reuse ts in markdown
  • (eslint-plugin-putout) markdown: disable no-unreachable
  • (eslint-plugin-putout) add support of typescript
  • (@putout/plugin-remove-useless-map) add support of id function
putout - putout v18.15.0

Published by coderaiser about 3 years ago

๐Ÿž fix

  • (@putout/compare) link: arrays
  • (putout) parse-options: read rules with "putout-plugin" prefix
  • (eslint-plugin-putout) rm additiona esm handling
  • (@putout/engine-runner) empty key

๐Ÿ”ฅ feature

  • (putout) eslint-plugin-putout v9.0.0
  • (putout) eslint v8
  • (eslint-plugin-putout) drop support of eslint < 8
  • (@putout/eslint-config) add support of es2022
  • (eslint-plugin-putout) node: disable node/no-unsupported-features/es-syntax
  • (@putout/plugin-tape) convert-match-regexp-to-string: add ability to check if regexp is simple
  • (@putout/plugin-regexp) export isSimpleRegExp
  • (@putout/plugin-tape) add convert-match-regexp-to-string
  • (@putout/processor-markdown) remark-preset-lint-consistent v5.0.0
  • (@putout/engine-parser) babel: enable allowImportExportEverywhere: to use ImportDeclaration in block while transform
  • (@putout/compare) add support of templates beginning with big char
putout - putout v18.14.0

Published by coderaiser about 3 years ago

๐Ÿ”ฅ feature

  • (putout) --match: reformulate
  • (@putout/plugin-apply-is-array) add
  • (@putout/compare) add support of template contains big char
putout - putout v18.13.0

Published by coderaiser about 3 years ago

๐Ÿž fix

  • (eslint-plugin-putout) single-property-destructuring: miss import with single specifier

๐Ÿ”ฅ feature

putout - putout v18.12.0

Published by coderaiser about 3 years ago

๐Ÿ”ฅ feature

  • (@putout/plugin-apply-utility-types) add
putout - putout v18.11.0

Published by coderaiser about 3 years ago

๐Ÿ”ฅ feature

  • (@putout/plugin-remove-useless-mapping-modifiers) add
  • (package) remark-stringify v10.0.0
  • (package) remark-parse v10.0.0
putout - putout v18.10.0

Published by coderaiser about 3 years ago

๐Ÿž fix

  • (eslint-plugin-putout) putout: range of null

๐Ÿ”ฅ feature

  • (@putout/plugin-remove-useless-mapped-types) add
  • (@putout/plugin-putout) check-replace-code: add support of typescript
  • (@putout/compare) compare: add support of TSTypeParameter
  • (eslint-plugin-putout) putout: move out fix
  • (@putout/plugin-regexp) remove-useless-group: add support of empty non capturing group
  • (@putout/plugin-convert-for-to-for-of) add support of not BlockStatement loop body
putout - putout v18.9.1

Published by coderaiser about 3 years ago

๐Ÿž fix

  • (putout) strict-mode/add on empty ts files
  • (@putout/plugin-putout) check-replace-code: false positive on empty result

๐Ÿ”ฅ feature

  • (@putout/plugin-convert-commonjs-to-esm) require: add support of "undefined" as argument of "require"
  • (package) estrace v2.1.0
  • (@putout/plugin-putout) check-replace-code: add support of __array, __object
  • (@putout/compare) add support of same empty strings
  • (@putout/compare) add support of top-level linked nodes
  • (@putout/plugin-cli-validate-args) rm unused mock-require
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