-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix to work some rules use
?=
RegExp (#12)
* test: add test for ?= RegExp * fix(prh): fix to work rule that using `?=` RegExp * fix: fix test case * test: add more test case * refactor: remove unused function
- Loading branch information
Showing
5 changed files
with
329 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
version: 1 | ||
|
||
rules: | ||
|
||
# 大文字小文字全角半角の統一 | ||
- expected: Cookie | ||
# 以下と等価 正規表現には強制でgフラグが付く | ||
# - expected: Cookie | ||
# pattern: "/[CcCc][OoOo][OoOo][KkKk][IiIi][EeEe]/g" | ||
# options: | ||
# wordBoundary: false | ||
# specs: [] | ||
|
||
# 変換結果についてテストも書ける | ||
- expected: jQuery | ||
specs: | ||
- from: jquery | ||
to: jQuery | ||
- from: JQUERY | ||
to: jQuery | ||
|
||
# 変換結果が期待通りではなかった場合、ルールのロードに失敗する つまり、ルールのテストが書ける | ||
# - expected: JavaScript | ||
# specs: | ||
# - from: JAVASCRIPT | ||
# to: JavaScprit # この場合はテスト側が間違ってる! | ||
# Error: JavaScript spec failed. "JAVASCRIPT", expected "JavaScprit", but got "JavaScript", /[JjJj][AaAa][VvVv][AaAa][SsSs][CcCc][RrRr][IiIi][PpPp][TtTt]/g | ||
|
||
# 表現の統一を図る | ||
- expected: デフォルト | ||
pattern: ディフォルト | ||
|
||
# patternは複数記述可能 patterns としてもOK | ||
- expected: ハードウェア | ||
patterns: | ||
- ハードウエアー # 正規表現に変換する都合上、より長いものを先に書いたほうがよい | ||
- ハードウェアー | ||
- ハードウエア | ||
|
||
# patternには正規表現が利用可能 | ||
- expected: ($1) | ||
pattern: /\(([^)]+)\)/ | ||
specs: | ||
# 半角括弧を全角括弧へ | ||
- from: (そのとおり) | ||
to: (そのとおり) | ||
|
||
# 否定戻り先読みが欲しいがJSにはない… regexpMustEmptyで、特定のキャプチャグループが空であることを指定して代用とする | ||
- expected: ソフトウェア | ||
pattern: /(日経)?ソフトウエア/ | ||
regexpMustEmpty: $1 | ||
specs: | ||
# 普通に変換 | ||
- from: 広義のソフトウエア | ||
to: 広義のソフトウェア | ||
# 日経ソフトウエア(書名)は変換しない | ||
- from: 日経ソフトウエア | ||
to: 日経ソフトウエア | ||
|
||
# 長音の統一には否定後読みを活用する そうしないと サーバー が サーバーー にされてしまったりする | ||
- expected: サーバー | ||
pattern: /サーバ(?!ー)/ | ||
specs: | ||
- from: サーバ | ||
to: サーバー | ||
|
||
# 単語境界の区別 | ||
- expected: js | ||
# pattern: "/\b[JjJj][SsSs]\b/g" # と等価 \b が前後に付与される | ||
options: | ||
wordBoundary: true | ||
specs: | ||
- from: foo JS bar | ||
to: foo js bar | ||
- from: foo altJS bar | ||
to: foo altJS bar | ||
# 日本語+単語境界の仕様は自分で調べてね…! | ||
- from: 今日もJS祭り | ||
to: 今日もjs祭り |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
version: 1 | ||
|
||
rules: | ||
- prh: 「行う」「行なう」は開く。 | ||
expected: おこな | ||
pattern: /(おこな|行な?)(?=[わいっうえお])/ | ||
specs: | ||
- from: 行わない | ||
to: おこなわない | ||
- from: 行います | ||
to: おこないます | ||
- from: 行うとき | ||
to: おこなうとき | ||
- from: 行えば | ||
to: おこなえば | ||
- from: 行なう | ||
to: おこなう | ||
- from: おこなう | ||
to: おこなう | ||
# チェックされなくてよい部分 | ||
- from: 行く | ||
to: 行く |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters