Skip to content

Commit 64959db

Browse files
committed
refactor: convert addYearToDateText to arrow function and improve readability
1 parent 0a407bb commit 64959db

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/textlint-rule-date-weekday-mismatch.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,14 @@ const detectLang = (tags, preferLang) => {
5050
const selectedLang = targetLangs[0];
5151
return selectedLang[1];
5252
};
53-
5453
/**
5554
* Add current year to date string if missing.
5655
* @param {string} dateText
5756
* @param {number} year
5857
* @param {string} lang
5958
* @returns {string}
6059
*/
61-
function addYearToDateText(dateText, year, lang) {
60+
const addYearToDateText = (dateText, year, lang) => {
6261
// Japanese: 4月23日(月) → 2024年4月23日(月)
6362
if (lang === "ja") {
6463
return `${year}${dateText}`;
@@ -102,7 +101,9 @@ function reporter(context, config = {}) {
102101
) {
103102
// Detect language for the date string
104103
const lang = detectLang(Object.keys(chronoDate.tags), preferLang);
105-
if (!lang) return;
104+
if (!lang) {
105+
return;
106+
}
106107
// Re-parse the text with the year added
107108
const newText = addYearToDateText(chronoDate.text, currentYear, lang);
108109
const reparsed = chrono.parse(newText, undefined, {forwardDate: true});

0 commit comments

Comments
 (0)