@futdevpro/dynamo-eslint 1.12.1 → 1.14.3

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.
Files changed (117) hide show
  1. package/.github/workflows/main.yml +1 -2
  2. package/README.md +286 -17
  3. package/build/configs/base.d.ts +9 -80
  4. package/build/configs/base.d.ts.map +1 -1
  5. package/build/configs/base.js +89 -49
  6. package/build/configs/base.js.map +1 -1
  7. package/build/configs/fsm.d.ts +1 -81
  8. package/build/configs/fsm.d.ts.map +1 -1
  9. package/build/configs/fsm.js +7 -6
  10. package/build/configs/fsm.js.map +1 -1
  11. package/build/configs/ngx-package.d.ts +1 -80
  12. package/build/configs/ngx-package.d.ts.map +1 -1
  13. package/build/configs/ngx-package.js +7 -6
  14. package/build/configs/ngx-package.js.map +1 -1
  15. package/build/configs/ngx.d.ts +4 -80
  16. package/build/configs/ngx.d.ts.map +1 -1
  17. package/build/configs/ngx.js +71 -11
  18. package/build/configs/ngx.js.map +1 -1
  19. package/build/configs/nts-package.d.ts +1 -82
  20. package/build/configs/nts-package.d.ts.map +1 -1
  21. package/build/configs/nts-package.js +16 -10
  22. package/build/configs/nts-package.js.map +1 -1
  23. package/build/configs/nts.d.ts +1 -81
  24. package/build/configs/nts.d.ts.map +1 -1
  25. package/build/configs/nts.js +30 -11
  26. package/build/configs/nts.js.map +1 -1
  27. package/build/plugin/index.d.ts +4 -0
  28. package/build/plugin/index.d.ts.map +1 -1
  29. package/build/plugin/index.js +7 -1
  30. package/build/plugin/index.js.map +1 -1
  31. package/build/plugin/rules/import/import-order.d.ts +4 -0
  32. package/build/plugin/rules/import/import-order.d.ts.map +1 -0
  33. package/build/plugin/rules/{import-order.js → import/import-order.js} +16 -17
  34. package/build/plugin/rules/import/import-order.js.map +1 -0
  35. package/build/plugin/rules/import/import-order.spec.d.ts.map +1 -0
  36. package/build/plugin/rules/{import-order.spec.js → import/import-order.spec.js} +40 -40
  37. package/build/plugin/rules/import/import-order.spec.js.map +1 -0
  38. package/build/plugin/rules/import/no-import-type.d.ts +4 -0
  39. package/build/plugin/rules/import/no-import-type.d.ts.map +1 -0
  40. package/build/plugin/rules/import/no-import-type.js +35 -0
  41. package/build/plugin/rules/import/no-import-type.js.map +1 -0
  42. package/build/plugin/rules/import/no-import-type.spec.d.ts +2 -0
  43. package/build/plugin/rules/import/no-import-type.spec.d.ts.map +1 -0
  44. package/build/plugin/rules/import/no-import-type.spec.js +60 -0
  45. package/build/plugin/rules/import/no-import-type.spec.js.map +1 -0
  46. package/build/plugin/rules/import/no-js-import.d.ts +4 -0
  47. package/build/plugin/rules/import/no-js-import.d.ts.map +1 -0
  48. package/build/plugin/rules/import/no-js-import.js +33 -0
  49. package/build/plugin/rules/import/no-js-import.js.map +1 -0
  50. package/build/plugin/rules/import/no-js-import.spec.d.ts +2 -0
  51. package/build/plugin/rules/import/no-js-import.spec.d.ts.map +1 -0
  52. package/build/plugin/rules/import/no-js-import.spec.js +68 -0
  53. package/build/plugin/rules/import/no-js-import.spec.js.map +1 -0
  54. package/build/plugin/rules/naming-patterns.d.ts +1 -1
  55. package/build/plugin/rules/naming-patterns.d.ts.map +1 -1
  56. package/build/plugin/rules/naming-patterns.spec.js +1 -1
  57. package/build/plugin/rules/naming-patterns.spec.js.map +1 -1
  58. package/build/scripts/dynamo-fix.d.ts +3 -0
  59. package/build/scripts/dynamo-fix.d.ts.map +1 -0
  60. package/build/scripts/dynamo-fix.js +92 -0
  61. package/build/scripts/dynamo-fix.js.map +1 -0
  62. package/build/scripts/eslintrc-audit.js.map +1 -1
  63. package/build/scripts/fix-return-types.d.ts +3 -0
  64. package/build/scripts/fix-return-types.d.ts.map +1 -0
  65. package/build/scripts/fix-return-types.js +109 -0
  66. package/build/scripts/fix-return-types.js.map +1 -0
  67. package/build/scripts/validate-imports.js +10 -9
  68. package/build/scripts/validate-imports.js.map +1 -1
  69. package/build/scripts/validate-naming.js +11 -26
  70. package/build/scripts/validate-naming.js.map +1 -1
  71. package/build-test/plugin/rules/import-order.d.ts +1 -1
  72. package/build-test/plugin/rules/naming-patterns.d.ts +1 -1
  73. package/eslint.config.js +55 -0
  74. package/futdevpro-dynamo-eslint-01.14.3.tgz +0 -0
  75. package/package.json +27 -18
  76. package/samples/.vscode/settings.json +13 -0
  77. package/samples/base/eslint.config.js +3 -0
  78. package/samples/fsm/.eslintrc.json +4 -0
  79. package/samples/fsm/eslint.config.js +3 -0
  80. package/samples/ngx/eslint.config.js +3 -0
  81. package/samples/ngx-package/.eslintrc.json +4 -0
  82. package/samples/ngx-package/eslint.config.js +3 -0
  83. package/samples/nts/eslint.config.js +3 -0
  84. package/samples/nts-package/.eslintrc.json +4 -0
  85. package/samples/nts-package/eslint.config.js +3 -0
  86. package/samples/package.json.example +26 -0
  87. package/samples/poc-violations.ts +32 -3
  88. package/src/configs/base.ts +93 -48
  89. package/src/configs/fsm.ts +8 -7
  90. package/src/configs/ngx-package.ts +8 -7
  91. package/src/configs/ngx.ts +71 -11
  92. package/src/configs/nts-package.ts +16 -10
  93. package/src/configs/nts.ts +30 -11
  94. package/src/plugin/index.ts +9 -1
  95. package/src/plugin/rules/{import-order.spec.ts → import/import-order.spec.ts} +46 -40
  96. package/src/plugin/rules/{import-order.ts → import/import-order.ts} +20 -18
  97. package/src/plugin/rules/import/no-import-type.spec.ts +69 -0
  98. package/src/plugin/rules/import/no-import-type.ts +37 -0
  99. package/src/plugin/rules/import/no-js-import.spec.ts +82 -0
  100. package/src/plugin/rules/import/no-js-import.ts +35 -0
  101. package/src/plugin/rules/naming-patterns.spec.ts +3 -1
  102. package/src/plugin/rules/naming-patterns.ts +1 -1
  103. package/src/scripts/dynamo-fix.ts +108 -0
  104. package/src/scripts/eslintrc-audit.ts +6 -2
  105. package/src/scripts/fix-return-types.ts +148 -0
  106. package/src/scripts/validate-imports.ts +95 -13
  107. package/src/scripts/validate-naming.ts +16 -28
  108. package/.eslintrc.json +0 -16
  109. package/INTEGRATION.md +0 -74
  110. package/POC-README.md +0 -147
  111. package/build/plugin/rules/import-order.d.ts +0 -4
  112. package/build/plugin/rules/import-order.d.ts.map +0 -1
  113. package/build/plugin/rules/import-order.js.map +0 -1
  114. package/build/plugin/rules/import-order.spec.d.ts.map +0 -1
  115. package/build/plugin/rules/import-order.spec.js.map +0 -1
  116. package/futdevpro-dynamo-eslint-01.12.01.tgz +0 -0
  117. /package/build/plugin/rules/{import-order.spec.d.ts → import/import-order.spec.d.ts} +0 -0
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "example-project",
3
+ "version": "1.0.0",
4
+ "scripts": {
5
+ "lint": "eslint src --ext .ts",
6
+ "lint:fix": "eslint src --ext .ts --fix",
7
+ "lint:fix-all": "eslint src --ext .ts --fix && dynamo-fix-return-types",
8
+ "validate:imports": "dynamo-validate-imports",
9
+ "validate:naming": "dynamo-validate-naming",
10
+ "audit:eslintrc": "dynamo-eslintrc-audit",
11
+ "fix": "dynamo-fix",
12
+ "fix:return-types": "dynamo-fix-return-types",
13
+ "test": "npm run lint && npm run validate:imports && npm run validate:naming"
14
+ },
15
+ "devDependencies": {
16
+ "@futdevpro/dynamo-eslint": "^01.14.2",
17
+ "@typescript-eslint/eslint-plugin": "^8.0.0",
18
+ "@typescript-eslint/parser": "^8.0.0",
19
+ "eslint": "^9.0.0",
20
+ "eslint-plugin-import": "^2.29.0",
21
+ "eslint-plugin-jsdoc": "^48.0.0",
22
+ "eslint-plugin-prettier": "^5.1.3",
23
+ "prettier": "^3.3.0",
24
+ "typescript": "^5.5.4"
25
+ }
26
+ }
@@ -4,6 +4,16 @@
4
4
  // ❌ VIOLATIONS: This file contains multiple import ordering violations
5
5
 
6
6
  // Wrong order: FutDevPro packages before non-FutDevPro packages
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
7
17
  import { DyFM_Error } from '@futdevpro/fsm-dynamo';
8
18
  import { Component } from '@angular/core';
9
19
 
@@ -12,13 +22,32 @@ import { Router } from '@angular/router';
12
22
  import { FDP_User } from '@futdevpro/fdp-templates';
13
23
 
14
24
  // Wrong order: same module before other modules
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
15
35
  import { LocalService } from './local.service';
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+
16
45
  import { SomeService } from '../../../services/some.service';
17
46
 
18
47
  // ❌ Forbidden patterns:
19
- import { Something } from '../../../NPM-packages/some-package'; // Forbidden NPM-packages import
20
- import { AnotherThing } from './some-file.js'; // Forbidden .js extension
21
- import type { SomeType } from './some-file'; // Forbidden import type
48
+ import { Something } from '@futdevpro/some-package'; // Forbidden NPM-packages import
49
+ import { AnotherThing } from './some-file'; // Forbidden .js extension
50
+ import { SomeType } from './some-file'; // Forbidden import type
22
51
 
23
52
  export class PocViolationsComponent {
24
53
  // This class demonstrates various import violations
@@ -1,51 +1,96 @@
1
- export = {
2
- env: { browser: true, es2021: true },
3
- parser: '@typescript-eslint/parser',
4
- parserOptions: { ecmaVersion: 'latest' },
5
- plugins: [
6
- '@typescript-eslint',
7
- 'unused-imports',
8
- 'max-params-no-constructor',
9
- ],
10
- extends: [
11
- 'eslint:recommended',
12
- 'plugin:@typescript-eslint/recommended',
13
- ],
14
- rules: {
15
- 'no-warning-comments': ['warn', { terms: ['todo', 'fixme', 'removable', '??'], location: 'anywhere' }],
16
- indent: ['warn', 2, { SwitchCase: 1 }],
17
- 'max-len': ['warn', { code: 100, comments: 120 }],
18
- 'max-lines': ['warn', 1000],
19
- 'linebreak-style': 'off',
20
- semi: ['warn', 'always'],
21
- 'no-unused-vars': 'off',
22
- 'no-prototype-builtins': 'off',
23
- 'no-empty': 'warn',
24
- 'comma-dangle': ['warn', { arrays: 'always-multiline', objects: 'always-multiline', functions: 'only-multiline', imports: 'never', exports: 'never' }],
25
- 'brace-style': ['warn', '1tbs', { allowSingleLine: false }],
26
- 'object-curly-spacing': ['warn', 'always'],
27
- 'array-bracket-spacing': ['warn', 'always', { objectsInArrays: false, arraysInArrays: false }],
28
- 'padding-line-between-statements': [
29
- 'warn',
30
- { blankLine: 'always', prev: '*', next: ['return','throw','if','for','while','switch','default'] },
31
- { blankLine: 'always', prev: ['const','let','var','break'], next: '*' },
32
- { blankLine: 'any', prev: ['const','let','var'], next: ['const','let','var'] },
33
- ],
34
- 'prefer-const': 'warn',
35
- 'no-case-declarations': 'off',
36
- 'no-fallthrough': 'off',
37
- 'keyword-spacing': 'warn',
38
- 'no-else-return': 'warn',
39
- 'no-duplicate-imports': 'warn',
40
- 'max-params': ['warn', 4],
41
- 'max-params-no-constructor/max-params-no-constructor': ['warn', 5],
42
- quotes: ['warn', 'single', { allowTemplateLiterals: true }],
43
- '@typescript-eslint/quotes': ['warn', 'single', { allowTemplateLiterals: true }],
44
- '@typescript-eslint/no-unused-vars': 'warn',
45
- '@typescript-eslint/explicit-function-return-type': ['warn', { allowTypedFunctionExpressions: false }],
46
- '@typescript-eslint/no-explicit-any': 'warn',
47
- '@typescript-eslint/typedef': 'warn',
1
+
2
+ /**
3
+ * Base Rulesets For Dynamo Based Systems
4
+ * ESLint v9 Flat Config Format
5
+ */
6
+ const tsParser = require('@typescript-eslint/parser');
7
+ const tsPlugin = require('@typescript-eslint/eslint-plugin');
8
+ const unusedImportsPlugin = require('eslint-plugin-unused-imports');
9
+ const maxParamsNoConstructorPlugin = require('eslint-plugin-max-params-no-constructor');
10
+ const dynamoPlugin = require('../plugin');
11
+
12
+ module.exports = [
13
+ {
14
+ ignores: [
15
+ 'node_modules/**',
16
+ 'dist/**',
17
+ 'build/**',
18
+ '*.d.ts'
19
+ ]
20
+ },
21
+ {
22
+ files: ['**/*.ts', '**/*.tsx'],
23
+ languageOptions: {
24
+ parser: tsParser,
25
+ parserOptions: {
26
+ ecmaVersion: 'latest',
27
+ sourceType: 'module'
28
+ },
29
+ globals: {
30
+ // Browser globals
31
+ window: 'readonly',
32
+ document: 'readonly',
33
+ console: 'readonly',
34
+ process: 'readonly',
35
+ Buffer: 'readonly',
36
+ global: 'readonly',
37
+ __dirname: 'readonly',
38
+ __filename: 'readonly',
39
+ module: 'readonly',
40
+ require: 'readonly',
41
+ exports: 'readonly'
42
+ }
43
+ },
44
+ plugins: {
45
+ '@typescript-eslint': tsPlugin,
46
+ 'unused-imports': unusedImportsPlugin,
47
+ 'max-params-no-constructor': maxParamsNoConstructorPlugin,
48
+ '@futdevpro/dynamo': dynamoPlugin,
49
+ },
50
+ rules: {
51
+ // ESLint recommended rules
52
+ 'no-warning-comments': ['warn', { terms: ['todo', 'fixme', 'removable', '??'], location: 'anywhere' }],
53
+ 'indent': ['warn', 2, { SwitchCase: 1 }],
54
+ 'max-len': ['warn', { code: 100, comments: 120 }],
55
+ 'max-lines': ['warn', 1000],
56
+ 'linebreak-style': 'off',
57
+ 'semi': ['warn', 'always'],
58
+ 'no-unused-vars': 'off',
59
+ 'no-prototype-builtins': 'off',
60
+ 'no-empty': 'warn',
61
+ 'comma-dangle': ['warn', { arrays: 'always-multiline', objects: 'always-multiline', functions: 'only-multiline', imports: 'never', exports: 'never' }],
62
+ 'brace-style': ['warn', '1tbs', { allowSingleLine: false }],
63
+ 'object-curly-spacing': ['warn', 'always'],
64
+ 'array-bracket-spacing': ['warn', 'always', { objectsInArrays: false, arraysInArrays: false }],
65
+ 'padding-line-between-statements': [
66
+ 'warn',
67
+ { blankLine: 'always', prev: '*', next: ['return','throw','if','for','while','switch','default'] },
68
+ { blankLine: 'always', prev: ['const','let','var','break'], next: '*' },
69
+ { blankLine: 'any', prev: ['const','let','var'], next: ['const','let','var'] },
70
+ ],
71
+ 'prefer-const': 'warn',
72
+ 'no-case-declarations': 'off',
73
+ 'no-fallthrough': 'off',
74
+ 'keyword-spacing': 'warn',
75
+ 'no-else-return': 'warn',
76
+ 'no-duplicate-imports': 'warn',
77
+ 'max-params': ['warn', 4],
78
+ 'max-params-no-constructor/max-params-no-constructor': ['warn', 5],
79
+ 'quotes': ['warn', 'single', { allowTemplateLiterals: true }],
80
+
81
+ // TypeScript rules
82
+ '@typescript-eslint/no-unused-vars': 'warn',
83
+ '@typescript-eslint/explicit-function-return-type': ['warn', { allowTypedFunctionExpressions: false }],
84
+ '@typescript-eslint/no-explicit-any': 'warn',
85
+ '@typescript-eslint/typedef': 'warn',
86
+
87
+ // Dynamo custom rules
88
+ '@futdevpro/dynamo/import-order': 'warn',
89
+ '@futdevpro/dynamo/naming-patterns': 'warn',
90
+ '@futdevpro/dynamo/no-import-type': 'warn',
91
+ '@futdevpro/dynamo/no-js-import': 'warn',
92
+ },
48
93
  },
49
- };
94
+ ];
50
95
 
51
96
 
@@ -1,9 +1,10 @@
1
- import nts = require('./nts');
2
-
3
- const config = {
4
- ...nts,
5
- };
6
-
7
- export = config;
1
+ const fsmBaseConfig = require('./base');
2
+
3
+ /**
4
+ * Rulesets For Dynamo Based Systems
5
+ * FSM: Full Stack Module
6
+ * ESLint v9 Flat Config Format
7
+ */
8
+ module.exports = fsmBaseConfig;
8
9
 
9
10
 
@@ -1,9 +1,10 @@
1
- import ngx = require('./ngx');
2
-
3
- const config = {
4
- ...ngx,
5
- };
6
-
7
- export = config;
1
+ const ngxConfig = require('./ngx');
2
+
3
+ /**
4
+ * Rulesets For Dynamo Based Systems
5
+ * NGX-PACKAGE: Angular Package
6
+ * ESLint v9 Flat Config Format
7
+ */
8
+ module.exports = ngxConfig;
8
9
 
9
10
 
@@ -1,14 +1,74 @@
1
- import base = require('./base');
1
+ const ngxBaseConfig = require('./base');
2
+ const angularPlugin = require('@angular-eslint/eslint-plugin');
3
+ const angularTemplatePlugin = require('@angular-eslint/eslint-plugin-template');
4
+ const angularTemplateParser = require('@angular-eslint/template-parser');
2
5
 
3
- const config = {
4
- ...base,
5
- env: { browser: true, es2021: true },
6
- extends: [
7
- ...base.extends,
8
- 'plugin:@angular-eslint/recommended',
9
- ],
10
- };
11
-
12
- export = config;
6
+ /**
7
+ * Rulesets For Dynamo Based Systems
8
+ * NGX: Angular Projects
9
+ * ESLint v9 Flat Config Format
10
+ */
11
+ module.exports = [
12
+ ...ngxBaseConfig,
13
+ {
14
+ files: ['**/*.ts', '**/*.tsx'],
15
+ languageOptions: {
16
+ ...ngxBaseConfig[1].languageOptions,
17
+ globals: {
18
+ // Angular globals
19
+ window: 'readonly',
20
+ document: 'readonly',
21
+ console: 'readonly',
22
+ process: 'readonly',
23
+ Buffer: 'readonly',
24
+ global: 'readonly',
25
+ __dirname: 'readonly',
26
+ __filename: 'readonly',
27
+ module: 'readonly',
28
+ require: 'readonly',
29
+ exports: 'readonly'
30
+ }
31
+ },
32
+ plugins: {
33
+ ...ngxBaseConfig[1].plugins,
34
+ '@angular-eslint': angularPlugin,
35
+ },
36
+ rules: {
37
+ ...ngxBaseConfig[1].rules,
38
+ // Angular-specific rules
39
+ '@angular-eslint/directive-selector': 'error',
40
+ '@angular-eslint/component-selector': 'error',
41
+ '@angular-eslint/no-conflicting-lifecycle': 'error',
42
+ '@angular-eslint/no-host-metadata-property': 'error',
43
+ '@angular-eslint/no-input-rename': 'error',
44
+ '@angular-eslint/no-output-rename': 'error',
45
+ '@angular-eslint/no-outputs-metadata-property': 'error',
46
+ '@angular-eslint/use-lifecycle-interface': 'error',
47
+ '@angular-eslint/use-pipe-transform-interface': 'error',
48
+ },
49
+ },
50
+ {
51
+ files: ['**/*.html'],
52
+ languageOptions: {
53
+ parser: angularTemplateParser,
54
+ parserOptions: {
55
+ ecmaVersion: 'latest',
56
+ sourceType: 'module',
57
+ },
58
+ },
59
+ plugins: {
60
+ '@angular-eslint/template': angularTemplatePlugin,
61
+ },
62
+ rules: {
63
+ '@angular-eslint/template/banana-in-box': 'error',
64
+ '@angular-eslint/template/cyclomatic-complexity': 'error',
65
+ '@angular-eslint/template/eqeqeq': 'error',
66
+ '@angular-eslint/template/no-call-expression': 'error',
67
+ '@angular-eslint/template/no-duplicate-attributes': 'error',
68
+ '@angular-eslint/template/no-negated-async': 'error',
69
+ '@angular-eslint/template/use-track-by-function': 'error',
70
+ },
71
+ },
72
+ ];
13
73
 
14
74
 
@@ -1,14 +1,20 @@
1
- import nts = require('./nts');
1
+ const ntsConfig = require('./nts');
2
2
 
3
- const config = {
4
- ...nts,
5
- rules: {
6
- ...nts.rules,
7
- '@typescript-eslint/ban-types': 'off',
8
- '@typescript-eslint/no-explicit-any': 'off',
3
+ /**
4
+ * Rulesets For Dynamo Based Systems
5
+ * NTS-PACKAGE: Node TypeScript Package
6
+ * ESLint v9 Flat Config Format
7
+ */
8
+ module.exports = [
9
+ ...ntsConfig,
10
+ {
11
+ files: ['**/*.ts', '**/*.tsx'],
12
+ rules: {
13
+ ...ntsConfig[1].rules,
14
+ '@typescript-eslint/ban-types': 'off',
15
+ '@typescript-eslint/no-explicit-any': 'off',
16
+ },
9
17
  },
10
- };
11
-
12
- export = config;
18
+ ];
13
19
 
14
20
 
@@ -1,15 +1,34 @@
1
- import base = require('./base');
1
+ const ntsBaseConfig = require('./base');
2
2
 
3
- const config = {
4
- ...base,
5
- env: { node: true, es2021: true },
6
- parserOptions: { ...base.parserOptions, sourceType: 'module' },
7
- rules: {
8
- ...base.rules,
9
- 'max-lines': ['warn', 1500],
3
+ /**
4
+ * Rulesets For Dynamo Based Systems
5
+ * NTS: Node TypeScript
6
+ * ESLint v9 Flat Config Format
7
+ */
8
+ module.exports = [
9
+ ...ntsBaseConfig,
10
+ {
11
+ files: ['**/*.ts', '**/*.tsx'],
12
+ languageOptions: {
13
+ ...ntsBaseConfig[1].languageOptions,
14
+ globals: {
15
+ // Node.js globals
16
+ process: 'readonly',
17
+ Buffer: 'readonly',
18
+ global: 'readonly',
19
+ __dirname: 'readonly',
20
+ __filename: 'readonly',
21
+ module: 'readonly',
22
+ require: 'readonly',
23
+ exports: 'readonly',
24
+ console: 'readonly'
25
+ }
26
+ },
27
+ rules: {
28
+ ...ntsBaseConfig[1].rules,
29
+ 'max-lines': ['warn', 1500],
30
+ },
10
31
  },
11
- };
12
-
13
- export = config;
32
+ ];
14
33
 
15
34
 
@@ -1,15 +1,23 @@
1
- import importOrderRule from './rules/import-order';
1
+ import importOrderRule from './rules/import/import-order';
2
2
  import namingPatternsRule from './rules/naming-patterns';
3
+ import noImportTypeRule from './rules/import/no-import-type';
4
+ import noJsExtensionRule from './rules/import/no-js-import';
3
5
 
4
6
  export = {
5
7
  rules: {
6
8
  'import-order': importOrderRule,
9
+ 'no-import-type': noImportTypeRule,
10
+ 'no-js-import': noJsExtensionRule,
11
+
7
12
  'naming-patterns': namingPatternsRule,
8
13
  },
9
14
  configs: {
10
15
  recommended: {
11
16
  rules: {
12
17
  '@futdevpro/dynamo/import-order': 'warn',
18
+ '@futdevpro/dynamo/no-import-type': 'warn',
19
+ '@futdevpro/dynamo/no-js-import': 'warn',
20
+
13
21
  '@futdevpro/dynamo/naming-patterns': 'warn',
14
22
  },
15
23
  },
@@ -11,24 +11,25 @@ describe('| import-order', () => {
11
11
  const mockContext = {
12
12
  getSourceCode: () => ({
13
13
  ast: {},
14
- getLines: () => ['line1', 'line2', 'line3']
14
+ getLines: () => [ 'line1', 'line2', 'line3' ],
15
15
  }),
16
16
  getFilename: () => 'test.ts',
17
17
  report: () => {},
18
18
  } as any;
19
19
 
20
20
  const result = importOrderRule.create(mockContext);
21
+
21
22
  expect(typeof result).toBe('object');
22
23
  expect(typeof result.Program).toBe('function');
23
24
  });
24
25
 
25
26
  it('| should detect forbidden NPM-packages imports', () => {
26
27
  const mockContext = {
27
- getSourceCode: () => ({
28
+ sourceCode: {
28
29
  ast: {},
29
- getLines: () => ['import { Something } from \'../../../NPM-packages/some-package\';']
30
- }),
31
- getFilename: () => 'test.ts',
30
+ getLines: () => [ 'import { Something } from \'../../../NPM-packages/some-package\';' ],
31
+ },
32
+ filename: 'test.ts',
32
33
  report: (options: any) => {
33
34
  expect(options.messageId).toBe('forbiddenNpmPackages');
34
35
  },
@@ -42,22 +43,23 @@ describe('| import-order', () => {
42
43
  type: 'ImportDeclaration',
43
44
  source: { value: '../../../NPM-packages/some-package' },
44
45
  importKind: 'value',
45
- loc: { start: { line: 1 }, end: { line: 1 } }
46
- }
47
- ]
46
+ loc: { start: { line: 1 }, end: { line: 1 } },
47
+ },
48
+ ],
48
49
  } as any;
49
50
 
50
51
  const rule = importOrderRule.create(mockContext);
52
+
51
53
  rule.Program(mockNode);
52
54
  });
53
55
 
54
56
  it('| should detect forbidden .js extension imports', () => {
55
57
  const mockContext = {
56
- getSourceCode: () => ({
58
+ sourceCode: {
57
59
  ast: {},
58
- getLines: () => ['import { Something } from \'./some-file.js\';']
59
- }),
60
- getFilename: () => 'test.ts',
60
+ getLines: () => [ 'import { Something } from \'./some-file.js\';' ],
61
+ },
62
+ filename: 'test.ts',
61
63
  report: (options: any) => {
62
64
  expect(options.messageId).toBe('forbiddenJsExtension');
63
65
  },
@@ -71,22 +73,23 @@ describe('| import-order', () => {
71
73
  type: 'ImportDeclaration',
72
74
  source: { value: './some-file.js' },
73
75
  importKind: 'value',
74
- loc: { start: { line: 1 }, end: { line: 1 } }
75
- }
76
- ]
76
+ loc: { start: { line: 1 }, end: { line: 1 } },
77
+ },
78
+ ],
77
79
  } as any;
78
80
 
79
81
  const rule = importOrderRule.create(mockContext);
82
+
80
83
  rule.Program(mockNode);
81
84
  });
82
85
 
83
86
  it('| should detect forbidden import type usage', () => {
84
87
  const mockContext = {
85
- getSourceCode: () => ({
88
+ sourceCode: {
86
89
  ast: {},
87
- getLines: () => ['import type { SomeType } from \'./some-file\';']
88
- }),
89
- getFilename: () => 'test.ts',
90
+ getLines: () => [ 'import type { SomeType } from \'./some-file\';' ],
91
+ },
92
+ filename: 'test.ts',
90
93
  report: (options: any) => {
91
94
  expect(options.messageId).toBe('forbiddenImportType');
92
95
  },
@@ -100,26 +103,27 @@ describe('| import-order', () => {
100
103
  type: 'ImportDeclaration',
101
104
  source: { value: './some-file' },
102
105
  importKind: 'type',
103
- loc: { start: { line: 1 }, end: { line: 1 } }
104
- }
105
- ]
106
+ loc: { start: { line: 1 }, end: { line: 1 } },
107
+ },
108
+ ],
106
109
  } as any;
107
110
 
108
111
  const rule = importOrderRule.create(mockContext);
112
+
109
113
  rule.Program(mockNode);
110
114
  });
111
115
 
112
116
  it('| should detect misordered imports', () => {
113
117
  let reportCount = 0;
114
118
  const mockContext = {
115
- getSourceCode: () => ({
119
+ sourceCode: {
116
120
  ast: {},
117
121
  getLines: () => [
118
122
  'import { DyFM_Error } from \'@futdevpro/fsm-dynamo\';',
119
- 'import { Component } from \'@angular/core\';'
120
- ]
121
- }),
122
- getFilename: () => 'test.ts',
123
+ 'import { Component } from \'@angular/core\';',
124
+ ],
125
+ },
126
+ filename: 'test.ts',
123
127
  report: (options: any) => {
124
128
  if (options.messageId === 'misordered') {
125
129
  reportCount++;
@@ -135,18 +139,19 @@ describe('| import-order', () => {
135
139
  type: 'ImportDeclaration',
136
140
  source: { value: '@futdevpro/fsm-dynamo' },
137
141
  importKind: 'value',
138
- loc: { start: { line: 1 }, end: { line: 1 } }
142
+ loc: { start: { line: 1 }, end: { line: 1 } },
139
143
  },
140
144
  {
141
145
  type: 'ImportDeclaration',
142
146
  source: { value: '@angular/core' },
143
147
  importKind: 'value',
144
- loc: { start: { line: 2 }, end: { line: 2 } }
145
- }
146
- ]
148
+ loc: { start: { line: 2 }, end: { line: 2 } },
149
+ },
150
+ ],
147
151
  } as any;
148
152
 
149
153
  const rule = importOrderRule.create(mockContext);
154
+
150
155
  rule.Program(mockNode);
151
156
 
152
157
  expect(reportCount).toBeGreaterThan(0);
@@ -155,14 +160,14 @@ describe('| import-order', () => {
155
160
  it('| should detect missing empty line between groups', () => {
156
161
  let reportCount = 0;
157
162
  const mockContext = {
158
- getSourceCode: () => ({
163
+ sourceCode: {
159
164
  ast: {},
160
165
  getLines: () => [
161
166
  'import { Component } from \'@angular/core\';',
162
- 'import { DyFM_Error } from \'@futdevpro/fsm-dynamo\';'
163
- ]
164
- }),
165
- getFilename: () => 'test.ts',
167
+ 'import { DyFM_Error } from \'@futdevpro/fsm-dynamo\';',
168
+ ],
169
+ },
170
+ filename: 'test.ts',
166
171
  report: (options: any) => {
167
172
  if (options.messageId === 'missingEmptyLine') {
168
173
  reportCount++;
@@ -178,18 +183,19 @@ describe('| import-order', () => {
178
183
  type: 'ImportDeclaration',
179
184
  source: { value: '@angular/core' },
180
185
  importKind: 'value',
181
- loc: { start: { line: 1 }, end: { line: 1 } }
186
+ loc: { start: { line: 1 }, end: { line: 1 } },
182
187
  },
183
188
  {
184
189
  type: 'ImportDeclaration',
185
190
  source: { value: '@futdevpro/fsm-dynamo' },
186
191
  importKind: 'value',
187
- loc: { start: { line: 2 }, end: { line: 2 } }
188
- }
189
- ]
192
+ loc: { start: { line: 2 }, end: { line: 2 } },
193
+ },
194
+ ],
190
195
  } as any;
191
196
 
192
197
  const rule = importOrderRule.create(mockContext);
198
+
193
199
  rule.Program(mockNode);
194
200
 
195
201
  expect(reportCount).toBeGreaterThan(0);