Skip to content

Commit

Permalink
Fix the warnings of the static analyzer
Browse files Browse the repository at this point in the history
  • Loading branch information
cedx committed Jul 11, 2024
1 parent 1169ffb commit 4c5785a
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 18 deletions.
83 changes: 67 additions & 16 deletions etc/eslint.config.js → etc/eslint.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
import babelParser from "@babel/eslint-parser";
import {join} from "node:path";
import js from "@eslint/js";
import globals from "globals";
import ts from "typescript-eslint";

export default [
export default ts.config(
js.configs.recommended,
...ts.configs.strictTypeChecked,
...ts.configs.stylisticTypeChecked,
{
languageOptions: {
globals: {...globals.nodeBuiltin},
parser: babelParser,
parserOptions: {
requireConfigFile: false,
babelOptions: {
babelrc: false,
configFile: false,
plugins: ["@babel/plugin-syntax-import-attributes"]
}
project: "tsconfig.json",
tsconfigRootDir: join(import.meta.dirname, "..")
}
},
rules: {
Expand All @@ -28,7 +24,7 @@ export default [
"no-template-curly-in-string": "error",
"no-unmodified-loop-condition": "error",
"no-unreachable-loop": "error",
"no-use-before-define": ["error", {functions: false}],
"no-use-before-define": "off",
"no-useless-assignment": "error",
"require-atomic-updates": ["error", {allowProperties: true}],

Expand Down Expand Up @@ -64,7 +60,6 @@ export default [
"max-nested-callbacks": "error",
"max-params": "off",
"max-statements": ["error", {max: 25}],
"multiline-comment-style": ["error", "separate-lines"],
"new-cap": ["error", {capIsNewExceptions: ["RangeError", "SyntaxError", "TypeError"]}],
"no-alert": "error",
"no-array-constructor": "error",
Expand Down Expand Up @@ -155,8 +150,64 @@ export default [
"vars-on-top": "error",
"yoda": "error",

"line-comment-position": "error",
"unicode-bom": "error"
"unicode-bom": "error",

"@typescript-eslint/class-methods-use-this": "off",
"@typescript-eslint/consistent-return": "error",
"@typescript-eslint/consistent-type-exports": "error",
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/default-param-last": "error",
"@typescript-eslint/explicit-function-return-type": ["error", {allowExpressions: true}],
"@typescript-eslint/explicit-member-accessibility": ["error", {accessibility: "no-public"}],
"@typescript-eslint/explicit-module-boundary-types": "error",
"@typescript-eslint/init-declarations": "error",
"@typescript-eslint/max-params": ["error", {max: 4}],
"@typescript-eslint/member-ordering": "error",
"@typescript-eslint/method-signature-style": "error",
"@typescript-eslint/naming-convention": "off",
"@typescript-eslint/no-confusing-void-expression": "off",
"@typescript-eslint/no-dupe-class-members": "error",
"@typescript-eslint/no-empty-object-type": "error",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-import-type-side-effects": "error",
"@typescript-eslint/no-invalid-this": "error",
"@typescript-eslint/no-loop-func": "error",
"@typescript-eslint/no-magic-numbers": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-redeclare": "error",
"@typescript-eslint/no-require-imports": "error",
"@typescript-eslint/no-restricted-imports": "error",
"@typescript-eslint/no-shadow": "error",
"@typescript-eslint/no-unnecessary-parameter-property-assignment": "error",
"@typescript-eslint/no-unnecessary-qualifier": "error",
"@typescript-eslint/no-unnecessary-type-parameters": "error",
"@typescript-eslint/no-unsafe-unary-minus": "error",
"@typescript-eslint/no-unused-expressions": ["error", {allowTaggedTemplates: true, allowTernary: true}],
"@typescript-eslint/no-use-before-define": ["error", {functions: false}],
"@typescript-eslint/no-useless-empty-export": "error",
"@typescript-eslint/parameter-properties": "error",
"@typescript-eslint/prefer-destructuring": "error",
"@typescript-eslint/prefer-enum-initializers": "off",
"@typescript-eslint/prefer-find": "error",
"@typescript-eslint/prefer-readonly": "error",
"@typescript-eslint/prefer-readonly-parameter-types": "off",
"@typescript-eslint/prefer-regexp-exec": "error",
"@typescript-eslint/promise-function-async": "off",
"@typescript-eslint/require-array-sort-compare": "error",
"@typescript-eslint/restrict-template-expressions": "off",
"@typescript-eslint/return-await": "error",
"@typescript-eslint/strict-boolean-expressions": "off",
"@typescript-eslint/switch-exhaustiveness-check": "error",
"@typescript-eslint/typedef": "error"
}
},
{
files: ["gulpfile.js", "test/**/*.js"],
rules: {
"prefer-arrow-callback": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-floating-promises": "off"
}
}
];
);
4 changes: 2 additions & 2 deletions src/usage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ export class Usage {
*/
static fromJson(json: Record<string, any>): Usage {
return new this({
limit: Number.isInteger(json.limit) ? json.limit : -1,
limit: Number.isInteger(json.limit) ? json.limit as number : -1,
percentage: typeof json.percentage == "number" ? json.percentage : 0,
throttled: typeof json.throttled == "boolean" ? json.throttled : false,
usage: Number.isInteger(json.usage) ? json.usage : 0
usage: Number.isInteger(json.usage) ? json.usage as number : 0
});
}
}
Expand Down

0 comments on commit 4c5785a

Please sign in to comment.