Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correct replace range #3

Merged
merged 2 commits into from
Jul 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: test
on: [push, pull_request]
jobs:
test:
name: "Test on Node.js ${{ matrix.node-version }}"
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 12, 14, 16 ]
steps:
- name: checkout
uses: actions/checkout@v2
- name: setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Install
run: yarn install
- name: Test
run: yarn test
3 changes: 0 additions & 3 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# textlint-rule-date-weekday-mismatch [![Build Status](https://travis-ci.org/textlint-rule/textlint-rule-date-weekday-mismatch.svg?branch=master)](https://travis-ci.org/textlint-rule/textlint-rule-date-weekday-mismatch) [![textlint rule](https://img.shields.io/badge/textlint-fixable-green.svg?style=social)](https://textlint.github.io/)
# textlint-rule-date-weekday-mismatch [![Actions Status: test](https://github.com/textlint-rule/textlint-rule-date-weekday-mismatch.svg?branch=master)](https://travis-ci.org/textlint-rule/textlint-rule-date-weekday-mismatch) [![textlint rule](https://img.shields.io/badge/textlint-fixable-green/workflows/test/badge.svg)](https://github.com/textlint-rule/textlint-rule-date-weekday-mismatch.svg?branch=master)](https://travis-ci.org/textlint-rule/textlint-rule-date-weekday-mismatch) [![textlint rule](https://img.shields.io/badge/textlint-fixable-green/actions?query=workflow%3A"test")

textlint rule that found mismatch between date and weekday.

Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@
},
"homepage": "https://github.com/textlint-rule/textlint-rule-date-weekday-mismatch",
"devDependencies": {
"textlint-scripts": "^3.0.0"
"textlint-scripts": "^12.0.2"
},
"keywords": [
"textlintrule"
],
"dependencies": {
"chrono-node": "^1.2.5",
"moment": "^2.17.1"
"moment": "^2.29.1",
"textlint-tester": "^12.0.2"
}
}
}
4 changes: 2 additions & 2 deletions src/textlint-rule-date-weekday-mismatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function reporter(context, config = {}) {
const expectedWeekday = $moment.format(format);
if (maybeWeekdayText !== expectedWeekday) {
const fix = fixer.replaceTextRange(
[paddingIndex, paddingIndex + expectedWeekday.length],
[paddingIndex, paddingIndex + maybeWeekdayText.length],
expectedWeekday
);
report(node, new RuleError(`${actualTextAll} mismatch weekday.\n${actualTextAll} => ${chronoDate.text}${pairStartSymbol}${expectedWeekday}${pairEndSymbol}`, {
Expand All @@ -136,4 +136,4 @@ function reporter(context, config = {}) {
module.exports = {
linter: reporter,
fixer: reporter
};
};
18 changes: 15 additions & 3 deletions test/textlint-rule-date-weekday-mismatch-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const TextLintTester = require("textlint-tester");
import TextLintTester from "textlint-tester";

const tester = new TextLintTester();
// rule
const rule = require("../src/textlint-rule-date-weekday-mismatch");
Expand Down Expand Up @@ -32,6 +33,17 @@ tester.run("rule", rule, {
}
]
},
{
text: "2021-07-02 (Thursday)",
output: "2021-07-02 (Friday)",
errors: [
{
message: "2021-07-02 (Thursday) mismatch weekday.\n2021-07-02 (Thursday) => 2021-07-02 (Friday)",
line: 1,
column: 13
}
]
},
{
text: "2017年1月1日 (火)",
output: "2017年1月1日 (日)",
Expand Down Expand Up @@ -110,6 +122,6 @@ tester.run("rule", rule, {
}
]
},

]
});
});
Loading