Socket
Socket
Sign inDemoInstall

@putout/operator-match-files

Package Overview
Dependencies
389
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @putout/operator-match-files

🐊Putout operator adds ability to match files to plugins


Version published
Weekly downloads
2K
increased by15.83%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

@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

Keywords

FAQs

Last updated on 17 Apr 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc