textlint / playground

textlint online playground.
https://textlint.github.io/playground
MIT License
14 stars 2 forks source link

How to add new rules? #4

Closed hiloki closed 5 years ago

hiloki commented 5 years ago

I tried to add new rule (e.g. textlint-rule-no-mix-dearu-desumasu) to defaultRuleList.js, not working at playground.

Steps

  1. yarn add textlint-rule-no-mix-dearu-desumas
  2. Add new rule to defaultRuleList.js
  3. Start Playground.

Code

{
        id: 5,
        name: "textlint-rule-no-mix-dearu-desumasu",
        rule: require("textlint-rule-no-mix-dearu-desumasu").default,
        enable: true
}

Error

TextlintEditor.js:59 TypeError: Cannot read property 'fixer' of undefined
    at Object.hasFixer (rule-creator-helper.js:41)
    at DescriptorsFactory.js:14
    at Array.map (<anonymous>)
    at Object../node_modules/@textlint/kernel/lib/kernel/src/descriptor/DescriptorsFactory.js.exports.createTextlintRuleDescriptors (DescriptorsFactory.js:13)
    at new TextlintKernelDescriptor (TextlintKernelDescriptor.js:18)
    at textlint-kernel.js:70
(anonymous) @ TextlintEditor.js:59
TextlintEditor.js:72 TypeError: Cannot read property 'fixer' of undefined
    at Object.hasFixer (rule-creator-helper.js:41)
    at DescriptorsFactory.js:14
    at Array.map (<anonymous>)
    at Object../node_modules/@textlint/kernel/lib/kernel/src/descriptor/DescriptorsFactory.js.exports.createTextlintRuleDescriptors (DescriptorsFactory.js:13)
    at new TextlintKernelDescriptor (TextlintKernelDescriptor.js:18)
    at textlint-kernel.js:70
azu commented 5 years ago

https://github.com/textlint-ja/textlint-rule-no-mix-dearu-desumasu/blob/b0ff44aa704d9f09e09a5cd88885e3924e5843a6/src/no-mix-dearu-desumasu.js#L21

textlint-rule-no-mix-dearu-desumasu does not export default property. Probably, rule: require("textlint-rule-no-mix-dearu-desumasu"), is correct?

hiloki commented 5 years ago

Exactly! resolved some errors. thanks 👍