@qvaroo/configs 1.0.3 → 1.0.5
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 +23 -56
- package/eslint/index.js +1 -5
- package/index.d.ts +0 -1
- package/index.js +0 -1
- package/index.mjs +13 -0
- package/package.json +2 -1
- package/eslint/rules/architecture.js +0 -152
package/README.md
CHANGED
|
@@ -27,39 +27,38 @@ npm install --save-dev eslint prettier typescript
|
|
|
27
27
|
|
|
28
28
|
## 🚀 Quick Setup
|
|
29
29
|
|
|
30
|
-
### 1. ESLint Configuration
|
|
30
|
+
### 1. ESLint Configuration (New Flat Config)
|
|
31
|
+
Create `eslint.config.mjs` in your project root:
|
|
31
32
|
|
|
32
|
-
Create `.eslintrc.js` in your project root:
|
|
33
|
-
|
|
34
|
-
**For React/Next.js projects:**
|
|
35
33
|
```javascript
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
34
|
+
import { createRequire } from 'module';
|
|
35
|
+
const require = createRequire(import.meta.url);
|
|
36
|
+
|
|
37
|
+
const {
|
|
38
|
+
namingConventions,
|
|
39
|
+
codeQuality,
|
|
40
|
+
spellcheck
|
|
41
|
+
} = require('@qvaroo/configs');
|
|
42
|
+
|
|
43
|
+
export default [
|
|
44
|
+
{
|
|
45
|
+
files: ['**/*.{ts,tsx}'],
|
|
46
|
+
rules: {
|
|
47
|
+
...namingConventions,
|
|
48
|
+
...codeQuality,
|
|
49
|
+
...spellcheck
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
];
|
|
43
53
|
```
|
|
44
54
|
|
|
45
|
-
**
|
|
46
|
-
|
|
47
|
-
module.exports = {
|
|
48
|
-
extends: ['./node_modules/@qvaroo/configs/eslint/node.js'],
|
|
49
|
-
parserOptions: {
|
|
50
|
-
project: './tsconfig.json',
|
|
51
|
-
tsconfigRootDir: __dirname,
|
|
52
|
-
},
|
|
53
|
-
};
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
**For base TypeScript projects:**
|
|
55
|
+
** Legacy Config (.eslintrc.js):**
|
|
56
|
+
If you are still using the legacy config system:
|
|
57
57
|
```javascript
|
|
58
58
|
module.exports = {
|
|
59
59
|
extends: ['./node_modules/@qvaroo/configs/eslint/index.js'],
|
|
60
60
|
parserOptions: {
|
|
61
61
|
project: './tsconfig.json',
|
|
62
|
-
tsconfigRootDir: __dirname,
|
|
63
62
|
},
|
|
64
63
|
};
|
|
65
64
|
```
|
|
@@ -137,38 +136,7 @@ Create `tsconfig.json`:
|
|
|
137
136
|
|
|
138
137
|
---
|
|
139
138
|
|
|
140
|
-
## 🏗️ Folder Structure Enforcement
|
|
141
139
|
|
|
142
|
-
Required project structure:
|
|
143
|
-
|
|
144
|
-
```
|
|
145
|
-
src/
|
|
146
|
-
├── api/ # API clients & endpoints
|
|
147
|
-
├── components/ # Reusable UI components
|
|
148
|
-
├── services/ # Business logic layer
|
|
149
|
-
├── events/ # Event handlers & emitters
|
|
150
|
-
├── animations/ # Animation definitions
|
|
151
|
-
├── styles/ # Global styles & themes
|
|
152
|
-
├── hooks/ # Custom React hooks
|
|
153
|
-
├── views/ # Page-level components (presentation only)
|
|
154
|
-
├── types/ # TypeScript interfaces & types
|
|
155
|
-
├── constants/ # Application constants
|
|
156
|
-
└── utils/ # Utility functions
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
### Boundary Rules
|
|
160
|
-
|
|
161
|
-
| Layer | Can Import From |
|
|
162
|
-
|-------|-----------------|
|
|
163
|
-
| `views` | components, styles, hooks, animations, constants |
|
|
164
|
-
| `components` | components, styles, hooks, utils, types, animations |
|
|
165
|
-
| `hooks` | services, api, types, utils |
|
|
166
|
-
| `services` | api, types, utils, constants |
|
|
167
|
-
| `api` | types, utils, constants |
|
|
168
|
-
|
|
169
|
-
> ⚠️ **Views cannot import from `api` or `services` directly!** Use hooks instead.
|
|
170
|
-
|
|
171
|
-
---
|
|
172
140
|
|
|
173
141
|
## ⛔️ Local Enforcement (Pre-commit Hooks)
|
|
174
142
|
|
|
@@ -404,7 +372,6 @@ module.exports = {
|
|
|
404
372
|
│ └── rules/
|
|
405
373
|
│ ├── naming-conventions.js
|
|
406
374
|
│ ├── code-quality.js
|
|
407
|
-
│ ├── architecture.js
|
|
408
375
|
│ └── spellcheck.js
|
|
409
376
|
├── prettier/
|
|
410
377
|
│ └── index.js # Prettier config
|
package/eslint/index.js
CHANGED
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
|
|
11
11
|
const namingConventionRules = require('./rules/naming-conventions');
|
|
12
12
|
const codeQualityRules = require('./rules/code-quality');
|
|
13
|
-
const architectureRules = require('./rules/architecture');
|
|
14
13
|
const spellcheckRules = require('./rules/spellcheck');
|
|
15
14
|
|
|
16
15
|
/** @type {import('eslint').Linter.Config} */
|
|
@@ -81,10 +80,7 @@ module.exports = {
|
|
|
81
80
|
// ═══════════════════════════════════════════════════════════════════════
|
|
82
81
|
...codeQualityRules,
|
|
83
82
|
|
|
84
|
-
|
|
85
|
-
// ARCHITECTURE - Folder boundaries and separation of concerns
|
|
86
|
-
// ═══════════════════════════════════════════════════════════════════════
|
|
87
|
-
...architectureRules,
|
|
83
|
+
|
|
88
84
|
|
|
89
85
|
// ═══════════════════════════════════════════════════════════════════════
|
|
90
86
|
// SPELLCHECK - Variable name clarity
|
package/index.d.ts
CHANGED
|
@@ -5,5 +5,4 @@ export declare const prettier: import('prettier').Config;
|
|
|
5
5
|
|
|
6
6
|
export declare const namingConventions: Record<string, any>;
|
|
7
7
|
export declare const codeQuality: Record<string, any>;
|
|
8
|
-
export declare const architecture: Record<string, any>;
|
|
9
8
|
export declare const spellcheck: Record<string, any>;
|
package/index.js
CHANGED
|
@@ -12,6 +12,5 @@ module.exports = {
|
|
|
12
12
|
// Individual Rule Sets
|
|
13
13
|
namingConventions: require('./eslint/rules/naming-conventions'),
|
|
14
14
|
codeQuality: require('./eslint/rules/code-quality'),
|
|
15
|
-
architecture: require('./eslint/rules/architecture'),
|
|
16
15
|
spellcheck: require('./eslint/rules/spellcheck'),
|
|
17
16
|
};
|
package/index.mjs
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qvaroo/configs",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "Centralized Qvaroo coding standards, ESLint, Prettier, and TypeScript configurations for TypeScript frontend projects",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"prettier/",
|
|
25
25
|
"typescript/",
|
|
26
26
|
"index.js",
|
|
27
|
+
"index.mjs",
|
|
27
28
|
"index.d.ts"
|
|
28
29
|
],
|
|
29
30
|
"exports": {
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Architecture Rules
|
|
3
|
-
*
|
|
4
|
-
* Enforces folder structure and separation of concerns:
|
|
5
|
-
* - /api, /components, /services, /events, /animations, /styles
|
|
6
|
-
* - Presentation-only views: No business logic or API calls
|
|
7
|
-
* - Boundary enforcement between layers
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
module.exports = {
|
|
11
|
-
// ═══════════════════════════════════════════════════════════════════════
|
|
12
|
-
// BOUNDARY RULES - Folder separation enforcement
|
|
13
|
-
// ═══════════════════════════════════════════════════════════════════════
|
|
14
|
-
|
|
15
|
-
'boundaries/element-types': [
|
|
16
|
-
'error',
|
|
17
|
-
{
|
|
18
|
-
default: 'disallow',
|
|
19
|
-
rules: [
|
|
20
|
-
// Components can import from: styles, types, utils, hooks, components, animations
|
|
21
|
-
{
|
|
22
|
-
from: 'components',
|
|
23
|
-
allow: ['components', 'styles', 'types', 'utils', 'hooks', 'animations', 'constants'],
|
|
24
|
-
},
|
|
25
|
-
|
|
26
|
-
// Views can import from: components, styles, types, hooks (NO services, NO api)
|
|
27
|
-
{
|
|
28
|
-
from: 'views',
|
|
29
|
-
allow: ['components', 'styles', 'types', 'hooks', 'animations', 'constants'],
|
|
30
|
-
disallow: ['api', 'services'], // Presentation-only views
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
// Services can import from: api, types, utils, constants
|
|
34
|
-
{
|
|
35
|
-
from: 'services',
|
|
36
|
-
allow: ['api', 'types', 'utils', 'constants', 'services'],
|
|
37
|
-
},
|
|
38
|
-
|
|
39
|
-
// API layer can only import from: types, utils, constants
|
|
40
|
-
{
|
|
41
|
-
from: 'api',
|
|
42
|
-
allow: ['types', 'utils', 'constants'],
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
// Hooks can import from: services, api, types, utils
|
|
46
|
-
{
|
|
47
|
-
from: 'hooks',
|
|
48
|
-
allow: ['services', 'api', 'types', 'utils', 'constants', 'hooks'],
|
|
49
|
-
},
|
|
50
|
-
|
|
51
|
-
// Events can import from: types, utils
|
|
52
|
-
{
|
|
53
|
-
from: 'events',
|
|
54
|
-
allow: ['types', 'utils', 'constants'],
|
|
55
|
-
},
|
|
56
|
-
|
|
57
|
-
// Animations can import from: types, utils, styles
|
|
58
|
-
{
|
|
59
|
-
from: 'animations',
|
|
60
|
-
allow: ['types', 'utils', 'styles', 'constants'],
|
|
61
|
-
},
|
|
62
|
-
|
|
63
|
-
// Styles: standalone, no business imports
|
|
64
|
-
{
|
|
65
|
-
from: 'styles',
|
|
66
|
-
allow: ['styles', 'constants'],
|
|
67
|
-
},
|
|
68
|
-
|
|
69
|
-
// Utils: standalone, no circular dependencies
|
|
70
|
-
{
|
|
71
|
-
from: 'utils',
|
|
72
|
-
allow: ['types', 'constants'],
|
|
73
|
-
},
|
|
74
|
-
|
|
75
|
-
// Types: standalone
|
|
76
|
-
{
|
|
77
|
-
from: 'types',
|
|
78
|
-
allow: ['types'],
|
|
79
|
-
},
|
|
80
|
-
|
|
81
|
-
// Constants: standalone
|
|
82
|
-
{
|
|
83
|
-
from: 'constants',
|
|
84
|
-
allow: ['types'],
|
|
85
|
-
},
|
|
86
|
-
],
|
|
87
|
-
},
|
|
88
|
-
],
|
|
89
|
-
|
|
90
|
-
// ═══════════════════════════════════════════════════════════════════════
|
|
91
|
-
// IMPORT BOUNDARIES - Prevent circular dependencies
|
|
92
|
-
// ═══════════════════════════════════════════════════════════════════════
|
|
93
|
-
|
|
94
|
-
'import/no-cycle': ['error', { maxDepth: 3 }],
|
|
95
|
-
|
|
96
|
-
'import/no-restricted-paths': [
|
|
97
|
-
'error',
|
|
98
|
-
{
|
|
99
|
-
zones: [
|
|
100
|
-
// Views cannot import directly from API
|
|
101
|
-
{
|
|
102
|
-
target: './src/views',
|
|
103
|
-
from: './src/api',
|
|
104
|
-
message: 'Views must not import from API directly. Use hooks or services instead.',
|
|
105
|
-
},
|
|
106
|
-
// Views cannot import directly from Services
|
|
107
|
-
{
|
|
108
|
-
target: './src/views',
|
|
109
|
-
from: './src/services',
|
|
110
|
-
message: 'Views must not import from services directly. Use hooks instead.',
|
|
111
|
-
},
|
|
112
|
-
// Components cannot import from views (prevent circular)
|
|
113
|
-
{
|
|
114
|
-
target: './src/components',
|
|
115
|
-
from: './src/views',
|
|
116
|
-
message: 'Components cannot import from views. This creates circular dependencies.',
|
|
117
|
-
},
|
|
118
|
-
// Styles cannot import business logic
|
|
119
|
-
{
|
|
120
|
-
target: './src/styles',
|
|
121
|
-
from: './src/api',
|
|
122
|
-
message: 'Styles must not contain business logic or API dependencies.',
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
target: './src/styles',
|
|
126
|
-
from: './src/services',
|
|
127
|
-
message: 'Styles must not contain business logic or service dependencies.',
|
|
128
|
-
},
|
|
129
|
-
],
|
|
130
|
-
},
|
|
131
|
-
],
|
|
132
|
-
|
|
133
|
-
// ═══════════════════════════════════════════════════════════════════════
|
|
134
|
-
// FILE NAMING PATTERNS
|
|
135
|
-
// ═══════════════════════════════════════════════════════════════════════
|
|
136
|
-
|
|
137
|
-
// Enforce consistent file naming
|
|
138
|
-
'unicorn/filename-case': [
|
|
139
|
-
'error',
|
|
140
|
-
{
|
|
141
|
-
cases: {
|
|
142
|
-
kebabCase: true, // Regular files: my-component.ts
|
|
143
|
-
pascalCase: true, // React components: MyComponent.tsx
|
|
144
|
-
},
|
|
145
|
-
ignore: [
|
|
146
|
-
'^README\\.md$',
|
|
147
|
-
'^CHANGELOG\\.md$',
|
|
148
|
-
'^LICENSE$',
|
|
149
|
-
],
|
|
150
|
-
},
|
|
151
|
-
],
|
|
152
|
-
};
|