arrowrowe / textlint-rule-editorconfig

Let EditorConfig and Textlint work together.
MIT License
12 stars 4 forks source link

charset false positive #2

Open HansHammel opened 7 years ago

HansHammel commented 7 years ago

charset gives false positives and reports utf8 to be ascii how do i disable the rule? "editorconfig/charset" : false, has no effect.

arrowrowe commented 7 years ago

Hey @HansHammel, Thanks for reporting! I will take a look this weekend.

For now, does a .textlintrc as following work for you?

{
  "rules": {
    "editorconfig": {
        "charset": false
    }
  }
}
HansHammel commented 7 years ago

no sir! tried that already. btw. other rules in the rc file are working fine.

arrowrowe commented 7 years ago

Sorry for the delay. Will try tonight.

arrowrowe commented 7 years ago

Seems that I did not handle .textlintrc, leaving charset and all other stuff configured by .editorconfig.

A quick workaround is to set charset to false in your .editorconfig.

arrowrowe commented 7 years ago

Hey @HansHammel would you like to checkout v1.0.3? the textlintrc we mentioned before should work now.

diff I made: https://github.com/arrowrowe/textlint-rule-editorconfig/commit/cbd63e3b96032ce8e0b41abcf7932f820b84b897 rules/charset.js

+  if (args.option.charset === false) {
+    return;
+  }
arrowrowe commented 7 years ago

Also, since we use JsChardet to detect the charset, maybe you could report your false alarm there if confirmed?

HansHammel commented 7 years ago
"editorconfig": {
    "charset": false
}

is working, just like the "no entry" case, but every other value like true, "utf8" or "UTF-8" leads to

TypeError: Cannot read property 'toLowerCase' of null
at C:\a-project\AUTHORS.md
    at module.exports (C:\a-project\node_modules\textlint-rule-editorconfig\rules\charset.js:14:32)
    at rules.forEach (C:\a-project\node_modules\textlint-rule-editorconfig\index.js:15:29)
    at Array.forEach (native)
    at getConfig.then (C:\a-project\node_modules\textlint-rule-editorconfig\index.js:15:11)
    at tryCatcher (C:\a-project\node_modules\textlint-rule-editorconfig\node_modules\bluebird\js\release\util.js:16:23)
    at Promise._settlePromiseFromHandler (C:\a-project\node_modules\textlint-rule-editorconfig\node_modules\bluebird\js\release\promise.js:503:31)
    at Promise._settlePromise (C:\a-project\node_modules\textlint-rule-editorconfig\node_modules\bluebird\js\release\promise.js:560:18)
    at Promise._settlePromise0 (C:\a-project\node_modules\textlint-rule-editorconfig\node_modules\bluebird\js\release\promise.js:605:10)
    at Promise._settlePromises (C:\a-project\node_modules\textlint-rule-editorconfig\node_modules\bluebird\js\release\promise.js:684:18)
    at Async._drainQueue (C:\a-project\node_modules\textlint-rule-editorconfig\node_modules\bluebird\js\release\async.js:126:16)
    at Async._drainQueues (C:\a-project\node_modules\textlint-rule-editorconfig\node_modules\bluebird\js\release\async.js:136:10)
    at Immediate.Async.drainQueues (C:\a-project\node_modules\textlint-rule-editorconfig\node_modules\bluebird\js\release\async.js:16:14)
    at runCallback (timers.js:637:20)
    at tryOnImmediate (timers.js:610:5)
    at processImmediate [as _immediateCallback] (timers.js:582:5
docwhat commented 5 years ago

I'm not sure jschardet is the right package to be using because it just returns one answer.

What you really want is something that either returns a bunch of character sets so you can see if you have enough confidence that it is the editorconfig specified charset.

Alternatively, if there is a library where you can ask "is this file this charset" instead.

A bunch of my documents detect as ascii which is silly, since ascii is a subset of `utf-8'.

Another group of documents match as windows-1252 just because they have the UTF-8 non-breaking space character in it.