@scandipwa/eslint-plugin-scandipwa-guidelines
Advanced tools
Comparing version 2.0.4 to 2.0.5
@@ -113,3 +113,4 @@ /** | ||
return stack.reverse().join(path.sep); | ||
// not using path.sep on purpose | ||
return stack.reverse().join('/'); | ||
} | ||
@@ -125,2 +126,6 @@ | ||
/** | ||
* We do not want the \\ paths on Windows, rather / => | ||
* split and then join with correct delimiter | ||
**/ | ||
return path.join( | ||
@@ -131,8 +136,20 @@ dir, | ||
postfix | ||
); | ||
).split(path.sep) | ||
// Filter out empty strings if they exist | ||
.filter(x => !!x); | ||
} | ||
const preparePackageName = (packageName) => { | ||
const [org, name] = packageName.split(path.sep); | ||
// This is on purpose not a path.sep (windows support) | ||
const [org = '', name = ''] = packageName.split('/'); | ||
if (!name) { | ||
// if there is no name => there is not ORG | ||
if (packageName === '<%= name %>') { | ||
return 'placeholder' | ||
} | ||
return packageName; | ||
} | ||
if (org === '@scandipwa') { | ||
@@ -147,3 +164,3 @@ // Legacy support | ||
return path.join(org.slice(1), name); | ||
return `${org.slice(1)}/${name}`; | ||
}; | ||
@@ -158,15 +175,16 @@ | ||
const pathname = path.join( | ||
// Not using path.join to support windows | ||
const pathname = [ | ||
// remove @ from organization, support @scandipwa legacy namespaces | ||
preparePackageName(packageName), | ||
// trim post-fixes if they are not present | ||
prepareFilePath(toFile) | ||
).replace( | ||
// Trim post-fixes if they are not present | ||
...prepareFilePath(toFile) | ||
].join('/').replace( | ||
// Convert to pascal-case, and trim "-" | ||
/\b[a-z](?=[a-z]{2})/g, | ||
(letter) => letter.toUpperCase() | ||
).replace('-', ''); | ||
).replace('-', ''); | ||
// do not transform code to uppercase / lowercase it should be written alright | ||
return path.join(pathname, getNodeNamespace(node)); | ||
// Do not transform code to uppercase / lowercase it should be written alright | ||
return `${pathname}/${getNodeNamespace(node)}`; | ||
} | ||
@@ -173,0 +191,0 @@ |
{ | ||
"name": "@scandipwa/eslint-plugin-scandipwa-guidelines", | ||
"description": "ESLint plugin used by CSA.", | ||
"version": "2.0.4", | ||
"version": "2.0.5", | ||
"keywords": [ | ||
@@ -29,3 +29,3 @@ "eslint", | ||
}, | ||
"gitHead": "0d9c00cbc175f43a2a7ccfdc1846272f3384f93e" | ||
"gitHead": "3f522fb67772340bfdaeb6e4cf49bb0d88f474c1" | ||
} |
48519
1260