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 v24.0.1

Published by coderaiser almost 3 years ago

πŸ”₯ feature

  • (@putout/plugin-nodejs) merge convert-top-level-return
  • (@putout/plugin-putout) declare: add getProperty, getProperties
putout - putout v24.0.0

Published by coderaiser almost 3 years ago

image

Barefooted and naked of breast,
I mingle with the people of the world.
My clothes are ragged and dust-laden,
and I am ever blissful.
I use no magic to extend my life;
Now, before me, the dead trees
become alive.
(c) Zen Ten Bulls

Hi folks! The time is came for a major release!

🧨 Renamed methods of @putout/operate

That's simple. For API was consistent two methods was renamed:

-findProperties(path, names);
-findProperty(path, name);
+getProperties(path, names);
+getProperty(path, name);

And of course putout/declare rule declare it for you when you use it 😏.

🧨 remove-process-exit was merged to @putout/plugin-nodejs

Since this rule is nodejs related it was moved. So here is changes you should made to .putout.json if you disabled this rule:

{
    "rules": {
-       "remove-process-exit": "off"
+       "nodejs/remove-process-exit": "off"
    }
}

🧨 convert-top-level-return was merged to @putout/plugin-nodejs

Since this rule is nodejs related it was moved. So here is changes you should made to .putout.json if you disabled this rule:

{
    "rules": {
-       "convert-top-level-return": "off"
+       "nodejs/convert-top-level-return": "off"
    }
}

🧨 Bundle all TypeScript related plugins to @putout/plugin-typescript

All rules related to TypeScript was moved to separate package. So if you disabled one of those, add prefix typescript:

{
    "rules: {
-       "apply-as-type-assertions": "off",
-       "apply-utility-types": "off",
-       "convert-generic-to-shorthand": "off",
-       "remove-duplicate-interface-keys": "off",
-       "remove-useless-types": "off",
-       "remove-useless-mapped-types": "off",
-       "remove-useless-mapping-modifiers": "off",
-       "remove-useless-types-from-constants": "off",
-       "remove-unused-types": "off"
+       "typescript/apply-as-type-assertions": "off",
+       "typescript/apply-utility-types": "off",
+       "typescript/convert-generic-to-shorthand": "off",
+       "typescript/remove-duplicate-interface-keys": "off",
+       "typescript/remove-useless-types": "off",
+       "typescript/remove-useless-mapped-types": "off",
+       "typescript/remove-useless-mapping-modifiers": "off",
+       "typescript/remove-useless-types-from-constants": "off",
+       "typescript/remove-unused-types": "off"
    }
}

Yes, there is a lot TS rules in 🐊Putout for this moment :)!

🧨 Disabled apply-array-at was removed from default install

Because array.at support on node v16 and higher and 🐊Putout (still) supports node v14. The rule is supported and can be installed separately with:

npm i @putout/plugin-apply-array-at

If you use it, update .putout.json with:

{
+   "plugins": [
+       "apply-array-at"
+   ]
}

In this release we have 19% less dependencies πŸŽ‰! It makes installation a faster a bit😏.

That's all for today and this is latest day of Ten Bulls Zen marathon πŸŽ‰! That's was crazy couple weeks :) I had a lot of fun πŸ˜ƒ.

Cheers πŸ₯€!

πŸ”₯ feature

  • (putout) eslint-plugin-putout v13
  • (@putout/plugin-nodejs) drop support of putout < 24
  • (eslint-plugin-putout) drop support of putout < 24
  • (eslint-plugin-putout) safe: disable nodejs/remove-process-exit
  • (@putout/plugin-nodejs) merge remove-process-exit
  • (putout) remove from default install disabled apply-array-it
  • (package) @putout/plugin-package-json v3.0.0
  • (package) @putout/plugin-putout v9.0.0
  • (package) @putout/plugin-madrun v13.0.0
  • (package) @putout/operate v7.0.0
  • (@putout/plugin-putout) drop support of putout < 24
  • (@putout/plugin-package-json) drop support of putout < 24
  • (@putout/plugin-madrun) drop support of putout < 24
  • (@putout/operate) findProperty -> getProperty
putout - putout v23.8.0

Published by coderaiser almost 3 years ago

New ways of working with AST

image

Too many steps have been taken
returning to the root and the source.
Better to have been blind and deaf
from the beginning!
Dwelling in one's true abode,
unconcerned with and without -
The river flows tranquilly on
and the flowers are red
(c) Zen Ten Bulls

Hi folks! New day, new release πŸ˜„!

findProperty

If you want to iterate over object searching for a property with a key, this method do this for you.
Let's suppose you have an object:

{
    "test": "npm test"
}

Here is how you can remove property with a name test:

import {operate} from 'putout';
const {getExportDefault} = operate;

const testPath = findProperty(path, 'test');
testPath.remove();

getExportDefault

When you need to get export default this method will help you out!

import {operate} from 'putout';
const {getExportDefault} = operate;

const exportPath = getExportDefault(path);
exportPath.remove();

How it's related to plugins?

The thing is two new rules added to @putout/plugin-madrun that improves using madly comfortable script runner madrun.

Both of them using methods described earlier to convert code like this:

export default {
    'test': () => [env, 'npm test'],
    'test:only': () => 'npm test',
-   'coverage': async () => [env, await run('test')],
-   'coverage:only': async () => [env, await cutEnv('test:only')],
+   'coverage': async () => [env, await cutEnv('test')],
+   'coverage:only': async () => [env, await run('test:only')],
};

That's all for today! Have I nice day πŸ¦‰!

πŸ”₯ feature

  • (package) @putout/plugin-madrun v12.0.0
  • (@putout/plugin-madrun) drop support of putout < 23
  • (@putout/operate) add getExportDefault
  • (@putout/plugin-madrun) add convert-cut-env-to-run
  • (@putout/plugin-madrun) add convert-run-to-cut-env
  • (@putout/plugin-remove-useless-spread) exclude comments
putout - putout v23.7.0

Published by coderaiser almost 3 years ago

Simplified ESLint API

image

Whip, rope, person, and Ox -
all merge in No Thing.
This heaven is so vast,
no message can stain it.
How may a snowflake exist
in a raging fire.
Here are the footprints of
the Ancestors.
(c) Zen Ten Bulls

Hi folks :)!

ESLint begins his work as a formatter when 🐊Putout done his transformations. That's why it used a lot in different parts of application, for testing purpose and using API in a simplest possible way. You can access it with:

import {eslint} from 'putout/eslint';

Usage as simple as:

const [source, places] = await eslint({
    name: 'hello.js',
    code: `const t = 'hi'\n`,
    fix: false,
});

In a similar to 🐊Putout way.

☝️ The only difference is 🐊Putout return object with code and places properties

Also it has a name property it used by ESLint to calculate configuration file.

This API doesn't suppose to came in 🌴 Public Space, anyways it is already used in eslint-plugin-putout to test plugins, so why not :)? Anyways it's signature didn't changed from the beginning.

βš™οΈ Config

And starting from today you can override any ESLint options with help of config property πŸŽ‰

const [source, places] = await eslint({
    name: 'hello.js',
    code: `const t = 'hi'\n`,
    fix: false,
    config: {
        extends: [
            'plugin:putout/recommended'
       ]
    }
});

That's all for today guys! Have a nice day!

🐞 fix

  • (@putout/plugin-nodejs) convert-dirname-to-url

πŸ”₯ feature

  • (putout) eslint: add ability to pass config
  • (eslint-plugin-putout) safe: disable remove-newline-from-empty-objects
  • (eslint-plugin-putout) remove-newline-from-empty-object: add support of inner comments
  • (@putout/plugin-remove-empty) add support of export
  • (@putout/plugin-remove-empty) simplify namings
putout - putout v23.6.0

Published by coderaiser almost 3 years ago

🎩 A Couple words about coverage

image

Astride the Ox, I reach home.
I am serene. The Ox too can rest.
The dawn has come. In blissful repose,
Within my thatched dwelling
I have abandoned the whip and ropes.
(c) Zen Ten Bulls

Hi guys!

I think you know that 🐊Putout has 100% test coverage. Why so? The thing is writing parsers is very hard task, but wary not! There is a helpers 😏 !

Mock the import!

Mock-import exists for about a year and used to mock things when you using EcmaScript Modules. It uses 🐊Putout and changes ImportDeclarations to VariableDeclaration when you need it the most.
So such code:

import {readFile} from 'fs/promises';

Becomes:

const {readFile} = global.__mockImportCache.get('fs/promises');

It works amazing! But there is a problem with coverage:

Taking into accord this two factors...

🧨 New player in the game get you covered!

One more coverage tool come into world: 🎩 ESCover. It's also based on 🐊Putout and what t does is changing:

export const sum = (a, b) => {
    return a + b;
};

Into this:

export const sum = (a, b) => {
    return __c4['🧨'](5, 4), a + b;
};

__c4 is a variable with a special meaning. It provides function which gives information about line and number of current instruction.
Here is how report looks like when every thing is fine:

# CAP version 13

1..3
# files: 3
# covered: 3

# 🌴 ok

When something isn't right:

# CAP version 13

# /Users/coderaiser/escover/example/example.js
🧨 should be covered
---
lines:
 ️- 1 at file:///Users/coderaiser/escover/example/example.js:1

1..3
# files: 3
# covered: 2

# 🧨 fail: 1

🎩ESCover on early stages of development, so a lot things can change!

πŸ€·β€β™‚οΈ What more can I do with 🐊Putout?

You can trace execution of functions with help of ESTrace. It provides such information:

coderaiser@cloudcmd:~/estrace$ node --loader estrace example/lint.js
..πŸ’£ lint([]) 16.05mb file:///Users/coderaiser/estrace/example/lint.js:5
....πŸ’£ getFiles([]) 16.05mb file:///Users/coderaiser/estrace/example/lint.js:12
....πŸ’₯ getFiles 16.06mb file:///Users/coderaiser/estrace/example/lint.js:12
....πŸ’£ lintFiles([]) 16.06mb file:///Users/coderaiser/estrace/example/lint.js:22
....πŸ’₯ lintFiles 16.06mb file:///Users/coderaiser/estrace/example/lint.js:22
..πŸ’₯ lint 16.06mb file:///Users/coderaiser/estrace/example/lint.js:5

And does such transformations. Let's suppost you have a function: const fn = (a) => a. EStrace will replace it with:

const fn = (a) => {
    try {
        var __estrace_context = __estrace.enter('<anonymous:2>', 'file://hello.js:2', arguments);
        return a;
    } finally {
        __estrace.exit('<anonymous:2>', 'file://hello.js:2', __estrace_context);
    }
};

πŸ€·β€β™‚οΈ What with new rules?

@putout/plugin-convert-commonjs-to-esm doesn't require simport anymore. Only built-in modules πŸ’ͺ (Thanks to @putout/plugin-declare-undefined-variables which supports native node.js modules, and will declare it, when you use it πŸ˜‰).

@putout/plugin-nodejs got new rule: convert-dirname-to-url. What it does?

Changes:

import {readFile} from 'fs/promises';
const file1 = join(__dirname, '../../package.json');

To:

import {readFile} from 'fs/promises';
const file1 = new URL('../../package.json', import.meta.url).pathname;

This will help to get rid of __dirname in EcmaScript Modules. Here is fast draft and results.

πŸ¦” Real world uses

I just found out (I knew that they were going, but who knew…) that folks from Stylelint used 🐊 Putout to convert their codebase to ESM πŸŽ‰ but got a little problems with jest: it doesn't recognize import.meta.url πŸ€·β€β™‚οΈ. This is why πŸ“Ό Supertape exists, simple testing with native speed.
Thank you guys! That's awesome and very inspiring!

That's all for today! Happy holidays πŸŽ„!

🐞 fix

  • (@putout/engine-runner) find: options
  • (eslint-plugin-putout) add-newline-after-function-call: multiple empty lines
  • feature(@putout/plugin-declare-undefined-variables) add fixtures
  • feature(@putout/engine-runner) add support to clear replace watermarks after fix round is done
  • (@putout/engine-parser) btoa: get back node v14 support
  • (@putout/engine-parser) sourcemap url

πŸ”₯ feature

  • (package) @putout/plugin-nodejs v2.0.0
  • (@putout/plugin-nodejs) drop support of putout < 23
  • (@putout/plugin-nodejs) add convert-dirname-to-url
  • (@putout/plugin-putout) declare: add isESM
  • (package) @putout/plugin-convert-commonjs-to-esm v7.0.0
  • (@putout/plugin-convert-commonjs-to-esm) drop support of putout < 23
  • (@putout/plugin-convert-commonjs-to-esm) commonjs: use node.js built-ins, instead of simport
  • (@putout/operator-declare) add ability to pass only "esm" or only "commonjs"
  • (@putout/eslint-config) padding-line-between-statements: add newline before "for", after block-like
  • (eslint-plugin-putout) add-newline-before-function-call: add support of AssignmentExpression
  • (@putout/plugin-tape) add convert-equal-to-deep-equal
  • (@putout/plugin-gitignore) add support of .idea
  • (@putout/plugin-eslint) add apply-safe-align
  • (eslint-plugin-putout) add safe+align
  • (@putout/plugin-declare-undefined-variables) add fixtures
  • (@putout/plugin-putout) declare: add compareAny, compareAll
  • (@putout/plugin-putout) declare: add replaceWithMultiple
  • (@putout/plugin-convert-commonjs-to-esm) require: add support of MemberExpression
  • (@putout/plugin-tape) convert-equal-to-not-ok: add support of equal/notEqual with one argument passed
  • (@putout/plugin-remove-useless-return) add support of nested functions
  • (@putout/compare) is: parseTemplate: avoid caching exception as undefined
  • (@putout/engine-runner) add support to clear replace watermarks after fix round is done
putout - putout v23.5.0

Published by coderaiser almost 3 years ago

What about πŸ—ΊSource Map?

image

Mounting the Ox, slowly
I return homeward.
The voice of my flute intones
through the evening.
Measuring with hand-beats
the pulsating harmony,
I direct the endless rhythm.
Whoever hears this melody
will join me
(c) Zen Ten Bulls

Hi folks!

Source maps is everywhere! Each time you open a website, it loads tones of minified JavaScript bundles and some of them has source maps to simplify debugging.

Same thing exists in node.js and one nice tool requires it. This is mock-import. It helps to mock import you are using, so you can test it easily with πŸ“ΌSupertape (of course 😏!).

πŸ—Ί Sourcemap

When you need sourcemap you can have it easily, just pass:

  • βœ… sourceFileName;
  • βœ… sourceMapName;
putout(source, {
    fix: false,
    sourceFileName: 'hello.js',
    sourceMapName: 'world.js',
    plugins: [
        'remove-unused-variables',
    ],
});
// returns
({
    code: '\n' +
    `    const hello = 'world';\n` +
    `    const hi = 'there';\n` +
    '    \n' +
    '    console.log(hello);\n' +
    '// {"version": 3, ...}',
    places: [{
        rule: 'remove-unused-variables',
        message: '"hi" is defined but never used',
        position: {line: 3, column: 10},
    }],
});

That's all for today! Have a nice maps πŸ¦‰ πŸ₯³ !

🐞 fix

  • (eslint-plugin-putout) newline-function-call-arguments: exclude code contains quote

πŸ”₯ feature

  • (putout) add support of sourcemaps
  • (@putout/engine-parser) add sourcemaps support
putout - putout v23.4.0

Published by coderaiser almost 3 years ago

Share code with 🐊Putout Editor

image

The whip and rope are necessary,
Else he might stray off down
some dusty road.
Being well-trained, he becomes
naturally gentle.
Then, unfettered, he obeys his master.
(c) Zen Ten Bulls

Hi folks! When you write plugin for 🐊Putout there is a lot things to consider:

  • how part of JavaScript called in AST;
  • what type of plugin to use;
  • how to make fast check of all edge cases of transformation;

And there is an answer to all of this questions πŸ₯:
🐊Putout Editor! It exists for a long time, but now it has ability to share the code ☘️!

For example you can edit a brand new rule package-json/add-type.

Add module type with package-json/add-type

A couple more words about new transformation. What it does is:

{
    "name": "hello",
    "version": "1.0.0",
+   "type": "commonjs"
}

adds type of used module to package.json.
How it does it you ask? Read next!

Find the properties with operator.findProperties

When you need to find properties in your package.json or any ObjectExpression or ObjectPattern you can use findProperties:

const {homepagePath} = findProperties(__aPath, ['homepage']);

It takes a path and array of top-level elements you need to traverse, and if the found they returned with Path prefix, so you can manipulate them in any way you like 😏!

That's all for today! Have a good day and nice transformations πŸ¦‰!

πŸ”₯ feature

  • (package) @putout/plugin-package-json v2.0.0
  • (@putout/package-json) drop support of putout < 23
  • (@putout/plugin-putout) declare: add findProperties
  • (@putout/plugin-package-json) add add-type
  • (@putout/operate) add findProperties
putout - putout v23.3.0

Published by coderaiser almost 3 years ago

A couple words about variable declarations

image

I seize him with a terrific struggle.
His great will and power
are inexhaustible.
He charges to the high plateau
far above the cloud-mists,
Or in an impenetrable ravine he stands.
(c) Zen Ten Bulls

Hi folks! It's a new day, and new release πŸ˜„!

Today I want to tell you about some useful feature that was improved drastically is:

operator.getBindingPath and variable declarations

Let's start from the code example:

const x  = {
   y: 'hello',
};

typeof hello === 'string';
typeof x.y === 'number';

How do you determine whether hello variable is declared or not? Let's try to solve it.

When you have a path like this one you get using match in Replacer:

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

module.exports.match = () => ({
    'typeof __a === "__b"': ({__a}, path) => {
        // when __a declared proceed to replace
        return getBindingPath(path, __a))
    }
});

And want to know is node __a is declared you can use getBindingPath, and it will solve it for you:

getBindingPath(path, 'hello');
// returns
null;

getBindingPath(path, 'x');
// returns
Path;

But what if you don't know what is the type of node you going to receive, but you know definitely that you need a name of this node to proceed? Just pass the node and getBindingPath will parse the name for you :)!

getBindingPath(path, node); // node can be Identifier or MemberExpression
// parse the name first, and then find it's declaration
Path;

New abilities of convert-typeof-to-is-type.

Now convert-typeof-to-is-type supports MemberExpressions is well:

const hello = {
    world: '',
};

-typeof hello.world === 'string'
+isString(hello.world);

And with help of declare-undefined-variables you will get:

+const isString = (a) => typeof a === 'string';
const hello = {
    world: '',
};

isString(hello.world);

So use both of them to get the most benefit 🎈!
Of course, both of them enabled by default 😏

Autofixes for Includer

When you using Includer and for some reason forget the it requires a function which returns an array
putout/includer will get you covered!

And such code:

module.exports.include = [
    'const __a = __b',
];

And even such:

module.exports.include = 'const __a = __b';

Will be converted to the only one correct:

module.exports.include = () => [
    'const __a = __b',
];

☝️ To get things working enable putout rule in .putout.json:

{
    "rules": {
        "putout": "on"
    }
}

Always use the simplest possible plugin type for your needs 🍬.

That's all for today! Happy holidays πŸŽ„!

πŸ”₯ feature

  • (package) @putout/operate v6.13.0
  • (package) @putout/plugin-convert-typeof-to-is-type v2.0.0
  • (@putout/plugin-convert-typeof-to-is-type) drop support of putout < 23
  • (@putout/plugin-convert-typeof-to-is-type) add support of MemberExpression
  • (@putout/operate) getBinding/getBindingPath: name: string -> name: string | Node'
  • (@putout/plugin-putout) add includer
putout - putout v23.2.0

Published by coderaiser almost 3 years ago

More stores to save the data

image

I hear the song of the nightingale.
The sun is warm, the wind is mild,
willows are green along the shore -
Here no Ox can hide!
What artist can draw that massive head,
those majestic horns?
(c) Zen Ten Bulls

Hi folks!
A couple updates for today 🎁.

πŸ’ͺ Rule reuse-duplicate-init now supports MemberExpression

And such code:

const {operator} = require('putout');
const {replaceWith} = require('putout').operator

Will be easily transformed to 😏:

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

New guy on the stores block

When you need to store the data of traversing for future processing, and want to do it right: use Stores.
There was two types of stores:

  • store - to store simple values to objects;
  • listStore to store array items;

And now we have upstore, that hav ability to update information you put in accordance to the name you provide.

not-rule- prefix for Rules

When you using rules specific to your project, and don't want to publish them (but do want to keep them in repository) - use --rulesdir:

putout --rulesdir rules

Similar to the way to it's done in 🐊Putout repository in directory /ruels πŸŽ‰

That's all for today! Happy holidays πŸ₯³!

πŸ”₯ feature

  • (package) @putout/plugin-reuse-duplicate-init v3.0.0
  • (package) @putout/plugin-remove-unused-types v2.0.0
  • (package) @putout/engine-runner v12.0.0
  • (@putout/plugin-reuse-duplicate-init) drop support of putout < 23
  • (@putout/plugin-reuse-duplicate-init) add support of MemberExpression
  • (@putout/plugin-remove-unused-types) drop support of putout < 23
  • (@putout/plugin-remove-unused-types) store -> upstore
  • (@putout/engine-runner) add support of upstore
  • (@putout/engine-runner) improve support of Program: exit + exclude
  • (@putout/plugin-github) traverse-property: callback -> return array
  • (putout) rules: exclude "not-rule-*" glob
  • (@putout/rule-add-readme-to-homepage) add
putout - putout v23.1.0

Published by coderaiser almost 3 years ago

Inception of Array.entries()

image

Along the riverbank under the trees,
I discover footprints.
Even under the fragrant grass,
I see his prints.
Deep in remote mountains they are found.
These traces can no more be hidden
than one's nose, looking heavenward.
(c) Zen Ten Bulls

Todays 🐊Putout minor release notes will be about Array.entries, that can help you to get rid of for loops even when you need to use index. In good old days we used to use:

for (let i = 0; i < elements.length; i++) {
    const element = elements[i];
    console.log(i, element);
}

But now we are using for-of most of the time, because it's simpler and does only what's needed:

for (const element of elements) {
    console.log(i, element); // <-- we have no i πŸ„
}

But hold up, what with i variable? Where we should get it from?
Worry not πŸ˜„, array.entries() to the rescue!

for (const [i, element] of elements.entries()) {
    console.log(i, element);
}

convert-for-to-for-of

Of course such transformation already waiting for you in convert-for-to-for-of 🎈 .

remove-useless-array-entries

But what if you used array.entries() for some time with index but then stoped using index and your code became looking like this:

for (const [, element] of elements.entries()) {
    console.log(element);
}

Worry not! remove-useless-array-entries will convert code to usual for-of:

for (const element of elements) {
    console.log(element);
}

Guys have fun and always use for-of (with the exception of hot code that requires a lot of speed ☝️!) πŸ¦‰.

🐞 fix

  • (@putout/plugin-convert-for-to-for-of) entries: count i references (should be more then 3)

πŸ”₯ feature

  • (@putout/plugin-remove-useless-array-entries) add
  • (@putout/plugin-convert-for-to-for-of) length: add support of destructuring
  • (@putout/plugin-convert-for-to-for-of) entries: add support of destructuring
  • (@putout/plugin-convert-for-to-for-of) add support of entries with declared n
  • (@putout/plugin-convert-for-to-for-of) add support of entries
  • (eslint-plugin-putout) no-unresolved: add support of export declarations
  • (@putout/plugin-remove-useless-escape) set RegExp raw
  • (@putout/plugin-remove-useless-escape) improve support of handling "," in RegExp
  • (@putout/plugin-regexp) remove-useless-group: add support of Alternative
putout - putout v23.0.0

Published by coderaiser almost 3 years ago

Dropped support of JSCodeshift

image

In the pasture of the world,
I endlessly push aside the tall
grasses in search of the Ox.
Following unnamed rivers,
lost upon the interpenetrating
paths of distant mountains,
My strength failing and my vitality exhausted, I cannot find the Ox.
(c) Zen Ten Bulls

Hi folks!

JSCodeshift inspired me a lot from the beginning of work on 🐊Putout. It started from the great idea: codemods simple and popular.
BUT, for last couple years I see no growth in this tool.

Here is the most significant downsides of JSCodeshift:

  • still no plugins support;
  • still no configuration support;
  • pure maintenance, last release half year ago;
  • pure testing culture of codemods;
  • pure codemods imperative API;

So yes, JSCodeshift inspired me. Inspired in a way how things should be made in totally different way!

Every time I install 🐊Putout I see this deprecations notice:

image

Which I'm tired of a lot, and don't want see it again. Ever.
And installing now will be a little bit faster, what is amazing πŸ₯³ !

About supported JSCodeshift codemods. This feature wasn't very popular. Any codemod could be connected to 🐊Putout, but it will work slower, because of recast printing that should be done to distinguish transformed and original sources. Very naive and slow approach. And with release of @putout/recast v1.5.0 the time is come to drop JSCodeshift because it started work incorrect and if recast is heart of 🐊Putout, JSCodeshift was just one of supported tools.
So the time is come to say Good Bye!

That's all for today. Have fun guys 🎈!

πŸ”₯ feature

  • (package) @putout/engine-loader v5.0.0
  • (package) @putout/plugin-regexp v4.0.0
  • (@putout/plugin-regexp) drop support of putout < 23
  • (putout) drop jscodeshift support
  • (@putout/engine-loader) drop support of jscodeshift
  • (putout) apply @putout/recast v1.5.1 modifications
  • (eslint-plugin-putout) putout: add ability parse error instead of throw
  • (eslint-plugin-putout) ts: add no-redeclare
  • (@putout/plugin-tape) add-await-to-re-import: add suport of nested blocks
putout - putout v22.9.0

Published by coderaiser almost 3 years ago

🐞 fix

  • (@putout/plugin-putout) convert-replace-with: crawl

πŸ”₯ feature

  • (@putout/plugin-apply-await-import) exclude cases where parent not VariableDeclarator
  • (@putout/plugin-apply-await-import) add
  • (@putout/plugin-putout) declare: add replaceWith
  • (@putout/plugin-tape) add-args: add support of async functions
  • (package) ts-morph v13.0.2
  • (@putout/plugin-declare-undefined-variables) add support of url
  • (@putout/engine-loader) improve Yarn PnP support (#93)
  • (@putout/plugin-remove-useless-return) improve handling of call expressions
  • (@putout/plugin-tape) add-t-end: exclude case where callback used
putout - putout v22.8.2

Published by coderaiser almost 3 years ago

🐞 fix

  • (@putout/formatter-memory) memry -> memory

πŸ”₯ feature

  • (putout) options: ignore: add .pnp.*
  • (@putout/engine-loader) improve support of Yarn PnP (#93)
putout - putout v22.8.1

Published by coderaiser almost 3 years ago

πŸ”₯ feature

  • (putout) config: ignore .yarn directory
putout - putout v22.8.0

Published by coderaiser almost 3 years ago

First class support of Yarn PnP

image

Zoology of Egypt, 1898

β€œOnce upon a time, I dreamt I was a butterfly, fluttering hither and thither, to all intents and purposes a butterfly. I was conscious only of my happiness as a butterfly, unaware that I was myself. Soon I awaked, and there I was, veritably myself again. Now I do not know whether I was then a man dreaming I was a butterfly, or whether I am now a butterfly, dreaming I am a man.”
― Zhuangzi

Thanks to @EvgenyOrekhov, today was added first class support of Yarn PnP πŸŽ‰ (https://github.com/coderaiser/putout/issues/93).

All you need to get started is:

  • cd to your project directory;
  • run yarn set version berry;
  • run yarn;

After that a file .pnp.cjs will be created, this is a bundle with content of all your node_modules.
Then if you put putout into your scripts, you can run it with: yarn putout ..

Have fun 🎈!

🐞 fix

  • (@putout/processor-css) disable property-no-vendor-prefix, selector-no-vendor-prefix
  • (@putout/engine-parser) try-catch: devDependencies -> dependencies (#92)
  • (@putout/operate) try-catch: dependencies -> devDependencies

πŸ”₯ feature

  • (putout) formatters: use chalk v4 to have support of Yarn PnP (https://github.com/yarnpkg/berry/issues/3843)
  • (putout) add support of yarn PnP by formatters loader (#93)
  • (@putout/engine-loader) add support of Yarn PnP (#93)
  • (package) stylelint-config-standard v24.0.0
  • (package) stylelint v14.1.0
  • (@putout/operate) compute: nested MemberExpressions: extract -> compute
  • (@putout/plugin-convert-typeof-to-is-type) exclude undefined undeclared
  • (@putout/operate) compute: exclude values of MemberExpression that cannot be extracted
  • (@putout/plugin-remove-useless-variables) for-of: add support of ArrayPattern
  • (eslint-plugin-putout) wrap: add getSpacesAfterNode
  • (@putout/plugin-putout) add apply-create-test
  • (@putout/plugin-putout) add convert-dirname-to-url
  • (@putout/operator-declare) use isESM from @putout/operate
  • (@putout/operate) add isESM
  • (@putout/formatter-progress-bar) add color constant
  • (@putout/operate) compute: isSimbleMemberExpression: simplify object check: not MemberExpression, not CallExpression -> not computed and Identifier'
putout - putout v22.7.0

Published by coderaiser almost 3 years ago

image

Lubumbashi, Democratic Republic of the Congo 1940s

putout/check-replace-code improvements

Thanks to compute of @putout/operate, such code can be checked:

const BODIES = {
    function: `typeof __a === 'function'`,
};

module.exports.replace = () => ({
    [BODIES.function]: 'isFn(__a)',
});

πŸ”₯ feature

  • (package) @putout/plugin-convert-comparison-to-boolean v2.0.0
  • (@putout/operate) compute: add support of evaluate
  • (@putout/plugin-convert-comparison-to-boolean) improve support of member expressions
  • (@putout/plugin-convert-comparison-to-boolean) drop support of putout < 22
  • (@putout/plugin-putout) check-replace-code: simplify
  • (@putout/operate) compute: add support of Literal
  • (@putout/plugin-putout) check-replace-code: use compute from operate
  • (@putout/operate) add compute
  • (@putout/plugin-putout) check-replace-code: add support of MemberExpression in computed property
  • (@putout/plugin-convert-typeof-to-is-type) use getBindingPath from operate
  • (@putout/operate) add getBinding, getBindingPath
  • (@putout/operate) add getBinding
  • (@putout/engine-runner) replace: validation output: ["__b"] ["__a"] -> ["__a"] -> ["__b"]
  • (@putout/plugin-putout) add move-require-on-top-level
  • (@putout/test) add support of createTest
  • (@putout/engine-loader) is-enabled: use isBool
  • (@putout/plugin-convert-typeof-to-is-type) improve binding search
  • (@putout/plugin-putout) check-replace-code: exclude computed keys
  • (@putout/plugin-convert-typeof-to-is-type) add support of isSymbol
  • (@putout/plugin-declare-undefined-variables) add support of isSymbol
putout - putout v22.6.2

Published by coderaiser almost 3 years ago

🐞 fix

  • (eslint-plugin-putout) putout: traverse: use faster version

πŸ”₯ feature

  • (package) @putout/plugin-remove-useless-return v4.0.0
  • (eslint-plugin-putout) safe: disable no-useless-return
  • (@putout/plugin-remove-useless-return) report: Useless "return" should be avoided -> Avoid useless "return"
  • (@putout/eslint-config) add space-in-parens
  • (eslint-plugin-putout) putout: simplify according to https://github.com/eslint/eslint/issues/15394#issuecomment-989410995
  • (package) @babel/traverse v7.16.3
putout - putout v22.6.1

Published by coderaiser almost 3 years ago

🐞 fix

  • (putout) transform: runPlugins: rm useless parser

πŸ”₯ feature

putout - putout v22.6.0

Published by coderaiser almost 3 years ago

πŸ”₯ feature

  • (putout) add exit code: CANNOT_LOAD_FORMATTER
  • (package) @putout/formatter-json-lines v2.0.0
  • (@putout/formatter-json-lines) convert to ESM (#91)
  • (package) @putout/formatter-stream v3.0.0
  • (package) @putout/formatter-json v2.0.0
  • (package) @putout/formatter-json v2.0.0
  • (package) @putout/formatter-json v2.0.0
  • (package) @putout/formatter-json v2.0.0
  • (@putout/formatter-json) convert to ESM (#91)
  • (@putout/formatter-stream) convert to ESM (#91)
putout - putout v22.5.5

Published by coderaiser almost 3 years ago

πŸ”₯ feature

  • (package) @putout/formatter-frame v2.0.0
  • (@putout/formatter-frame) convert to ESM (#91)
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