Skip to content

Commit

Permalink
fix(#53): update NEXT_JS_APP_ROUTER_CASE
Browse files Browse the repository at this point in the history
  • Loading branch information
dukeluo committed Jan 9, 2025
1 parent bd82d9d commit 8ba26db
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/constants/next-js-naming-convention.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ const NEXT_JS_NAMED_SLOTS = `\\@${KEBAB_CASE}`;
*/
const NEXT_JS_PRIVATE_FOLDERS = `\\_${KEBAB_CASE}`;

/**
* @example rss.xml
*/
const NEXT_JS_FILENAME_ROUTE = `+([a-z])?(.+([a-z]))`;

/**
* @example app, [helpPageId], [...auth], [[...auth]], (auth), \@feed
*/
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})`;
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})`;
31 changes: 31 additions & 0 deletions tests/lib/rules/folder-naming-convention.posix.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,11 @@ ruleTester.run(
filename: 'src/app/_components/page.ts',
options: [{ 'src/**/': 'NEXT_JS_APP_ROUTER_CASE' }],
},
{
code: "var foo = 'bar';",
filename: 'src/app/rss.xml/route.ts',
options: [{ 'src/**/': 'NEXT_JS_APP_ROUTER_CASE' }],
},
],

invalid: [
Expand Down Expand Up @@ -559,6 +564,32 @@ ruleTester.run(
},
],
},
{
code: "var foo = 'bar';",
filename: 'src/app/rss.xml.xl/route.ts',
options: [{ 'src/**/': 'NEXT_JS_APP_ROUTER_CASE' }],
errors: [
{
message:
'The folder "rss.xml.xl" does not match the "NEXT_JS_APP_ROUTER_CASE" pattern',
column: 1,
line: 1,
},
],
},
{
code: "var foo = 'bar';",
filename: 'src/app/Rss.xml/route.ts',
options: [{ 'src/**/': 'NEXT_JS_APP_ROUTER_CASE' }],
errors: [
{
message:
'The folder "Rss.xml" does not match the "NEXT_JS_APP_ROUTER_CASE" pattern',
column: 1,
line: 1,
},
],
},
],
}
);
Expand Down
31 changes: 31 additions & 0 deletions tests/lib/rules/folder-naming-convention.windows.js
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,11 @@ ruleTester.run(
filename: 'src\\app\\_components\\page.ts',
options: [{ 'src/**/': 'NEXT_JS_APP_ROUTER_CASE' }],
},
{
code: "var foo = 'bar';",
filename: 'src\\app\\rss.xml\\route.ts',
options: [{ 'src/**/': 'NEXT_JS_APP_ROUTER_CASE' }],
},
],

invalid: [
Expand Down Expand Up @@ -562,6 +567,32 @@ ruleTester.run(
},
],
},
{
code: "var foo = 'bar';",
filename: 'src\\app\\rss.xml.xl\\route.ts',
options: [{ 'src/**/': 'NEXT_JS_APP_ROUTER_CASE' }],
errors: [
{
message:
'The folder "rss.xml.xl" does not match the "NEXT_JS_APP_ROUTER_CASE" pattern',
column: 1,
line: 1,
},
],
},
{
code: "var foo = 'bar';",
filename: 'src\\app\\Rss.xml\\route.ts',
options: [{ 'src/**/': 'NEXT_JS_APP_ROUTER_CASE' }],
errors: [
{
message:
'The folder "Rss.xml" does not match the "NEXT_JS_APP_ROUTER_CASE" pattern',
column: 1,
line: 1,
},
],
},
],
}
);
Expand Down

0 comments on commit 8ba26db

Please sign in to comment.