Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"undefined method `params' for nil:NilClass" when defining custom rule #244

Closed
apjanke opened this issue Dec 20, 2018 · 1 comment
Closed

Comments

@apjanke
Copy link
Contributor

apjanke commented Dec 20, 2018

Hi, markdownlint folks,

I'm having trouble defining a custom rule.

In my linter definition file, I've created a new rule with a simple definition. But when I run it, I get an "undefined method params" error.

$ mdl _pages --style _linter/markdown-linter-style.rb
Traceback (most recent call last):
	7: from /Users/janke/bin/mdl:23:in `<main>'
	6: from /Users/janke/bin/mdl:23:in `load'
	5: from /usr/local/lib/ruby/gems/2.5.0/gems/mdl-0.5.0/bin/mdl:10:in `<top (required)>'
	4: from /usr/local/lib/ruby/gems/2.5.0/gems/mdl-0.5.0/lib/mdl.rb:26:in `run'
	3: from /usr/local/lib/ruby/gems/2.5.0/gems/mdl-0.5.0/lib/mdl/style.rb:51:in `load'
	2: from /usr/local/lib/ruby/gems/2.5.0/gems/mdl-0.5.0/lib/mdl/style.rb:51:in `instance_eval'
	1: from _linter/markdown-linter-style.rb:56:in `load'
/usr/local/lib/ruby/gems/2.5.0/gems/mdl-0.5.0/lib/mdl/style.rb:30:in `rule': undefined method `params' for nil:NilClass (NoMethodError)

This happens even when I just copy and paste the example custom rule from https://github.com/markdownlint/markdownlint/blob/a9e80fcf3989d73b654b00bb2225a00be53983e8/docs/creating_rules.md#creating-rules.

Any idea what's going on here?

I'm using markdownlint 0.5.0.

Reproduction example:

repro-mdl-no-such-method.zip

$ make lint
mdl *.md --style style.rb
Traceback (most recent call last):
	7: from /Users/janke/bin/mdl:23:in `<main>'
	6: from /Users/janke/bin/mdl:23:in `load'
	5: from /usr/local/lib/ruby/gems/2.5.0/gems/mdl-0.5.0/bin/mdl:10:in `<top (required)>'
	4: from /usr/local/lib/ruby/gems/2.5.0/gems/mdl-0.5.0/lib/mdl.rb:26:in `run'
	3: from /usr/local/lib/ruby/gems/2.5.0/gems/mdl-0.5.0/lib/mdl/style.rb:51:in `load'
	2: from /usr/local/lib/ruby/gems/2.5.0/gems/mdl-0.5.0/lib/mdl/style.rb:51:in `instance_eval'
	1: from style.rb:1:in `load'
/usr/local/lib/ruby/gems/2.5.0/gems/mdl-0.5.0/lib/mdl/style.rb:30:in `rule': undefined method `params' for nil:NilClass (NoMethodError)
make: *** [lint] Error 1
@apjanke
Copy link
Contributor Author

apjanke commented Dec 20, 2018

Nevermind. The problem was that I had put the custom rule definition in the style definition file, instead of a separate rules definitions file, so it was calling a different rule function. Maybe the "Creating Rules" document should mention where they go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant