Skip to content

Commit cefdcff

Browse files
committed
Enable new rules in typescript-eslint and apply it to the code
1 parent b705abb commit cefdcff

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

.eslintrc.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,34 +35,37 @@ module.exports = {
3535
"import/no-cycle": "error",
3636
"import/no-default-export": "error",
3737

38-
"@typescript-eslint/no-unused-vars": "warn",
38+
"@typescript-eslint/await-thenable": "warn",
3939
"@typescript-eslint/array-type": ["warn", { default: "generic" }],
4040
"@typescript-eslint/camelcase": "warn",
4141
"@typescript-eslint/class-name-casing": "warn", // to allow the initial underscore
42+
"@typescript-eslint/restrict-plus-operands": ["warn", { "checkCompoundAssignments": true }],
4243
"@typescript-eslint/no-non-null-assertion": "warn", // NOTE: pay attention to it because it may cause unexpected behavior
44+
"@typescript-eslint/no-throw-literal": "warn",
45+
"@typescript-eslint/no-extra-semi": "warn",
46+
"@typescript-eslint/no-extra-non-null-assertion": "warn",
47+
"@typescript-eslint/no-unused-vars": "warn",
48+
"@typescript-eslint/no-use-before-define": "warn",
49+
"@typescript-eslint/no-for-in-array": "warn",
50+
"@typescript-eslint/no-unnecessary-condition": ["warn", { "allowConstantLoopConditions": true }],
4351
"@typescript-eslint/prefer-for-of": "warn",
4452
"@typescript-eslint/prefer-includes": "warn",
4553
"@typescript-eslint/prefer-string-starts-ends-with": "warn",
4654
"@typescript-eslint/prefer-readonly": "warn",
4755
"@typescript-eslint/prefer-regexp-exec": "warn",
48-
"@typescript-eslint/no-use-before-define": "warn",
49-
"@typescript-eslint/await-thenable": "warn",
50-
"@typescript-eslint/no-for-in-array": "warn",
5156
"@typescript-eslint/prefer-nullish-coalescing": "warn",
5257
"@typescript-eslint/prefer-optional-chain": "warn",
53-
"@typescript-eslint/no-extra-non-null-assertion": "warn",
54-
"@typescript-eslint/restrict-plus-operands": ["warn", { "checkCompoundAssignments": true } ],
5558

5659
"@typescript-eslint/indent": "off",
57-
"@typescript-eslint/no-explicit-any": "off",
5860
"@typescript-eslint/explicit-function-return-type": "off",
5961
"@typescript-eslint/explicit-member-accessibility": "off",
62+
"@typescript-eslint/no-explicit-any": "off",
6063
"@typescript-eslint/no-object-literal-type-assertion": "off",
6164
"@typescript-eslint/no-empty-interface": "off",
65+
"@typescript-eslint/no-empty-function": "off",
6266
"@typescript-eslint/no-parameter-properties": "off",
6367
"@typescript-eslint/no-var-requires": "off", // enforces `import x = require("x")`, which is TypeScript-specific
6468
"@typescript-eslint/prefer-interface": "off",
65-
"@typescript-eslint/no-empty-function": "off",
6669

6770
"prettier/prettier": "warn",
6871
},

src/Decoder.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,9 @@ export class Decoder {
388388
state.key = object;
389389
state.type = State.MAP_VALUE;
390390
continue DECODE;
391-
} else if (state.type === State.MAP_VALUE) {
391+
} else {
392+
// it must be `state.type === State.MAP_VALUE` here
393+
392394
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
393395
state.map[state.key!] = object;
394396
state.readCount++;

src/ExtensionCodec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ export class ExtensionCodec implements ExtensionCodecType {
1717
public static readonly defaultCodec: ExtensionCodecType = new ExtensionCodec();
1818

1919
// built-in extensions
20-
private readonly builtInEncoders: Array<ExtensionEncoderType> = [];
21-
private readonly builtInDecoders: Array<ExtensionDecoderType> = [];
20+
private readonly builtInEncoders: Array<ExtensionEncoderType | undefined | null> = [];
21+
private readonly builtInDecoders: Array<ExtensionDecoderType | undefined | null> = [];
2222

2323
// custom extensions
24-
private readonly encoders: Array<ExtensionEncoderType> = [];
25-
private readonly decoders: Array<ExtensionDecoderType> = [];
24+
private readonly encoders: Array<ExtensionEncoderType | undefined | null> = [];
25+
private readonly decoders: Array<ExtensionDecoderType | undefined | null> = [];
2626

2727
public constructor() {
2828
this.register(timestampExtension);

0 commit comments

Comments
 (0)