Skip to content

Commit

Permalink
Merge pull request #1 from textlint-ja/migrate-textlint-scripts
Browse files Browse the repository at this point in the history
refactor(rule): migrate textlint-scripts
  • Loading branch information
azu authored Oct 20, 2019
2 parents 12fe5d2 + 61cb306 commit 6de41bb
Show file tree
Hide file tree
Showing 8 changed files with 4,144 additions and 41 deletions.
13 changes: 0 additions & 13 deletions .babelrc

This file was deleted.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# textlint-rule-no-nfd [![Build Status](https://travis-ci.org/azu/textlint-rule-no-nfd.svg?branch=master)](https://travis-ci.org/azu/textlint-rule-no-nfd) [![textlint rule](https://img.shields.io/badge/textlint-fixable-green.svg?style=social)](https://textlint.github.io/)
# textlint-rule-no-nfd [![Build Status](https://travis-ci.org/textlint-ja/textlint-rule-no-nfd.svg?branch=master)](https://travis-ci.org/textlint-ja/textlint-rule-no-nfd) [![textlint rule](https://img.shields.io/badge/textlint-fixable-green.svg?style=social)](https://textlint.github.io/)

[textlint](https://textlint.github.io/ "textlint") rule that disallow to use NFD like UTF8-MAC 濁点.

Expand Down Expand Up @@ -56,7 +56,7 @@ textlint --rule no-nfd README.md

## Changelog

See [Releases page](https://github.com/azu/textlint-rule-no-nfd/releases).
See [Releases page](https://github.com/textlint-ja/textlint-rule-no-nfd/releases).

## Running tests

Expand Down Expand Up @@ -102,7 +102,7 @@ via [Unicodeの特殊な文字 “結合文字列” | ものかの](http://tama
## Contributing

Pull requests and stars are always welcome.
For bugs and feature requests, [please create an issue](https://github.com/azu/textlint-rule-no-nfd/issues).
For bugs and feature requests, [please create an issue](https://github.com/textlint-ja/textlint-rule-no-nfd/issues).

1. Fork it!
2. Create your feature branch: `git checkout -b my-new-feature`
Expand Down
28 changes: 13 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
"name": "textlint-rule-no-nfd",
"repository": {
"type": "git",
"url": "https://github.com/azu/textlint-rule-no-nfd.git"
"url": "https://github.com/textlint-ja/textlint-rule-no-nfd.git"
},
"author": "azu",
"email": "[email protected]",
"homepage": "https://github.com/azu/textlint-rule-no-nfd",
"homepage": "https://github.com/textlint-ja/textlint-rule-no-nfd",
"license": "MIT",
"bugs": {
"url": "https://github.com/azu/textlint-rule-no-nfd/issues"
"url": "https://github.com/textlint-ja/textlint-rule-no-nfd/issues"
},
"files": [
"src/",
Expand All @@ -22,27 +22,25 @@
"test": "test"
},
"scripts": {
"test": "mocha test/",
"build": "NODE_ENV=production babel src --out-dir lib --source-maps",
"watch": "babel src --out-dir lib --watch --source-maps",
"test": "textlint-scripts test",
"build": "textlint-scripts build",
"watch": "textlint-scripts build --watch",
"prepublish": "npm run --if-present build"
},
"keywords": [
"textlint"
],
"devDependencies": {
"babel-cli": "^6.8.0",
"babel-preset-es2015": "^6.6.0",
"babel-preset-jsdoc-to-assert": "^1.0.1",
"babel-preset-power-assert": "^1.0.0",
"babel-register": "^6.8.0",
"mocha": "^2.4.5",
"@textlint/types": "^1.2.2",
"@types/node": "^12.11.1",
"power-assert": "^1.3.1",
"textlint-tester": "^1.2.0"
"textlint-scripts": "^3.0.0",
"ts-node": "^8.4.1",
"typescript": "^3.6.4"
},
"dependencies": {
"match-index": "^1.0.1",
"textlint-rule-helper": "^1.1.5",
"match-index": "^1.0.3",
"textlint-rule-helper": "^2.1.1",
"unorm": "^1.4.1"
}
}
14 changes: 9 additions & 5 deletions src/textlint-rule-no-nfd.js → src/textlint-rule-no-nfd.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
// LICENSE : MIT
"use strict";
import {RuleHelper} from "textlint-rule-helper";
import {matchCaptureGroupAll} from "match-index"
import {RuleHelper} from "textlint-rule-helper";
import {TextlintRuleReporter} from "@textlint/types";

const unorm = require("unorm");
function reporter(context) {

const reporter: TextlintRuleReporter = function (context) {
const {Syntax, RuleError, report, fixer, getSource} = context;
const helper = new RuleHelper(context);
return {
[Syntax.Str](node){
[Syntax.Str](node) {
if (helper.isChildNode(node, [Syntax.Link, Syntax.Image, Syntax.BlockQuote, Syntax.Emphasis])) {
return;
}
Expand All @@ -28,8 +31,9 @@ function reporter(context) {
});
}
}
}
};

module.exports = {
linter: reporter,
fixer: reporter
};
};
1 change: 0 additions & 1 deletion test/mocha.opts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const TextLintTester = require("textlint-tester");
const tester = new TextLintTester();
// rule
import rule from "../src/textlint-rule-no-nfd";
const rule = require("../src/textlint-rule-no-nfd");
// ruleName, rule, { valid, invalid }
tester.run("no-nfd", rule, {
valid: [
Expand Down Expand Up @@ -35,7 +35,7 @@ tester.run("no-nfd", rule, {
},
{
text: "エンシ\u3099ン",
output:"エンジン",
output: "エンジン",
errors: [
{
message: `Disallow to use NFD(well-known as UTF8-MAC 濁点): "シ\u3099" => "ジ"`,
Expand All @@ -47,7 +47,7 @@ tester.run("no-nfd", rule, {

{
text: "エンシ゛ン",
output:"エンジン",
output: "エンジン",
errors: [
{
message: `Disallow to use NFD(well-known as UTF8-MAC 濁点): "シ\u309b" => "ジ"`,
Expand All @@ -57,4 +57,4 @@ tester.run("no-nfd", rule, {
]
}
]
});
});
21 changes: 21 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"compilerOptions": {
/* Basic Options */
"module": "commonjs",
"moduleResolution": "node",
"esModuleInterop": true,
"noEmit": true,
"target": "es2015",
/* Strict Type-Checking Options */
"strict": true,
/* Additional Checks */
/* Report errors on unused locals. */
"noUnusedLocals": true,
/* Report errors on unused parameters. */
"noUnusedParameters": true,
/* Report error when not all code paths in function return a value. */
"noImplicitReturns": true,
/* Report errors for fallthrough cases in switch statement. */
"noFallthroughCasesInSwitch": true
}
}
Loading

0 comments on commit 6de41bb

Please sign in to comment.