@textlint/utils
Advanced tools
Comparing version 12.0.0-beta.0 to 12.0.0-beta.1
@@ -5,20 +5,20 @@ "use strict"; | ||
// @org/preset/@org/rule | ||
var patternOrgXOrg = /^(@.*?\/.*?)\/(@.*?\/.*?)$/; | ||
const patternOrgXOrg = /^(@.*?\/.*?)\/(@.*?\/.*?)$/; | ||
// @org/preset/rule | ||
var patternOrgXRule = /^(@.*?\/.*?)\/(.*?)$/; | ||
const patternOrgXRule = /^(@.*?\/.*?)\/(.*?)$/; | ||
// preset/@org/rule | ||
var patternPresetXOrg = /^(.*?)\/(@.*?)$/; | ||
const patternPresetXOrg = /^(.*?)\/(@.*?)$/; | ||
// preset/rule | ||
var patternPresetXRule = /^([^@].*?)\/(.*?)$/; | ||
const patternPresetXRule = /^([^@].*?)\/(.*?)$/; | ||
/** | ||
* pattern list of key path | ||
*/ | ||
var patternList = [patternOrgXOrg, patternOrgXRule, patternPresetXOrg, patternPresetXRule]; | ||
const patternList = [patternOrgXOrg, patternOrgXRule, patternPresetXOrg, patternPresetXRule]; | ||
/** | ||
* split "preset/rule" string to {preset, rule} | ||
*/ | ||
var splitKeyToPresetSubRule = function (name) { | ||
for (var i = 0; i < patternList.length; i++) { | ||
var pattern = patternList[i]; | ||
var result = name.match(pattern); | ||
const splitKeyToPresetSubRule = (name) => { | ||
for (let i = 0; i < patternList.length; i++) { | ||
const pattern = patternList[i]; | ||
const result = name.match(pattern); | ||
if (!result) { | ||
@@ -40,11 +40,11 @@ continue; | ||
*/ | ||
var removePrefixFromPackageName = function (prefixList, packageName) { | ||
for (var i = 0; i < prefixList.length; i++) { | ||
var prefix = prefixList[i]; | ||
const removePrefixFromPackageName = (prefixList, packageName) => { | ||
for (let i = 0; i < prefixList.length; i++) { | ||
const prefix = prefixList[i]; | ||
// @scope/name -> @scope/name | ||
// @scope/textlint-rule-name -> @scope/name | ||
if (packageName.charAt(0) === "@") { | ||
var _a = packageName.split("/"), namespace = _a[0], name_1 = _a[1]; | ||
if (name_1.startsWith(prefix)) { | ||
return namespace + "/" + name_1.slice(prefix.length); | ||
const [namespace, name] = packageName.split("/"); | ||
if (name.startsWith(prefix)) { | ||
return `${namespace}/${name.slice(prefix.length)}`; | ||
} | ||
@@ -51,0 +51,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.normalizeTextlintPluginKey = exports.normalizeTextlintRulePresetKey = exports.normalizeTextlintFilterRuleKey = exports.normalizeTextlintRuleKey = exports.normalizeTextlintPresetSubRuleKey = exports.normalizeTextlintKeyPath = void 0; | ||
var TextlintPackagePrefix_1 = require("./TextlintPackagePrefix"); | ||
var KeyPathUtil_1 = require("./KeyPathUtil"); | ||
const TextlintPackagePrefix_1 = require("./TextlintPackagePrefix"); | ||
const KeyPathUtil_1 = require("./KeyPathUtil"); | ||
/** | ||
@@ -15,8 +15,8 @@ * normalize `keyPath` that is specific path for rule | ||
*/ | ||
var normalizeTextlintKeyPath = function (keyPath) { | ||
var _a = KeyPathUtil_1.splitKeyToPresetSubRule(keyPath), preset = _a.preset, rule = _a.rule; | ||
const normalizeTextlintKeyPath = (keyPath) => { | ||
const { preset, rule } = KeyPathUtil_1.splitKeyToPresetSubRule(keyPath); | ||
if (!preset) { | ||
return exports.normalizeTextlintRuleKey(rule); | ||
} | ||
return exports.normalizeTextlintRulePresetKey(preset) + "/" + exports.normalizeTextlintRuleKey(rule); | ||
return `${exports.normalizeTextlintRulePresetKey(preset)}/${exports.normalizeTextlintRuleKey(rule)}`; | ||
}; | ||
@@ -27,5 +27,5 @@ exports.normalizeTextlintKeyPath = normalizeTextlintKeyPath; | ||
*/ | ||
var normalizeTextlintPresetSubRuleKey = function (names) { | ||
var preset = names.preset, rule = names.rule; | ||
return exports.normalizeTextlintRulePresetKey(preset) + "/" + exports.normalizeTextlintRuleKey(rule); | ||
const normalizeTextlintPresetSubRuleKey = (names) => { | ||
const { preset, rule } = names; | ||
return `${exports.normalizeTextlintRulePresetKey(preset)}/${exports.normalizeTextlintRuleKey(rule)}`; | ||
}; | ||
@@ -37,3 +37,3 @@ exports.normalizeTextlintPresetSubRuleKey = normalizeTextlintPresetSubRuleKey; | ||
*/ | ||
var normalizeTextlintRuleKey = function (name) { | ||
const normalizeTextlintRuleKey = (name) => { | ||
return KeyPathUtil_1.removePrefixFromPackageName([TextlintPackagePrefix_1.TextlintPackageNamePrefix.rule], name); | ||
@@ -46,3 +46,3 @@ }; | ||
*/ | ||
var normalizeTextlintFilterRuleKey = function (name) { | ||
const normalizeTextlintFilterRuleKey = (name) => { | ||
return KeyPathUtil_1.removePrefixFromPackageName([TextlintPackagePrefix_1.TextlintPackageNamePrefix.filterRule], name); | ||
@@ -55,3 +55,3 @@ }; | ||
*/ | ||
var normalizeTextlintRulePresetKey = function (name) { | ||
const normalizeTextlintRulePresetKey = (name) => { | ||
// "preset-<name>" and "textlint-rule-preset-" | ||
@@ -65,3 +65,3 @@ return KeyPathUtil_1.removePrefixFromPackageName([TextlintPackagePrefix_1.TextlintPackageNamePrefix.rulePreset, "preset-"], name); | ||
*/ | ||
var normalizeTextlintPluginKey = function (name) { | ||
const normalizeTextlintPluginKey = (name) => { | ||
return KeyPathUtil_1.removePrefixFromPackageName([TextlintPackagePrefix_1.TextlintPackageNamePrefix.plugin], name); | ||
@@ -68,0 +68,0 @@ }; |
// @org/preset/@org/rule | ||
var patternOrgXOrg = /^(@.*?\/.*?)\/(@.*?\/.*?)$/; | ||
const patternOrgXOrg = /^(@.*?\/.*?)\/(@.*?\/.*?)$/; | ||
// @org/preset/rule | ||
var patternOrgXRule = /^(@.*?\/.*?)\/(.*?)$/; | ||
const patternOrgXRule = /^(@.*?\/.*?)\/(.*?)$/; | ||
// preset/@org/rule | ||
var patternPresetXOrg = /^(.*?)\/(@.*?)$/; | ||
const patternPresetXOrg = /^(.*?)\/(@.*?)$/; | ||
// preset/rule | ||
var patternPresetXRule = /^([^@].*?)\/(.*?)$/; | ||
const patternPresetXRule = /^([^@].*?)\/(.*?)$/; | ||
/** | ||
* pattern list of key path | ||
*/ | ||
var patternList = [patternOrgXOrg, patternOrgXRule, patternPresetXOrg, patternPresetXRule]; | ||
const patternList = [patternOrgXOrg, patternOrgXRule, patternPresetXOrg, patternPresetXRule]; | ||
/** | ||
* split "preset/rule" string to {preset, rule} | ||
*/ | ||
export var splitKeyToPresetSubRule = function (name) { | ||
for (var i = 0; i < patternList.length; i++) { | ||
var pattern = patternList[i]; | ||
var result = name.match(pattern); | ||
export const splitKeyToPresetSubRule = (name) => { | ||
for (let i = 0; i < patternList.length; i++) { | ||
const pattern = patternList[i]; | ||
const result = name.match(pattern); | ||
if (!result) { | ||
@@ -35,11 +35,11 @@ continue; | ||
*/ | ||
export var removePrefixFromPackageName = function (prefixList, packageName) { | ||
for (var i = 0; i < prefixList.length; i++) { | ||
var prefix = prefixList[i]; | ||
export const removePrefixFromPackageName = (prefixList, packageName) => { | ||
for (let i = 0; i < prefixList.length; i++) { | ||
const prefix = prefixList[i]; | ||
// @scope/name -> @scope/name | ||
// @scope/textlint-rule-name -> @scope/name | ||
if (packageName.charAt(0) === "@") { | ||
var _a = packageName.split("/"), namespace = _a[0], name_1 = _a[1]; | ||
if (name_1.startsWith(prefix)) { | ||
return namespace + "/" + name_1.slice(prefix.length); | ||
const [namespace, name] = packageName.split("/"); | ||
if (name.startsWith(prefix)) { | ||
return `${namespace}/${name.slice(prefix.length)}`; | ||
} | ||
@@ -46,0 +46,0 @@ } |
@@ -12,8 +12,8 @@ import { TextlintPackageNamePrefix } from "./TextlintPackagePrefix"; | ||
*/ | ||
export var normalizeTextlintKeyPath = function (keyPath) { | ||
var _a = splitKeyToPresetSubRule(keyPath), preset = _a.preset, rule = _a.rule; | ||
export const normalizeTextlintKeyPath = (keyPath) => { | ||
const { preset, rule } = splitKeyToPresetSubRule(keyPath); | ||
if (!preset) { | ||
return normalizeTextlintRuleKey(rule); | ||
} | ||
return normalizeTextlintRulePresetKey(preset) + "/" + normalizeTextlintRuleKey(rule); | ||
return `${normalizeTextlintRulePresetKey(preset)}/${normalizeTextlintRuleKey(rule)}`; | ||
}; | ||
@@ -23,5 +23,5 @@ /** | ||
*/ | ||
export var normalizeTextlintPresetSubRuleKey = function (names) { | ||
var preset = names.preset, rule = names.rule; | ||
return normalizeTextlintRulePresetKey(preset) + "/" + normalizeTextlintRuleKey(rule); | ||
export const normalizeTextlintPresetSubRuleKey = (names) => { | ||
const { preset, rule } = names; | ||
return `${normalizeTextlintRulePresetKey(preset)}/${normalizeTextlintRuleKey(rule)}`; | ||
}; | ||
@@ -32,3 +32,3 @@ /** | ||
*/ | ||
export var normalizeTextlintRuleKey = function (name) { | ||
export const normalizeTextlintRuleKey = (name) => { | ||
return removePrefixFromPackageName([TextlintPackageNamePrefix.rule], name); | ||
@@ -40,3 +40,3 @@ }; | ||
*/ | ||
export var normalizeTextlintFilterRuleKey = function (name) { | ||
export const normalizeTextlintFilterRuleKey = (name) => { | ||
return removePrefixFromPackageName([TextlintPackageNamePrefix.filterRule], name); | ||
@@ -48,3 +48,3 @@ }; | ||
*/ | ||
export var normalizeTextlintRulePresetKey = function (name) { | ||
export const normalizeTextlintRulePresetKey = (name) => { | ||
// "preset-<name>" and "textlint-rule-preset-" | ||
@@ -57,5 +57,5 @@ return removePrefixFromPackageName([TextlintPackageNamePrefix.rulePreset, "preset-"], name); | ||
*/ | ||
export var normalizeTextlintPluginKey = function (name) { | ||
export const normalizeTextlintPluginKey = (name) => { | ||
return removePrefixFromPackageName([TextlintPackageNamePrefix.plugin], name); | ||
}; | ||
//# sourceMappingURL=TextlintKeyPath.js.map |
@@ -7,3 +7,3 @@ /** | ||
*/ | ||
export var TextlintPackageNamePrefix = { | ||
export const TextlintPackageNamePrefix = { | ||
config: "textlint-config-", | ||
@@ -10,0 +10,0 @@ rule: "textlint-rule-", |
{ | ||
"name": "@textlint/utils", | ||
"version": "12.0.0-beta.0", | ||
"version": "12.0.0-beta.1", | ||
"description": "textlint internal utils.", | ||
@@ -59,3 +59,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "1e0d0d7f628be0bfce04b6cd36fcc8390ca43096" | ||
"gitHead": "2856b387cfb0a151655a809e8253b242e7b90725" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
140693
0