Repository: gregberge/svgr
Pull request #747 (2022-07-19 02:59:31)

fix: fix duplicate plugin/preset detected error
Closes: #746

<!-- Thanks for submitting a pull request! Please provide enough information so that others can review your pull request. The two fields below are mandatory. -->

## Summary

<!-- Explain the **motivation** for making this change. What existing problem does the pull request solve? -->

## Test plan

<!-- Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes UI. -->


vercel[bot]: **The latest updates on your projects**. Learn more about [Vercel for Git ↗︎](https://vercel.link/github-learn-more)

| Name | Status | Preview | Updated |
| :--- | :----- | :------ | :------ |
| **svgr** | 🔄 Building ([Inspect](https://vercel.com/gregberge/svgr/5t8wdGoZ41qpz3aDQjmbMVLSxgqV)) |  | Jul 19, 2022 at 2:59AM (UTC) |


codecov[bot]: # [Codecov](https://codecov.io/gh/gregberge/svgr/pull/747?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Greg+Berg%C3%A9) Report
> Merging [#747](https://codecov.io/gh/gregberge/svgr/pull/747?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Greg+Berg%C3%A9) (efc8466) into [main](https://codecov.io/gh/gregberge/svgr/commit/d2a2f0715378f27c5bc8f45a28c45767b6e11b98?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Greg+Berg%C3%A9) (d2a2f07) will **not change** coverage.
> The diff coverage is `100.00%`.

```diff
@@           Coverage Diff           @@
##             main     #747   +/-   ##
=======================================
  Coverage   92.26%   92.26%           
=======================================
  Files          32       32           
  Lines         802      802           
  Branches      249      249           
=======================================
  Hits          740      740           
  Misses         61       61           
  Partials        1        1           
```


| [Impacted Files](https://codecov.io/gh/gregberge/svgr/pull/747?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Greg+Berg%C3%A9) | Coverage Δ | |
|---|---|---|
| [packages/babel-preset/src/index.ts](https://codecov.io/gh/gregberge/svgr/pull/747/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Greg+Berg%C3%A9#diff-cGFja2FnZXMvYmFiZWwtcHJlc2V0L3NyYy9pbmRleC50cw==) | `95.74% <100.00%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/gregberge/svgr/pull/747?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Greg+Berg%C3%A9).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Greg+Berg%C3%A9)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/gregberge/svgr/pull/747?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Greg+Berg%C3%A9). Last update [d2a2f07...efc8466](https://codecov.io/gh/gregberge/svgr/pull/747?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Greg+Berg%C3%A9). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Greg+Berg%C3%A9).


Patch:
diff --git a/packages/babel-preset/src/index.ts b/packages/babel-preset/src/index.ts
index aa8faf5..c77b239 100644
--- a/packages/babel-preset/src/index.ts
+++ b/packages/babel-preset/src/index.ts
@@ -143,7 +143,7 @@ const plugin = (_: ConfigAPI, opts: Options) => {
   }
 
   if (opts.descProp) {
-    plugins.push([svgDynamicTitle, { tag: 'desc' }])
+    plugins.push([svgDynamicTitle, { tag: 'desc' }, 'desc'])
   }
 
   if (opts.native) {


Test patch:
diff --git a/packages/babel-preset/src/index.test.ts b/packages/babel-preset/src/index.test.ts
index bf09b86..8460c9f 100644
--- a/packages/babel-preset/src/index.test.ts
+++ b/packages/babel-preset/src/index.test.ts
@@ -132,6 +132,26 @@ describe('preset', () => {
     `)
   })
 
+  it('handles descProp and titleProp', () => {
+    expect(
+      testPreset('<svg></svg>', {
+        titleProp: true,
+        descProp: true,
+      }),
+    ).toMatchInlineSnapshot(`
+      "import * as React from \\"react\\";
+
+      const SvgComponent = ({
+        title,
+        titleId,
+        desc,
+        descId
+      }) => <svg aria-labelledby={titleId} aria-describedby={descId}>{desc ? <desc id={descId}>{desc}</desc> : null}{title ? <title id={titleId}>{title}</title> : null}</svg>;
+
+      export default SvgComponent;"
+    `)
+  })
+
   it('handles replaceAttrValues', () => {
     expect(
       testPreset('<svg a="#000" b="#fff" />', {