get-alex / alex

Catch insensitive, inconsiderate writing
https://alexjs.com
MIT License
4.81k stars 208 forks source link

using globs and .alexignore #287

Closed Licenser closed 4 years ago

Licenser commented 4 years ago

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 :(

wooorm commented 4 years ago

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

Licenser commented 4 years ago

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

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.

wooorm commented 4 years ago

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?

wooorm commented 4 years ago

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?

Licenser commented 4 years ago

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

wooorm commented 4 years ago

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

Licenser commented 4 years ago

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.

wooorm commented 4 years ago

Several thoughts on this:

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.