{"name":"@putout/operator-match-files","version":"12.3.2","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@12.3.2","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":"35098207aa77548866ab79407ff4826f24922c56","tarball":"http://registry-npm.ywwl.com/@putout/operator-match-files/download/@putout/operator-match-files-12.3.2.tgz","fileCount":6,"integrity":"sha512-TwGrKCnklGkt5ggak0qbcuj48ueZ4hVpXzrBZUxRyMV42f0+pIpWUVGQ+aa4wcYW687svY8C4vDygt7UGTpbpw==","signatures":[{"sig":"MEYCIQDccZcMblxHYSciR1PbxaVGF2907JnwD7EUeyUhOnCefgIhAIY938z3roipnVSaiiG2oiZZb6jn55O3futSOdphhOCL","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":12874,"size":4042,"noattachment":false,"key":"/@putout/operator-match-files/-/@putout/operator-match-files-12.3.2.tgz"},"main":"lib/match-files.js","type":"module","engines":{"node":">=22"},"gitHead":"13c87e441b4ff08c1089c6fc078b3bb93e9f7061","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":"26.3.0","dependencies":{"@putout/babel":"^5.0.0","@putout/engine-parser":"^15.0.1","@putout/operator-json":"^3.0.0","@putout/processor-toml":"^1.1.20","@putout/processor-yaml":"^10.0.0","@putout/operator-filesystem":"^11.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"eslint":"^10.0.0","madrun":"^13.0.0","montag":"^2.0.0","nodemon":"^3.0.1","superc8":"^12.0.0","supertape":"^13.0.0","try-catch":"^4.0.0","@putout/test":"^15.0.0","@putout/eslint-flat":"^4.0.0","eslint-plugin-putout":"^31.0.0","@putout/plugin-nodejs":"*"},"peerDependencies":{"putout":">=42"},"_npmOperationalInternal":{"tmp":"tmp/operator-match-files_12.3.2_1781097718949_0.8974715743393955","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":1781097719090,"_cnpm_publish_time":1781097719090,"dist-tags":{"latest":"12.12.0"}}