textlint-rule / textlint-rule-unexpanded-acronym

textlint rule that check unexpanded acronym.
MIT License
9 stars 3 forks source link

Cannot read property 'fixer' of undefined #5

Open donganzh-zz opened 5 years ago

donganzh-zz commented 5 years ago

Hi, @azu Hope you are having a great day.

I forked this rule and tried to build it on my laptop with some new features. Before I run npm run build, I need to install the helper npm packages:

npm install textlint-scripts --save-dev
npm install --save is-capitalized
npm install --save array-includes

then I run npm run build and textlint --rulesdir lib/ example.md -f pretty-error to test the rule with some sample document, I got this error message Cannot read property 'fixer' of undefined as output. I don't think there is anything related to the fixer in this rule. Do you know what might cause this problem? Thanks

azu commented 5 years ago

Probably, npm run build has converted export default function (context, options = {}) { to module.exports.default = function (context, options = {}) {.

https://github.com/textlint-rule/textlint-rule-unexpanded-acronym/blob/1775e0facc37a5057ca170a13347221a1726ac2e/src/textlint-rule-unexpanded-acronym.js#L30

textlint --rulesdir expected to export module.exports = function (context, options = {}) { (without .default).

Maybe, rewrite export default function (context, options = {}) { to module.exports = function (context, options = {}) { and textlint --rulesdir can load it.


FYI: You can test the rule via npm test.

donganzh-zz commented 5 years ago

Thanks, even if I rewrite export default function, it still reports error cannot read property 'fixer'. But I will go with the npm test.