Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-mickey-i18n

Package Overview
Dependencies
Maintainers
4
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-mickey-i18n - npm Package Compare versions

Comparing version 1.0.2-beta.1 to 1.0.2-beta.2

39

lib/getDetector.js

@@ -10,4 +10,2 @@ "use strict";

var _lodash2 = _interopRequireDefault(require("lodash.isfunction"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -20,25 +18,22 @@

function getDetector(_ref) {
var pattern = _ref.pattern;
var detector;
var exclude = _ref.exclude;
if (pattern) {
if ((0, _lodash2.default)(pattern)) {
detector = pattern;
} else if ((0, _lodash.default)(pattern)) {
detector = function detector(text) {
return pattern.test(text);
};
} else {
detector = function detector(text) {
return pattern === text;
};
var detector = function detector(text) {
return /[\u4e00-\u9fa5]/.test(text);
};
var cache = {};
return function (text, filename) {
if (exclude && filename) {
if ((0, _lodash.default)(exclude) && exclude.test(filename)) {
return false;
}
if (Array.isArray(exclude) && exclude.some(function (regExp) {
return regExp.test(filename);
})) {
return false;
}
}
} else {
detector = function detector(text) {
return /[\u4e00-\u9fa5]/.test(text);
};
}
var cache = {};
return function (text) {
if (text === '__proto__') {

@@ -45,0 +40,0 @@ // __proto__ property could not be set, it's value of 'cache' is always {}

@@ -14,7 +14,10 @@ "use strict";

_opts$debug = opts.debug,
debug = _opts$debug === void 0 ? false : _opts$debug;
debug = _opts$debug === void 0 ? false : _opts$debug,
_opts$exclude = opts.exclude,
exclude = _opts$exclude === void 0 ? false : _opts$exclude;
return {
dest: dest,
filename: filename,
debug: debug
debug: debug,
exclude: exclude
};

@@ -21,0 +24,0 @@ }

@@ -141,3 +141,5 @@ "use strict";

function detectAndReport(path, text) {
if (detectFn(text)) {
var filename = path.hub.file.opts.filename;
if (detectFn(text, filename)) {
return report(path, text);

@@ -230,4 +232,5 @@ }

var node = path.node;
var filename = path.hub.file.opts.filename;
var exist = node.quasis.some(function (item) {
return detectFn(item.value.raw);
return detectFn(item.value.raw, filename);
});

@@ -234,0 +237,0 @@

{
"name": "babel-plugin-mickey-i18n",
"version": "1.0.2-beta.1",
"version": "1.0.2-beta.2",
"description": "Extract i18n message files and replace text with i18n-formatter.",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

@@ -112,5 +112,6 @@ # babel-plugin-mickey-i18n

- `dest` The target directory of message file. Default: `./i18n_messages`
- `filename` The target file name of message file. Default: `i18n.json`
- `debug` If `true` we will get message files of each component. Default: `false`
- `dest: string;` The target directory of message file. Default: `./i18n_messages`
- `filename: string;` The target file name of message file. Default: `i18n.json`
- `debug: boolean;` If `true` we will get message files of each component. Default: `false`
- `exclude: RegExp | RegExp[];` Prevent mickey-i18n parsing any file if its path matches the RegExp(s) provided. Default: `false`

@@ -117,0 +118,0 @@ ## Contributing

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc