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

How to use deny properly #292

Closed
owlpaste opened this issue Jul 23, 2020 · 10 comments
Closed

How to use deny properly #292

owlpaste opened this issue Jul 23, 2020 · 10 comments

Comments

@owlpaste
Copy link

I am having issues getting the deny filter to work. Can I get an example where both allow and deny lists are used?

I was trying to use

.alexrc

{
  "allow": ["pop", "mom", "reject"],
  "deny": ["master"]
}

And the allow part gets applied fine, however deny does not. It wasn't really clear from examples as to how to use this?

@wooorm
Copy link
Member

wooorm commented Jul 24, 2020

Sorry about that, I hadn’t released the recent deny feature yet. It’s now in alex@8.2.0!

Let me know if you have further questions.

@wooorm wooorm closed this as completed Jul 24, 2020
@owlpaste
Copy link
Author

owlpaste commented Jul 27, 2020

Hiya, thanks for the quick reply, but still having issues @wooorm

➜ cat .alexrc
{
  "allow": ["pop", "mom", "reject"],
  "deny": ["master"]
}
➜ cat example.js
console.log(`bad example
it should fail
because he is silly
master
and sometimes
even a slave`);
➜ ./node_modules/.bin/alex example.js
example.js: no issues found
➜ ./node_modules/.bin/alex --version
8.2.0

@owlpaste
Copy link
Author

owlpaste commented Aug 4, 2020

Should I make a new issue/question @wooorm ?

@wooorm
Copy link
Member

wooorm commented Aug 5, 2020

Sorry about the wait. The deny field is a recent addition, if it is configured, only deny is used, not allow. You should see an error if both are configured, so it’s a bug if you don’t see it (or you’re not on the latest alex? 🤔).

With deny, you create a list of rules to warn for. All the other rules don’t run. With allow, it’s the inverse: everything runs, except for the ones in allow!

@owlpaste
Copy link
Author

owlpaste commented Aug 6, 2020

Hiya, created https://github.com/owlpaste/alex-test as a quick test.

Was running this with

npm run lint-language *

> alex-test@0.0.1 lint-language /Users/user/projects/random/alex-test
> alex "example.js" "example.md" "node_modules" "package-lock.json" "package.json"

example.js: no issues found
example.md
  4:1-4:4  warning  `pop` may be insensitive, use `parent` instead  dad-mom  retext-equality

Fairly sure I am using it wrong, but a couple of things that are confusing me.

  • Seems like its not making use of .alexrc (maybe that is why no error is raised when using both allow and deny?)
  • Ignoring js files even when passed in

@wooorm
Copy link
Member

wooorm commented Aug 23, 2020

Good catch! Welp, thanks to your repo I found out that deny isn’t supported on the CLI

@wooorm
Copy link
Member

wooorm commented Aug 23, 2020

For your second point, “Ignoring js files even when passed in”, I don’t see that. It is checking a javascript file with alex example.js. But it’s interpreting it as markdown. Your backticks in example.js are seen in markdown as inline code, which alex ignored.

@wooorm
Copy link
Member

wooorm commented Aug 23, 2020

Please see 9.0.1, which includes a fix for deny on the CLI!

@owlpaste
Copy link
Author

For your second point, “Ignoring js files even when passed in”, I don’t see that. It is checking a javascript file with alex example.js. But it’s interpreting it as markdown. Your backticks in example.js are seen in markdown as inline code, which alex ignored.

Oh I see, thanks for the explanation, I didn't think of that.

Will test out the fix.

@wooorm
Copy link
Member

wooorm commented Aug 25, 2020

If you don't want a file to be interpreted as md, mdx, html, or whatnot, I think there's a --text flag!

Good luck

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

No branches or pull requests

2 participants