Skip to content
This repository was archived by the owner on Nov 21, 2025. It is now read-only.

Commit 0791852

Browse files
filipposarzanarakannimer
authored andcommitted
Update example to use correct Regexp (#1300)
`[w-]*` means to match `w` character literally or `-` character, zero or unlimited times. So now this Regex is matching everything that endsWith `.ts` or `.tsx`, even a file with empty filename. If this is intended, so the first parti of the regular expression is completely useless. Otherwise we could be more strict on this (since we are speaking of an example, of course) Moreover the capturing group around `(js|jsx|ts|tsx)` is not needed since it's unused inside a `.test` method and it's heavier than `(?:j|t)sx? This new regex does exactly half of the steps than before. *Before*: 85 steps *After*: 21 steps
1 parent 87cb335 commit 0791852

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

examples/with-algolia-search/src/docs/general/usage-with-typescript.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@ If you have particular needs or need to control exactly which files are being pi
4747
export default {
4848
filterComponents: files =>
4949
//This overrides the default filtering of components
50-
files.filter(filepath => /[w-]*.(js|jsx|ts|tsx)$/.test(filepath)),
50+
files.filter(filepath => /[\w-]+.(?:j|t)sx?$/.test(filepath)),
5151
}
5252
```

0 commit comments

Comments
 (0)