@craft-ng/dev-tools 0.1.0 → 0.1.2
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 +44 -292
- package/package.json +5 -4
- package/src/eslint-rules/brand-angular-deps-match.cjs +10 -30
- package/src/eslint-rules/index.cjs +0 -1
- package/src/eslint-rules/index.d.cts +5 -0
- package/src/eslint-rules/no-angular-inject.cjs +1 -2
- package/src/eslint-rules/no-direct-angular-class-export.cjs +9 -32
- package/src/eslint/angular.mjs +0 -26
- package/src/eslint/index.mjs +0 -18
package/README.md
CHANGED
|
@@ -10,315 +10,67 @@ Development tools for ng-craft: ESLint configs, ESLint rules, and codemods.
|
|
|
10
10
|
npm install -D @craft-ng/dev-tools
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
### Publication sur npm
|
|
14
|
-
|
|
15
|
-
Pour publier le package sur npm (mainteneurs uniquement) :
|
|
16
|
-
|
|
17
|
-
#### 1. Se connecter à npm
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
npm login
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
Vous aurez besoin d'un compte npm avec les droits de publication sur le scope `@craft-ng`.
|
|
24
|
-
|
|
25
|
-
#### 2. Builder le package
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
npx nx build dev-tools
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
#### 3. Mettre à jour la version
|
|
32
|
-
|
|
33
|
-
Modifiez la version dans `libs/dev-tools/package.json` selon [semver](https://semver.org/) :
|
|
34
|
-
|
|
35
|
-
- **Patch** (0.1.0 → 0.1.1) : Corrections de bugs
|
|
36
|
-
- **Minor** (0.1.0 → 0.2.0) : Nouvelles fonctionnalités rétrocompatibles
|
|
37
|
-
- **Major** (0.1.0 → 1.0.0) : Changements non rétrocompatibles
|
|
38
|
-
|
|
39
|
-
#### 4. Publier
|
|
40
|
-
|
|
41
|
-
Depuis le répertoire de build :
|
|
42
|
-
|
|
43
13
|
```bash
|
|
44
|
-
cd dist/libs/dev-tools
|
|
45
|
-
npm publish --access public
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
> **Note** : L'option `--access public` est nécessaire pour les packages scoped (`@craft-ng/...`) si vous souhaitez les rendre publics.
|
|
49
|
-
|
|
50
|
-
#### 5. Créer un tag Git (recommandé)
|
|
51
|
-
|
|
52
|
-
Retournez à la racine et créez un tag :
|
|
53
|
-
|
|
54
|
-
```bash
|
|
55
|
-
cd ../../..
|
|
56
|
-
git tag dev-tools-v0.1.0
|
|
57
|
-
git push origin dev-tools-v0.1.0
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
### En développement local (avant publication)
|
|
61
|
-
|
|
62
|
-
Pour tester ce package dans un autre projet avant de le publier sur npm :
|
|
63
|
-
|
|
64
|
-
#### 1. Builder le package
|
|
65
|
-
|
|
66
|
-
Depuis la racine du monorepo ng-craft :
|
|
67
|
-
|
|
68
|
-
```bash
|
|
69
|
-
npx nx build dev-tools
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
Cela génère les fichiers compilés dans `dist/libs/dev-tools/`.
|
|
73
|
-
|
|
74
|
-
#### 2. Créer un lien npm local
|
|
75
|
-
|
|
76
|
-
Depuis la racine du monorepo :
|
|
77
|
-
|
|
78
|
-
```bash
|
|
79
|
-
cd dist/libs/dev-tools
|
|
80
|
-
npm link
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
#### 3. Utiliser le lien dans votre autre projet
|
|
84
|
-
|
|
85
|
-
Dans votre projet Angular externe :
|
|
86
|
-
|
|
87
|
-
```bash
|
|
88
|
-
cd /chemin/vers/votre-projet
|
|
89
|
-
npm link @craft-ng/dev-tools
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
> **Note** : Après chaque modification du code de `@craft-ng/dev-tools`, vous devez rebuilder avec `npx nx build dev-tools` pour que les changements soient pris en compte dans les projets liés.
|
|
93
|
-
|
|
94
|
-
#### 4. Supprimer le lien (quand terminé)
|
|
95
|
-
|
|
96
|
-
Dans votre projet externe :
|
|
97
|
-
|
|
98
|
-
```bash
|
|
99
|
-
npm unlink @craft-ng/dev-tools
|
|
100
|
-
npm install
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
## Configuration complète dans un nouveau projet
|
|
104
|
-
|
|
105
|
-
Voici un exemple de configuration complète pour utiliser tous les outils dans un projet Angular :
|
|
106
|
-
|
|
107
|
-
### 1. Installer les dépendances
|
|
108
|
-
|
|
109
|
-
```bash
|
|
110
|
-
npm install -D @craft-ng/dev-tools @craft-ng/core
|
|
111
|
-
npm install -D @angular-eslint/eslint-plugin @typescript-eslint/eslint-plugin eslint
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
### 2. Configurer ESLint
|
|
115
|
-
|
|
116
|
-
Créez ou modifiez `eslint.config.mjs` :
|
|
117
|
-
|
|
118
|
-
```javascript
|
|
119
|
-
import craftAngular from '@craft-ng/dev-tools/eslint/angular';
|
|
120
14
|
import craftRules from '@craft-ng/dev-tools/eslint-rules';
|
|
121
15
|
|
|
122
16
|
export default [
|
|
123
17
|
{
|
|
124
|
-
ignores: ['dist/**', 'node_modules/**'],
|
|
125
|
-
},
|
|
126
|
-
...craftAngular,
|
|
127
|
-
{
|
|
128
|
-
files: ['**/*.ts'],
|
|
129
18
|
plugins: {
|
|
130
|
-
'
|
|
19
|
+
'craft-ng': craftRules
|
|
131
20
|
},
|
|
132
21
|
rules: {
|
|
133
|
-
|
|
134
|
-
'
|
|
135
|
-
'
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
},
|
|
22
|
+
'craft-ng/brand-angular-deps-match': 'error',
|
|
23
|
+
'craft-ng/no-angular-inject': 'error',
|
|
24
|
+
'craft-ng/no-direct-angular-class-export': 'error',
|
|
25
|
+
}
|
|
26
|
+
}
|
|
139
27
|
];
|
|
140
28
|
```
|
|
141
29
|
|
|
142
|
-
### 3. Transformer votre code existant
|
|
143
|
-
|
|
144
30
|
```bash
|
|
145
|
-
|
|
146
|
-
npx craft-brand --root ./src --dry-run
|
|
147
|
-
|
|
148
|
-
# Appliquer les transformations
|
|
149
|
-
npx craft-brand --root ./src
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
### 4. Ajouter des scripts npm
|
|
153
|
-
|
|
154
|
-
Dans votre `package.json` :
|
|
155
|
-
|
|
156
|
-
```json
|
|
157
|
-
{
|
|
158
|
-
"scripts": {
|
|
159
|
-
"lint": "eslint .",
|
|
160
|
-
"lint:fix": "eslint . --fix",
|
|
161
|
-
"codemod:preview": "craft-brand --dry-run",
|
|
162
|
-
"codemod:apply": "craft-brand"
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
## Features
|
|
168
|
-
|
|
169
|
-
### 1. ESLint Configurations
|
|
170
|
-
|
|
171
|
-
Pre-configured ESLint settings for ng-craft projects.
|
|
172
|
-
|
|
173
|
-
#### Basic TypeScript Config
|
|
174
|
-
|
|
175
|
-
```javascript
|
|
176
|
-
// eslint.config.mjs
|
|
177
|
-
import craftEslint from '@craft-ng/dev-tools/eslint';
|
|
178
|
-
|
|
179
|
-
export default [...craftEslint];
|
|
180
|
-
```
|
|
31
|
+
const craftRules = require('@craft-ng/dev-tools/eslint-rules');
|
|
181
32
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
```javascript
|
|
185
|
-
// eslint.config.mjs
|
|
186
|
-
import craftAngular from '@craft-ng/dev-tools/eslint/angular';
|
|
187
|
-
|
|
188
|
-
export default [...craftAngular];
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
### 2. ESLint Rules
|
|
192
|
-
|
|
193
|
-
Custom ESLint rules for enforcing ng-craft patterns.
|
|
194
|
-
|
|
195
|
-
#### Available Rules
|
|
196
|
-
|
|
197
|
-
- **`brand-angular-deps-match`** - Ensures `deps({ injected, importDeps, providers })` matches the Angular symbol dependencies
|
|
198
|
-
- **`no-angular-inject`** - Disallows Angular `inject()`, `@Injectable`, and `@Service` usage
|
|
199
|
-
- **`no-direct-angular-class-export`** - Disallows direct exports of Angular symbols managed through `brandAngularSymbol`
|
|
200
|
-
|
|
201
|
-
#### Usage
|
|
202
|
-
|
|
203
|
-
```javascript
|
|
204
|
-
// eslint.config.mjs
|
|
205
|
-
import craftAngular from '@craft-ng/dev-tools/eslint/angular';
|
|
206
|
-
import craftRules from '@craft-ng/dev-tools/eslint-rules';
|
|
207
|
-
|
|
208
|
-
export default [
|
|
209
|
-
...craftAngular,
|
|
33
|
+
module.exports = defineConfig([
|
|
210
34
|
{
|
|
35
|
+
files: ['**/*.ts'],
|
|
36
|
+
extends: [
|
|
37
|
+
eslint.configs.recommended,
|
|
38
|
+
tseslint.configs.recommended,
|
|
39
|
+
tseslint.configs.stylistic,
|
|
40
|
+
angular.configs.tsRecommended,
|
|
41
|
+
],
|
|
42
|
+
processor: angular.processInlineTemplates,
|
|
211
43
|
plugins: {
|
|
212
|
-
'
|
|
44
|
+
'craft-ng': craftRules,
|
|
213
45
|
},
|
|
214
46
|
rules: {
|
|
215
|
-
'@
|
|
216
|
-
|
|
217
|
-
|
|
47
|
+
'@angular-eslint/directive-selector': [
|
|
48
|
+
'error',
|
|
49
|
+
{
|
|
50
|
+
type: 'attribute',
|
|
51
|
+
prefix: 'app',
|
|
52
|
+
style: 'camelCase',
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
'@angular-eslint/component-selector': [
|
|
56
|
+
'error',
|
|
57
|
+
{
|
|
58
|
+
type: 'element',
|
|
59
|
+
prefix: 'app',
|
|
60
|
+
style: 'kebab-case',
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
'@typescript-eslint/consistent-type-definitions': 'off',
|
|
64
|
+
// Ajoutez vos règles craft-ng ici
|
|
65
|
+
'craft-ng/brand-angular-deps-match': 'error',
|
|
66
|
+
'craft-ng/no-angular-inject': 'error',
|
|
67
|
+
'craft-ng/no-direct-angular-class-export': 'error',
|
|
218
68
|
},
|
|
219
69
|
},
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
#### CLI Usage
|
|
228
|
-
|
|
229
|
-
```bash
|
|
230
|
-
# Transform all TypeScript files in the current directory
|
|
231
|
-
npx craft-brand
|
|
232
|
-
|
|
233
|
-
# Transform with specific root directory
|
|
234
|
-
npx craft-brand --root ./src
|
|
235
|
-
|
|
236
|
-
# Dry run (preview changes without writing)
|
|
237
|
-
npx craft-brand --dry-run
|
|
238
|
-
|
|
239
|
-
# Only transform standalone components/directives
|
|
240
|
-
npx craft-brand --transform-only-standalone-declarables
|
|
241
|
-
|
|
242
|
-
# Custom helper import path
|
|
243
|
-
npx craft-brand --helper-import @my-lib/core
|
|
244
|
-
|
|
245
|
-
# Use specific tsconfig
|
|
246
|
-
npx craft-brand --tsconfig ./tsconfig.app.json
|
|
247
|
-
```
|
|
248
|
-
|
|
249
|
-
#### Programmatic Usage
|
|
250
|
-
|
|
251
|
-
```typescript
|
|
252
|
-
import { runAngularBrandCodemod } from '@craft-ng/dev-tools';
|
|
253
|
-
|
|
254
|
-
await runAngularBrandCodemod({
|
|
255
|
-
rootDir: './src',
|
|
256
|
-
dryRun: true,
|
|
257
|
-
transformOnlyStandaloneDeclarables: false,
|
|
258
|
-
includeProviders: true,
|
|
259
|
-
includeViewProviders: true,
|
|
260
|
-
helperImportPath: '@craft-ng/core',
|
|
261
|
-
log: console.log,
|
|
262
|
-
});
|
|
263
|
-
```
|
|
264
|
-
|
|
265
|
-
#### What it does
|
|
266
|
-
|
|
267
|
-
Transforms this:
|
|
268
|
-
|
|
269
|
-
```typescript
|
|
270
|
-
import { Component, inject } from '@angular/core';
|
|
271
|
-
|
|
272
|
-
@Component({
|
|
273
|
-
standalone: true,
|
|
274
|
-
imports: [CommonModule],
|
|
275
|
-
providers: [MyService],
|
|
276
|
-
})
|
|
277
|
-
export class DemoComponent {
|
|
278
|
-
private api = inject(ApiService);
|
|
279
|
-
constructor(private http: HttpClient) {}
|
|
280
|
-
}
|
|
281
|
-
```
|
|
282
|
-
|
|
283
|
-
Into this:
|
|
284
|
-
|
|
285
|
-
```typescript
|
|
286
|
-
import { Component, inject } from '@angular/core';
|
|
287
|
-
import { brandAngularSymbol, deps } from '@craft-ng/core';
|
|
288
|
-
|
|
289
|
-
@Component({
|
|
290
|
-
standalone: true,
|
|
291
|
-
imports: [CommonModule],
|
|
292
|
-
providers: [MyService],
|
|
293
|
-
})
|
|
294
|
-
class DemoComponent {
|
|
295
|
-
private api = inject(ApiService);
|
|
296
|
-
constructor(private http: HttpClient) {}
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
export default brandAngularSymbol(
|
|
300
|
-
DemoComponent,
|
|
301
|
-
deps({
|
|
302
|
-
injected: [HttpClient, ApiService],
|
|
303
|
-
importDeps: [CommonModule],
|
|
304
|
-
providers: [MyService],
|
|
305
|
-
}),
|
|
306
|
-
);
|
|
70
|
+
{
|
|
71
|
+
files: ['**/*.html'],
|
|
72
|
+
extends: [angular.configs.templateRecommended, angular.configs.templateAccessibility],
|
|
73
|
+
rules: {},
|
|
74
|
+
},
|
|
75
|
+
]);
|
|
307
76
|
```
|
|
308
|
-
|
|
309
|
-
#### CLI Options
|
|
310
|
-
|
|
311
|
-
| Option | Description | Default |
|
|
312
|
-
| ----------------------------------------- | -------------------------------------------------- | ---------------------- |
|
|
313
|
-
| `--root <dir>` | Project root directory | `cwd` |
|
|
314
|
-
| `--tsconfig <path>` | Path to tsconfig.json | `<root>/tsconfig.json` |
|
|
315
|
-
| `--helper-import <path>` | Import path for `brandAngularSymbol` and `deps` | `@craft-ng/core` |
|
|
316
|
-
| `--transform-only-standalone-declarables` | Only transform standalone components/directives | `false` |
|
|
317
|
-
| `--no-providers` | Do not include metadata providers in `deps()` | `false` |
|
|
318
|
-
| `--no-view-providers` | Do not include component viewProviders in `deps()` | `false` |
|
|
319
|
-
| `--dry-run` | Print results without writing files | `false` |
|
|
320
|
-
| `--help` | Show help | - |
|
|
321
|
-
|
|
322
|
-
## License
|
|
323
|
-
|
|
324
|
-
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@craft-ng/dev-tools",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Development tools for ng-craft: ESLint configs, ESLint rules, and codemods",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -10,9 +10,10 @@
|
|
|
10
10
|
"types": "./src/index.d.ts",
|
|
11
11
|
"default": "./src/index.js"
|
|
12
12
|
},
|
|
13
|
-
"./eslint":
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
"./eslint-rules": {
|
|
14
|
+
"types": "./src/eslint-rules/index.d.cts",
|
|
15
|
+
"default": "./src/eslint-rules/index.cjs"
|
|
16
|
+
},
|
|
16
17
|
"./package.json": "./package.json"
|
|
17
18
|
},
|
|
18
19
|
"bin": {
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
const fs = require('node:fs');
|
|
2
2
|
const path = require('node:path');
|
|
3
3
|
|
|
4
|
+
process.env.TS_NODE_PROJECT ??= path.resolve(__dirname, '../tsconfig.codemod.json');
|
|
5
|
+
require('ts-node/register/transpile-only');
|
|
6
|
+
|
|
4
7
|
const { Project } = require('ts-morph');
|
|
5
8
|
const {
|
|
6
9
|
analyzeSourceFileDependencies,
|
|
7
10
|
readExistingDependencyGroups,
|
|
8
|
-
} = require('../
|
|
11
|
+
} = require('../angular-brand-codemod.ts');
|
|
9
12
|
|
|
10
13
|
const projectCache = new Map();
|
|
11
14
|
|
|
@@ -32,24 +35,13 @@ module.exports = {
|
|
|
32
35
|
return;
|
|
33
36
|
}
|
|
34
37
|
|
|
35
|
-
const sourceFile = getProjectSourceFile(
|
|
36
|
-
getProject(getCwd(context)),
|
|
37
|
-
filePath,
|
|
38
|
-
text,
|
|
39
|
-
);
|
|
38
|
+
const sourceFile = getProjectSourceFile(getProject(getCwd(context)), filePath, text);
|
|
40
39
|
const analysis = analyzeSourceFileDependencies(sourceFile);
|
|
41
|
-
if (
|
|
42
|
-
!analysis.classDeclaration ||
|
|
43
|
-
analysis.skipped ||
|
|
44
|
-
!analysis.className
|
|
45
|
-
) {
|
|
40
|
+
if (!analysis.classDeclaration || analysis.skipped || !analysis.className) {
|
|
46
41
|
return;
|
|
47
42
|
}
|
|
48
43
|
|
|
49
|
-
const existing = readExistingDependencyGroups(
|
|
50
|
-
sourceFile,
|
|
51
|
-
analysis.className,
|
|
52
|
-
);
|
|
44
|
+
const existing = readExistingDependencyGroups(sourceFile, analysis.className);
|
|
53
45
|
if (!existing.found) {
|
|
54
46
|
return;
|
|
55
47
|
}
|
|
@@ -145,14 +137,7 @@ function getCwd(context) {
|
|
|
145
137
|
return context.cwd ?? process.cwd();
|
|
146
138
|
}
|
|
147
139
|
|
|
148
|
-
function reportIfMismatch(
|
|
149
|
-
context,
|
|
150
|
-
sourceCode,
|
|
151
|
-
existing,
|
|
152
|
-
propertyName,
|
|
153
|
-
expected,
|
|
154
|
-
actual,
|
|
155
|
-
) {
|
|
140
|
+
function reportIfMismatch(context, sourceCode, existing, propertyName, expected, actual) {
|
|
156
141
|
if (isSameDependencyList(expected, actual)) {
|
|
157
142
|
return;
|
|
158
143
|
}
|
|
@@ -160,9 +145,7 @@ function reportIfMismatch(
|
|
|
160
145
|
reportNode(
|
|
161
146
|
context,
|
|
162
147
|
sourceCode,
|
|
163
|
-
existing.propertyNodes[propertyName] ??
|
|
164
|
-
existing.depsObjectNode ??
|
|
165
|
-
existing.exportAssignmentNode,
|
|
148
|
+
existing.propertyNodes[propertyName] ?? existing.depsObjectNode ?? existing.exportAssignmentNode,
|
|
166
149
|
`deps.${propertyName} does not match the Angular symbol. Expected ${formatDependencyList(expected)} but found ${formatDependencyList(actual)}.`,
|
|
167
150
|
);
|
|
168
151
|
}
|
|
@@ -182,10 +165,7 @@ function getNodeLoc(sourceCode, node) {
|
|
|
182
165
|
}
|
|
183
166
|
|
|
184
167
|
function isSameDependencyList(left, right) {
|
|
185
|
-
return (
|
|
186
|
-
left.length === right.length &&
|
|
187
|
-
left.every((value, index) => value === right[index])
|
|
188
|
-
);
|
|
168
|
+
return left.length === right.length && left.every((value, index) => value === right[index]);
|
|
189
169
|
}
|
|
190
170
|
|
|
191
171
|
function formatDependencyList(dependencies) {
|
|
@@ -131,8 +131,7 @@ function getAngularBlockedDecoratorName(
|
|
|
131
131
|
expression.object.type === 'Identifier' &&
|
|
132
132
|
angularNamespaceImports.has(expression.object.name) &&
|
|
133
133
|
expression.property.type === 'Identifier' &&
|
|
134
|
-
(expression.property.name === 'Injectable' ||
|
|
135
|
-
expression.property.name === 'Service')
|
|
134
|
+
(expression.property.name === 'Injectable' || expression.property.name === 'Service')
|
|
136
135
|
) {
|
|
137
136
|
return expression.property.name;
|
|
138
137
|
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
const fs = require('node:fs');
|
|
2
2
|
const path = require('node:path');
|
|
3
3
|
|
|
4
|
+
process.env.TS_NODE_PROJECT ??= path.resolve(__dirname, '../tsconfig.codemod.json');
|
|
5
|
+
require('ts-node/register/transpile-only');
|
|
6
|
+
|
|
4
7
|
const { Project, Node, SyntaxKind } = require('ts-morph');
|
|
5
|
-
const { getAngularKind } = require('../
|
|
8
|
+
const { getAngularKind } = require('../angular-brand-codemod.ts');
|
|
6
9
|
|
|
7
10
|
const projectCache = new Map();
|
|
8
11
|
|
|
@@ -29,11 +32,7 @@ module.exports = {
|
|
|
29
32
|
return;
|
|
30
33
|
}
|
|
31
34
|
|
|
32
|
-
const sourceFile = getProjectSourceFile(
|
|
33
|
-
getProject(getCwd(context)),
|
|
34
|
-
filePath,
|
|
35
|
-
text,
|
|
36
|
-
);
|
|
35
|
+
const sourceFile = getProjectSourceFile(getProject(getCwd(context)), filePath, text);
|
|
37
36
|
const angularClasses = sourceFile
|
|
38
37
|
.getClasses()
|
|
39
38
|
.map((classDeclaration) => ({
|
|
@@ -43,12 +42,7 @@ module.exports = {
|
|
|
43
42
|
.filter((entry) => Boolean(entry.angularKind));
|
|
44
43
|
|
|
45
44
|
for (const { classDeclaration, angularKind } of angularClasses) {
|
|
46
|
-
reportDirectClassExport(
|
|
47
|
-
context,
|
|
48
|
-
sourceCode,
|
|
49
|
-
classDeclaration,
|
|
50
|
-
angularKind,
|
|
51
|
-
);
|
|
45
|
+
reportDirectClassExport(context, sourceCode, classDeclaration, angularKind);
|
|
52
46
|
reportIdentifierExportAssignment(
|
|
53
47
|
context,
|
|
54
48
|
sourceCode,
|
|
@@ -56,13 +50,7 @@ module.exports = {
|
|
|
56
50
|
classDeclaration,
|
|
57
51
|
angularKind,
|
|
58
52
|
);
|
|
59
|
-
reportNamedExports(
|
|
60
|
-
context,
|
|
61
|
-
sourceCode,
|
|
62
|
-
sourceFile,
|
|
63
|
-
classDeclaration,
|
|
64
|
-
angularKind,
|
|
65
|
-
);
|
|
53
|
+
reportNamedExports(context, sourceCode, sourceFile, classDeclaration, angularKind);
|
|
66
54
|
}
|
|
67
55
|
},
|
|
68
56
|
};
|
|
@@ -119,12 +107,7 @@ function getCwd(context) {
|
|
|
119
107
|
return context.cwd ?? process.cwd();
|
|
120
108
|
}
|
|
121
109
|
|
|
122
|
-
function reportDirectClassExport(
|
|
123
|
-
context,
|
|
124
|
-
sourceCode,
|
|
125
|
-
classDeclaration,
|
|
126
|
-
angularKind,
|
|
127
|
-
) {
|
|
110
|
+
function reportDirectClassExport(context, sourceCode, classDeclaration, angularKind) {
|
|
128
111
|
const hasDirectExportModifier = classDeclaration
|
|
129
112
|
.getModifiers()
|
|
130
113
|
.some(
|
|
@@ -176,13 +159,7 @@ function reportIdentifierExportAssignment(
|
|
|
176
159
|
}
|
|
177
160
|
}
|
|
178
161
|
|
|
179
|
-
function reportNamedExports(
|
|
180
|
-
context,
|
|
181
|
-
sourceCode,
|
|
182
|
-
sourceFile,
|
|
183
|
-
classDeclaration,
|
|
184
|
-
angularKind,
|
|
185
|
-
) {
|
|
162
|
+
function reportNamedExports(context, sourceCode, sourceFile, classDeclaration, angularKind) {
|
|
186
163
|
const className = classDeclaration.getName();
|
|
187
164
|
if (!className) {
|
|
188
165
|
return;
|
package/src/eslint/angular.mjs
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import baseConfig from './index.mjs';
|
|
2
|
-
|
|
3
|
-
export default [
|
|
4
|
-
...baseConfig,
|
|
5
|
-
{
|
|
6
|
-
files: ['**/*.ts'],
|
|
7
|
-
rules: {
|
|
8
|
-
'@angular-eslint/directive-selector': [
|
|
9
|
-
'error',
|
|
10
|
-
{
|
|
11
|
-
type: 'attribute',
|
|
12
|
-
prefix: 'app',
|
|
13
|
-
style: 'camelCase',
|
|
14
|
-
},
|
|
15
|
-
],
|
|
16
|
-
'@angular-eslint/component-selector': [
|
|
17
|
-
'error',
|
|
18
|
-
{
|
|
19
|
-
type: 'element',
|
|
20
|
-
prefix: 'app',
|
|
21
|
-
style: 'kebab-case',
|
|
22
|
-
},
|
|
23
|
-
],
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
];
|
package/src/eslint/index.mjs
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export default [
|
|
2
|
-
{
|
|
3
|
-
files: ['**/*.ts'],
|
|
4
|
-
rules: {
|
|
5
|
-
'@typescript-eslint/no-unused-vars': [
|
|
6
|
-
'warn',
|
|
7
|
-
{
|
|
8
|
-
argsIgnorePattern: '^_',
|
|
9
|
-
varsIgnorePattern: '^_',
|
|
10
|
-
caughtErrorsIgnorePattern: '^_',
|
|
11
|
-
},
|
|
12
|
-
],
|
|
13
|
-
'no-empty-object-type': 'off',
|
|
14
|
-
'@typescript-eslint/no-empty-object-type': 'off',
|
|
15
|
-
'@typescript-eslint/no-unsafe-function-type': 'off',
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
];
|