Xo: Add ability to ignore directories

Created on 7 Sep 2015  路  18Comments  路  Source: xojs/xo

Issuehunt badges

https://github.com/joakimbeng/unistyle/commit/4dfa6bc4137c47aaee00662bc079eac79df64422#commitcomment-13087626

Right now you have to do directory/** to ignore all files in a directory, but would be nice, and probably more natural, if you could ignore a directroy directly by using directroy.

There is a $60.00 open bounty on this issue. Add more on Issuehunt.

Funded on Issuehunt enhancement help wanted

Most helpful comment

Is this still an issue? When testing locally using the latest version of XO (v0.23.0), XO seems to correctly ignore a directory given that package.json contains the following config:

{
    ...
    "xo": {
        "ignores": [
            "dir"
        ]
    },
    ...
}

All 18 comments

Could I get some more info about this? I think I could help, but not really sure what needs to be done exactly!

@nevilgeorge, you'd need to check if the items in ignores is a directory or not, and then append /** to it.

Should this issue be closed now that https://github.com/sindresorhus/globby/pull/46 is merged?

Yes, just needs to be mentioned in the docs first.

After testing it doesn't works because globby expand directory only for the patterns not for the ignores.

That should works if we merge #288 though.

But it probably something that should be fixed in globby?

But it probably something that should be fixed in globby?

Yes. Can you open an issue over there?

@issuehuntfest has funded $60.00 to this issue. See it on IssueHunt

Is this still an issue? When testing locally using the latest version of XO (v0.23.0), XO seems to correctly ignore a directory given that package.json contains the following config:

{
    ...
    "xo": {
        "ignores": [
            "dir"
        ]
    },
    ...
}

Didn't mean to closed before someone else confirms

@pvdlg I think we need to update globby first. I haven't done so yet, as it drops support for Windows paths (or rather fast-glob did), so we need to manually handle that here or wait for https://github.com/mrmlnc/fast-glob/issues/240.

Just to be sure I fully understand.
The problem is about passing a non glob windows path to XO such as:

$ xo C:\my-project\my-file.js

which fast-glob wrongly interprets as a glob.

But it's not related to use globs with windows backslashes such as:

$ xo C:\my-project\*.js

Is that right?
If yes we should be able to add the code you linked in https://github.com/sindresorhus/del/commit/01da91f548a318f33a82e9f09eb27f4e5c6cb94b#diff-168726dbe96b3ce427e7fedce31bb0bcR41-R53 to globby?

No, the inverse. xo C:\my-project\*.js will no longer work as globbing patterns can only have forward slashes now. So we need to manually convert the backward slashes to forward slashes.


If yes we should be able to add the code you linked in sindresorhus/del@01da91f#diff-168726dbe96b3ce427e7fedce31bb0bcR41-R53 to globby?

Yes, but I'm not super excited about having to do that manually in every library that uses globby. I would prefer to solve the problem at the globby side with maybe a separate method that accepts both paths and globs, or an option, which would handle transforming the slashes.

No, the inverse. xo C:\my-project*.js will no longer work as globbing patterns can only have forward slashes now. So we need to manually convert the backward slashes to forward slashes.

I'm confused then. https://github.com/sindresorhus/del/commit/01da91f548a318f33a82e9f09eb27f4e5c6cb94b#diff-168726dbe96b3ce427e7fedce31bb0bcR45 make the transformation only if the pattern is not a glob.
The way I understand the code is that C:\my-project\*.js will not be transformed while C:\my-project\my-file.js will be.

Yes, but I'm not super excited about having to do that manually in every library that uses globby. I would prefer to solve the problem at the globby side with maybe a separate method that accepts both paths and globs, or an option, which would handle transforming the slashes.

What I meant was to call normalizePatterns inside globby before passing the patterns to fast-glob so libraries using globby wouldn't have to do anything.

Ah, your right. I was just confused by your wording:

which fast-glob wrongly interprets as a glob.

It doesn't "wrongly interpret it as a glob", fast-glob doesn't do anything wrong. Anything you pass it is a glob and the backslashes are interpreted as escapes.


So yes, we're on the same page.


What I meant was to call normalizePatterns inside globby before passing the patterns to fast-glob so libraries using globby wouldn't have to do anything.

:+1:

eslint already supports ignoring patterns: https://eslint.org/docs/user-guide/configuring#ignorepatterns-in-config-files

Setting xo.ignorePatterns should work, according to https://github.com/xojs/xo/issues/428#issuecomment-591005878

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dawsbot picture dawsbot  路  5Comments

sindresorhus picture sindresorhus  路  5Comments

sindresorhus picture sindresorhus  路  3Comments

SteveALee picture SteveALee  路  5Comments

sindresorhus picture sindresorhus  路  5Comments