3.3.0 β€’ Published 19 days ago

@putout/operator-match-files v3.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
19 days ago

@putout/operator-match-files NPM version

🐊Putout operator adds ability to match files to plugins.

Install

npm i putout @putout/operator-match-files

API

If you want to create 🐊Putout plugin that will match files according to your needs just:

const {operator} = require('putout');
const {matchFiles} = operator;
const updateTSConfig = require('../update-tsconfig');

module.exports = matchFiles({
    'tsconfig.json': updateTSConfig,
});

This will help in case when update-tsconfig is disabled by default:

const updateTSConfig = require('./update-tsconfig');

module.exports.rules = {
    'update-tsconfig': ['off', updateTSConfig],
};

And you want to help users avoid updating .putout.json config with:

{
    "match": {
        "tsconfig.json": {
            "nextjs/update-tsconfig": "on"
        }
    },
    "plugins": ["nextjs"]
}

If you want to pass options use:

{
    "match": {
        "tsconfig.json": {
            "nextjs/update-tsconfig": ["on", {
                "ignore": []
            }]
        }
    },
    "plugins": ["nextjs"]
}

Instead of this, redlint can be used, it will generate .filesystem.json which can be processed by 🐊Putout.

Rename

If you want to save with other name use ->:

const {operator} = require('putout');
const {matchFiles} = operator;
const updateTSConfig = require('../update-tsconfig');

module.exports = matchFiles({
    'tsconfig.json -> hello.json': updateTSConfig,
});

Matcher

You can even use file matchers:

{
    "rules": {
        "filesystem/convert-json-to-js": ["on", {
            "filename": "package.json"
        }]
    }
}

Matchers: __filename = __name.__ext

const {operator} = require('putout');
const {matchFiles} = operator;
const updateTSConfig = require('../update-tsconfig');

module.exports = matchFiles({
    '__name.json -> __name.js': updateTSConfig,
});

License

MIT

3.3.0

19 days ago

3.2.2

19 days ago

3.2.1

19 days ago

3.2.0

21 days ago

3.1.0

21 days ago

3.0.1

3 months ago

3.0.0

3 months ago

2.4.1

4 months ago

2.4.0

4 months ago

2.3.0

4 months ago

2.2.0

4 months ago

2.1.0

4 months ago

2.0.1

5 months ago

2.0.0

5 months ago

1.3.1

6 months ago

1.3.0

6 months ago

1.2.0

6 months ago

1.1.0

6 months ago

1.0.1

6 months ago

1.0.0

6 months ago