Skip to content

Commit 446318b

Browse files
Copilotrubensworks
andauthored
Migrate linter from tslint to @rubensworks/eslint-config (#75)
* Changes before error encountered Agent-Logs-Url: https://github.com/rubensworks/rdfa-streaming-parser.js/sessions/2dc0ad2e-9480-4194-94cd-520bf5ceeb37 Co-authored-by: rubensworks <440384+rubensworks@users.noreply.github.com> * chore: migrate from tslint to eslint (partial fixes) Agent-Logs-Url: https://github.com/rubensworks/rdfa-streaming-parser.js/sessions/3244748a-5ae5-4252-a0f9-7f7e0b1e696e Co-authored-by: rubensworks <440384+rubensworks@users.noreply.github.com> * Changes before error encountered Agent-Logs-Url: https://github.com/rubensworks/rdfa-streaming-parser.js/sessions/5a05c36d-c144-42ef-bfe4-ae02d5954db7 Co-authored-by: rubensworks <440384+rubensworks@users.noreply.github.com> * fix: resolve CI failures - TypeScript errors, ESLint errors, and test issues Agent-Logs-Url: https://github.com/rubensworks/rdfa-streaming-parser.js/sessions/adc4fdf2-bbd3-4c49-8311-99ed24dc63b4 Co-authored-by: rubensworks <440384+rubensworks@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: rubensworks <440384+rubensworks@users.noreply.github.com>
1 parent 50b1a88 commit 446318b

21 files changed

Lines changed: 4868 additions & 3017 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ yarn-error.log
1818
**/index.js.map
1919
**/index.d.ts
2020
coverage
21+
.eslintcache
2122
documentation
2223
.rdf-test-suite-cache
2324

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ _or_
3535
const RdfaParser = require("rdfa-streaming-parser").RdfaParser;
3636
```
3737

38-
3938
## Usage
4039

4140
`RdfaParser` is a Node [Transform stream](https://nodejs.org/api/stream.html#stream_class_stream_transform)

eslint.config.js

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
const config = require('@rubensworks/eslint-config');
2+
3+
module.exports = config([
4+
{
5+
// Exclude performance benchmark scripts from linting
6+
ignores: [ 'perf/**' ],
7+
},
8+
{
9+
files: [ '**/*.ts' ],
10+
languageOptions: {
11+
parserOptions: {
12+
tsconfigRootDir: __dirname,
13+
project: [ './tsconfig.eslint.json' ],
14+
},
15+
},
16+
},
17+
{
18+
rules: {
19+
// Allow importing Node.js built-in modules (used in tests and webpack config)
20+
'import/no-nodejs-modules': 'off',
21+
22+
// Allow file extensions in import paths (required for JSON imports)
23+
'import/extensions': 'off',
24+
},
25+
},
26+
{
27+
files: [ '**/*.ts' ],
28+
rules: {
29+
// This rule requires strictNullChecks, which is not enabled in this project
30+
'ts/prefer-nullish-coalescing': 'off',
31+
32+
// Extended naming conventions for this project
33+
'ts/naming-convention': [
34+
'error',
35+
{
36+
selector: 'default',
37+
format: [ 'camelCase' ],
38+
leadingUnderscore: 'forbid',
39+
trailingUnderscore: 'forbid',
40+
},
41+
{
42+
selector: 'import',
43+
format: null,
44+
},
45+
{
46+
selector: 'variable',
47+
format: [ 'camelCase', 'UPPER_CASE' ],
48+
leadingUnderscore: 'forbid',
49+
trailingUnderscore: 'forbid',
50+
},
51+
{
52+
selector: 'typeLike',
53+
format: [ 'PascalCase' ],
54+
},
55+
{
56+
selector: [ 'typeParameter' ],
57+
format: [ 'PascalCase' ],
58+
prefix: [ 'T' ],
59+
},
60+
{
61+
selector: 'interface',
62+
format: [ 'PascalCase' ],
63+
custom: {
64+
regex: '^I[A-Z]',
65+
match: true,
66+
},
67+
},
68+
{
69+
// Allow UPPER_CASE for static class properties (e.g., namespace constants)
70+
selector: 'classProperty',
71+
modifiers: [ 'static' ],
72+
format: [ 'camelCase', 'UPPER_CASE' ],
73+
leadingUnderscore: 'forbid',
74+
trailingUnderscore: 'forbid',
75+
},
76+
{
77+
// Allow leading underscore for class methods (e.g., _transform, _flush from Node.js Transform API)
78+
selector: 'classMethod',
79+
format: [ 'camelCase' ],
80+
leadingUnderscore: 'allow',
81+
trailingUnderscore: 'forbid',
82+
},
83+
{
84+
// Allow any format for object literal property names (e.g., MIME type keys like 'text/html')
85+
selector: 'objectLiteralProperty',
86+
format: null,
87+
},
88+
],
89+
},
90+
},
91+
]);

lib/IActiveTag.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import * as RDF from "@rdfjs/types";
2-
import {IRdfaPattern} from "./IRdfaPattern";
1+
import type * as RDF from '@rdfjs/types';
2+
import type { IRdfaPattern } from './IRdfaPattern';
33

44
/**
55
* Data holder for the RDFa state in XML tags.
66
*/
77
export interface IActiveTag {
88
name: string;
9-
prefixesAll: {[prefix: string]: string};
10-
prefixesCustom: {[prefix: string]: string};
9+
prefixesAll: Record<string, string>;
10+
prefixesCustom: Record<string, string>;
1111
subject?: RDF.NamedNode | RDF.BlankNode | boolean;
1212
explicitNewSubject?: boolean;
1313
predicates?: RDF.NamedNode[];
@@ -21,10 +21,10 @@ export interface IActiveTag {
2121
collectChildTagsForCurrentTag?: boolean;
2222
collectedPatternTag?: IRdfaPattern;
2323
interpretObjectAsTime?: boolean;
24-
incompleteTriples?: { predicate: RDF.Quad_Predicate, reverse: boolean, list?: boolean }[];
24+
incompleteTriples?: { predicate: RDF.Quad_Predicate; reverse: boolean; list?: boolean }[];
2525
inlist: boolean;
26-
listMapping: {[predicate: string]: (RDF.Term|boolean)[]};
27-
listMappingLocal: {[predicate: string]: (RDF.Term|boolean)[]};
26+
listMapping: Record<string, (RDF.Term | boolean)[]>;
27+
listMappingLocal: Record<string, (RDF.Term | boolean)[]>;
2828
skipElement: boolean;
2929
localBaseIRI?: RDF.NamedNode;
3030
}

lib/IHtmlParseListener.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,23 @@ export interface IHtmlParseListener {
77
* @param {string} name The tag name.
88
* @param {{[p: string]: string}} attributes A hash of attributes.
99
*/
10-
onTagOpen(name: string, attributes: {[s: string]: string}): void;
10+
onTagOpen: (name: string, attributes: Record<string, string>) => void;
1111

1212
/**
1313
* Called when a tag is closed.
1414
*/
15-
onTagClose(): void;
15+
onTagClose: () => void;
1616

1717
/**
1818
* Called when text contents are parsed.
1919
* Note that this can be called multiple times per tag,
2020
* when for example the string is spread over multiple chunks.
2121
* @param {string} data A string.
2222
*/
23-
onText(data: string): void;
23+
onText: (data: string) => void;
2424

2525
/**
2626
* Called when parsing has ended.
2727
*/
28-
onEnd(): void;
28+
onEnd: () => void;
2929
}

lib/IRdfaPattern.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import * as RDF from "@rdfjs/types";
2-
import {IActiveTag} from "./IActiveTag";
1+
import type * as RDF from '@rdfjs/types';
2+
import type { IActiveTag } from './IActiveTag';
33

44
/**
55
* A datastructure for storing an rdfa:Pattern.
66
*/
77
export interface IRdfaPattern {
88
rootPattern: boolean;
99
name: string;
10-
attributes: {[s: string]: string};
10+
attributes: Record<string, string>;
1111
text: string[];
1212
children: IRdfaPattern[];
1313
referenced: boolean;

0 commit comments

Comments
 (0)