Skip to content

Commit dd3f2d2

Browse files
committed
fix: update NEXT_JS_PAGE_ROUTER_FILENAME_CASE
1 parent d9f5762 commit dd3f2d2

File tree

4 files changed

+33
-2
lines changed

4 files changed

+33
-2
lines changed

docs/rules/filename-naming-convention.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,17 @@ In addition to the built-in naming conventions, you can also set custom naming p
5757

5858
The `NEXT_JS_PAGE_ROUTER_FILENAME_CASE` aims to support a wide range of filename naming convention in Next.js Page Router projects. If you would like to enforce a camelCase naming convention for your filename, but also support Next.js' Dynamic segments, Catch-all segments and Optional Catch-all Segments, this pattern is for you.
5959

60+
```js
61+
...
62+
'check-file/filename-naming-convention': [
63+
'error',
64+
{
65+
'src/**/*': 'NEXT_JS_PAGE_ROUTER_FILENAME_CASE',
66+
},
67+
],
68+
...
69+
```
70+
6071
While `NEXT_JS_PAGE_ROUTER_FILENAME_CASE` covers many naming cases, it's possible that some cases may be missing. If you come across any missing cases, I encourage you to open an issue and provide the necessary details. Your feedback will help me improve and enhance the naming convention.
6172

6273
### Prefined Match Syntax

lib/constants/next-js-naming-convention.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ const NEXT_JS_FILENAME_ROUTE = `+([a-z])?(.+([a-z]))`;
4343
/**
4444
* @example app, [helpPageId], [...auth], [[...auth]], (auth), \@feed
4545
*/
46-
export const NEXT_JS_APP_ROUTER_CASE = `@(${KEBAB_CASE}|${NEXT_JS_DYNAMIC_SEGMENTS}|${NEXT_JS_CATCH_ALL_SEGMENTS}|${NEXT_JS_OPTIONAL_CATCH_ALL_SEGMENTS}|${NEXT_JS_ROUTE_GROUPS}|${NEXT_JS_NAMED_SLOTS}|${NEXT_JS_PRIVATE_FOLDERS}|${NEXT_JS_FILENAME_ROUTE})`;
46+
export const NEXT_JS_APP_ROUTER_CASE = `@(${KEBAB_CASE}|${NEXT_JS_FILENAME_ROUTE}|${NEXT_JS_DYNAMIC_SEGMENTS}|${NEXT_JS_CATCH_ALL_SEGMENTS}|${NEXT_JS_OPTIONAL_CATCH_ALL_SEGMENTS}|${NEXT_JS_ROUTE_GROUPS}|${NEXT_JS_NAMED_SLOTS}|${NEXT_JS_PRIVATE_FOLDERS})`;
4747

4848
/**
4949
* @example _app, _document, index, [helpPageId], [...auth], [[...auth]]
5050
*/
51-
export const NEXT_JS_PAGE_ROUTER_FILENAME_CASE = `@(_app|_document|404|500|_error|index|${NEXT_JS_DYNAMIC_SEGMENTS}|${NEXT_JS_CATCH_ALL_SEGMENTS}|${NEXT_JS_OPTIONAL_CATCH_ALL_SEGMENTS})`;
51+
export const NEXT_JS_PAGE_ROUTER_FILENAME_CASE = `@(_app|_document|404|500|_error|index|${CAMEL_CASE}|${NEXT_JS_DYNAMIC_SEGMENTS}|${NEXT_JS_CATCH_ALL_SEGMENTS}|${NEXT_JS_OPTIONAL_CATCH_ALL_SEGMENTS})`;

tests/lib/rules/filename-naming-convention.posix.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,16 @@ ruleTester.run(
719719
},
720720
],
721721
},
722+
{
723+
code: "var foo = 'bar';",
724+
filename: 'src/services/getBlogPosts.js',
725+
options: [
726+
{
727+
'**/*.js': 'NEXT_JS_PAGE_ROUTER_FILENAME_CASE',
728+
'**/*.jsx': 'NEXT_JS_PAGE_ROUTER_FILENAME_CASE',
729+
},
730+
],
731+
},
722732
{
723733
code: "var foo = 'bar';",
724734
filename: 'src/pages/blog/[post].js',

tests/lib/rules/filename-naming-convention.windows.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,16 @@ ruleTester.run(
741741
},
742742
],
743743
},
744+
{
745+
code: "var foo = 'bar';",
746+
filename: 'src\\services\\getBlogPosts.js',
747+
options: [
748+
{
749+
'**/*.js': 'NEXT_JS_PAGE_ROUTER_FILENAME_CASE',
750+
'**/*.jsx': 'NEXT_JS_PAGE_ROUTER_FILENAME_CASE',
751+
},
752+
],
753+
},
744754
{
745755
code: "var foo = 'bar';",
746756
filename: 'src\\pages\\blog\\[post].js',

0 commit comments

Comments
 (0)