Skip to content

Commit

Permalink
3.8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Igorkowalski94 committed Oct 21, 2024
1 parent 6e92eba commit 79468b6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
2 changes: 1 addition & 1 deletion 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.8.0",
"version": "3.8.1",
"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
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,24 @@ describe("getImportPaths", () => {
},
expected: ["src/rules/independentModules/independentModules"],
},

{
importPath: "@clerk/nextjs",
paths: {
"@/*": ["./src/*"],
},
expected: ["@clerk/nextjs"],
},

{
importPath: "@/components/hello",
paths: {
"@/*": ["./src/*", "../../test/*"],
},
expected: ["src/components/hello", "test/components/hello"],
},
])(
"Should return correct value for %s",
"Should return correct value for %o",
({ importPath, paths, expected }) => {
expect(getImportPaths({ importPath, paths })).toEqual(expected);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@ export const getImportPaths = ({

return pathsKays
.map((key) => {
const keyCleared = key.replace("/*", "");
const keyCleared = key.replace("*", "");
const importPaths = paths[key];

return importPaths.map((importPathReplace) =>
importPath.replace(keyCleared, importPathReplace.replace("/*", "")),
);
return importPaths
.map((importPath) =>
importPath.replaceAll("../", "").replaceAll("./", ""),
)
.map((importPathReplace) =>
importPath.replace(keyCleared, importPathReplace.replace("*", "")),
);
})
.flat();
};

0 comments on commit 79468b6

Please sign in to comment.