@roq/eslint-plugin
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -15,3 +15,6 @@ module.exports = { | ||
const importPathParts = node.source ? node.source.value.split('/') : []; | ||
if (node.source && node.source.value.startsWith('..')) { | ||
const lastPartOfImportPath = importPathParts.length > 0 ? importPathParts[importPathParts.length - 1] : ''; | ||
const dotSeparatedLastPart = lastPartOfImportPath.split('.'); | ||
const firstSectionOfLastPartOfImportPath = dotSeparatedLastPart.length <= 2 ? dotSeparatedLastPart[0] : dotSeparatedLastPart.slice(0, dotSeparatedLastPart.length - 1).join('.'); | ||
if (node.source && (node.source.value.startsWith('..') || node.source.value.startsWith('.'))) { | ||
context.report({ | ||
@@ -22,3 +25,3 @@ node, | ||
} | ||
if (node.source && importPathParts.length > 0 && importPathParts[importPathParts.length - 1].startsWith('index')) { | ||
if (node.source && firstSectionOfLastPartOfImportPath === 'index') { | ||
context.report({ | ||
@@ -25,0 +28,0 @@ node, |
@@ -78,4 +78,8 @@ const { fileContext, executionContext } = require('../../helper'); | ||
node.body.forEach((e) => { | ||
if (e.type === 'ImportDeclaration' && e.source.value.includes('services')) { | ||
e.specifiers.forEach((el) => importedServices.push(el.local.name)); | ||
if(e.type === 'ImportDeclaration'){ | ||
e.specifiers.forEach((el) => { | ||
if(e.source.value.includes('services') || (el.local.name && el.local.name.toLowerCase().endsWith('service'))){ | ||
importedServices.push(el.local.name); | ||
} | ||
}); | ||
} | ||
@@ -82,0 +86,0 @@ }); |
{ | ||
"name": "@roq/eslint-plugin", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -34,3 +34,14 @@ const { RuleTester } = require('eslint'); | ||
}, | ||
{ | ||
code: 'import Something from "./folder/component"', | ||
errors: [{ | ||
message: 'Use absolute path instead of relative.', | ||
line: 1, | ||
column: 1, | ||
endLine: 1, | ||
endColumn: 43, | ||
}], | ||
filename: 'sample.ts', | ||
}, | ||
], | ||
}); |
@@ -96,3 +96,3 @@ const { RuleTester } = require('eslint'); | ||
{ | ||
code: `/* AnyOtherDirNamePage definition */ | ||
code: `/* UsersEditPage definition */ | ||
export default AnyOtherDirNamePage;`, | ||
@@ -99,0 +99,0 @@ errors: [ |
165598
4582