get-alex / alex

Catch insensitive, inconsiderate writing

Home Page:https://alexjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

using globs and .alexignore

Licenser opened this issue · comments

Hi,
I'm running in some issues with using .alexignore and globs. The basic problem I'm trying to solve is:

  1. Ignore some .md files
  2. Lint all other .md files in this and all folders underneath it (i.e. **/*.md)

This will cause an error that the ignored .md file is included.

One solution is to specify all subfolders but with 15 and growing that's really painful :(

commented

Hi there, welcome!

Could you provide more info? Unfortunately you removed the issue template. Filling that in really helps us help you. See https://github.com/get-alex/.github/blob/master/.github/ISSUE_TEMPLATE/1-bug.md and https://github.com/get-alex/.github/blob/master/support.md#asking-quality-questions

Hi! I can add those but I didn't remove the template, the "question" template (I don't think it's a bug, just a question) I used is empty other than a comment in the beginning.

I found that for .md files using alex . instead of alex solves the issue, but it persists when using files Alex doesn't discover automatically.


name: Question - how to deal with globs and .alexignore
about: how to deal with globs and .alexignore
labels: status/open, type/question

Subject of the issue

Dealing with

Your environment

  • OS: Linux 5.4.0-39-generic #43-Ubuntu SMP Fri Jun 19 10:28:31 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
  • Packages: None, not a node project
  • Env: None, not a node project

Steps to reproduce

  1. create an Alex ignore file that ignores a folder (or file)
  2. use a pattern to find certain files that would also include files in the ignore file
mkdir example
cd example
mkdir src
mkdir ignored
touch src/bad.rs
echo "poop" > src/bad.rs
touch ignored/something.rs
echo "ignored/**" > .alexignore
alex **/*.rs
cd ..

Expected behaviour

A way to achieve "all files of this type but not the ignored ones".

I've no preference how this works a few ideas however:

  1. --allow-ignored-globs (toggels the behaviour)
  2. remove ignored files silently from globs
  3. --discover-extensions rs -e markdown -e md -e txt (allow adding extensions to discover via alex .
  4. everything I've missed / not thought about :D

Actual behaviour

I could not find a way to include files where folders are ignored that might also match the pattern without Alex erroring.

commented

Ahh good, sorry, my mistake, I should fix that 😅

I think I almost understand your question.
It seems your original and the new explanaintion are different? Because the original question should be supported as alex ., with a couple of globs in an .alexignore file?

So is the question about new extensions, such as .rs?

commented

One solution is to specify all subfolders but with 15 and growing that's really painful :(

Instead of generalizing the question, could you provide exactly what you do? What alex ... looks like, and what the .alexignore file looks like?

This pretty much sums the issue up:

mkdir example
cd example
mkdir src
mkdir ignored
touch src/bad.rs
echo "poop" > src/bad.rs
touch ignored/something.rs
echo "ignored/**" > .alexignore # ignore file
alex **/*.rs # alex call
cd ..

alex . seems to work fine for files that are recognized if not it's not

commented

Right. To confirm, the question then is about new extensions, such as .rs? You don’t have problems if the extension is .md?

Yes, I think alex . solves the issue for recognized files, or at least I couldn't reproduce it after finding that so it looks like being related only to additional extensions.

commented

Several thoughts on this:

  • It is definitely not suggested to use alex on rust files. Please don’t do it. Rather, integrate with a rust tool to check comments or so.
  • We can go the route of adding support for passing -e, --ext to the cli
  • We can support a --silently-ignore flag

I don’t feel very strongly about 2 and 3, because of 1 🤔
The whole reason for having the error in place, is that it’s probably a user error and being silent is often unexpected to users.