babel-plugin-transform-xregexp
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
'use strict'; | ||
@@ -31,2 +31,12 @@ Object.defineProperty(exports, "__esModule", { | ||
} | ||
}, | ||
MemberExpression: function MemberExpression(path) { | ||
var _path$node = path.node, | ||
object = _path$node.object, | ||
property = _path$node.property; | ||
if (object.type === 'RegExpLiteral' && property.name === 'source') { | ||
path.replaceWith(t.StringLiteral(object.pattern)); | ||
} | ||
} | ||
@@ -37,3 +47,3 @@ } | ||
var _xregexp = require("xregexp"); | ||
var _xregexp = require('xregexp'); | ||
@@ -49,8 +59,8 @@ var _xregexp2 = _interopRequireDefault(_xregexp); | ||
if (!evaluatedArgs.every(function (a) { | ||
return a.confident === true && typeof a.value === "string"; | ||
return a.confident && typeof a.value === 'string'; | ||
})) { | ||
return; | ||
} | ||
var pattern = evaluatedArgs.length >= 1 && evaluatedArgs[0].value !== "" ? evaluatedArgs[0].value : "(?:)"; | ||
var flags = evaluatedArgs.length >= 2 ? evaluatedArgs[1].value : ""; | ||
var pattern = evaluatedArgs.length >= 1 && evaluatedArgs[0].value !== '' ? evaluatedArgs[0].value : '(?:)'; | ||
var flags = evaluatedArgs.length >= 2 ? evaluatedArgs[1].value : ''; | ||
@@ -63,6 +73,6 @@ var xregexp = new _xregexp2.default(pattern, flags); | ||
function maybeReplaceWithRegExpLiteral(path, t) { | ||
if (!t.isIdentifier(path.node.callee, { name: "RegExp" })) { | ||
if (!t.isIdentifier(path.node.callee, { name: 'RegExp' })) { | ||
return; | ||
} | ||
var regExpLiteral = createRegExpLiteral(path.get("arguments"), t); | ||
var regExpLiteral = createRegExpLiteral(path.get('arguments'), t); | ||
if (regExpLiteral) { | ||
@@ -69,0 +79,0 @@ path.replaceWith(regExpLiteral); |
{ | ||
"name": "babel-plugin-transform-xregexp", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "Use XRegExp syntax in your regular expressions", | ||
@@ -24,2 +24,3 @@ "repository": "https://github.com/josephfrazier/babel-plugin-transform-xregexp", | ||
"diff": "^3.2.0", | ||
"standard": "^8.6.0", | ||
"watch": "^1.0.1" | ||
@@ -29,2 +30,4 @@ }, | ||
"build": "babel src --out-dir dist", | ||
"lint": "standard", | ||
"pretest": "npm run lint", | ||
"test": "node test", | ||
@@ -34,2 +37,7 @@ "watch": "node test --watch", | ||
}, | ||
"standard": { | ||
"ignore": [ | ||
"test/fixtures/*/*.js" | ||
] | ||
}, | ||
"keywords": [ | ||
@@ -36,0 +44,0 @@ "babel-plugin", |
@@ -13,3 +13,5 @@ # babel-plugin-transform-xregexp | ||
```sh | ||
$ npm install babel-plugin-transform-xregexp | ||
yarn add --dev babel-plugin-transform-xregexp | ||
# or | ||
npm install --save-dev babel-plugin-transform-xregexp | ||
``` | ||
@@ -16,0 +18,0 @@ |
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
3876
60
43
10