flow icon indicating copy to clipboard operation
flow copied to clipboard

Support negative lookaheads in .flowconfig excludes

Open mroch opened this issue 11 years ago • 5 comments

There's currently no good way to exclude an entire directory except for a single subdirectory. For example, say you have

foo/.flowconfig
foo/bar/a/
foo/bar/b/
foo/bar/...
foo/bar/z/

and you want to exclude foo/bar/ except foo/bar/b/.

since excludes win over includes, I think the only way right now is to list all of the other dirs in excludes.

it'd be nice if we supported negative lookaheads, like bar/(?!b/). using Pcre would do it.

mroch avatar Jun 25 '15 19:06 mroch

:+1:

This will be nice for including certain flow definitions from node_modules without pulling in all the errors from modules you don't care about

kyldvs avatar Jun 25 '15 21:06 kyldvs

+1

As for the proposed switch to PCRE, note that the current OCaml-flavor uses slashes in its syntax: \(...\) for groups and \| for alternatives. This wouldn’t be compatible with PCRE, which doesn’t uses those slashes.

As a temporary workaround, I resorted to .*\(\(\([^/]s\|[^s]\)r\|[^r]\)c\|[^c]\)/main.js today (matching .../main.js but not .../src/main.js).

bm-w avatar Oct 30 '15 00:10 bm-w

+1 Does anybody could clarify why flowtype uses different approaches to define [ignore] and [include]. I can't see any advantages in using OCaml regular expressions and match it against absolute path.

Efimster avatar Jun 01 '16 08:06 Efimster

we use ocaml regular expressions simply because flow is written in ocaml. linking in PCRE or using ocaml-re adds dependencies that would make building flow more difficult. obviously that's not a very good reason which is why I want to change them as soon as we can figure out a migration path.

mroch avatar Jun 01 '16 08:06 mroch

We already have !

SamChou19815 avatar Jul 21 '26 17:07 SamChou19815