-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 94db072
Showing
17 changed files
with
8,218 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: test | ||
on: | ||
push: | ||
pull_request: | ||
permissions: | ||
contents: read | ||
jobs: | ||
test: | ||
name: "Test on Node.js ${{ matrix.node-version }} OS: ${{matrix.os}}" | ||
runs-on: ${{matrix.os}} | ||
strategy: | ||
matrix: | ||
os: [ macos-latest, windows-latest, ubuntu-latest ] | ||
node-version: [ 18, 20 ] | ||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v4 | ||
- name: setup Node ${{ matrix.node-version }} | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- name: Install | ||
run: npm ci | ||
- name: Test | ||
run: npm test |
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,34 @@ | ||
test.md | ||
webdb.yml | ||
|
||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directory | ||
# https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git | ||
node_modules | ||
|
||
# Optional npm cache directory | ||
.npm |
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,4 @@ | ||
{ | ||
"forbidOnly": true, | ||
"spec": ["test/**/*.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,62 @@ | ||
# gulp-textlint | ||
|
||
gulp plugin for [textlint](https://github.com/textlint/textlint). | ||
|
||
* Require [.textlintrc](https://github.com/textlint/textlint#textlintrc) | ||
* Require [rules](https://github.com/textlint/textlint#rule-list---collection-of-textlint-rule) | ||
* As you can use [vvakame/prh](https://github.com/vvakame/prh)'s format dictionary. | ||
|
||
## Usage | ||
|
||
```js | ||
var gulp = require('gulp'); | ||
var textlint = require('gulp-textlint'); | ||
|
||
gulp.task('textlint', function() { | ||
return gulp.src('./path/to/src/**/*.md') | ||
.pipe(textlint()); | ||
}); | ||
``` | ||
|
||
As you can path to config for textlint. Like below. | ||
|
||
```js | ||
... | ||
gulp.task('textlint', function() { | ||
return gulp.src('./path/to/src/**/*.md') | ||
.pipe(textlint({ | ||
formatterName: "pretty-error" | ||
}); | ||
}); | ||
``` | ||
When you would like to change target dynamically you should use [yargs](https://github.com/bcoe/yargs). | ||
e.g. | ||
```js | ||
var argv = require('yargs').argv; | ||
|
||
gulp.task('textlint', function() { | ||
var src = argv.t; | ||
return gulp.src(src) | ||
.pipe(textlint()); | ||
}); | ||
|
||
gulp.task('watch', function() { | ||
var src = argv.t; | ||
if (src) { | ||
gulp.watch(src, ['textlint']); | ||
} | ||
}); | ||
``` | ||
Then execute `watch` task with `-t` option. | ||
```sh | ||
gulp watch -t "./path/to/*.md" | ||
``` | ||
## Example | ||
Please See [example/](./example/). |
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,8 @@ | ||
{ | ||
"rules": { | ||
"no-todo": true, | ||
"prh": { | ||
"rulePaths" :["./prh.yml"] | ||
} | ||
} | ||
} |
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,13 @@ | ||
# Example | ||
|
||
Example of gulp-textlint | ||
|
||
## Usage | ||
|
||
npm run textlint | ||
# or | ||
gulp textlint | ||
|
||
## Playground | ||
|
||
Add `- [ ]` to Here and run textlint. |
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,6 @@ | ||
"use strict"; | ||
const gulp = require("gulp"); | ||
const textlint = require("gulp-textlint"); | ||
gulp.task("textlint", function () { | ||
return gulp.src("./*.md").pipe(textlint()); | ||
}); |
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,17 @@ | ||
{ | ||
"name": "example", | ||
"version": "1.0.0", | ||
"private": true, | ||
"scripts": { | ||
"textlint": "gulp textlint", | ||
"test": "npm rm gulp-textlint && npm i --production && npm run textlint" | ||
}, | ||
"author": "azu", | ||
"license": "MIT", | ||
"dependencies": { | ||
"gulp": "^3.9.1", | ||
"gulp-textlint": "file:..", | ||
"textlint-rule-no-todo": "^1.0.3", | ||
"textlint-rule-prh": "^2.4.1" | ||
} | ||
} |
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,80 @@ | ||
version: 1 | ||
|
||
# もし、もっと別なルールを使いたい時は以下のURLを参照して真似してください。 | ||
# https://github.com/vvakame/prh/tree/master/misc | ||
# おすすめは techbooster.yml です。 | ||
|
||
# 別の設定ファイルを読み込み、mergeすることもできます。 | ||
imports: | ||
# - ./techbooster.yml | ||
|
||
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: 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,35 @@ | ||
const log = require("fancy-log"); | ||
const PluginError = require("plugin-error"); | ||
const through = require("through2"); | ||
const TextLintEngine = require("textlint").TextLintEngine; | ||
|
||
module.exports = function (options) { | ||
options = options || {}; | ||
const textlint = new TextLintEngine(options); | ||
const filePaths = []; | ||
|
||
return through.obj( | ||
function (file, enc, cb) { | ||
filePaths.push(file.path); | ||
this.push(file); | ||
cb(); | ||
}, | ||
function (cb) { | ||
const that = this; | ||
textlint | ||
.executeOnFiles(filePaths) | ||
.then(function (results) { | ||
if (textlint.isErrorResults(results)) { | ||
log(textlint.formatResults(results)); | ||
that.emit("error", new PluginError("textlint", "Lint failed.")); | ||
} | ||
}) | ||
.catch(function (error) { | ||
that.emit("error", new PluginError("textlint", `Lint failed. \n${error.message}`)); | ||
}) | ||
.then(function () { | ||
cb(); | ||
}); | ||
} | ||
); | ||
}; |
Oops, something went wrong.