@application-kit/lint-config 0.5.3 → 0.6.0

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @application-kit/lint-config
2
2
 
3
+ ## 0.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - e8a72ad: Оболочка не импортирует другие модули: `no-restricted-imports` закрывает алиас `@/modules/<другой модуль>/…` и любой относительный подъём с заходом в другой каталог, свой код оболочка импортирует по алиасу. Спеки и `testing` вне запрета.
8
+
9
+ ### Patch Changes
10
+
11
+ - 3a17e1a: Импорт `@application-kit/observability/logging/nest` разрешён в приложениях.
12
+
3
13
  ## 0.5.3
4
14
 
5
15
  ### Patch Changes
package/README.md CHANGED
@@ -47,6 +47,10 @@ export default [
47
47
  | `src/**/*.vue` | классы вендора — правилом `vue/no-restricted-class` |
48
48
  | `src/modules/**/user-interface/client/**` | набор корня модуля и серверный GraphQL-класс |
49
49
  | `src/modules/<оболочка>/user-interface/**` | набор оболочки, внутренности субмодулей и серверный GraphQL-класс |
50
+ | `src/modules/<оболочка>/**` без спек и `testing` | плюс к наборам двух строк выше — импорт других модулей |
51
+
52
+ Из оболочки закрыт и относительный подъём с заходом в другой каталог: `../<модуль>/…` от своего `../<каталог>/…` по
53
+ строке импорта не отличить, поэтому свой код оболочка импортирует по алиасу.
50
54
 
51
55
  Каждый запрет держит два якоря — алиас `@/…` и относительную форму того же пути. `shellModule` — имя папки в
52
56
  kebab-case, `roleDictionary` — путь вида `@/<полка>/<путь>` из таких имён; иное значение роняет сборку конфига.
@@ -14,6 +14,7 @@ const APPLICATION_KIT_ENTRIES = [
14
14
  '@application-kit/kafka/event-contract',
15
15
  '@application-kit/observability/*',
16
16
  '@application-kit/observability/health/*',
17
+ '@application-kit/observability/logging/*',
17
18
  '@application-kit/security/password-hasher',
18
19
  '@application-kit/security/password-strength',
19
20
  '@application-kit/testing/stryker',
@@ -42,6 +42,11 @@ const shellInternalsImport = (shellModule) => ({
42
42
  message: `Внутренности модуля ${shellModule} не импортируются извне: общий код — в src/libs.`,
43
43
  regex: String.raw `^(?:@/modules/|${RELATIVE_UP}(?:modules/)?)${shellModule}/`,
44
44
  });
45
+ const shellForeignModuleImport = (shellModule) => ({
46
+ message: `Модуль ${shellModule} не импортирует другие модули: удаление модуля не должно его задевать. `
47
+ + `Свой код — по алиасу @/modules/${shellModule}/…, общий — из src/libs.`,
48
+ regex: String.raw `^(?:@/modules/(?!${shellModule}/)|${RELATIVE_UP}[^/.][^/]*/)`,
49
+ });
45
50
  const roleDictionaryImport = (roleDictionary) => {
46
51
  const aliasPath = roleDictionary.slice(ALIAS.length);
47
52
  const shelf = aliasPath.slice(0, aliasPath.indexOf('/'));
@@ -54,6 +59,23 @@ const roleDictionaryImport = (roleDictionary) => {
54
59
  const restrictedImports = (patterns) => ({
55
60
  'no-restricted-imports': ['error', { patterns }],
56
61
  });
62
+ const shellForeignModuleBlocks = (shellModule, shell, shellUserInterface) => {
63
+ const foreignModule = shellForeignModuleImport(shellModule);
64
+ const userInterfaceFiles = `src/modules/${shellModule}/user-interface/**`;
65
+ const testFiles = [`src/modules/${shellModule}/**/*.spec.ts`, `src/modules/${shellModule}/**/testing/**`];
66
+ return [
67
+ {
68
+ files: [`src/modules/${shellModule}/**`],
69
+ ignores: [...testFiles, userInterfaceFiles],
70
+ rules: restrictedImports([foreignModule, ...shell]),
71
+ },
72
+ {
73
+ files: [userInterfaceFiles],
74
+ ignores: testFiles,
75
+ rules: restrictedImports([foreignModule, ...shellUserInterface]),
76
+ },
77
+ ];
78
+ };
57
79
  export const defineRestrictedImportBlocks = (options) => {
58
80
  assertLayout(options);
59
81
  const { roleDictionary, shellModule } = options;
@@ -61,6 +83,7 @@ export const defineRestrictedImportBlocks = (options) => {
61
83
  const roleDictionaryPath = roleDictionaryImport(roleDictionary);
62
84
  const modules = [shellInternals, roleDictionaryPath, UI_VENDOR_IMPORT, I18N_VENDOR_IMPORT];
63
85
  const shell = [roleDictionaryPath, UI_VENDOR_IMPORT, I18N_VENDOR_IMPORT];
86
+ const shellUserInterface = [...shell, SUBMODULE_INTERNALS_IMPORT, SERVER_GRAPHQL_CLASS_IMPORT];
64
87
  const moduleRoot = [...modules, SUBMODULE_INTERNALS_IMPORT];
65
88
  return [
66
89
  { files: ['src/modules/*/**'], ignores: [`src/modules/${shellModule}/**`], rules: restrictedImports(moduleRoot) },
@@ -75,9 +98,7 @@ export const defineRestrictedImportBlocks = (options) => {
75
98
  files: ['src/modules/**/user-interface/client/**'],
76
99
  rules: restrictedImports([...moduleRoot, SERVER_GRAPHQL_CLASS_IMPORT]),
77
100
  },
78
- {
79
- files: [`src/modules/${shellModule}/user-interface/**`],
80
- rules: restrictedImports([...shell, SUBMODULE_INTERNALS_IMPORT, SERVER_GRAPHQL_CLASS_IMPORT]),
81
- },
101
+ { files: [`src/modules/${shellModule}/user-interface/**`], rules: restrictedImports(shellUserInterface) },
102
+ ...shellForeignModuleBlocks(shellModule, shell, shellUserInterface),
82
103
  ];
83
104
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@application-kit/lint-config",
3
- "version": "0.5.3",
3
+ "version": "0.6.0",
4
4
  "description": "Пресет ESLint приложения на пакетах @application-kit: flat-config с границами слоёв, разрешёнными подпутями пакетов и запретами UI-вендора",
5
5
  "keywords": [
6
6
  "eslint-config",