textlint / textlint Goto Github PK
View Code? Open in Web Editor NEWThe pluggable natural language linter for text and markdown.
Home Page: https://textlint.github.io/
License: MIT License
The pluggable natural language linter for text and markdown.
Home Page: https://textlint.github.io/
License: MIT License
// index.md
もっとです。
もっとする。もっとだ。
$ textlint --plugin textlint-plugin-jtf-style index.md
D:\develop\personal\falsandtru.github.io\index.md
2:10 error 本文を敬体(ですます調)に統一して下さい。
本文の文体は、敬体(ですます調)あるいは常体(である調)のどちらかで統一します。
"だ。"が常体(である調)です。 jtf-style/1.1.1.本文
✖ 1 problem (1 error, 0 warnings)
should be error:
// index.md
もっとです。
もっとする。もっとだ。もっと。
$ textlint --plugin textlint-plugin-jtf-style index.md
$ textlint --rule textlint-rule-no-mix-dearu-desumasu index.md
Is this correct behavior?
textlint html support is experimetanl.
it's used and show warning message.
#4 do curve out formatter too!
Reference information
https://github.com/twada/power-assert-formatter
not default #51
You can use HTML support as a plugin after 5.0.0
npm install textlint-plugin-html
.textlintrc
{
"plugins": [
"html"
]
}
Babel 6 kill module.exports = x
behavior.
It means that doesn't resolve dynamic require(name)
.
textlint use dynamic loading for rule and plugin.
We should use interop-require instead of require
function.
need document!
A use case is spellcheck-tech-word-textlint-rule
We want to get an alternative of MoOx/rc-loader.
rc
module is fragile, I think.
rc
use shabang
RangeError: Maximum call stack size exceeded ?
textlint-core.js
is not single, but rule-manager.js
is a singleton.
var textlint1 = new TextLintCore();
textlint1.setupRule()
// do lint...
var textlint2 = new TextLintCore();
// textlint2 has rules that are defined by textlint1.
That is too bad.
texlint
is a Node module.
It mean that use of textlint for purpose other than linting.
textlint structure:
I'm creating https://github.com/azu/textstat.
It is not linting tool, but is statistics tool top on the textlint.
Currently, bottleneck object is Config
that is not expose public.
Is Config
should public?
We want to add example/
that is actually executable.
These examples are used for testing(so-called example testing).
We need logo and icon for oraganization.#55
Currently, textlint's rule not support async.
Use case: Allow to create the rule that use REST API like 校正支援Web API.
Add New API on the rule and change lintFile
API for support async.
We want to add performance test.
npm run perf
textlint require options for each rules.
{
"parser": "esprima",
"rules": {
"max-comma": {
"max-len": 3
}
}
}
and
support .textlintrc
?
It is a like eslint/eslint-tester.
$ textlint -h
textlint [options] file.md [file.txt] [dir]
Options:
-h, --help Show help.
-c, --config path::String Use configuration from this file or sharable config.
--plugin [String] Specify plugins
--rule [path::String] Set rule package name and set all default rules to off.
--rulesdir [path::String] Set rules from this directory and set all default rules to off.
-f, --format String Use a specific output format. - default: stylish
===> Available : XXX
-v, --version Outputs the version number.
--ext [String] Specify text file extensions.
--no-color Enable color in piped output.
-o, --output-file path::String Enable report to be written to a file.
--quiet Report errors only. - default: false
--stdin Lint code provided on <STDIN>. - default: false
textlint/packages/textlint/src/options.ts
Line 83 in 37bccdb
Which is better?
textlint -f -h
show formatter names?
textlint -h
show formatter names?
Following Issues need to resolve before try to implement this feature
Breaking Change
TextLintMessage
#40The Breaking Change related to textlint
module user(use-as-modules.md).
Feature
textlint find invalid text and always throw Error.
ESLint has severity
options.
0 - turn the rule off
1 - turn the rule on as a warning (doesn't affect exit code)
2 - turn the rule on as an error (exit code is 1 when triggered)
Currently, textlint fixed severity
to Error(2
).
It should be configurable/
We should support getAncestors()
method OR parent
property on TxtNode
.
Reference:
Current:
var TextLintEngine = require("textlint").TextLintEngine;
var engine = new TextLintEngine({
rules: ["textlint-rule-spellcheck-tech-word"]
});
var TextLintEngine = require("textlint").TextLintEngine;
var engine = new TextLintEngine({
rules: [require("textlint-rule-spellcheck-tech-word")]
});
Good?
Is npm install -q
better?
RuleError
optionshttps://github.com/azu/textlint/blob/8c4567f9f7e54acc086d3371a7ed41b028c1ce26/lib/options.js#L65-L68
We have to support output-file
option!
When many rule is loaded, occur this warning
(node) warning: possible EventEmitter memory leak detected. 11 Str listeners added. Use emitter.setMaxListeners() to increase limit.
Trace
at TextlintCore.addListener (events.js:239:17)
at /Users/azu/.ghq/github.com/azu/JavaScript-Plugin-Architecture/node_modules/textlint/lib/textlint-core.js:31:16
at Array.forEach (native)
at addListenRule (/Users/azu/.ghq/github.com/azu/JavaScript-Plugin-Architecture/node_modules/textlint/lib/textlint-core.js:30:23)
at /Users/azu/.ghq/github.com/azu/JavaScript-Plugin-Architecture/node_modules/textlint/lib/textlint-core.js:80:21
at Array.forEach (native)
at TextlintCore.setupRules (/Users/azu/.ghq/github.com/azu/JavaScript-Plugin-Architecture/node_modules/textlint/lib/textlint-core.js:65:32)
at TextLintEngine.setupRules (/Users/azu/.ghq/github.com/azu/JavaScript-Plugin-Architecture/node_modules/textlint/lib/textlint-engine.js:81:22)
at TextLintEngine.executeOnFiles (/Users/azu/.ghq/github.com/azu/JavaScript-Plugin-Architecture/node_modules/textlint/lib/textlint-engine.js:172:18)
at Object.execute (/Users/azu/.ghq/github.com/azu/JavaScript-Plugin-Architecture/node_modules/textlint/lib/cli.js:75:70)
TypeError: ruleContextAgent.listenerCount is not a function
Node.js 0.x's EventEmitter#listenerCount is not found.
is a parts of #4
Expected: plguin's rulesConfig is set as <plugin>/<rule>
.
Actual: plguin's rulesConfig is set as <rule>
.
from 4.5~
Can Plugin wrap RuleContext?
Atomのプラグインを作りたいときに、Atomで開かれているディレクトリのnode_modules/textlint-rule-*
をtextlintにロードしてあげると、そのプロジェクトのpackage.json
と.textlintrc
に依存関係を完結させることが出来そうなので・・・。
つまり、
https://github.com/azu/textlint/blob/master/lib/textlint-engine.js#L65-L80
あたりをTextLintEngineのインスタンスから実行したいです。
https://github.com/1000ch/linter-textlint/blob/master/index.js#L20-L26
RuleContext should have Config object.
context.config = config;
config
should be read only, but ...
Related #18
Expose https://github.com/azu/textlint/blob/master/src/textlint-core.js to index.js
I good to like that textlint rule naming start with textlint-rule-*
.
It is inspired by Babel.
textlint-rule-*
--rule <rule name>
for CLISome formatter has East Asian Width problem.
textlint -f pretty-error
This issue is come from textlint/textlint-formatter#2
ReferenceError: rule: 4.3.8.一重引用符 is not found
to be
ReferenceError: rule: 4.3.8.一重引用符 is not found
Did you mean: jtf-style/4.3.8.一重引用符
ESLint did http://eslint.org/docs/developer-guide/shareable-configs.html
--config
support sharable config.
--config @user/textlint-config
extend:"config"
in .textlintrc
?from: textlint-ja/textlint-rule-preset-JTF-style#5 (comment)
try to set the following and textlint throw ReferenceError.
{
"plugins": [
"jtf-style"
],
"rules": {
"jtf-style/2.1.2.漢字": {
"severity" : "warning"
},
"jtf-style/4.1.1.句点(。)": false,
"jtf-style/3.1.1.全角文字と半角文字の間": false
}
}
Error mesasage:
[ReferenceError: rule: jtf-style/2.1.2.漢字 is not found]
But, following case is safe.(no error)
"rules": {
"jtf-style/2.1.2.漢字": true,
"jtf-style/4.1.1.句点(。)": false,
"jtf-style/3.1.1.全角文字と半角文字の間": false
}
It seem bug in textlint. @
textlint/src/textlint-engine.js
Line 150 in 93a70dd
We use CommonMark now, but maybe switch to wooorm/mdast.
We separate off parser
(Markdown and plain text) from textlint
to prepare for switching.
Related issue : syntax-tree/mdast#2
We recently research column index.
ESLint switch column numbers to be 1-based.
Does textlint follow this?
This has a breaking change.
move to https://github.com/textlint
// index.md
もっとです。
もっとする。もっとだ。
// README.md (empty)
$ textlint --plugin textlint-plugin-jtf-style README.md index.md
~\index.md
10:10 error 本文を敬体(ですます調)に統一して下さい。
本文の文体は、敬体(ですます調)あるいは常体(である調)のどちらかで統一します。
"だ。"が常体(である調)です。 jtf-style/1.1.1.本文
✖ 1 problem (1 error, 0 warnings)
$ textlint --plugin textlint-plugin-jtf-style index.md README.md
~\index.md
10:10 error 本文を敬体(ですます調)に統一して下さい。
本文の文体は、敬体(ですます調)あるいは常体(である調)のどちらかで統一します。
"だ。"が常体(である調)です。 jtf-style/1.1.1.本文
~\README.md
10:10 error 本文を敬体(ですます調)に統一して下さい。
本文の文体は、敬体(ですます調)あるいは常体(である調)のどちらかで統一します。
"だ。"が常体(である調)です。 jtf-style/1.1.1.本文
✖ 2 problems (2 errors, 0 warnings)
We already support Rule Config at #15 .
Next, support User Config.
There are many types of punctuation in the world.
They define it is like punctuation in User Config.
It is just idea.
Related #39
{
"rules": {
// a is foo
"a": true
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.