Correct way to specify rules globs?

There’s a lot of different ways people are specifying the globs in rules, I’m wondering what is the official schema for them?

YAML Array

globs: ['src/**/*.ts', 'tests/**/*.ts']

or

globs:
  - 'src/**/*.ts'
  - 'tests/**/*.ts'

Single String w/ quotes

globs: 'src/**/*.ts, tests/**/*.ts'

Single string (no quotes)

globs: src/**/*.ts, tests/**/*.ts

I’m seeing lots of files with the last but I’m guessing the first format is the correct one?

Specifying this better would make a great addition to the docs.

3 Likes

last version works

2 Likes

Yeah, that’s what I’m gathering but would be great for the Cursor team to put at least one example with the correct syntax in the docs.

7 Likes

Will let them know

3 Likes

It would also be nice if the supported glob patterns were clarified. For example, does *.?(m|c)ts?(x) work?

Support for ignore patterns would be very nice to have

I found this example:


globs: *.ts

please document the glob syntax. no spaces after commas for example is huge as the IDE has no visual indication of a space when editing a rule.

Space after comma:

No space after comma:

Also syntax support for groups, optional, negate, etc would be really nice. For example, /**/*.{j,t}s?(x) or /tests/**/*.{spec,test}.{js,ts}

4 Likes

Cursor team, please include examples in the docs for glob patterns.

@deanrie any chance for this to get some highlight?

Hey, thanks, I’ll pass this to the team.

I can’t find documentation anywhere online for the globs format. This is super frustrating. Can we please get some documentation?

Same here — I can’t believe there’s no clear documentation on the exact syntax and format for glob rules in Cursor.