You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

eslint-plugin-forum-react

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-forum-react - npm Package Compare versions

Comparing version

to
0.0.10

28

lib/rules/path-checker.js

@@ -40,3 +40,20 @@ "use strict";

if(shouldBeRelative(fromFilename, importTo)) {
context.report(node, 'В рамках одного слайса все пути должны быть относительными');
context.report({
node,
message: 'В рамках одного слайса все пути должны быть относительными',
fix: (fixer) => {
const normalizedPath = getNormalizedCurrentFilePath(fromFilename)
.split('/')
.slice(0, -1)
.join('/');
let relativePath = path.relative(normalizedPath, `/${importTo}`)
.split('\\')
.join('/');
if(!relativePath.startsWith('.')) {
relativePath = './' + relativePath;
}
return fixer.replaceText(node.source, `'${relativePath}'`)
}
});
}

@@ -56,2 +73,8 @@ }

function getNormalizedCurrentFilePath(currenFilePath) {
const normalizedPath = path.toNamespacedPath(currenFilePath);
const projectFrom = normalizedPath.split('src')[1];
return projectFrom.split('\\').join('/')
}
function shouldBeRelative(from, to) {

@@ -71,4 +94,3 @@ if(isPathRelative(to)) {

const normalizedPath = path.toNamespacedPath(from);
const projectFrom = normalizedPath.split('src')[1];
const projectFrom = getNormalizedCurrentFilePath(from);
const fromArray = projectFrom.split('\\')

@@ -75,0 +97,0 @@

2

package.json
{
"name": "eslint-plugin-forum-react",
"version": "0.0.9",
"version": "0.0.10",
"description": "plugin for forum-react-project",

@@ -5,0 +5,0 @@ "keywords": [