Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Commit 5c25589

Browse files
committed
update typescript/lint config and fix issues
1 parent 672af9a commit 5c25589

File tree

3 files changed

+24
-10
lines changed

3 files changed

+24
-10
lines changed

.eslintrc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ module.exports = {
99
'plugin:@typescript-eslint/recommended',
1010
],
1111
rules: {
12+
'@typescript-eslint/ban-ts-comment': 'off',
1213
'@typescript-eslint/no-explicit-any': 'off',
13-
'@typescript-eslint/explicit-module-boundary-types': 'off',
1414
'@typescript-eslint/no-unused-vars': 'off',
1515
'guard-for-in': 'off',
1616
'prefer-rest-params': 'off',

src/Layout.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,8 @@ export function nameWithProperty(name: string, lo: { property?: string }): strin
373373
* @param {Layout} layout - the {@link Layout} instance used to encode
374374
* instances of `Class`.
375375
*/
376+
// `Class` must be a constructor Function, but the assignment of a `layout_` property to it makes it difficult to type
377+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
376378
export function bindConstructorLayout<T>(Class: any, layout: Layout<T>): void {
377379
if ('function' !== typeof Class) {
378380
throw new TypeError('Class must be constructor');
@@ -1424,6 +1426,8 @@ export class UnionLayoutDiscriminator extends UnionDiscriminator<number> {
14241426
* @augments {Layout}
14251427
*/
14261428
export class Union extends Layout<LayoutObject> {
1429+
// `property` is assigned in the Layout constructor
1430+
// @ts-ignore
14271431
property: string;
14281432
discriminator: UnionDiscriminator;
14291433
usesPrefixDiscriminator: boolean;
@@ -1644,6 +1648,8 @@ export class Union extends Layout<LayoutObject> {
16441648
}
16451649
dest = this.makeDestinationObject();
16461650
dest[dlo.property] = discr;
1651+
// defaultLayout.property can be undefined, but this is allowed by buffer-layout
1652+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
16471653
dest[defaultLayout!.property!] = defaultLayout!.decode(b, offset + contentOffset);
16481654
} else {
16491655
dest = clo.decode(b, offset);
@@ -1662,13 +1668,15 @@ export class Union extends Layout<LayoutObject> {
16621668
if (undefined === vlo) {
16631669
const dlo = this.discriminator;
16641670
// this.defaultLayout is not undefined when vlo is undefined
1671+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
16651672
const clo = this.defaultLayout!;
16661673
let contentOffset = 0;
16671674
if (this.usesPrefixDiscriminator) {
16681675
contentOffset = (dlo as UnionLayoutDiscriminator).layout.span;
16691676
}
16701677
dlo.encode(src[dlo.property], b, offset);
16711678
// clo.property is not undefined when vlo is undefined
1679+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
16721680
return contentOffset + clo.encode(src[clo.property!], b, offset + contentOffset);
16731681
}
16741682
return vlo.encode(src, b, offset);
@@ -1748,6 +1756,8 @@ export class Union extends Layout<LayoutObject> {
17481756
* @augments {Layout}
17491757
*/
17501758
export class VariantLayout extends Layout<LayoutObject> {
1759+
// `property` is assigned in the Layout constructor
1760+
// @ts-ignore
17511761
property: string;
17521762
union: Union;
17531763
variant: number;
@@ -2029,10 +2039,10 @@ export class BitStructure extends Layout<LayoutObject> {
20292039
* Layout#property|property}.
20302040
*
20312041
* @return {Boolean} */
2042+
// `Boolean` conflicts with the native primitive type
20322043
// eslint-disable-next-line @typescript-eslint/ban-types
20332044
addBoolean(property: string): Boolean {
20342045
// This is my Boolean, not the Javascript one.
2035-
// eslint-disable-next-line no-new-wrappers
20362046
const bf = new Boolean(this, property);
20372047
this.fields.push(bf);
20382048
return bf;

tsconfig.json

+12-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
{
22
"compilerOptions": {
3-
"lib": ["es2020"],
4-
"module": "commonjs",
3+
"outDir": "lib",
54
"declaration": true,
6-
"noImplicitAny": true,
7-
"noImplicitReturns": true,
8-
"noImplicitThis": true,
95
"sourceMap": true,
10-
"strictNullChecks": true,
11-
"outDir": "lib",
6+
"noEmitOnError": true,
7+
"stripInternal": true,
8+
"target": "es6",
9+
"module": "commonjs",
10+
"moduleResolution": "node",
11+
"lib": ["es2020"],
12+
"strict": true,
13+
"esModuleInterop": true,
14+
"resolveJsonModule": true,
15+
"isolatedModules": true
1216
},
1317
"include": ["src"],
14-
"exclude": ["node_modules", "**/*.spec.ts"]
18+
"exclude": ["node_modules"]
1519
}

0 commit comments

Comments
 (0)