@futdevpro/dynamo-eslint 1.12.1
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/.eslintrc.json +16 -0
- package/.github/workflows/main.yml +393 -0
- package/INTEGRATION.md +74 -0
- package/POC-README.md +147 -0
- package/README.md +36 -0
- package/build/configs/base.d.ts +81 -0
- package/build/configs/base.d.ts.map +1 -0
- package/build/configs/base.js +51 -0
- package/build/configs/base.js.map +1 -0
- package/build/configs/fsm.d.ts +82 -0
- package/build/configs/fsm.d.ts.map +1 -0
- package/build/configs/fsm.js +7 -0
- package/build/configs/fsm.js.map +1 -0
- package/build/configs/ngx-package.d.ts +81 -0
- package/build/configs/ngx-package.d.ts.map +1 -0
- package/build/configs/ngx-package.js +7 -0
- package/build/configs/ngx-package.js.map +1 -0
- package/build/configs/ngx.d.ts +81 -0
- package/build/configs/ngx.d.ts.map +1 -0
- package/build/configs/ngx.js +12 -0
- package/build/configs/ngx.js.map +1 -0
- package/build/configs/nts-package.d.ts +83 -0
- package/build/configs/nts-package.d.ts.map +1 -0
- package/build/configs/nts-package.js +12 -0
- package/build/configs/nts-package.js.map +1 -0
- package/build/configs/nts.d.ts +82 -0
- package/build/configs/nts.d.ts.map +1 -0
- package/build/configs/nts.js +13 -0
- package/build/configs/nts.js.map +1 -0
- package/build/index.d.ts +2 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +3 -0
- package/build/index.js.map +1 -0
- package/build/plugin/index.d.ts +16 -0
- package/build/plugin/index.d.ts.map +1 -0
- package/build/plugin/index.js +19 -0
- package/build/plugin/index.js.map +1 -0
- package/build/plugin/rules/import-order.d.ts +4 -0
- package/build/plugin/rules/import-order.d.ts.map +1 -0
- package/build/plugin/rules/import-order.js +134 -0
- package/build/plugin/rules/import-order.js.map +1 -0
- package/build/plugin/rules/import-order.spec.d.ts +2 -0
- package/build/plugin/rules/import-order.spec.d.ts.map +1 -0
- package/build/plugin/rules/import-order.spec.js +181 -0
- package/build/plugin/rules/import-order.spec.js.map +1 -0
- package/build/plugin/rules/naming-patterns.d.ts +4 -0
- package/build/plugin/rules/naming-patterns.d.ts.map +1 -0
- package/build/plugin/rules/naming-patterns.js +23 -0
- package/build/plugin/rules/naming-patterns.js.map +1 -0
- package/build/plugin/rules/naming-patterns.spec.d.ts +2 -0
- package/build/plugin/rules/naming-patterns.spec.d.ts.map +1 -0
- package/build/plugin/rules/naming-patterns.spec.js +36 -0
- package/build/plugin/rules/naming-patterns.spec.js.map +1 -0
- package/build/scripts/eslintrc-audit.d.ts +3 -0
- package/build/scripts/eslintrc-audit.d.ts.map +1 -0
- package/build/scripts/eslintrc-audit.js +36 -0
- package/build/scripts/eslintrc-audit.js.map +1 -0
- package/build/scripts/validate-imports.d.ts +3 -0
- package/build/scripts/validate-imports.d.ts.map +1 -0
- package/build/scripts/validate-imports.js +76 -0
- package/build/scripts/validate-imports.js.map +1 -0
- package/build/scripts/validate-naming.d.ts +3 -0
- package/build/scripts/validate-naming.d.ts.map +1 -0
- package/build/scripts/validate-naming.js +76 -0
- package/build/scripts/validate-naming.js.map +1 -0
- package/build-test/plugin/rules/import-order.d.ts +3 -0
- package/build-test/plugin/rules/import-order.js +23 -0
- package/build-test/plugin/rules/import-order.spec.d.ts +1 -0
- package/build-test/plugin/rules/import-order.spec.js +44 -0
- package/build-test/plugin/rules/naming-patterns.d.ts +3 -0
- package/build-test/plugin/rules/naming-patterns.js +22 -0
- package/build-test/plugin/rules/naming-patterns.spec.d.ts +1 -0
- package/build-test/plugin/rules/naming-patterns.spec.js +41 -0
- package/futdevpro-dynamo-eslint-01.12.01.tgz +0 -0
- package/package.json +95 -0
- package/samples/base/.eslintrc.json +6 -0
- package/samples/ngx/.eslintrc.json +6 -0
- package/samples/nts/.eslintrc.json +6 -0
- package/samples/poc-sample.ts +38 -0
- package/samples/poc-violations.ts +25 -0
- package/spec/support/jasmine.json +24 -0
- package/src/configs/base.ts +51 -0
- package/src/configs/fsm.ts +9 -0
- package/src/configs/ngx-package.ts +9 -0
- package/src/configs/ngx.ts +14 -0
- package/src/configs/nts-package.ts +14 -0
- package/src/configs/nts.ts +15 -0
- package/src/index.ts +4 -0
- package/src/plugin/index.ts +19 -0
- package/src/plugin/rules/import-order.spec.ts +197 -0
- package/src/plugin/rules/import-order.ts +167 -0
- package/src/plugin/rules/naming-patterns.spec.ts +39 -0
- package/src/plugin/rules/naming-patterns.ts +25 -0
- package/src/scripts/eslintrc-audit.ts +39 -0
- package/src/scripts/validate-imports.ts +98 -0
- package/src/scripts/validate-naming.ts +97 -0
- package/tsconfig.json +32 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const fast_glob_1 = tslib_1.__importDefault(require("fast-glob"));
|
|
6
|
+
const eslint_1 = require("eslint");
|
|
7
|
+
async function validateNamingInFile(filePath) {
|
|
8
|
+
const eslint = new eslint_1.ESLint({
|
|
9
|
+
baseConfig: {
|
|
10
|
+
parser: '@typescript-eslint/parser',
|
|
11
|
+
parserOptions: {
|
|
12
|
+
ecmaVersion: 2020,
|
|
13
|
+
sourceType: 'module',
|
|
14
|
+
},
|
|
15
|
+
rules: {
|
|
16
|
+
'@futdevpro/dynamo/naming-patterns': 'error',
|
|
17
|
+
},
|
|
18
|
+
plugins: {
|
|
19
|
+
'@futdevpro/dynamo': {
|
|
20
|
+
rules: {
|
|
21
|
+
'naming-patterns': require('../plugin/rules/naming-patterns').default,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
const results = await eslint.lintFiles([filePath]);
|
|
28
|
+
const result = results[0];
|
|
29
|
+
return {
|
|
30
|
+
file: filePath,
|
|
31
|
+
errors: result.messages.map(msg => ({
|
|
32
|
+
line: msg.line,
|
|
33
|
+
column: msg.column,
|
|
34
|
+
message: msg.message,
|
|
35
|
+
ruleId: msg.ruleId || 'unknown',
|
|
36
|
+
})),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
async function main() {
|
|
40
|
+
const files = await (0, fast_glob_1.default)(['**/*.{ts,tsx}'], {
|
|
41
|
+
ignore: ['**/node_modules/**', '**/build/**', '**/dist/**', '**/*.spec.ts', '**/*.test.ts']
|
|
42
|
+
});
|
|
43
|
+
console.log(`[dynamo-validate-naming] Scanning ${files.length} files...`);
|
|
44
|
+
const results = [];
|
|
45
|
+
let totalErrors = 0;
|
|
46
|
+
for (const file of files) {
|
|
47
|
+
try {
|
|
48
|
+
const result = await validateNamingInFile(file);
|
|
49
|
+
results.push(result);
|
|
50
|
+
totalErrors += result.errors.length;
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
console.error(`Error processing ${file}:`, error);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
// Report results
|
|
57
|
+
const filesWithErrors = results.filter(r => r.errors.length > 0);
|
|
58
|
+
if (filesWithErrors.length === 0) {
|
|
59
|
+
console.log('✅ All naming validations passed!');
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
console.log(`\n❌ Found ${totalErrors} naming validation errors in ${filesWithErrors.length} files:\n`);
|
|
63
|
+
filesWithErrors.forEach(result => {
|
|
64
|
+
console.log(`📁 ${result.file}:`);
|
|
65
|
+
result.errors.forEach(error => {
|
|
66
|
+
console.log(` ${error.line}:${error.column} - ${error.message}`);
|
|
67
|
+
});
|
|
68
|
+
console.log('');
|
|
69
|
+
});
|
|
70
|
+
process.exit(1);
|
|
71
|
+
}
|
|
72
|
+
main().catch((err) => {
|
|
73
|
+
console.error('Validation failed:', err);
|
|
74
|
+
process.exit(1);
|
|
75
|
+
});
|
|
76
|
+
//# sourceMappingURL=validate-naming.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-naming.js","sourceRoot":"","sources":["../../src/scripts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IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,oBAAoB,EAAE,GAAG,CAAC,CAAC;IACzC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const rule = {
|
|
4
|
+
meta: {
|
|
5
|
+
type: 'suggestion',
|
|
6
|
+
docs: { description: 'Validate import ordering based on DyFM conventions' },
|
|
7
|
+
schema: [],
|
|
8
|
+
messages: {
|
|
9
|
+
misordered: 'Import statements should be grouped and ordered by convention.',
|
|
10
|
+
},
|
|
11
|
+
fixable: 'code',
|
|
12
|
+
},
|
|
13
|
+
create(context) {
|
|
14
|
+
return {
|
|
15
|
+
Program() {
|
|
16
|
+
// Basic implementation - no validation for now
|
|
17
|
+
// This prevents the rule from causing false positives
|
|
18
|
+
return;
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
exports.default = rule;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const eslint_1 = require("eslint");
|
|
7
|
+
const import_order_1 = __importDefault(require("./import-order"));
|
|
8
|
+
const ruleTester = new eslint_1.RuleTester({
|
|
9
|
+
parser: require.resolve('@typescript-eslint/parser'),
|
|
10
|
+
parserOptions: {
|
|
11
|
+
ecmaVersion: 2020,
|
|
12
|
+
sourceType: 'module',
|
|
13
|
+
},
|
|
14
|
+
rules: {
|
|
15
|
+
// Disable all rules to prevent interference
|
|
16
|
+
'@futdevpro/dyfm/import-order': 'off',
|
|
17
|
+
'@futdevpro/dyfm/naming-patterns': 'off',
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
describe('| import-order', () => {
|
|
21
|
+
it('| should not report errors for valid code', () => {
|
|
22
|
+
// Test the rule directly without using RuleTester to avoid interference
|
|
23
|
+
const mockContext = {
|
|
24
|
+
report: () => { },
|
|
25
|
+
getSourceCode: () => ({ ast: {} }),
|
|
26
|
+
};
|
|
27
|
+
const result = import_order_1.default.create(mockContext);
|
|
28
|
+
expect(typeof result).toBe('object');
|
|
29
|
+
expect(typeof result.Program).toBe('function');
|
|
30
|
+
});
|
|
31
|
+
it('| should be a valid ESLint rule', () => {
|
|
32
|
+
expect(import_order_1.default.meta?.type).toBe('suggestion');
|
|
33
|
+
expect(import_order_1.default.meta?.docs?.description).toContain('import ordering');
|
|
34
|
+
expect(import_order_1.default.meta?.fixable).toBe('code');
|
|
35
|
+
});
|
|
36
|
+
it('| should have create function that returns object with Program method', () => {
|
|
37
|
+
const mockContext = {
|
|
38
|
+
getSourceCode: () => ({ ast: {} }),
|
|
39
|
+
};
|
|
40
|
+
const result = import_order_1.default.create(mockContext);
|
|
41
|
+
expect(typeof result).toBe('object');
|
|
42
|
+
expect(typeof result.Program).toBe('function');
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const rule = {
|
|
4
|
+
meta: {
|
|
5
|
+
type: 'suggestion',
|
|
6
|
+
docs: { description: 'Enforce naming conventions using DyFM patterns' },
|
|
7
|
+
schema: [],
|
|
8
|
+
messages: {
|
|
9
|
+
invalidName: 'Identifier "{{name}}" does not match required naming pattern.',
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
create(context) {
|
|
13
|
+
return {
|
|
14
|
+
Identifier(node) {
|
|
15
|
+
// Basic implementation - no validation for now
|
|
16
|
+
// This prevents the rule from causing false positives
|
|
17
|
+
return;
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
exports.default = rule;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const eslint_1 = require("eslint");
|
|
7
|
+
const naming_patterns_1 = __importDefault(require("./naming-patterns"));
|
|
8
|
+
const ruleTester = new eslint_1.RuleTester({
|
|
9
|
+
parser: require.resolve('@typescript-eslint/parser'),
|
|
10
|
+
parserOptions: {
|
|
11
|
+
ecmaVersion: 2020,
|
|
12
|
+
sourceType: 'module',
|
|
13
|
+
},
|
|
14
|
+
rules: {
|
|
15
|
+
// Disable all rules to prevent interference
|
|
16
|
+
'@futdevpro/dyfm/import-order': 'off',
|
|
17
|
+
'@futdevpro/dyfm/naming-patterns': 'off',
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
describe('| naming-patterns', () => {
|
|
21
|
+
it('| should not report errors for valid code', () => {
|
|
22
|
+
// Test the rule directly without using RuleTester to avoid interference
|
|
23
|
+
const mockContext = {
|
|
24
|
+
report: () => { },
|
|
25
|
+
getSourceCode: () => ({ ast: {} }),
|
|
26
|
+
};
|
|
27
|
+
const result = naming_patterns_1.default.create(mockContext);
|
|
28
|
+
expect(typeof result).toBe('object');
|
|
29
|
+
expect(typeof result.Identifier).toBe('function');
|
|
30
|
+
});
|
|
31
|
+
it('| should be a valid ESLint rule', () => {
|
|
32
|
+
expect(naming_patterns_1.default.meta?.type).toBe('suggestion');
|
|
33
|
+
expect(naming_patterns_1.default.meta?.docs?.description).toContain('naming conventions');
|
|
34
|
+
});
|
|
35
|
+
it('| should have create function that returns object with Identifier method', () => {
|
|
36
|
+
const mockContext = {};
|
|
37
|
+
const result = naming_patterns_1.default.create(mockContext);
|
|
38
|
+
expect(typeof result).toBe('object');
|
|
39
|
+
expect(typeof result.Identifier).toBe('function');
|
|
40
|
+
});
|
|
41
|
+
});
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@futdevpro/dynamo-eslint",
|
|
3
|
+
"version": "01.12.01",
|
|
4
|
+
"description": "Shared ESLint configs, Dynamo-powered plugin and validators for FutDevPro stacks",
|
|
5
|
+
"author": "Future Development Program Ltd.",
|
|
6
|
+
"license": "ISC",
|
|
7
|
+
"type": "commonjs",
|
|
8
|
+
"main": "./build/index.js",
|
|
9
|
+
"types": "./build/index.d.ts",
|
|
10
|
+
"DyBu_settings": {
|
|
11
|
+
"packageType": "full-stack-package",
|
|
12
|
+
"tgzFolderName": "dynamo-eslint",
|
|
13
|
+
"systemName": "dynamo"
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"prep": "npm i -g pnpm rimraf nodemon jasmine && pnpm i",
|
|
17
|
+
"start": "npm run prep && nodemon",
|
|
18
|
+
|
|
19
|
+
"deploy": "npm run build",
|
|
20
|
+
"clean-deploy": "pnpm run clean && pnpm run build-all",
|
|
21
|
+
|
|
22
|
+
"build": "pnpm run build-base && jasmine && npm publish",
|
|
23
|
+
"build-tgz": "pnpm run build-base && jasmine && pnpm pack && move ./*.tgz ../tgz-collection/dynamo-eslint",
|
|
24
|
+
"build-all": "pnpm run build-tgz && pnpm run build",
|
|
25
|
+
"build-base": "rimraf ./build && npx tsc",
|
|
26
|
+
"build-clean": "pnpm run clean && pnpm run build-base",
|
|
27
|
+
"build-n-test": "pnpm i && pnpm run build-tgz",
|
|
28
|
+
|
|
29
|
+
"clean": "pnpm run prep && rimraf ./build && rimraf package-lock.json && rimraf pnpm-lock.yaml && rimraf ./node_modules",
|
|
30
|
+
|
|
31
|
+
"test": "pnpm run build-base && jasmine",
|
|
32
|
+
"test-clean": "pnpm run build-clean && jasmine",
|
|
33
|
+
"test-full": "pnpm run prep && pnpm run test",
|
|
34
|
+
|
|
35
|
+
"nodemon-run": "npm run build-tgz",
|
|
36
|
+
|
|
37
|
+
"lint": "eslint src --ext .ts",
|
|
38
|
+
"lint:fix": "eslint src --ext .ts --fix"
|
|
39
|
+
},
|
|
40
|
+
"exports": {
|
|
41
|
+
".": {
|
|
42
|
+
"types": "./build/index.d.ts",
|
|
43
|
+
"default": "./build/index.js"
|
|
44
|
+
},
|
|
45
|
+
"./base": "./build/configs/base.js",
|
|
46
|
+
"./nts": "./build/configs/nts.js",
|
|
47
|
+
"./ngx": "./build/configs/ngx.js",
|
|
48
|
+
"./fsm": "./build/configs/fsm.js",
|
|
49
|
+
"./nts-package": "./build/configs/nts-package.js",
|
|
50
|
+
"./ngx-package": "./build/configs/ngx-package.js",
|
|
51
|
+
"./plugin": "./build/plugin/index.js"
|
|
52
|
+
},
|
|
53
|
+
"bin": {
|
|
54
|
+
"dynamo-validate-imports": "./build/scripts/validate-imports.js",
|
|
55
|
+
"dynamo-validate-naming": "./build/scripts/validate-naming.js",
|
|
56
|
+
"dynamo-eslintrc-audit": "./build/scripts/eslintrc-audit.js"
|
|
57
|
+
},
|
|
58
|
+
"keywords": [
|
|
59
|
+
"eslint",
|
|
60
|
+
"typescript",
|
|
61
|
+
"angular",
|
|
62
|
+
"node",
|
|
63
|
+
"dynamo"
|
|
64
|
+
],
|
|
65
|
+
"peerDependencies": {
|
|
66
|
+
"eslint": "^9.0.0",
|
|
67
|
+
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
68
|
+
"@typescript-eslint/parser": "^8.0.0",
|
|
69
|
+
"eslint-plugin-import": "^2.29.0",
|
|
70
|
+
"eslint-plugin-jsdoc": "^48.0.0",
|
|
71
|
+
"eslint-plugin-prettier": "^5.1.3",
|
|
72
|
+
"prettier": "^3.3.0",
|
|
73
|
+
"@angular-eslint/eslint-plugin": "^19.0.0",
|
|
74
|
+
"@angular-eslint/eslint-plugin-template": "^19.0.0",
|
|
75
|
+
"@angular-eslint/template-parser": "^19.0.0"
|
|
76
|
+
},
|
|
77
|
+
"dependencies": {
|
|
78
|
+
"@futdevpro/fsm-dynamo": "1.12.16",
|
|
79
|
+
"fast-glob": "^3.3.2",
|
|
80
|
+
"tslib": "~2.8.1"
|
|
81
|
+
},
|
|
82
|
+
"devDependencies": {
|
|
83
|
+
"@types/node": "~20.12.12",
|
|
84
|
+
"@types/jasmine": "~4.3.5",
|
|
85
|
+
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
86
|
+
"@typescript-eslint/parser": "^8.0.0",
|
|
87
|
+
"eslint": "^9.0.0",
|
|
88
|
+
"jasmine": "5.10.0",
|
|
89
|
+
"jasmine-spec-reporter": "^7.0.0",
|
|
90
|
+
"rimraf": "^5.0.5",
|
|
91
|
+
"typescript": "~5.5.4"
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// POC Sample demonstrating Dynamo ESLint import ordering rules
|
|
2
|
+
// This file shows the correct import ordering according to the new rules
|
|
3
|
+
|
|
4
|
+
// Group 1: Non-FutDevPro packages
|
|
5
|
+
import { Component, OnInit } from '@angular/core';
|
|
6
|
+
import { Router } from '@angular/router';
|
|
7
|
+
import { HttpClient } from '@angular/common/http';
|
|
8
|
+
|
|
9
|
+
// Group 2: FutDevPro packages
|
|
10
|
+
import { DyFM_Error, DyFM_Log } from '@futdevpro/fsm-dynamo';
|
|
11
|
+
import { FDP_User, FDP_Account } from '@futdevpro/fdp-templates';
|
|
12
|
+
|
|
13
|
+
// Group 3: Scripts from other modules (3+ levels without underscore, or 3+ levels with underscore)
|
|
14
|
+
import { SomeService } from '../../../services/some.service';
|
|
15
|
+
import { AnotherService } from '../../../../models/another.interface';
|
|
16
|
+
|
|
17
|
+
// Group 4: Scripts from same module (up to 2 levels, or up to 3 levels with underscore)
|
|
18
|
+
import { LocalComponent } from './local.component';
|
|
19
|
+
import { LocalService } from '../_services/local.service';
|
|
20
|
+
import { LocalInterface } from '../../../_models/local.interface';
|
|
21
|
+
|
|
22
|
+
export class PocSampleComponent implements OnInit {
|
|
23
|
+
constructor(
|
|
24
|
+
private router: Router,
|
|
25
|
+
private http: HttpClient,
|
|
26
|
+
private localService: LocalService
|
|
27
|
+
) {}
|
|
28
|
+
|
|
29
|
+
ngOnInit(): void {
|
|
30
|
+
// Example usage
|
|
31
|
+
DyFM_Log.info('Component initialized');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// This would be flagged as errors:
|
|
35
|
+
// import { Something } from '../../../NPM-packages/some-package'; // ❌ Forbidden NPM-packages
|
|
36
|
+
// import { Something } from './some-file.js'; // ❌ Forbidden .js extension
|
|
37
|
+
// import type { SomeType } from './some-file'; // ❌ Forbidden import type
|
|
38
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// POC Sample demonstrating Dynamo ESLint import ordering violations
|
|
2
|
+
// This file shows various violations that should be caught by the linter
|
|
3
|
+
|
|
4
|
+
// ❌ VIOLATIONS: This file contains multiple import ordering violations
|
|
5
|
+
|
|
6
|
+
// Wrong order: FutDevPro packages before non-FutDevPro packages
|
|
7
|
+
import { DyFM_Error } from '@futdevpro/fsm-dynamo';
|
|
8
|
+
import { Component } from '@angular/core';
|
|
9
|
+
|
|
10
|
+
// Missing empty line between groups
|
|
11
|
+
import { Router } from '@angular/router';
|
|
12
|
+
import { FDP_User } from '@futdevpro/fdp-templates';
|
|
13
|
+
|
|
14
|
+
// Wrong order: same module before other modules
|
|
15
|
+
import { LocalService } from './local.service';
|
|
16
|
+
import { SomeService } from '../../../services/some.service';
|
|
17
|
+
|
|
18
|
+
// ❌ 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
|
|
22
|
+
|
|
23
|
+
export class PocViolationsComponent {
|
|
24
|
+
// This class demonstrates various import violations
|
|
25
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"reporters": [
|
|
3
|
+
{
|
|
4
|
+
"name": "jasmine-json-reporter",
|
|
5
|
+
"options": {
|
|
6
|
+
"pretty": true
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
],
|
|
10
|
+
"spec_dir": "build/",
|
|
11
|
+
"spec_files": [
|
|
12
|
+
"**/*.spec.ts",
|
|
13
|
+
"**/*.spec.js",
|
|
14
|
+
"**/*[sS]pec.ts"
|
|
15
|
+
],
|
|
16
|
+
"helpers": [
|
|
17
|
+
"helpers/**/*.ts",
|
|
18
|
+
"helpers/**/*.js"
|
|
19
|
+
],
|
|
20
|
+
"env": {
|
|
21
|
+
"stopSpecOnExpectationFailure": false,
|
|
22
|
+
"random": true
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
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',
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import base = require('./base');
|
|
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],
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export = config;
|
|
14
|
+
|
|
15
|
+
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import importOrderRule from './rules/import-order';
|
|
2
|
+
import namingPatternsRule from './rules/naming-patterns';
|
|
3
|
+
|
|
4
|
+
export = {
|
|
5
|
+
rules: {
|
|
6
|
+
'import-order': importOrderRule,
|
|
7
|
+
'naming-patterns': namingPatternsRule,
|
|
8
|
+
},
|
|
9
|
+
configs: {
|
|
10
|
+
recommended: {
|
|
11
|
+
rules: {
|
|
12
|
+
'@futdevpro/dynamo/import-order': 'warn',
|
|
13
|
+
'@futdevpro/dynamo/naming-patterns': 'warn',
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
|