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 v22.5.4

Published by coderaiser almost 3 years ago

🐞 fix

  • (@putout/plugin-putout) convert-putout-test-to-create-test: declared createTest

πŸ”₯ feature

  • (package) @putout/formatter-codeframe v3.0.0
  • (@putout/formatter-codeframe) convert to ESM (#91)
putout - putout v22.5.3

Published by coderaiser almost 3 years ago

🐞 fix

  • (eslint-plugin-putout) objects-braces-inside-array: whitespaces before open brace

πŸ”₯ feature

  • (package) @putout/formatter-memory v2.0.0
  • (@putout/formatter-memory) convert to ESM (#91)
  • (package) @putout/formatter-dump v3.0.0
putout - putout v22.5.2

Published by coderaiser almost 3 years ago

🐞 fix

  • (@putout/operator-declare) simplify

πŸ”₯ feature

  • (package) @putout/formatter-dump v3.0.0
  • (package) @putout/formatter-dump v3.0.0
  • (@putout/formatter-dump) convert to ESM (#91)
  • (package) @putout/plugin-remove-useless-escape v2.0.0
  • (eslint-plugin-putout) objects-braces-inside-array: add support of newlines in the middle
  • (@putout/plugin-remove-useless-escape) drop support of node < 14
  • (@putout/plugin-remove-useless-escape) add support of comma
  • (@putout/plugin-putout) add convert-putout-test-to-create-test
  • (@putout/operator-declare) add ability to handle missing case of dual package
  • (@putout/plugin-putout) add apply-async-formatter (#91)
  • (@putout/tape) add support of reRequire
putout - putout v22.5.1

Published by coderaiser almost 3 years ago

πŸ”₯ feature

  • (package) @putout/plugin-declare-undefined-variables v6.0.0
  • (package) @putout/plugin-tape v7.0.0
  • (package) @putout/operator-declare v2.0.0
  • (@putout/operator-declare) drop support of putout < 22.5
  • (@putout/plugin-tape) drop support of putout < 22.5
  • (@putout/plugin-tape) declare: add mockImport
  • (@putout/plugin-declare-undefined-variables) mv mock-import to @putout/plugin-tape
  • (@putout/plugin-declare-undefined-variables) drop support of putout < 22.5
  • (@putout/plugin-declare-undefined-variables) simport: add support of dual packages
  • (@putout/operator-declare) add support of dual packages: esm and commonjs
putout - putout v22.5.0

Published by coderaiser almost 3 years ago

Putout gets more ESM-friendly

β€œWisdom tells me I am nothing. Love tells me I am everything. And between the two my life flows.”
― Nisargadatta Maharaj

image

Giorgio Liberale da Udine, Crocodile (16th c.)

Hi friends πŸ‘‹ ! EcmaScript Modules gets more and more popular, and 🐊Putout goes towards community needs, and added some sweets in todays release 🍬 .

ESM Formatters

That's right! Formatters now can be in one of two formats CommonJS:

module.exports = function formatter({name, source, places, index, count, filesCount, errorsCount}) {
    return '';
}

or ESM:

export default function formatter({name, source, places, index, count, filesCount, errorsCount}) {
    return '';
}

Both supported πŸ₯³ !

And they can be async functions as well 🎈:

export default async function formatter({name, source, places, index, count, filesCount, errorsCount}) {
    return '';
}

Since ESLint v8.4.0 has support of async functions and 🐊Putout has @putout/formatter-eslint which supports all ESLint formatters this way:

ESLINT_FORMATTER=pretty putout --format eslint lib

It will work as well with promises starting from this release πŸŽ‚ .

async tests for formatters

Since formatters can be ESM and async, tests for them should support this change. And with @putout/test v4.0.0, it looks this way:

test('formatter: codeframe', async ({format}) => {
    await format(codeframe);
});

What if I want to help with converting built-in formatters?

That's awesome πŸŽ‰ ! You definitely can, and it's highly appreciated 🎈! You can find all the information in Convert formatters to ESM issue.

Also good first issue will always help you to find beginners-friendly issues, so you can helps a lot to project in a simplest possible way πŸš€ .

Have a nice day and happy coding ⌨️ !

🐞 fix

  • (@putout/plugin-convert-mock-require-to-mock-import) handle no stopAll case

πŸ”₯ feature

  • (@putout/plugin-declare-undefined-variables) add support of simport
  • (package) @putout/formatter-progress-bar v2.0.0
  • (@putout/test) format: improve ability to test ESM
  • (@putout/plugin-convert-commonjs-to-esm) require: call: exclude dot dot
  • (@putout/plugin-declare-undefined-variables) add fresh-import
  • (@putout/formatter-progress-bar) convert to ESM
  • (package) @putout/plugin-convert-commonjs-to-esm v6.0.0
  • (package) @putout/formatter-progress v3.0.0
  • (@putout/formatter-progress) convert to ESM
  • (@putout/plugin-convert-commonjs-to-esm) drop support of putout < 22
  • (@putout/plugin-convert-commonjs-to-esm) require: improve support of namespaces: PascalCase -> kebabCase
  • (@putout/test) v4.0.0
  • (putout) add support of ESM formatters
  • (@putout/formatter-eslint) convert to ESM
  • (@putout/formatter-eslint) convert to async
  • (@putout/test) format: convert to async
  • (putout) add support of async formatters
  • (@putout/plugin-declare-undefined-variables) add support of zlib
  • (@putout/plugin-declare-undefined-variables) logical: add id
  • (@putout/plugin-declare-undefined-variables) add logical
putout - putout v22.4.0

Published by coderaiser almost 3 years ago

Added support of Environment Variable PUTOUT_CONFIG_FILE

Just landed 🐊Putout v22.4.0 with ability to override default config with help of PUTOUT_CONFIG_FILE env variable (in the similar way as it works with ESLINT_CONFIG_FILE):

PUTOUT_CONFIG_FILE=.putout-off.json putout . --no-config

With .putout-off.json:

{
    "formatter": "progress-bar",
    "rules": {
        "remove-unused-variables": "on"
    },
    "processors": [
        "javascript",
        "json",
        "markdown",
        "ignore",
        "yaml",
        "css"
    ],
    "ignore": [
        "**/node_modules",
    ],
    "plugins": [
        "remove-unused-variables"
    ]
}

It runs one rule remove-unused-variables. So you can add any rules you want :).

First class support of TypeScript in ESLint plugin

eslint-plugin-putout v12.0.0 has better support of TypeScript because it uses @typescript-eslint and a lot of it's rules to format TypeScript files πŸŽ‰ .

πŸ”₯ feature

putout - putout v22.3.4

Published by coderaiser almost 3 years ago

🐞 fix

  • (putout) validate-options: add support of boolean
putout - putout v22.3.3

Published by coderaiser almost 3 years ago

🐞 fix

  • (putout) validate-options: add support of optional message
putout - putout v22.3.2

Published by coderaiser almost 3 years ago

🐞 fix

  • (putout) validate-options: rm rule names: has no sense for validation as any rule provided by plugin supported
putout - putout v22.3.1

Published by coderaiser almost 3 years ago

πŸ”₯ feature

  • validate-options: improve support of rules, match
  • (putout) validate-options: improve validations: ignore, processors
  • (putout) validate-options: add descriptions
putout - putout v22.3.0

Published by coderaiser almost 3 years ago

Config validation

Just added config validation, so if your .putout.json has something like this:

{
    "hello": "world"
}

You will see error message:

🐊 .putout.json: hello: must NOT have additional properties

And 🐊Putout exits with exit code 12 (INVALID_CONFIG).

πŸ”₯ feature

  • (putout) add config validation
  • (@putout/plugin-remove-empty-pattern) improve support of nested destructuring
  • (@putout/plugin-tape) add-stop-all: add support of mockRequire
  • (@putout/plugin-remove-unused-variables) improve support of nested destructuring
putout - putout v22.2.1

Published by coderaiser almost 3 years ago

🐞 fix

  • (@putout/plugin-remove-constant-conditions) report: "constant condtions should not be used" -> "Avoid constant conditions"

πŸ”₯ feature

  • (package) @putout/plugin-madrun v11.0.0
  • (putout) improve ability to test from IDE
  • (@putout/plugin-madrun) drop support of putout < 22
  • (@putout/plugin-madrun) add declare
  • (eslint-plugin-putout) putout: add ability to preserve comments places
putout - putout v22.2.0

Published by coderaiser almost 3 years ago

Improved support of typescript-eslint

image

If night and day were to approach the Sun, Both would disappear.
In the same way, their duality would vanish
If their essential unity were seen

(c) Jnaneshvara "Amritanubhav"

More TypeScript nodes supported πŸ’ͺ

Thanks for an issue reported by @brunoparga , typescrit-eslint support improved drastically πŸŽ‰ .

It's AST has couple differences with @babel/parser that should be handled.

To the point! When you use .eslintrc.json:

{
    "parser": "@typescript-eslint/parser",
    "plugins": [
        "putout",
        "@typescript-eslint"
    ],
    "extends": [
        "plugin:putout/recommended",
        "plugin:@typescript-eslint/recommended"
    ]
}

With help of estree-to-babel, such constructs:

// TSClassImplements
class A implements B {
}
// TSInterfaceHeritage
interface x extends y.z.m {
}

// TSAbstractMethodDefinition
class Base {
    abstract getName(): string;
}

// PrivateIdentifier
class ClassWithPrivateField implements B{
    #privateField;
    pubplicField = 5;
    constructor() {
        this.#privateField = 5;
    }
}

Will work as expected, and will be parsed without a problem.
here is a circle of transformations: TypeScript AST -> ESTree -> Babel. But that's not a problem for estree-to-babel.

Improved support of comments

When using both typescript-eslint and eslint-plugin-putout there was an issue with comments:

/**
 * Copyright (c) 2016 The xterm.js authors. All rights reserved.
 * @license MIT
 */
import { ICircularList } from 'common/Types';

/**
 * Represents a circular list; a list with a maximum size that wraps around when push is called,
 * overriding values at the start of the list.
 */
export class CircularList<T> implements ICircularList<T> {
    get maxLength() {
        if (2)  // <-- should be removed with remove-constant-conditions
            alert();

        return this._maxLength;
    }
}

After applying fixes all comments go on top:

/**
 * Copyright (c) 2016 The xterm.js authors. All rights reserved.
 * @license MIT
 */
/**
 * Represents a circular list; a list with a maximum size that wraps around when push is called,
 * overriding values at the start of the list.
 */

import { ICircularList } from 'common/Types';

export class CircularList<T> implements ICircularList<T> {
    get maxLength() {
        alert();

        return this._maxLength;
    }
}

Which is very bad and has no sense. Starting from eslint-plugin-putout v11.18.0 it's fixed, and comments placed in the way they should:

/**
 * Copyright (c) 2016 The xterm.js authors. All rights reserved.
 * @license MIT
 */
import { ICircularList } from 'common/Types';

/**
 * Represents a circular list; a list with a maximum size that wraps around when push is called,
 * overriding values at the start of the list.
 */
export class CircularList<T> implements ICircularList<T> {
    get maxLength() {
        alert();

        return this._maxLength;
    }
}

That's all folks 🎈.

Have a nice day!
If you got any problems, create an issue!

🐞 fix

πŸ”₯ feature

putout - putout v22.1.1

Published by coderaiser almost 3 years ago

πŸ”₯ feature

  • (package) yargs-parser v21.0.0
putout - putout v22.1.0

Published by coderaiser almost 3 years ago

🐞 fix

  • (@putout/plugin-convert-quotes-to-backticks) a couple newlines
  • (@putout/plugin-convert-quotes-to-backticks) newlines

πŸ”₯ feature

  • (putout) *.md: disable convert-quotes-to-backticks
  • (@putout/plugin-convert-quotes-to-backtics) add suport of newlines
  • (eslint-plugin-putout) objects-braces-inside-array: enable for json, disable for yaml
putout - putout v22.0.2

Published by coderaiser almost 3 years ago

🐞 fix

  • (@putout/plugin-convert-generic-to-shorthand) exclude when no type parameters

πŸ”₯ feature

  • (package) @putout/plugin-convert-generic-to-shorthand v2.0.0
  • (@putout/plugin-convert-generic-to-shorthand) drop support of node < 14
  • (eslint-plugin-putout) add array-element-newline
  • (eslint-plugin-putout) add remove-empty-newline-before-first-specifier
  • (@putout/engine-parser) export babel/plugins
  • (@putout/engine-parser) export acorn, espree, esprima
  • (@putout/engine-parser) export babel parser
  • (@putout/plugin-tape) convert-ok-to-match: exclude: keys
  • (@putout/plugin-tape) convert-ok-to-match: rm RegExp, t.match adds it
  • (eslint-plugin-putout) single-property-destructuring: exclude ImportSpecifier whith local different then imported
  • (@putout/compare) add support of empty template
  • (eslint-plugin-putout) remove-empty-newline-after-last-specifier: add support of ObjectExpression
putout - putout v22.0.1

Published by coderaiser almost 3 years ago

🐞 fix

  • (putout) parse-options: read rules: directory with config -> current working directory
  • (@putout/engine-processor) markdown disable change without fix in favour of simpler rules
  • (@putout/processor-markdown) add support of rules splited to fix and traverse

πŸ”₯ feature

  • (@putout/rules-set-homepage) update homepage so it linked to package directory (#88)
  • (@putout/processor-markdown) add merge-heading-spaces
  • (@putout/processor-markdown) add support of rules splited to fix and traverse
  • (@putout/processor-markdown) rules: add remove-dependencies-badge (#85)
  • (@putout/plugin-tape) remove-stop-all: add support of traceImport
putout - putout v22.0.0

Published by coderaiser almost 3 years ago

☣️ BREAKING CHANGE ☣️

image

Preoccupied with a single leaf, you won't see the tree.
Preoccupied with a single tree, you'll miss the entire forest.

(c) Takuan Soho

@putout/plugin-apply-filter-boolean is removed from default installation, since @putout/plugin-remove-useless-functions does all the same thing and much more πŸŽ‰ !

If you had apply-filter-boolean disabled, all you have to do is:

{
    "rules": {
-        "apply-filter-boolean": "off"
    }
}

πŸ”₯ feature

  • (putout) remove apply-filter-boolean from default install, use remove-useless-functions instead'
putout - putout v21.6.0

Published by coderaiser almost 3 years ago

No more apply-filter-boolean πŸ’₯

@putout/plugin-apply-filter-boolean is disabled and will be removed from default installation on next major bump of Putout. Thanks to @B2o5T for helping me to understand that @putout/plugin-remove-useless-functions feats much more for this purpose in https://github.com/coderaiser/putout/pull/86 πŸŽ‰

So now all kinds of code:

[].filter((a) => a);
[].find((a) => a);
[].findIndex((a) => a);
[].some((a) => a);
[].every((a) => a);

Will be fixed to:

[].filter(Boolean);
[].find(Boolean);
[].findIndex(Boolean);
[].some(Boolean);
[].every(Boolean);

πŸ”₯ feature

  • (package) @putout/plugin-remove-useless-functions v2.0.0
  • (@putout/plugin-remove-useless-functions) drop support of node < 14
  • (putout) apply-filter-boolean: disabled and will be removed in next major version
  • (@putout/plugin-remove-useless-functions) add support of id
  • (eslint-plugin-putout) add babel options from @putout/engine-parser for TypeScript and Markdown
  • (@putout/engine-parser) export babel/options
  • (@putout/plugin-tape) add-stop-all: add support of test.only(), test.skip()
  • (@putout/plugin-tape) remove-stop-all: add support of test.only(), test.skip()
putout - putout v21.5.0

Published by coderaiser almost 3 years ago

πŸ”₯ feature

  • (putout) terminal: add support of WebStorm, VS Code
  • (@putout/plugin-tape) add remove-stop-all
  • (@putout/plugin-tape) add add-await-to-re-import
  • (@putout/plugin-tape) add-stop-all: add support of async functions
  • (eslint-plugin-putout) add add-newlines-between-types-in-union
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