Skip to content

🐊Putout v33

Compare
Choose a tag to compare
@coderaiser coderaiser released this 09 Nov 14:11
· 2036 commits to master since this release

image

The soul can never be cut into pieces by any weapon, nor can he be burned by fire, nor moistened by water, nor withered by the wind.

(c) Bhagavad Gita

Hi folks 🎈!
The time is come for a new major release. It has some interesting visual features, and a couple breaking changes related to rule names.

🎁 Formatter Time

image

That's right! Now you can see how much time is gone while you linting. Use:

putout . -f time

to use @putout/formatter-time as a formatter.

🎁Choose Formatter easily

With help of @putout/cli-choose-formatter using:

putout -i

you can choose the formatter you like for you next lint:

image

🎁 Filesystem Processor

There is a thing that was impossible to do in 🐊Putout until today: lint filesystem.
But everything is changed now! Lint file system is as simple as running redlint:

redlint

It generates file .filesystem.json:

{
    "type": "directory",
    "filename": "/home/coderaiser/putout",
    "files": [{
        "type": "file",
        "filename": "/home/coderaiser/putout/README.md",
    }, {
        "type": "directory",
        "filename": "/home/coderaiser/putout/lib",
        "files": [{
            "type": "file",
            "filename": "/home/coderaiser/putout/lib/putout.js",
        }]
     }]
}

Let's suppose you want to rename README.md to readme.md.
You can traverse AST-representation of a filesystem using findFile() and modify it using renameFile().
Here is how Replacer can look like:

const FS = '__putout_processor_filesystem(__object)';

export const report = () => `Rename 'README.md' to 'readme.md'`;

export const fix = (path) => {
    renameFile(path, 'readme.md');
};

export const traverse = () => ({
    [FS](path) {
        const [filePath] = findFiles(path, 'README.md');
        push(filePath);
    }
});

Here is modified AST-representation of a filesystem:

{
    "type": "directory",
    "filename": "/home/coderaiser/putout",
    "files": [{
        "type": "file",
        "filename": "/home/coderaiser/putout/readme.md"
    }, {
        "type": "directory",
        "filename": "/home/coderaiser/putout/lib",
        "files": [{
            "type": "file",
            "filename": "/home/coderaiser/putout/lib/putout.js"
        }]
    }]
}

When you run it from terminal - modifications will be applied to filesystem.
It is possible, thanks to:

So now you have ability to create rules with atomic updates to your filesystem, just in the browser using 🐊Putout Editor, 📱Mobile Putout Editor, distribute it using npm and test it with @putout/test with no mocking at all 😏.

☝️ Checkout out in 🐊Putout Editor

A couple breaking changes have been made to simplify rules structure, and decrease dependencies count.

☢️convert-esm-to-commonjs and convert-commonjs-to-esm merged to @putout/plugin-nodejs

CommonJS is a module system supported in Node, it provides a require function, which can be used to access the exports object exposed by another file.

EcmaScript module syntax is the standard way to import and export values between files in JavaScript. The import statement can be used to reference a value exposed by the export statement in another file.

(c) parceljs

This rules now disabled by default. That's right, now you can make Nested Plugin rules disabled, by default with help of:

const convert = require('./convert-commonjs-to-esm');

module.exports.rules = {
    'convert-commonjs-to-esm': ['off', convert];
}
{
    "rules": {
+    "convert-esm-to-commonjs": "on",
+    "convert-commonjs-to-esm": "on',
-    "nodejs/convert-esm-to-commonjs": "on",
-    "nodejs/convert-commonjs-to-esm": "on',
    }
}

☢️convert-mock-require-to-mock-import merged to @putout/plugin-tape

{
    "rules": {
-    "convert-mock-require-to-mock-import": "off",
+    "tape/mock-require-to-mock-import": "off",
    }
}

nodejs/convert-exports-to-module-exports

One new rule appeared (#191).

Since exports = 5 wan't make any export, just change value of variable. Checkout in 🐊Putout Editor.

❌ Example of incorrect code

exports.x = 5;

✅ Example of correct code

module.exports.x = 5;

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

🔥 feature

  • d28219c @putout/engine-loader: rm unused isExluded
  • 6b2721d putout: add ability to provide disabled plugins
  • dea7843 @putout/processor-filesystem: is-filesystem
  • 5cfd75e putout: @putout/plugin-nodejs v9.0.0
  • 729e93c putout: @putout/plugin-tape v12.0.0
  • 29c77ff @putout/plugin-tape: drop support of 🐊 < 33
  • 54f5699 putout: @putout/plugin-nodejs v8.1.0
  • 71a3e48 putout: @putout/plugin-merge-duplicate-imports v10.0.0
  • 67b22c6 @putout/plugin-nodejs: drop support of 🐊 < 33
  • 67f1dde @putout/plugin-merge-duplicate-imports: drop support of 🐊 < 33
  • fa96049 @putout/plugin-merge-duplicate-imports: improve support of tape/declare, nodejs/convert-esm-to-commonjs
  • 4befa6e @putout/plugin-nodejs: merge convert-esm-to-commonjs
  • fbae703 @putout/plugin-nodejs: merge convert-commonjs-to-esm
  • d36d198 @putout/plugin-nodejs: convert-exports-to-module-exports: add (#191)