Skip to content

Commit

Permalink
3.11.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Igorkowalski94 committed Dec 5, 2024
1 parent 84d25c4 commit 4bd9767
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 13 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"author": "Igor Kowalski (Igorkowalski94)",
"name": "eslint-plugin-project-structure",
"version": "3.10.11",
"version": "3.11.0",
"license": "MIT",
"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",
"keywords": [
Expand Down Expand Up @@ -74,7 +74,7 @@
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-project-structure": "3.10.10",
"eslint-plugin-project-structure": "3.10.11",
"husky": "^9.1.7",
"jest": "^29.7.0",
"prettier": "^3.4.2",
Expand Down
27 changes: 26 additions & 1 deletion src/rules/independentModules/helpers/getDirnamePath.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,35 @@ describe("getDirnamePath", () => {
expected: "C:/Users/user/Desktop/repo",
},
{
filename: "C:/Users/user/Desktop/(components)/src/",
filename: "C:/Users/user/Desktop/(components)/src",
pattern: "{dirname}/*.ts",
expected: "C:/Users/user/Desktop/\\(components\\)",
},
{
filename: "C:/Users/user/Desktop/{components}/src",
pattern: "{dirname}/*.ts",
expected: "C:/Users/user/Desktop/\\{components\\}",
},
{
filename: "C:/Users/user/Desktop/[[...slug]]/src",
pattern: "{dirname}/*.ts",
expected: "C:/Users/user/Desktop/\\[\\[\\.\\.\\.slug\\]\\]",
},
{
filename: "C:/Users/user/Desktop/components!/src",
pattern: "{dirname}/*.ts",
expected: "C:/Users/user/Desktop/components\\!",
},
{
filename: "C:/Users/user/Desktop/components+/src",
pattern: "{dirname}/*.ts",
expected: "C:/Users/user/Desktop/components\\+",
},
{
filename: "C:/Users/user/Desktop/components,/src",
pattern: "{dirname}/*.ts",
expected: "C:/Users/user/Desktop/components\\,",
},
{
filename: "C:/Users/user/Desktop/repo/src/",
pattern: "{dirname_1}/*.ts",
Expand Down
3 changes: 2 additions & 1 deletion src/rules/independentModules/helpers/getDirnamePath.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import path from "path";

import { getLvlFromPattern } from "rules/independentModules/helpers/getLvlFromPattern";
import { removeMicromatchSpecialCharacters } from "rules/independentModules/helpers/removeMicromatchSpecialCharacters";

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

return dirnamePath.replace(/[()]/g, (match) => `\\${match}`);
return removeMicromatchSpecialCharacters(dirnamePath);
};
9 changes: 6 additions & 3 deletions src/rules/independentModules/helpers/getFamilyPath.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ describe("getFamilyPath", () => {
expected: "features/Feature1",
},
{
filename: "features/Feature1/(components)/Feature.tsx",
importPath: "features/Feature1/(components)/feature1.types.ts",
filename:
"[[...slug]]/[Feature1]/(components)/name!/name+/name!/{name}/Feature.tsx",
importPath:
"[[...slug]]/[Feature1]/(components)/name!/name+/name!/{name}/feature1.types.ts",
pattern: "{family}/*.ts",
expected: "features/Feature1/\\(components\\)",
expected:
"\\[\\[\\.\\.\\.slug\\]\\]/\\[Feature1\\]/\\(components\\)/name\\!/name\\+/name\\!/\\{name\\}",
},
{
filename: "features/Feature1/components/Child1.tsx",
Expand Down
3 changes: 2 additions & 1 deletion src/rules/independentModules/helpers/getFamilyPath.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getLvlFromPattern } from "rules/independentModules/helpers/getLvlFromPattern";
import { removeMicromatchSpecialCharacters } from "rules/independentModules/helpers/removeMicromatchSpecialCharacters";
import { NO_FAMILY } from "rules/independentModules/independentModules.consts";

interface GetFamilyPathProps {
Expand Down Expand Up @@ -30,5 +31,5 @@ export const getFamilyPath = ({

if (familyParts.length < lvl) return NO_FAMILY;

return familyParts.join("/").replace(/[()]/g, (match) => `\\${match}`);
return removeMicromatchSpecialCharacters(familyParts.join("/"));
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const removeMicromatchSpecialCharacters = (str: string): string =>
str.replaceAll(/[().,+!{}[\]]/g, "\\$&");
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2777,16 +2777,16 @@ __metadata:
languageName: node
linkType: hard

"eslint-plugin-project-structure@npm:3.10.10":
version: 3.10.10
resolution: "eslint-plugin-project-structure@npm:3.10.10"
"eslint-plugin-project-structure@npm:3.10.11":
version: 3.10.11
resolution: "eslint-plugin-project-structure@npm:3.10.11"
dependencies:
"@typescript-eslint/utils": ^8.17.0
comment-json: ^4.2.5
js-yaml: ^4.1.0
jsonschema: ^1.4.1
micromatch: ^4.0.8
checksum: 4515d8cff27553699f934b17f3c0ee59db3440960d3d0265c5185ec9f4e01ab37faf3c08bc7d497752b44a8cc09898fcf27179f007c5493b0d137cf709346fe1
checksum: 4c36b533fe76faf6e7ddac436ecebea82d60e6b5dcd73b59abff6baa4c266ac5c8b0177ed0bc14c25820ac2a8f45f3a76a94b6f79c38fb3db7c1647594e78d63
languageName: node
linkType: hard

Expand All @@ -2807,7 +2807,7 @@ __metadata:
eslint-config-prettier: ^9.1.0
eslint-plugin-import: ^2.31.0
eslint-plugin-prettier: ^5.2.1
eslint-plugin-project-structure: 3.10.10
eslint-plugin-project-structure: 3.10.11
husky: ^9.1.7
jest: ^29.7.0
js-yaml: ^4.1.0
Expand Down

0 comments on commit 4bd9767

Please sign in to comment.