DEV Community

Kriz Poon
Kriz Poon

Posted on

ESLint folder naming rule for NextJS [slug] folders

We have a check-file/folder-naming-convention ESLint rule in our NextJS project.

"check-file/folder-naming-convention": [
  "error",
  {
    "src/pages/**/": "KEBEB_CASE",
    ...
  }
]
Enter fullscreen mode Exit fullscreen mode

It was fine until we have a [slug] folder for some dynamic routes.

Luckily, check-file/folder-naming-convention supports custom pattern. Here is how we solved it:

"check-file/folder-naming-convention": [
  "error",
  {
    "src/pages/**/": "?(\\[)+([a-z0-9-])?(\\])",
    ...
  }
]
Enter fullscreen mode Exit fullscreen mode

Top comments (0)