Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

False positive in macrosRegex

See original GitHub issue

We recently released @formatjs/macro and got this issue for a user. The macro we use is not compatible with babel-plugin-macros because we use that in TS transformer & eslint as well so we don’t wrap it, but it looks like babel-plugin-macros might be too aggressive and throw an error if it detects anything that looks like macrosRegex. My suggestion: Can we turn this into a warning?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:18 (9 by maintainers)

github_iconTop GitHub Comments

AndyOGocommented, Dec 9, 2019

Alright, to whom it may concerns.

We had to extend our Babel config to supply a custom isMacrosName() function.


// Fixes
const macrosRegex = /[./]macro(\.js)?$/;
const testMacrosRegex = v =>
  macrosRegex.test(v) && v.indexOf('@formatjs/macro') === -1;
module.exports = {
  plugins: [
        isMacrosName: testMacrosRegex,
AndyOGocommented, Dec 9, 2019

@kentcdodds I couldn’t find any documentation for isMacrosName(), neither in user docs, nor author docs.

I face the same warning from @formatjs/macro as described here

Here is the reuslt of npm ls:

@axa-ch/aletheia@1.21.9 git-repos\aletheia
+-- babel-plugin-macros@2.8.0
+-- babel-plugin-react-intl@5.1.11
+-- import-all.macro@2.0.3
| `-- babel-plugin-macros@2.8.0  deduped
`-- react-intl@3.9.1

Error Log:

FAIL  src/components/wizard/Wizard.test.js
  ● Test suite failed to run
    git-repos\aletheia\node_modules\react-intl\dist\index.js: The macro imported from "@formatjs/macro" must be wrapped in "createMacro" which you can get from "babel-plugin-macros". Please refer to the documentation to see how to do this properly:
      at applyMacros (node_modules/babel-plugin-macros/dist/index.js:211:11)
      at node_modules/babel-plugin-macros/dist/index.js:153:30
          at Array.forEach (<anonymous>)
      at VariableDeclaration (node_modules/babel-plugin-macros/dist/index.js:143:55)
      at NodePath._call (node_modules/@babel/traverse/lib/path/context.js:55:20)
      at (node_modules/@babel/traverse/lib/path/context.js:42:17)
      at NodePath.visit (node_modules/@babel/traverse/lib/path/context.js:90:31)
      at TraversalContext.visitQueue (node_modules/@babel/traverse/lib/context.js:112:16)
      at TraversalContext.visitMultiple (node_modules/@babel/traverse/lib/context.js:79:17)
      at TraversalContext.visit (node_modules/@babel/traverse/lib/context.js:138:19)
Read more comments on GitHub >

github_iconTop Results From Across the Web

regex_macro false positive · Issue #2586 · rust-lang/rust-clippy ...
When defining a custom regex! macro to use the lazy_static pattern more easily, the regex_macro picks it up. This occurs with nom and...
Read more >
handling false positives regex - Stack Overflow
I have a regex responsible for matching tracking numbers for USPS. There are 2 expressions grouped together as follows:
Read more >
We would rather have a known false positive than a known false negative. As such, we will keep the dashes as they are....
Read more >
A Type System for Regular Expressions - Amazon S3
routines are recognized by the Regex Checker and cause it to be more precise in its type analysis by avoiding false positives.
Read more >
Suppression of false positive warnings - PVS-Studio
Suppressing false positives located within C/C++ macro statements (#define) and for other code fragments. It goes without saying that the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found