{"name":"@putout/operator-match-files","version":"10.1.0","keywords":["putout","putout-operator","operator","match-files"],"author":{"url":"https://github.com/coderaiser","name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"license":"MIT","_id":"@putout/operator-match-files@10.1.0","maintainers":[{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"}],"homepage":"https://github.com/coderaiser/putout/tree/master/packages/operator-match-files#readme","bugs":{"url":"https://github.com/coderaiser/putout/issues"},"tag":false,"dist":{"shasum":"b0e12540bffdca47b2760cf09329c44f58efe1b1","tarball":"http://registry-npm.ywwl.com/@putout/operator-match-files/download/@putout/operator-match-files-10.1.0.tgz","fileCount":4,"integrity":"sha512-1aeAA7N7moOZFXaO5kvYieznPtoIoLbtgBI4fizZKvQuKILt+8yfpzdHzkTxLD0Vn5ip223JsKjPryTYnfzMQw==","signatures":[{"sig":"MEUCIQCbHQAzlULk693oYn9x3CtQSIkHZUCCLlZ01S8HFP8BMgIgMbj++0Jj+vhfPuSLVDX/aQezAQ2qmeQ/vpUYk+WAHDI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":11337,"size":3760,"noattachment":false,"key":"/@putout/operator-match-files/-/@putout/operator-match-files-10.1.0.tgz"},"main":"lib/match-files.js","type":"commonjs","engines":{"node":">=20"},"gitHead":"9b063b62e7d0c40c7332e9d19dd3fea433df064b","release":false,"scripts":{"lint":"madrun lint","test":"madrun test","report":"madrun report","coverage":"madrun coverage","fix:lint":"madrun fix:lint","fresh:lint":"madrun fresh:lint","lint:fresh":"madrun lint:fresh","watch:test":"madrun watch:test"},"_npmUser":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"changelog":false,"repository":{"url":"git+https://github.com/coderaiser/putout.git","type":"git"},"_npmVersion":"11.4.2","description":"🐊Putout operator adds ability to match files to plugins","directories":{},"_nodeVersion":"25.2.1","dependencies":{"@putout/babel":"^5.0.0","@putout/engine-parser":"^15.0.1","@putout/operator-json":"^2.0.0","@putout/operator-filesystem":"^10.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^10.0.0","eslint":"^10.0.0-alpha.0","madrun":"^11.0.0","montag":"^1.2.1","nodemon":"^3.0.1","supertape":"^11.0.3","try-catch":"^3.0.0","@putout/test":"^14.0.0","@putout/eslint-flat":"^3.0.0","eslint-plugin-putout":"^29.0.0","@putout/plugin-nodejs":"*"},"peerDependencies":{"putout":">=41"},"_npmOperationalInternal":{"tmp":"tmp/operator-match-files_10.1.0_1767126954477_0.8615722480444283","host":"s3://npm-registry-packages-npm-production"},"readme":"# @putout/operator-match-files [![NPM version][NPMIMGURL]][NPMURL]\n\n[NPMIMGURL]: https://img.shields.io/npm/v/@putout/operator-match-files.svg?style=flat&longCache=true\n[NPMURL]: https://npmjs.org/package/@putout/operator-match-files \"npm\"\n\n🐊[**Putout**](https://github.com/coderaiser/putout) operator adds ability to match files to plugins.\n\n## Install\n\n```\nnpm i putout @putout/operator-match-files\n```\n\n## API\n\nIf you want to create 🐊[**Putout**](https://github.com/coderaiser/putout) `plugin` that will match files according to your needs just:\n\n```js\nimport {operator} from 'putout';\nimport * as updateTSConfig from '../update-tsconfig';\n\nconst {matchFiles} = operator;\n\nexport const {\n    report,\n    scan,\n    fix,\n} = matchFiles({\n    'tsconfig.json': updateTSConfig,\n});\n```\n\nThis will help in case when `update-tsconfig` is disabled by default:\n\n```js\nimport * as updateTSConfig from './update-tsconfig';\n\nexports;\nconst rules = {\n    'update-tsconfig': ['off', updateTSConfig],\n};\n```\n\nAnd you want to help users avoid updating `.putout.json` config with:\n\n```json\n{\n    \"match\": {\n        \"tsconfig.json\": {\n            \"nextjs/update-tsconfig\": \"on\"\n        }\n    },\n    \"plugins\": [\"nextjs\"]\n}\n```\n\nIf you want to pass options use:\n\n```json\n{\n    \"match\": {\n        \"tsconfig.json\": {\n            \"nextjs/update-tsconfig\": [\"on\", {\n                \"ignore\": []\n            }]\n        }\n    },\n    \"plugins\": [\"nextjs\"]\n}\n```\n\nInstead of this, [`redlint`](https://github.com/putoutjs/redlint) can be used, it will generate `.filesystem.json` which can be processed by 🐊**Putout**.\n\n### Rename\n\nIf you want to save with other name use `->`:\n\n```js\nimport {operator} from 'putout';\nimport * as updateTSConfig from '../update-tsconfig';\n\nconst {matchFiles} = operator;\n\nexport const {\n    report,\n    scan,\n    fix,\n} = matchFiles({\n    'tsconfig.json -> hello.json': updateTSConfig,\n});\n```\n\n### Matcher\n\nYou can even use file matchers:\n\n```json\n{\n    \"rules\": {\n        \"filesystem/convert-json-to-js\": [\"on\", {\n            \"filename\": \"package.json\"\n        }]\n    }\n}\n```\n\nMatchers: `__filename = __name.__ext`\n\n```js\nexport const {\n    report,\n    scan,\n    fix,\n} = matchFiles({\n    '__name.json -> __name.js': updateTSConfig,\n});\n```\n\n### `exclude`\n\nIf you want to exclude some files, use:\n\n```js\nimport {operator} from 'putout';\nimport * as updateTSConfig from '../update-tsconfig';\n\nconst {matchFiles} = operator;\n\nexport const {\n    report,\n    scan,\n    fix,\n} = matchFiles({\n    files: {\n        '__name.ts -> __name.js': updateTSConfig,\n    },\n    exclude: ['*.d.ts'],\n});\n```\n\n### Options\n\nYou can also pass `options`:\n\n```js\nexport const {\n    report,\n    scan,\n    fix,\n} = matchFiles({\n    '.eslintrc.json -> eslint.config.js': {\n        rules: {\n            'eslint/declare': ['on', {\n                type: 'esm',\n            }],\n        },\n        plugins: [\n            ['eslint/convert-rc-to-flat', rcToFlat],\n            ['eslint/declare', declare],\n        ],\n    },\n});\n```\n\n### Printer Options\n\nYou can also pass [`printer options`](https://github.com/putoutjs/printer?tab=readme-ov-file#overrides):\n\n```js\nexport const {\n    report,\n    scan,\n    fix,\n} = matchFiles({\n    '.eslintrc.json -> eslint.config.js': {\n        printer: ['putout', {\n            format: {\n                indent: '  ',\n            },\n        }],\n        rules: {\n            'eslint/declare': ['on', {\n                type: 'esm',\n            }],\n        },\n        plugins: [\n            ['eslint/convert-rc-to-flat', rcToFlat],\n            ['eslint/declare', declare],\n        ],\n    },\n});\n```\n\n### `filename`\n\nYou can pass default `filename`, so when no options provided it will be used.\n\n```js\nimport {operator} from 'putout';\nimport updateTSConfig from '../update-tsconfig';\n\nconst {matchFiles} = operator;\n\nexport const {\n    report,\n    scan,\n    fix,\n} = matchFiles({\n    filename: '*.d.ts',\n    files: {\n        '__name.ts -> __name.js': updateTSConfig,\n    },\n});\n```\n\n## License\n\nMIT\n","publish_time":1767126954711,"_cnpm_publish_time":1767126954711,"dist-tags":{"latest":"12.12.0"}}