eslint-plugin-power-esrules 0.1.6 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,28 +13,34 @@
13
13
  /**
14
14
  * Определяет тип импорта
15
15
  * @param {Object} node - AST узел ImportDeclaration
16
- * @returns {string} - 'external', 'internal', или 'component'
16
+ * @returns {string} - 'external', 'internal', 'component', или 'relative'
17
17
  */
18
18
  function getImportType(node) {
19
19
  const source = node.source.value;
20
- // Относительные импорты (./ или ../) всегда внутренние
20
+ // Относительные импорты (./ или ../) должны быть всегда самыми последними.
21
+ // Поэтому выделяем их в отдельный тип с самым низким приоритетом сортировки.
21
22
  if (source.startsWith("./") || source.startsWith("../")) {
22
- // Проверяем, является ли это компонентом
23
- // Компоненты обычно импортируются как default или с большой буквы
24
- const isDefaultImport = node.specifiers.some(
25
- (spec) => spec.type === "ImportDefaultSpecifier"
26
- );
27
- const hasComponentName = node.specifiers.some(
28
- (spec) =>
29
- spec.type === "ImportSpecifier" &&
30
- spec.imported &&
31
- /^[A-Z]/.test(spec.imported.name)
32
- );
33
- if (isDefaultImport || hasComponentName) {
34
- return "component";
35
- }
36
- return "internal";
23
+ return "relative";
37
24
  }
25
+ // Старое поведение (оставлено для истории):
26
+ // Относительные импорты (./ или ../) всегда внутренние
27
+ // if (source.startsWith("./") || source.startsWith("../")) {
28
+ // // Проверяем, является ли это компонентом
29
+ // // Компоненты обычно импортируются как default или с большой буквы
30
+ // const isDefaultImport = node.specifiers.some(
31
+ // (spec) => spec.type === "ImportDefaultSpecifier"
32
+ // );
33
+ // const hasComponentName = node.specifiers.some(
34
+ // (spec) =>
35
+ // spec.type === "ImportSpecifier" &&
36
+ // spec.imported &&
37
+ // /^[A-Z]/.test(spec.imported.name)
38
+ // );
39
+ // if (isDefaultImport || hasComponentName) {
40
+ // return "component";
41
+ // }
42
+ // return "internal";
43
+ // }
38
44
 
39
45
  // Сторонние библиотеки (не относительные и не начинаются с внутренних путей)
40
46
  const internalPathPatterns = [
@@ -105,6 +111,7 @@ function getImportPriority(type) {
105
111
  external: 1,
106
112
  internal: 2,
107
113
  component: 3,
114
+ relative: 4,
108
115
  };
109
116
  return priorities[type] || 999;
110
117
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-power-esrules",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "custom ESLint rules",
5
5
  "main": "index.js",
6
6
  "peerDependencies": {