@fullstory/babel-plugin-annotate-react
Advanced tools
Comparing version 2.2.0 to 2.2.1
# Changelog | ||
## 2.2.1 | ||
- Added a blocklist for known-incompatible node modules. | ||
## 2.2.0 | ||
@@ -4,0 +8,0 @@ |
73
index.js
@@ -10,5 +10,43 @@ const webComponentName = 'data-component'; | ||
const nativeOptionName = 'native'; | ||
const annotateFragmentsOptionName = 'annotate-fragments' | ||
const ignoreComponentsOptionName = 'ignoreComponents' | ||
const annotateFragmentsOptionName = 'annotate-fragments'; | ||
const ignoreComponentsOptionName = 'ignoreComponents'; | ||
const knownIncompatiblePlugins = [ | ||
// This module might be causing an issue preventing clicks. For safety, we won't run on this module. | ||
'react-native-testfairy', | ||
// This module checks for unexpected property keys and throws an exception. | ||
'@react-navigation', | ||
// The victory* modules use `dataComponent` and we get a collision. | ||
'victory', | ||
'victory-area', | ||
'victory-axis', | ||
'victory-bar', | ||
'victory-box-plot', | ||
'victory-brush-container', | ||
'victory-brush-line', | ||
'victory-candlestick', | ||
'victory-canvas', | ||
'victory-chart', | ||
'victory-core', | ||
'victory-create-container', | ||
'victory-cursor-container', | ||
'victory-errorbar', | ||
'victory-group', | ||
'victory-histogram', | ||
'victory-legend', | ||
'victory-line', | ||
'victory-native', | ||
'victory-pie', | ||
'victory-polar-axis', | ||
'victory-scatter', | ||
'victory-selection-container', | ||
'victory-shared-events', | ||
'victory-stack', | ||
'victory-tooltip', | ||
'victory-vendor', | ||
'victory-voronoi', | ||
'victory-voronoi-container', | ||
'victory-zoom-container', | ||
]; | ||
module.exports = function({ types: t }) { | ||
@@ -22,2 +60,3 @@ return { | ||
if (!path.node.id || !path.node.id.name) return | ||
if (isKnownIncompatiblePluginFromState(state)) return | ||
functionBodyPushAttributes( | ||
@@ -35,2 +74,3 @@ state.opts[annotateFragmentsOptionName] === true, | ||
if (!path.parent.id || !path.parent.id.name) return | ||
if (isKnownIncompatiblePluginFromState(state)) return | ||
functionBodyPushAttributes( | ||
@@ -56,2 +96,3 @@ state.opts[annotateFragmentsOptionName] === true, | ||
if (!render || !render.traverse) return | ||
if (isKnownIncompatiblePluginFromState(state)) return | ||
@@ -80,3 +121,3 @@ const ignoreComponentsFromOption = this.ignoreComponentsFromOption; | ||
function sourceFileNameFromState(state) { | ||
function fullSourceFileNameFromState(state) { | ||
const name = state.file.opts.parserOpts.sourceFileName | ||
@@ -86,2 +127,11 @@ if (typeof name !== 'string') { | ||
} | ||
return name | ||
} | ||
function sourceFileNameFromState(state) { | ||
const name = fullSourceFileNameFromState(state) | ||
if (name === undefined) { | ||
return undefined | ||
} | ||
if (name.indexOf('/') !== -1) { | ||
@@ -96,2 +146,19 @@ return name.split('/').pop() | ||
function isKnownIncompatiblePluginFromState(state) { | ||
const fullSourceFileName = fullSourceFileNameFromState(state) | ||
if (fullSourceFileName == undefined) { | ||
return false | ||
} | ||
for (let i = 0; i < knownIncompatiblePlugins.length; i += 1) { | ||
let pluginName = knownIncompatiblePlugins[i]; | ||
if (fullSourceFileName.includes("/node_modules/" + pluginName + "/") || | ||
fullSourceFileName.includes("\\node_modules\\" + pluginName + "\\")) { | ||
return true | ||
} | ||
} | ||
return false | ||
} | ||
function attributeNamesFromState(state) { | ||
@@ -98,0 +165,0 @@ if(state.opts[nativeOptionName] === true) { |
{ | ||
"name": "@fullstory/babel-plugin-annotate-react", | ||
"version": "2.2.0", | ||
"version": "2.2.1", | ||
"description": "A Babel plugin that annotates React components, making them easier to target with FullStory search", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16751
302