Skip to content

Commit e96ef49

Browse files
committed
Bump @typescript-eslint/typescript-estree to v7
1 parent dc60e5c commit e96ef49

40 files changed

+4566
-2039
lines changed

.eslintrc.js

Lines changed: 0 additions & 24 deletions
This file was deleted.

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ The following shows an example of the possible options:
125125
"source": "lib",
126126
"destination": "components",
127127
"extension": "jsonld",
128-
"ignorePackagePaths": [ "path/to/package-ignored1", "path/to/package-ignored2" ],
129-
"ignoreComponents": [ "Class1", "Class2" ],
128+
"ignorePackagePaths": ["path/to/package-ignored1", "path/to/package-ignored2"],
129+
"ignoreComponents": ["Class1", "Class2"],
130130
"logLevel": "info",
131131
"modulePrefix": "myprefix",
132132
"debugState": "true",
@@ -170,7 +170,7 @@ export class MyClass extends OtherClass {
170170
* @param paramA - My parameter
171171
*/
172172
constructor(paramA: boolean, paramB: number, paramC: string[]) {
173-
173+
174174
}
175175
}
176176
```
@@ -221,13 +221,13 @@ Component file:
221221

222222
Each argument in the constructor of the class must be one of the following:
223223

224-
* A primitive type such as `boolean, number, string`, which will be mapped to an [XSD type](https://componentsjs.readthedocs.io/en/latest/configuration/components/parameters/)
224+
* A primitive type such as `boolean, number, string`, which will be mapped to an [XSD type](https://componentsjs.readthedocs.io/en/latest/configuration/components/parameters/)
225225
* Another class, which will be mapped to the component `@id`.
226226
* A record or interface containing key-value pairs where each value matches one of the possible options. Nesting is allowed.
227227
* Reference to a generic type that is defined on the class.
228228
* An array, `keyof`, tuple, union, or intersection over any of the allowed types.
229-
230-
Here is an example that showcases all of these options:
229+
230+
Here is an example that showcases all of these options:
231231
```typescript
232232
import {Logger} from "@comunica/core";
233233
export class SampleActor {
@@ -252,7 +252,7 @@ Here is an example that showcases all of these options:
252252
export interface ExtendsTest {
253253
string: string;
254254
}
255-
```
255+
```
256256

257257
### Argument tags
258258

@@ -286,7 +286,7 @@ export class MyActor {
286286
/**
287287
* @param myByte - This is an array of bytes @range {byte}
288288
* @param ignoredArg - @ignored
289-
*/
289+
*/
290290
constructor(myByte: number[], ignoredArg: string) {
291291

292292
}
@@ -326,7 +326,7 @@ export class MyActor {
326326
/**
327327
* @param myValue - Values will be passed as parsed JSON @range {json}
328328
* @param ignoredArg - @ignored
329-
*/
329+
*/
330330
constructor(myValue: any, ignoredArg: string) {
331331

332332
}
@@ -364,7 +364,7 @@ When instantiating TestClass as follows, its JSON value will be passed directly
364364
"someKey": {
365365
"someOtherKey1": 1,
366366
"someOtherKey2": "abc"
367-
}
367+
}
368368
}
369369
}
370370
```

bin/componentsjs-generator.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env node
2-
import * as fs from 'fs';
2+
import * as fs from 'node:fs';
33
import * as minimist from 'minimist';
44
import { GeneratorFactory } from '../lib/config/GeneratorFactory';
55
import { ResolutionContext } from '../lib/resolution/ResolutionContext';
@@ -38,7 +38,7 @@ if (args.help) {
3838
} else {
3939
const packageRootDirectories = (args._.length > 0 ? args._ : [ '' ])
4040
.map(path => joinFilePath(normalizeFilePath(process.cwd()), path))
41-
.flatMap(path => {
41+
.flatMap((path) => {
4242
// Since path expansion does not work on Windows, we may receive wildcard paths, so let's expand those here
4343
if (path.endsWith('*')) {
4444
path = path.slice(0, -1);
@@ -56,4 +56,3 @@ if (args.help) {
5656
process.exit(1);
5757
});
5858
}
59-

eslint.config.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
const config = require('@rubensworks/eslint-config');
2+
3+
module.exports = config([
4+
{
5+
files: [ '**/*.ts' ],
6+
languageOptions: {
7+
parserOptions: {
8+
tsconfigRootDir: __dirname,
9+
project: [ './tsconfig.eslint.json' ],
10+
},
11+
},
12+
},
13+
{
14+
files: [ '**/*.ts' ],
15+
rules: {
16+
'import/no-nodejs-modules': 'off',
17+
'ts/naming-convention': [
18+
'error',
19+
{
20+
selector: 'interface',
21+
format: [ 'PascalCase' ],
22+
custom: {
23+
regex: '^[A-Z]',
24+
match: true,
25+
},
26+
},
27+
],
28+
// TODO: check if we can enable the following
29+
'ts/no-require-imports': 'off',
30+
'ts/no-unsafe-assignment': 'off',
31+
'ts/no-unsafe-argument': 'off',
32+
'ts/no-unsafe-return': 'off',
33+
},
34+
},
35+
{
36+
// Specific rules for NodeJS-specific files
37+
files: [
38+
'**/test/**/*.ts',
39+
],
40+
rules: {
41+
'import/no-nodejs-modules': 'off',
42+
'unused-imports/no-unused-vars': 'off',
43+
'ts/no-require-imports': 'off',
44+
'ts/no-var-requires': 'off',
45+
'ts/no-extraneous-class': 'off',
46+
// TODO: check if we can enable the following
47+
'node/no-path-concat': 'off',
48+
},
49+
},
50+
{
51+
// Files that do not require linting
52+
ignores: [
53+
'**/file-invalid.d.ts',
54+
],
55+
},
56+
]);

lib/parse/ClassIndexer.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
*/
44
import type { Logger } from 'winston';
55
import type { ClassFinder } from './ClassFinder';
6-
import type { ClassIndex,
6+
import type {
7+
ClassIndex,
78
ClassReference,
89
ClassReferenceLoaded,
910
ClassReferenceLoadedClassOrInterface,
1011
InterfaceLoaded,
11-
GenericallyTyped } from './ClassIndex';
12+
GenericallyTyped,
13+
} from './ClassIndex';
1214

1315
import type { ClassLoader } from './ClassLoader';
1416

@@ -55,8 +57,8 @@ export class ClassIndexer {
5557

5658
if (classReferenceLoaded.type === 'class') {
5759
// If the class has a super class, load it recursively
58-
const superClassName = this.classLoader.getSuperClassName(classReferenceLoaded.declaration,
59-
classReferenceLoaded.fileName);
60+
const superClassName = this.classLoader
61+
.getSuperClassName(classReferenceLoaded.declaration, classReferenceLoaded.fileName);
6062
if (superClassName && !(superClassName.value in this.ignoreClasses)) {
6163
let superClassLoaded;
6264
try {
@@ -80,13 +82,13 @@ export class ClassIndexer {
8082
}
8183

8284
// If the class implements interfaces, load them
83-
const interfaceNames = this.classLoader.getClassInterfaceNames(classReferenceLoaded.declaration,
84-
classReferenceLoaded.fileName);
85+
const interfaceNames = this.classLoader
86+
.getClassInterfaceNames(classReferenceLoaded.declaration, classReferenceLoaded.fileName);
8587
classReferenceLoaded.implementsInterfaces = <GenericallyTyped<ClassReferenceLoadedClassOrInterface>[]> (
8688
await Promise
8789
.all(interfaceNames
8890
.filter(interfaceName => !(interfaceName.value in this.ignoreClasses))
89-
.map(async interfaceName => {
91+
.map(async(interfaceName) => {
9092
let interfaceOrClassLoaded;
9193
try {
9294
interfaceOrClassLoaded = await this.classLoader.loadClassDeclaration({
@@ -106,14 +108,14 @@ export class ClassIndexer {
106108
genericTypeInstantiations: interfaceName.genericTypeInstantiations,
107109
};
108110
})))
109-
.filter(iface => Boolean(iface));
111+
.filter(Boolean);
110112
} else {
111113
const superInterfaceNames = this.classLoader
112114
.getSuperInterfaceNames(classReferenceLoaded.declaration, classReferenceLoaded.fileName);
113115
classReferenceLoaded.superInterfaces = <GenericallyTyped<InterfaceLoaded>[]> (await Promise
114116
.all(superInterfaceNames
115117
.filter(interfaceName => !(interfaceName.value in this.ignoreClasses))
116-
.map(async interfaceName => {
118+
.map(async(interfaceName) => {
117119
let superInterface;
118120
try {
119121
superInterface = await this.loadClassChain({
@@ -136,7 +138,7 @@ export class ClassIndexer {
136138
genericTypeInstantiations: interfaceName.genericTypeInstantiations,
137139
};
138140
})))
139-
.filter(iface => Boolean(iface));
141+
.filter(Boolean);
140142
}
141143

142144
return classReferenceLoaded;

lib/parse/ClassLoader.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export class ClassLoader {
4646
// Extensions in the form of `class A extends B`
4747
return {
4848
value: declaration.superClass.name,
49-
genericTypeInstantiations: declaration.superTypeParameters,
49+
genericTypeInstantiations: declaration.superTypeArguments,
5050
};
5151
}
5252
if (declaration.superClass.type === AST_NODE_TYPES.MemberExpression &&
@@ -62,27 +62,27 @@ export class ClassLoader {
6262
* Find the super interfaces of the given interface.
6363
* Throws an error for interface definitions that could not be interpreted.
6464
* @param declaration An interface declaration.
65-
* @param fileName The file name of the current class.
65+
* @param _fileName The file name of the current class.
6666
*/
6767
public getSuperInterfaceNames(
6868
declaration: TSESTree.TSInterfaceDeclaration,
69-
fileName: string,
69+
_fileName: string,
7070
): GenericallyTyped<string>[] {
71-
return <GenericallyTyped<string>[]> (declaration.extends || [])
71+
return <GenericallyTyped<string>[]> declaration.extends
7272
// eslint-disable-next-line array-callback-return
73-
.map(extendsExpression => {
73+
.map((extendsExpression) => {
7474
if (extendsExpression.type === AST_NODE_TYPES.TSInterfaceHeritage &&
7575
extendsExpression.expression.type === AST_NODE_TYPES.Identifier) {
7676
// Extensions in the form of `interface A extends B`
7777
return {
7878
value: extendsExpression.expression.name,
79-
genericTypeInstantiations: extendsExpression.typeParameters,
79+
genericTypeInstantiations: extendsExpression.typeArguments,
8080
};
8181
}
8282
// Ignore interfaces that we don't understand
8383
this.logger.debug(`Ignored an interface expression of unknown type ${extendsExpression.expression.type} on ${declaration.id.name}`);
8484
})
85-
.filter(iface => Boolean(iface));
85+
.filter(Boolean);
8686
}
8787

8888
/**
@@ -102,7 +102,7 @@ export class ClassLoader {
102102
}
103103
interfaceNames.push({
104104
value: implement.expression.name,
105-
genericTypeInstantiations: implement.typeParameters,
105+
genericTypeInstantiations: implement.typeArguments,
106106
});
107107
}
108108
}
@@ -375,15 +375,23 @@ export class ClassLoader {
375375
name: enumKey,
376376
loc: <any> undefined,
377377
range: <any> undefined,
378+
parent: <any> undefined,
379+
typeAnnotation: <any> undefined,
380+
optional: <any> undefined,
381+
decorators: <any> undefined,
378382
},
379383
typeAnnotation: {
380384
type: AST_NODE_TYPES.TSLiteralType,
381385
literal: enumMember.initializer,
382386
loc: <any> undefined,
383387
range: <any> undefined,
388+
parent: <any> undefined,
384389
},
385390
loc: <any> undefined,
386391
range: <any> undefined,
392+
parent: <any> undefined,
393+
declare: <any> undefined,
394+
typeParameters: <any> undefined,
387395
};
388396
return <any> <TypeLoaded> {
389397
type: 'type',

0 commit comments

Comments
 (0)