Skip to content

Commit 8ba26db

Browse files
committed
fix(#53): update NEXT_JS_APP_ROUTER_CASE
1 parent bd82d9d commit 8ba26db

File tree

3 files changed

+68
-1
lines changed

3 files changed

+68
-1
lines changed

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

+6-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@ const NEXT_JS_NAMED_SLOTS = `\\@${KEBAB_CASE}`;
3535
*/
3636
const NEXT_JS_PRIVATE_FOLDERS = `\\_${KEBAB_CASE}`;
3737

38+
/**
39+
* @example rss.xml
40+
*/
41+
const NEXT_JS_FILENAME_ROUTE = `+([a-z])?(.+([a-z]))`;
42+
3843
/**
3944
* @example app, [helpPageId], [...auth], [[...auth]], (auth), \@feed
4045
*/
41-
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})`;
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})`;

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

+31
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,11 @@ ruleTester.run(
413413
filename: 'src/app/_components/page.ts',
414414
options: [{ 'src/**/': 'NEXT_JS_APP_ROUTER_CASE' }],
415415
},
416+
{
417+
code: "var foo = 'bar';",
418+
filename: 'src/app/rss.xml/route.ts',
419+
options: [{ 'src/**/': 'NEXT_JS_APP_ROUTER_CASE' }],
420+
},
416421
],
417422

418423
invalid: [
@@ -559,6 +564,32 @@ ruleTester.run(
559564
},
560565
],
561566
},
567+
{
568+
code: "var foo = 'bar';",
569+
filename: 'src/app/rss.xml.xl/route.ts',
570+
options: [{ 'src/**/': 'NEXT_JS_APP_ROUTER_CASE' }],
571+
errors: [
572+
{
573+
message:
574+
'The folder "rss.xml.xl" does not match the "NEXT_JS_APP_ROUTER_CASE" pattern',
575+
column: 1,
576+
line: 1,
577+
},
578+
],
579+
},
580+
{
581+
code: "var foo = 'bar';",
582+
filename: 'src/app/Rss.xml/route.ts',
583+
options: [{ 'src/**/': 'NEXT_JS_APP_ROUTER_CASE' }],
584+
errors: [
585+
{
586+
message:
587+
'The folder "Rss.xml" does not match the "NEXT_JS_APP_ROUTER_CASE" pattern',
588+
column: 1,
589+
line: 1,
590+
},
591+
],
592+
},
562593
],
563594
}
564595
);

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

+31
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,11 @@ ruleTester.run(
416416
filename: 'src\\app\\_components\\page.ts',
417417
options: [{ 'src/**/': 'NEXT_JS_APP_ROUTER_CASE' }],
418418
},
419+
{
420+
code: "var foo = 'bar';",
421+
filename: 'src\\app\\rss.xml\\route.ts',
422+
options: [{ 'src/**/': 'NEXT_JS_APP_ROUTER_CASE' }],
423+
},
419424
],
420425

421426
invalid: [
@@ -562,6 +567,32 @@ ruleTester.run(
562567
},
563568
],
564569
},
570+
{
571+
code: "var foo = 'bar';",
572+
filename: 'src\\app\\rss.xml.xl\\route.ts',
573+
options: [{ 'src/**/': 'NEXT_JS_APP_ROUTER_CASE' }],
574+
errors: [
575+
{
576+
message:
577+
'The folder "rss.xml.xl" does not match the "NEXT_JS_APP_ROUTER_CASE" pattern',
578+
column: 1,
579+
line: 1,
580+
},
581+
],
582+
},
583+
{
584+
code: "var foo = 'bar';",
585+
filename: 'src\\app\\Rss.xml\\route.ts',
586+
options: [{ 'src/**/': 'NEXT_JS_APP_ROUTER_CASE' }],
587+
errors: [
588+
{
589+
message:
590+
'The folder "Rss.xml" does not match the "NEXT_JS_APP_ROUTER_CASE" pattern',
591+
column: 1,
592+
line: 1,
593+
},
594+
],
595+
},
565596
],
566597
}
567598
);

0 commit comments

Comments
 (0)