{"id":14968112,"url":"https://github.com/postcss/postcss-filter-plugins","last_synced_at":"2025-07-22T01:33:07.491Z","repository":{"id":35148823,"uuid":"39375334","full_name":"postcss/postcss-filter-plugins","owner":"postcss","description":"Exclude/warn on duplicated PostCSS plugins.","archived":false,"fork":false,"pushed_at":"2020-12-22T11:13:27.000Z","size":20,"stargazers_count":23,"open_issues_count":1,"forks_count":8,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-07-09T09:24:22.763Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/postcss.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-MIT","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-07-20T09:35:20.000Z","updated_at":"2023-01-17T00:22:09.000Z","dependencies_parsed_at":"2022-09-16T15:01:35.783Z","dependency_job_id":null,"html_url":"https://github.com/postcss/postcss-filter-plugins","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/postcss/postcss-filter-plugins","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postcss%2Fpostcss-filter-plugins","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postcss%2Fpostcss-filter-plugins/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postcss%2Fpostcss-filter-plugins/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postcss%2Fpostcss-filter-plugins/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/postcss","download_url":"https://codeload.github.com/postcss/postcss-filter-plugins/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postcss%2Fpostcss-filter-plugins/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265718759,"owners_count":23816871,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-24T13:39:18.973Z","updated_at":"2025-07-22T01:33:07.469Z","avatar_url":"https://github.com/postcss.png","language":"JavaScript","readme":"# [postcss][postcss]-filter-plugins [![Build Status](https://travis-ci.org/postcss/postcss-filter-plugins.svg?branch=master)][ci]\n\n\u003e Exclude/warn on duplicated PostCSS plugins.\n\n## Install\n\nWith [npm](https://npmjs.org/package/postcss-filter-plugins) do:\n\n```console\n$ npm install postcss-filter-plugins --save\n```\n\n## Example\n\nNote that this plugin does not actually transform your CSS; instead, it ensures\nthat plugins in the PostCSS instance are not duplicated. It is intended to be\nused by plugin packs such as [cssnano] or [cssnext].\n\n```js\nvar counter = postcss.plugin('counter', function () {\n    return function (css) {\n        css.eachDecl('foo', function (decl) {\n            let value = parseInt(decl.value, 10);\n            value += 1;\n            decl.value = String(value);\n        });\n    }\n});\n\nvar css = 'h1 { foo: 1 }';\nvar out = postcss([\n    filter(),\n    counter(),\n    counter()\n]).process(css).css;\n\nconsole.log(out);\n// =\u003e h1 { foo: 2 }\n// Note that you will get a PostCSS warning in the message registry\n```\n\n## API\n\n### filterPlugins([options])\n\n#### options\n\n##### direction\n\nType: `string`  \nDefault: `'both'`\n\nPass `'forward'`, `'backward'`, or `'both'` to customise the direction in which the\nplugin will look in the plugins array. See the [tests] for examples on how this\nworks.\n\n```js\npostcss([ filter({\n    direction: 'forward'\n}) ]).process(css).css);\n```\n\n##### exclude\n\nType: `array`  \nDefault: `[] (empty)`\n\nPlugins that should be excluded from the filter. Pass an array of plugin names.\n\n```js\npostcss([ filter({\n    exclude: ['postcss-cssstats']\n}) ]).process(css).css);\n```\n\n##### silent\n\nType: `boolean`  \nDefault: `false`\n\nSet this to true to disable the plugin from emitting any PostCSS warnings.\n\n```js\npostcss([ filter({\n    silent: true\n}) ]).process(css).css);\n```\n\n##### template\n\nType: `function`  \nDefault: `format function`\n\nThis function will be passed each PostCSS plugin object. You are expected to\nreturn a string from each call, which is then used to warn the user about her\nduplicated plugins.\n\n```js\npostcss([ filter({\n    template: function (plugin) {\n        return 'Duplicate plugin found: ' + plugin.postcssPlugin;\n    }\n}) ]).process(css).css);\n```\n\n## Usage\n\nSee the [PostCSS documentation](https://github.com/postcss/postcss#usage) for\nexamples for your environment.\n\n## Contributors\n\nThanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore --\u003e\n| [\u003cimg src=\"https://avatars.githubusercontent.com/u/1282980?v=3\" width=\"100px;\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eBen Briggs\u003c/b\u003e\u003c/sub\u003e](http://beneb.info)\u003cbr /\u003e[💻](https://github.com/postcss/postcss-filter-plugins/commits?author=ben-eb \"Code\") [📖](https://github.com/postcss/postcss-filter-plugins/commits?author=ben-eb \"Documentation\") [👀](#review-ben-eb \"Reviewed Pull Requests\") [⚠️](https://github.com/postcss/postcss-filter-plugins/commits?author=ben-eb \"Tests\") | [\u003cimg src=\"https://avatars.githubusercontent.com/u/157534?v=3\" width=\"100px;\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eMaxime Thirouin\u003c/b\u003e\u003c/sub\u003e](https://moox.io/)\u003cbr /\u003e[📖](https://github.com/postcss/postcss-filter-plugins/commits?author=MoOx \"Documentation\") | [\u003cimg src=\"https://avatars.githubusercontent.com/u/373545?v=3\" width=\"100px;\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eAndreas Lind\u003c/b\u003e\u003c/sub\u003e](https://github.com/papandreou)\u003cbr /\u003e[💻](https://github.com/postcss/postcss-filter-plugins/commits?author=papandreou \"Code\") | [\u003cimg src=\"https://avatars3.githubusercontent.com/u/17342435?v=4\" width=\"100px;\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eRyan Zimmerman\u003c/b\u003e\u003c/sub\u003e](http://www.ryanzim.com)\u003cbr /\u003e[💻](https://github.com/postcss/postcss-filter-plugins/commits?author=RyanZim \"Code\") | [\u003cimg src=\"https://avatars0.githubusercontent.com/u/1133591?v=4\" width=\"100px;\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eJames Hunt\u003c/b\u003e\u003c/sub\u003e](http://jamescodes.co.uk)\u003cbr /\u003e[💻](https://github.com/postcss/postcss-filter-plugins/commits?author=JamesCodes \"Code\") |\n| :---: | :---: | :---: | :---: | :---: |\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\nThis project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification.\nContributions of any kind welcome!\n\n\n## License\n\nMIT © [Ben Briggs](http://beneb.info)\n\n[ci]:      https://travis-ci.org/postcss/postcss-filter-plugins\n[cssnano]: http://cssnano.co\n[cssnext]: http://cssnext.io\n[postcss]: https://github.com/postcss/postcss\n[tests]:   src/__tests__\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpostcss%2Fpostcss-filter-plugins","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpostcss%2Fpostcss-filter-plugins","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpostcss%2Fpostcss-filter-plugins/lists"}