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

textlint-rule-ja-space-between-half-and-full-width

Package Overview
Dependencies
Maintainers
5
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

textlint-rule-ja-space-between-half-and-full-width - npm Package Compare versions

Comparing version 2.4.1 to 2.4.2

12

lib/index.js

@@ -18,3 +18,3 @@ // LICENSE : MIT

var PunctuationRegExp = /[。、]/;
var ZenRegExpStr = '[、。]|[\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF]|[\uD840-\uD87F][\uDC00-\uDFFF]|[ぁ-んァ-ヶ]';
var ZenRegExpStr = "[、。]|[\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF]|[\uD840-\uD87F][\uDC00-\uDFFF]|[ぁ-んァ-ヶ]";
var defaultSpaceOptions = {

@@ -44,3 +44,3 @@ alphabets: false,

var parseSpaceOption = (opt, exceptPunctuation) => {
if (typeof opt === 'string') {
if (typeof opt === "string") {
assert(opt === "always" || opt === "never", "\"space\" options should be \"always\", \"never\" or an array.");

@@ -145,4 +145,4 @@ if (opt === "always") {

var btwHanAndZen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
var alphabets = opt.alphabets ? 'A-Za-z' : '';
var numbers = opt.numbers ? '0-9' : '';
var alphabets = opt.alphabets ? "A-Za-z" : "";
var numbers = opt.numbers ? "0-9" : "";
var expStr;

@@ -158,3 +158,3 @@ if (btwHanAndZen) {

var betweenZenAndHanRegExp = generateRegExp(options, false);
var errorMsg = '原則として、全角文字と半角文字の間にスペースを入れます。';
var errorMsg = "原則として、全角文字と半角文字の間にスペースを入れます。";
var betweenHanAndZen = (0, _matchIndex.matchCaptureGroupAll)(text, betweenHanAndZenRegExp);

@@ -180,3 +180,3 @@ var betweenZenAndHan = (0, _matchIndex.matchCaptureGroupAll)(text, betweenZenAndHanRegExp);

var text = getSource(node);
var noSpace = key => key === 'punctuation' ? true : !spaceOption[key];
var noSpace = key => key === "punctuation" ? true : !spaceOption[key];
if (Object.keys(spaceOption).every(noSpace)) {

@@ -183,0 +183,0 @@ noSpaceBetween(node, text);

{
"name": "textlint-rule-ja-space-between-half-and-full-width",
"version": "2.4.1",
"version": "2.4.2",
"description": "半角文字と全角文字のスペースについてのtextlintルール",

@@ -32,10 +32,10 @@ "main": "lib/index.js",

"devDependencies": {
"@textlint/regexp-string-matcher": "^2.0.2",
"textlint-scripts": "^13.3.3"
},
"dependencies": {
"@textlint/regexp-string-matcher": "^2.0.2",
"match-index": "^1.0.1",
"textlint-rule-helper": "^2.2.4"
},
"gitHead": "3dd855f120d272d06419273766ab57ecc04264c5"
"gitHead": "9d642c1d8c9b812d4bb5778e19eeb16e1faefc22"
}

@@ -90,8 +90,8 @@ # textlint-rule-ja-space-between-half-and-full-width

スペースは必須だが、`Eコーマス`だけはスペースなしを許可する。
スペースは必須だが、`Eコマース`だけはスペースなしを許可する。
text: "例外的にEコーマスはスペースなしでも通す",
text: "例外的にEコマースはスペースなしでも通す",
options: {
space: "always",
allows: ["Eコーマス"]
allows: ["Eコマース"]
}

@@ -98,0 +98,0 @@

@@ -12,7 +12,7 @@ // LICENSE : MIT

const PunctuationRegExp = /[。、]/;
const ZenRegExpStr = '[、。]|[\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF]|[\uD840-\uD87F][\uDC00-\uDFFF]|[ぁ-んァ-ヶ]';
const ZenRegExpStr = "[、。]|[\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF]|[\uD840-\uD87F][\uDC00-\uDFFF]|[ぁ-んァ-ヶ]";
const defaultSpaceOptions = {
alphabets: false,
numbers: false,
punctuation: false,
punctuation: false
};

@@ -38,5 +38,5 @@ const defaultOptions = {

const parseSpaceOption = (opt, exceptPunctuation) => {
if (typeof opt === 'string') {
if (typeof opt === "string") {
assert(opt === "always" || opt === "never", `"space" options should be "always", "never" or an array.`);
if (opt === "always") {

@@ -60,15 +60,14 @@ if (exceptPunctuation === false) {

);
const userOptions = Object.fromEntries(opt.map(key => [key, true]));
const userOptions = Object.fromEntries(opt.map((key) => [key, true]));
return { ...defaultSpaceOptions, ...userOptions };
}
return defaultSpaceOptions;
}
};
const { Syntax, RuleError, report, fixer, getSource } = context;
const helper = new RuleHelper();
const spaceOption = parseSpaceOption(options.space, options.exceptPunctuation);
const lintStyledNode = options.lintStyledNode !== undefined
? options.lintStyledNode
: defaultOptions.lintStyledNode;
const lintStyledNode =
options.lintStyledNode !== undefined ? options.lintStyledNode : defaultOptions.lintStyledNode;
const allows = options.allows !== undefined ? options.allows : defaultOptions.allows;

@@ -101,6 +100,6 @@ /**

}
return false
})
return false;
});
return !isAllowed;
}
};
};

@@ -113,6 +112,9 @@ // Never: アルファベットと全角の間はスペースを入れない

const { index } = match;
report(node, new RuleError("原則として、全角文字と半角文字の間にスペースを入れません。", {
index: match.index,
fix: fixer.replaceTextRange([index, index + 1], "")
}));
report(
node,
new RuleError("原則として、全角文字と半角文字の間にスペースを入れません。", {
index: match.index,
fix: fixer.replaceTextRange([index, index + 1], "")
})
);
};

@@ -122,3 +124,3 @@ betweenHanAndZen.filter(createFilter(text, 1)).forEach(reportMatch);

};
// Always: アルファベットと全角の間はスペースを入れる

@@ -133,5 +135,5 @@ const needSpaceBetween = (node, text, options) => {

const generateRegExp = (opt, btwHanAndZen = true) => {
const alphabets = opt.alphabets ? 'A-Za-z' : '';
const numbers = opt.numbers ? '0-9' : '';
const alphabets = opt.alphabets ? "A-Za-z" : "";
const numbers = opt.numbers ? "0-9" : "";
let expStr;

@@ -143,10 +145,10 @@ if (btwHanAndZen) {

}
return new RegExp(expStr);
};
const betweenHanAndZenRegExp = generateRegExp(options);
const betweenZenAndHanRegExp = generateRegExp(options, false);
const errorMsg = '原則として、全角文字と半角文字の間にスペースを入れます。';
const errorMsg = "原則として、全角文字と半角文字の間にスペースを入れます。";
const betweenHanAndZen = matchCaptureGroupAll(text, betweenHanAndZenRegExp);

@@ -156,6 +158,9 @@ const betweenZenAndHan = matchCaptureGroupAll(text, betweenZenAndHanRegExp);

const { index } = match;
report(node, new RuleError(errorMsg, {
index: match.index,
fix: fixer.replaceTextRange([index + 1, index + 1], " ")
}));
report(
node,
new RuleError(errorMsg, {
index: match.index,
fix: fixer.replaceTextRange([index + 1, index + 1], " ")
})
);
};

@@ -171,4 +176,4 @@ betweenHanAndZen.filter(createFilter(text, 1)).forEach(reportMatch);

const text = getSource(node);
const noSpace = (key) => key === 'punctuation' ? true : !spaceOption[key];
const noSpace = (key) => (key === "punctuation" ? true : !spaceOption[key]);
if (Object.keys(spaceOption).every(noSpace)) {

@@ -180,3 +185,3 @@ noSpaceBetween(node, text);

}
}
};
}

@@ -183,0 +188,0 @@

Sorry, the diff of this file is not supported yet

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