Skip to content

Commit 4bd9767

Browse files
3.11.0
1 parent 84d25c4 commit 4bd9767

File tree

7 files changed

+45
-13
lines changed

7 files changed

+45
-13
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"author": "Igor Kowalski (Igorkowalski94)",
33
"name": "eslint-plugin-project-structure",
4-
"version": "3.10.11",
4+
"version": "3.11.0",
55
"license": "MIT",
66
"description": "Powerful ESLint plugin with rules to help you achieve a scalable, consistent, and well-structured project. Create your own framework! Define your folder structure, file composition, advanced naming conventions, and create independent modules. Take your project to the next level and save time by automating the review of key principles of a healthy project! react folder structure react file structure react project structure react conventions architecture react next.js angular node solid vue svelte",
77
"keywords": [
@@ -74,7 +74,7 @@
7474
"eslint-config-prettier": "^9.1.0",
7575
"eslint-plugin-import": "^2.31.0",
7676
"eslint-plugin-prettier": "^5.2.1",
77-
"eslint-plugin-project-structure": "3.10.10",
77+
"eslint-plugin-project-structure": "3.10.11",
7878
"husky": "^9.1.7",
7979
"jest": "^29.7.0",
8080
"prettier": "^3.4.2",

src/rules/independentModules/helpers/getDirnamePath.test.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,35 @@ describe("getDirnamePath", () => {
88
expected: "C:/Users/user/Desktop/repo",
99
},
1010
{
11-
filename: "C:/Users/user/Desktop/(components)/src/",
11+
filename: "C:/Users/user/Desktop/(components)/src",
1212
pattern: "{dirname}/*.ts",
1313
expected: "C:/Users/user/Desktop/\\(components\\)",
1414
},
15+
{
16+
filename: "C:/Users/user/Desktop/{components}/src",
17+
pattern: "{dirname}/*.ts",
18+
expected: "C:/Users/user/Desktop/\\{components\\}",
19+
},
20+
{
21+
filename: "C:/Users/user/Desktop/[[...slug]]/src",
22+
pattern: "{dirname}/*.ts",
23+
expected: "C:/Users/user/Desktop/\\[\\[\\.\\.\\.slug\\]\\]",
24+
},
25+
{
26+
filename: "C:/Users/user/Desktop/components!/src",
27+
pattern: "{dirname}/*.ts",
28+
expected: "C:/Users/user/Desktop/components\\!",
29+
},
30+
{
31+
filename: "C:/Users/user/Desktop/components+/src",
32+
pattern: "{dirname}/*.ts",
33+
expected: "C:/Users/user/Desktop/components\\+",
34+
},
35+
{
36+
filename: "C:/Users/user/Desktop/components,/src",
37+
pattern: "{dirname}/*.ts",
38+
expected: "C:/Users/user/Desktop/components\\,",
39+
},
1540
{
1641
filename: "C:/Users/user/Desktop/repo/src/",
1742
pattern: "{dirname_1}/*.ts",

src/rules/independentModules/helpers/getDirnamePath.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import path from "path";
22

33
import { getLvlFromPattern } from "rules/independentModules/helpers/getLvlFromPattern";
4+
import { removeMicromatchSpecialCharacters } from "rules/independentModules/helpers/removeMicromatchSpecialCharacters";
45

56
export const getDirnamePath = (fileName: string, pattern: string): string => {
67
const lvl = getLvlFromPattern(pattern, 1);
@@ -11,5 +12,5 @@ export const getDirnamePath = (fileName: string, pattern: string): string => {
1112
dirnamePath = path.dirname(dirnamePath);
1213
}
1314

14-
return dirnamePath.replace(/[()]/g, (match) => `\\${match}`);
15+
return removeMicromatchSpecialCharacters(dirnamePath);
1516
};

src/rules/independentModules/helpers/getFamilyPath.test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ describe("getFamilyPath", () => {
1010
expected: "features/Feature1",
1111
},
1212
{
13-
filename: "features/Feature1/(components)/Feature.tsx",
14-
importPath: "features/Feature1/(components)/feature1.types.ts",
13+
filename:
14+
"[[...slug]]/[Feature1]/(components)/name!/name+/name!/{name}/Feature.tsx",
15+
importPath:
16+
"[[...slug]]/[Feature1]/(components)/name!/name+/name!/{name}/feature1.types.ts",
1517
pattern: "{family}/*.ts",
16-
expected: "features/Feature1/\\(components\\)",
18+
expected:
19+
"\\[\\[\\.\\.\\.slug\\]\\]/\\[Feature1\\]/\\(components\\)/name\\!/name\\+/name\\!/\\{name\\}",
1720
},
1821
{
1922
filename: "features/Feature1/components/Child1.tsx",

src/rules/independentModules/helpers/getFamilyPath.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { getLvlFromPattern } from "rules/independentModules/helpers/getLvlFromPattern";
2+
import { removeMicromatchSpecialCharacters } from "rules/independentModules/helpers/removeMicromatchSpecialCharacters";
23
import { NO_FAMILY } from "rules/independentModules/independentModules.consts";
34

45
interface GetFamilyPathProps {
@@ -30,5 +31,5 @@ export const getFamilyPath = ({
3031

3132
if (familyParts.length < lvl) return NO_FAMILY;
3233

33-
return familyParts.join("/").replace(/[()]/g, (match) => `\\${match}`);
34+
return removeMicromatchSpecialCharacters(familyParts.join("/"));
3435
};
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export const removeMicromatchSpecialCharacters = (str: string): string =>
2+
str.replaceAll(/[().,+!{}[\]]/g, "\\$&");

yarn.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2777,16 +2777,16 @@ __metadata:
27772777
languageName: node
27782778
linkType: hard
27792779

2780-
"eslint-plugin-project-structure@npm:3.10.10":
2781-
version: 3.10.10
2782-
resolution: "eslint-plugin-project-structure@npm:3.10.10"
2780+
"eslint-plugin-project-structure@npm:3.10.11":
2781+
version: 3.10.11
2782+
resolution: "eslint-plugin-project-structure@npm:3.10.11"
27832783
dependencies:
27842784
"@typescript-eslint/utils": ^8.17.0
27852785
comment-json: ^4.2.5
27862786
js-yaml: ^4.1.0
27872787
jsonschema: ^1.4.1
27882788
micromatch: ^4.0.8
2789-
checksum: 4515d8cff27553699f934b17f3c0ee59db3440960d3d0265c5185ec9f4e01ab37faf3c08bc7d497752b44a8cc09898fcf27179f007c5493b0d137cf709346fe1
2789+
checksum: 4c36b533fe76faf6e7ddac436ecebea82d60e6b5dcd73b59abff6baa4c266ac5c8b0177ed0bc14c25820ac2a8f45f3a76a94b6f79c38fb3db7c1647594e78d63
27902790
languageName: node
27912791
linkType: hard
27922792

@@ -2807,7 +2807,7 @@ __metadata:
28072807
eslint-config-prettier: ^9.1.0
28082808
eslint-plugin-import: ^2.31.0
28092809
eslint-plugin-prettier: ^5.2.1
2810-
eslint-plugin-project-structure: 3.10.10
2810+
eslint-plugin-project-structure: 3.10.11
28112811
husky: ^9.1.7
28122812
jest: ^29.7.0
28132813
js-yaml: ^4.1.0

0 commit comments

Comments
 (0)