Skip to content

Commit

Permalink
fix(deps): update to analyze-desumasu-dearu@5 (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
azu authored Apr 24, 2021
1 parent 919a8aa commit 43b6833
Show file tree
Hide file tree
Showing 11 changed files with 1,694 additions and 1,543 deletions.
2 changes: 2 additions & 0 deletions .githook/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
npx --no-install lint-staged
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]
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
5 changes: 5 additions & 0 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"require": [
"textlint-scripts/register"
]
}
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-no-mix-dearu-desumasu [![Build Status](https://travis-ci.org/azu/textlint-rule-no-mix-dearu-desumasu.svg?branch=master)](https://travis-ci.org/azu/textlint-rule-no-mix-dearu-desumasu) [![Gitter](https://badges.gitter.im/textlint-ja/textlint-ja.svg)](https://gitter.im/textlint-ja/textlint-ja?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
# textlint-rule-no-mix-dearu-desumasu [![Actions Status: test](https://github.com/azu/textlint-rule-no-mix-dearu-desumasu/workflows/test/badge.svg)](https://github.com/azu/textlint-rule-no-mix-dearu-desumasu/actions?query=workflow%3A"test")

敬体(ですます調)と常体(である調)の混在をチェックする[textlint](http://textlint.github.io/ "textlint")ルール。

Expand Down
24 changes: 9 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"watch": "textlint-scripts build --watch",
"prepublish": "npm run --if-present build",
"test": "textlint-scripts test",
"prettier": "prettier --write \"{src,test}/*.{js,jsx,ts,tsx,css}\""
"prettier": "prettier --write \"**/*.{js,jsx,ts,tsx,css}\"",
"prepare": "git config --local core.hooksPath .githook"
},
"keywords": [
"japanese",
Expand All @@ -35,31 +36,24 @@
"textlintrule"
],
"devDependencies": {
"husky": "^4.2.5",
"lint-staged": "^10.1.7",
"prettier": "^2.0.5",
"lint-staged": "^10.5.4",
"prettier": "^2.2.1",
"textlint-scripts": "^3.0.0"
},
"dependencies": {
"analyze-desumasu-dearu": "^4.0.0",
"analyze-desumasu-dearu": "^5.0.0",
"textlint-rule-helper": "^2.0.0",
"unist-util-visit": "^2.0.2"
"unist-util-visit": "^3.0.0"
},
"prettier": {
"singleQuote": false,
"printWidth": 120,
"tabWidth": 4
"tabWidth": 4,
"trailingComma": "none"
},
"lint-staged": {
"*.{js,jsx,ts,tsx,css}": [
"prettier --write",
"git add"
"prettier --write"
]
},
"husky": {
"hooks": {
"post-commit": "git reset",
"pre-commit": "lint-staged"
}
}
}
8 changes: 4 additions & 4 deletions src/MixedChecker.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default class MixedChecker {
check(node, text) {
this._queue = this._queue.then(() => {
const analyzeOptions = {
ignoreConjunction: !this.options.isStrict,
ignoreConjunction: !this.options.isStrict
};
return analyze(text, analyzeOptions).then((results) => {
const retDearu = results.filter(isDearu);
Expand All @@ -34,14 +34,14 @@ export default class MixedChecker {
this.dearuCount = dearuCount;
this.dearuHitList.push({
node,
matches: retDearu,
matches: retDearu
});
}
if (this.desumasuCount !== desumasuCount) {
this.desumasuCount = desumasuCount;
this.desumasuHitList.push({
node,
matches: retDesumasu,
matches: retDesumasu
});
}
});
Expand Down Expand Up @@ -73,7 +73,7 @@ export default class MixedChecker {
}

const ruleError = new RuleError(this.outputMessage(token), {
index: token.index,
index: token.index
});
report(lastHitNode, ruleError);
});
Expand Down
14 changes: 7 additions & 7 deletions src/no-mix-dearu-desumasu.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import HeaderMixedChecker from "./HeaderMixedChecker";
import ListMixedChecker from "./ListMixedChecker";
export const PreferTypes = {
DESUMASU: "ですます",
DEARU: "である",
DEARU: "である"
};
// デフォルトでその項目で多く出現している方を優先します。
// 明示的にpreferの設定した場合は、そちらを優先した内容をエラーとして表示します。
Expand All @@ -15,7 +15,7 @@ const defaultOptions = {
preferInBody: "", // "である" or "ですます"
preferInList: "", // "である" or "ですます"
// 文末以外でも、敬体(ですます調)と常体(である調)を厳しくチェックするかどうか
strict: false,
strict: false
};

module.exports = function noMixedDearuDesumasu(context, options = defaultOptions) {
Expand All @@ -26,17 +26,17 @@ module.exports = function noMixedDearuDesumasu(context, options = defaultOptions
const bodyChecker = new BodyMixedChecker(context, {
preferDesumasu: options.preferInBody === PreferTypes.DESUMASU,
preferDearu: options.preferInBody === PreferTypes.DEARU,
isStrict,
isStrict
});
const headerChecker = new HeaderMixedChecker(context, {
preferDesumasu: options.preferInHeader === PreferTypes.DESUMASU,
preferDearu: options.preferInHeader === PreferTypes.DEARU,
isStrict,
isStrict
});
const listChecker = new ListMixedChecker(context, {
preferDesumasu: options.preferInList === PreferTypes.DESUMASU,
preferDearu: options.preferInList === PreferTypes.DEARU,
isStrict,
isStrict
});
return {
// 見出し
Expand Down Expand Up @@ -70,8 +70,8 @@ module.exports = function noMixedDearuDesumasu(context, options = defaultOptions
return Promise.all([
bodyChecker.checkout(ignoreManager),
headerChecker.checkout(ignoreManager),
listChecker.checkout(ignoreManager),
listChecker.checkout(ignoreManager)
]);
},
}
};
};
1 change: 0 additions & 1 deletion test/mocha.opts

This file was deleted.

Loading

0 comments on commit 43b6833

Please sign in to comment.