babel-plugin-jsx-remove-qa
Advanced tools
Comparing version 0.2.4 to 0.3.0
27
index.js
@@ -8,9 +8,12 @@ const RemoveQAClasses = ({ types: t }) => { | ||
let attributeIdentifiers = 'className'; | ||
let attributeIdentifiers = ['className']; | ||
if (state.opts && state.opts.attributes) { | ||
attributeIdentifiers = [attributeIdentifiers, ...state.opts.attributes]; | ||
attributeIdentifiers = [ | ||
...attributeIdentifiers, | ||
...state.opts.attributes | ||
]; | ||
} | ||
const classNameRegEx = /\s?qa-([-\w])*/g; | ||
const classNameRegEx = /(^qa-([-\w])*|\sqa-([-\w])*)/g; | ||
let newClassNameValue; | ||
@@ -36,10 +39,18 @@ | ||
return t.jSXAttribute( | ||
t.jSXIdentifier(attr.name.name), | ||
t.stringLiteral(newClassNameValue) | ||
); | ||
if (newClassNameValue.length) { | ||
return t.jSXAttribute( | ||
t.jSXIdentifier(attr.name.name), | ||
t.stringLiteral(newClassNameValue) | ||
); | ||
} | ||
}; | ||
const attrs = path.node.attributes.map(replaceQAClassName); | ||
const isDefined = value => typeof value !== 'undefined'; | ||
const attrs = ( | ||
path.node.attributes | ||
.map(replaceQAClassName) | ||
.filter(isDefined) | ||
); | ||
const node = t.jSXOpeningElement( | ||
@@ -46,0 +57,0 @@ path.node.name, |
{ | ||
"name": "babel-plugin-jsx-remove-qa", | ||
"version": "0.2.4", | ||
"version": "0.3.0", | ||
"description": "babel plugin to remove-qa-classes", | ||
@@ -14,3 +14,5 @@ "main": "dist/index.js", | ||
"strip", | ||
"className" | ||
"className", | ||
"jsx", | ||
"react" | ||
], | ||
@@ -20,3 +22,4 @@ "repository": "git://github.com/coderas/babel-plugin-jsx-remove-qa.git", | ||
"build": "babel -d dist index.js", | ||
"postinstall": "babel -d dist index.js" | ||
"postinstall": "babel -d dist index.js", | ||
"test": "mocha \"**/*.spec.js\" --compilers js:babel-core/register --reporter spec" | ||
}, | ||
@@ -32,4 +35,7 @@ "author": "Rich Gorman", | ||
"babel-plugin-transform-react-jsx": "^6.8.0", | ||
"babel-preset-es2015": "^6.16.0" | ||
"babel-preset-es2015": "^6.16.0", | ||
"chai": "^3.5.0", | ||
"mocha": "^3.1.2", | ||
"uglify-js": "^2.7.3" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
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
7653
6
135
7