@zintrust/governance 0.1.20

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/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # @zintrust/governance
2
+
3
+ ESLint configuration and TypeScript governance setup for Zintrust projects.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm i --save-dev @zintrust/governance
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ In your `eslint.config.js`:
14
+
15
+ ```ts
16
+ import { zintrust } from '@zintrust/governance';
17
+
18
+ export default zintrust();
19
+ ```
20
+
21
+ ## Includes
22
+
23
+ - TypeScript ESLint rules
24
+ - Flat config setup
25
+ - Best practices for Type-Safe backend development
26
+
27
+ ## License
28
+
29
+ This package and its dependencies are MIT licensed, permitting free commercial use.
@@ -0,0 +1,5 @@
1
+ export type ZintrustEslintOptions = Readonly<{
2
+ tsconfigPath?: string;
3
+ tsconfigRootDir?: string;
4
+ }>;
5
+ export declare function zintrustAppEslintConfig(opts?: ZintrustEslintOptions): unknown[];
package/dist/eslint.js ADDED
@@ -0,0 +1,102 @@
1
+ import eslint from '@eslint/js';
2
+ import globals from 'globals';
3
+ import tseslint from 'typescript-eslint';
4
+ const DEFAULT_IGNORES = [
5
+ 'node_modules/**',
6
+ 'dist/**',
7
+ '**/dist/**',
8
+ 'coverage/**',
9
+ '.git/**',
10
+ '.vscode/**',
11
+ '.idea/**',
12
+ '*.log',
13
+ '.DS_Store',
14
+ ];
15
+ const baseLanguageGlobals = () => ({
16
+ languageOptions: {
17
+ globals: {
18
+ ...globals.node,
19
+ ...globals.es2022,
20
+ },
21
+ },
22
+ });
23
+ const typeAwareAppConfig = (tsconfigPath, tsconfigRootDir) => ({
24
+ files: ['src/**/*.ts', 'app/**/*.ts', 'routes/**/*.ts', 'config/**/*.ts', 'database/**/*.ts'],
25
+ languageOptions: {
26
+ parserOptions: {
27
+ project: tsconfigPath,
28
+ tsconfigRootDir,
29
+ },
30
+ },
31
+ });
32
+ const testGlobalsConfig = () => ({
33
+ files: ['tests/**/*.ts'],
34
+ languageOptions: {
35
+ globals: {
36
+ describe: 'readonly',
37
+ it: 'readonly',
38
+ test: 'readonly',
39
+ expect: 'readonly',
40
+ vi: 'readonly',
41
+ beforeAll: 'readonly',
42
+ afterAll: 'readonly',
43
+ beforeEach: 'readonly',
44
+ afterEach: 'readonly',
45
+ },
46
+ },
47
+ rules: {
48
+ 'no-restricted-imports': 'off',
49
+ 'no-empty': 'off',
50
+ },
51
+ });
52
+ const zintrustRulesConfig = () => ({
53
+ rules: {
54
+ '@typescript-eslint/no-unused-vars': [
55
+ 'error',
56
+ { argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
57
+ ],
58
+ '@typescript-eslint/no-explicit-any': 'error',
59
+ 'no-console': 'error',
60
+ eqeqeq: ['error', 'always'],
61
+ 'prefer-const': 'warn',
62
+ // Keep app code on aliases (relative imports are allowed in tests).
63
+ 'no-restricted-imports': [
64
+ 'error',
65
+ {
66
+ patterns: [
67
+ {
68
+ group: ['./*', '../*'],
69
+ message: 'Please use path aliases (e.g., @app/Controllers/UserController) instead of relative imports.',
70
+ },
71
+ ],
72
+ },
73
+ ],
74
+ // Avoid raw throw Error(...) in app code.
75
+ 'no-restricted-syntax': [
76
+ 'error',
77
+ {
78
+ selector: "ThrowStatement > NewExpression[callee.name='Error']",
79
+ message: 'Do not throw raw Errors. Prefer ErrorFactory.create*Error() from @zintrust/core.',
80
+ },
81
+ ],
82
+ // Useful but intentionally lenient by default.
83
+ 'max-nested-callbacks': ['warn', 3],
84
+ },
85
+ });
86
+ export function zintrustAppEslintConfig(opts = {}) {
87
+ const tsconfigPath = opts.tsconfigPath ?? './tsconfig.json';
88
+ const tsconfigRootDir = opts.tsconfigRootDir ?? process.cwd();
89
+ return [
90
+ {
91
+ ignores: DEFAULT_IGNORES,
92
+ },
93
+ eslint.configs.recommended,
94
+ ...tseslint.configs.recommended,
95
+ ...tseslint.configs.strict,
96
+ baseLanguageGlobals(),
97
+ // Enable type-aware linting for app source.
98
+ typeAwareAppConfig(tsconfigPath, tsconfigRootDir),
99
+ testGlobalsConfig(),
100
+ zintrustRulesConfig(),
101
+ ];
102
+ }
@@ -0,0 +1,2 @@
1
+ export { zintrustAppEslintConfig } from './eslint';
2
+ export type { ZintrustEslintOptions } from './eslint';
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ export { zintrustAppEslintConfig } from './eslint';
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@zintrust/governance",
3
+ "version": "0.1.20",
4
+ "private": false,
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "default": "./dist/index.js"
15
+ },
16
+ "./eslint": {
17
+ "types": "./dist/eslint.d.ts",
18
+ "default": "./dist/eslint.js"
19
+ }
20
+ },
21
+ "engines": {
22
+ "node": ">=20.0.0"
23
+ },
24
+ "peerDependencies": {
25
+ "eslint": "^9.0.0",
26
+ "typescript": ">=5.0.0",
27
+ "@zintrust/core": "^0.1.20"
28
+ },
29
+ "publishConfig": {
30
+ "access": "public"
31
+ },
32
+ "dependencies": {
33
+ "@eslint/js": "^9.0.0",
34
+ "globals": "^16.4.0",
35
+ "typescript-eslint": "^8.38.0"
36
+ },
37
+ "scripts": {
38
+ "build": "tsc -p tsconfig.json",
39
+ "prepublishOnly": "npm run build"
40
+ }
41
+ }