about summary refs log tree commit diff
path: root/users
diff options
context:
space:
mode:
authorProfpatsch <mail@profpatsch.de>2024-10-01T01·54+0200
committerProfpatsch <mail@profpatsch.de>2024-10-05T13·49+0000
commitad711b15a06be8c3f6146f14454621f4a56997ba (patch)
tree152478301796624f72d976faee435bfe2c7347f9 /users
parent102c9b30a7ca3b41b0cfcd48f52bdf6c06f259ff (diff)
chore(users/Profpatsch/lyric): add typescript linting rules r/8766
Change-Id: I9ab0336450519648f7a8edeec94bd64b78e2f05b
Reviewed-on: https://cl.tvl.fyi/c/depot/+/12554
Tested-by: BuildkiteCI
Reviewed-by: Profpatsch <mail@profpatsch.de>
Diffstat (limited to 'users')
-rw-r--r--users/Profpatsch/lyric/eslint.config.mjs91
-rw-r--r--users/Profpatsch/lyric/extension/eslint.config.mjs91
-rw-r--r--users/Profpatsch/lyric/extension/src/extension.ts2
-rw-r--r--users/Profpatsch/lyric/src/index.ts14
-rw-r--r--users/Profpatsch/lyric/src/tap-bpm.ts29
-rw-r--r--users/Profpatsch/lyric/tsconfig.json2
6 files changed, 140 insertions, 89 deletions
diff --git a/users/Profpatsch/lyric/eslint.config.mjs b/users/Profpatsch/lyric/eslint.config.mjs
index 189efbd9be4c..1bb60bf639d6 100644
--- a/users/Profpatsch/lyric/eslint.config.mjs
+++ b/users/Profpatsch/lyric/eslint.config.mjs
@@ -1,6 +1,6 @@
-import tseslint from "typescript-eslint";
-import tsplugin from "@typescript-eslint/eslint-plugin";
-import parser from "@typescript-eslint/parser";
+import tseslint from 'typescript-eslint';
+import tsplugin from '@typescript-eslint/eslint-plugin';
+import parser from '@typescript-eslint/parser';
 
 export default tseslint.config(tseslint.configs.eslintRecommended, {
   languageOptions: {
@@ -9,34 +9,63 @@ export default tseslint.config(tseslint.configs.eslintRecommended, {
       projectService: true,
     },
   },
-  ignores: ["node_modules/", "eslint.config.mjs"],
-  plugins: { "@typescript-eslint": tsplugin },
+  ignores: ['node_modules/', 'eslint.config.mjs'],
+  plugins: { '@typescript-eslint': tsplugin },
   rules: {
-    "prettier/prettier": "off",
-    "prefer-const": "warn",
-    "@typescript-eslint/ban-ts-comment": "warn",
-    "no-array-constructor": "off",
-    "@typescript-eslint/no-array-constructor": "warn",
-    "@typescript-eslint/no-duplicate-enum-values": "warn",
-    "@typescript-eslint/no-empty-object-type": "warn",
-    "@typescript-eslint/no-explicit-any": "warn",
-    "@typescript-eslint/no-extra-non-null-assertion": "warn",
-    "@typescript-eslint/no-misused-new": "warn",
-    "@typescript-eslint/no-namespace": "warn",
-    "@typescript-eslint/no-non-null-asserted-optional-chain": "warn",
-    "@typescript-eslint/no-require-imports": "warn",
-    "@typescript-eslint/no-this-alias": "warn",
-    "@typescript-eslint/no-unnecessary-type-constraint": "warn",
-    "@typescript-eslint/no-unsafe-declaration-merging": "warn",
-    "@typescript-eslint/no-unsafe-function-type": "warn",
-    "@typescript-eslint/strict-boolean-expressions": ["warn"],
-    "no-unused-expressions": "off",
-    "@typescript-eslint/no-unused-expressions": "warn",
-    "no-unused-vars": "off",
-    "@typescript-eslint/no-unused-vars": "warn",
-    "@typescript-eslint/no-wrapper-object-types": "warn",
-    "@typescript-eslint/prefer-as-const": "warn",
-    "@typescript-eslint/prefer-namespace-keyword": "warn",
-    "@typescript-eslint/triple-slash-reference": "warn",
+    'prettier/prettier': 'off',
+    'prefer-const': 'warn',
+    '@typescript-eslint/ban-ts-comment': 'warn',
+    'no-array-constructor': 'off',
+    '@typescript-eslint/no-array-constructor': 'warn',
+    '@typescript-eslint/no-duplicate-enum-values': 'warn',
+    '@typescript-eslint/no-empty-object-type': 'warn',
+    '@typescript-eslint/no-explicit-any': 'warn',
+    '@typescript-eslint/no-extra-non-null-assertion': 'warn',
+    '@typescript-eslint/no-misused-new': 'warn',
+    '@typescript-eslint/no-namespace': 'warn',
+    '@typescript-eslint/no-non-null-asserted-optional-chain': 'warn',
+    '@typescript-eslint/no-require-imports': 'warn',
+    '@typescript-eslint/no-this-alias': 'warn',
+    '@typescript-eslint/no-unnecessary-type-constraint': 'warn',
+    '@typescript-eslint/no-unsafe-declaration-merging': 'warn',
+    '@typescript-eslint/no-unsafe-function-type': 'warn',
+    '@typescript-eslint/strict-boolean-expressions': ['warn'],
+    'no-unused-expressions': 'off',
+    '@typescript-eslint/no-unused-expressions': 'warn',
+    'no-unused-vars': 'off',
+    '@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
+    '@typescript-eslint/no-wrapper-object-types': 'warn',
+    '@typescript-eslint/prefer-as-const': 'warn',
+    '@typescript-eslint/prefer-namespace-keyword': 'warn',
+    '@typescript-eslint/triple-slash-reference': 'warn',
+
+    '@typescript-eslint/await-thenable': 'warn',
+    'no-array-constructor': 'off',
+    '@typescript-eslint/no-array-delete': 'warn',
+    '@typescript-eslint/no-base-to-string': 'warn',
+    '@typescript-eslint/no-duplicate-type-constituents': 'warn',
+    '@typescript-eslint/no-floating-promises': 'warn',
+    '@typescript-eslint/no-for-in-array': 'warn',
+    'no-implied-eval': 'off',
+    '@typescript-eslint/no-implied-eval': 'warn',
+    '@typescript-eslint/no-misused-promises': 'warn',
+    '@typescript-eslint/no-redundant-type-constituents': 'warn',
+    '@typescript-eslint/no-unnecessary-type-assertion': 'warn',
+    '@typescript-eslint/no-unsafe-argument': 'warn',
+    '@typescript-eslint/no-unsafe-assignment': 'warn',
+    '@typescript-eslint/no-unsafe-call': 'warn',
+    '@typescript-eslint/no-unsafe-enum-comparison': 'warn',
+    '@typescript-eslint/no-unsafe-member-access': 'warn',
+    '@typescript-eslint/no-unsafe-return': 'warn',
+    '@typescript-eslint/no-unsafe-unary-minus': 'warn',
+    'no-throw-literal': 'off',
+    '@typescript-eslint/only-throw-error': 'warn',
+    'prefer-promise-reject-errors': 'off',
+    '@typescript-eslint/prefer-promise-reject-errors': 'warn',
+    'require-await': 'off',
+    '@typescript-eslint/require-await': 'warn',
+    '@typescript-eslint/restrict-plus-operands': 'warn',
+    '@typescript-eslint/restrict-template-expressions': 'warn',
+    '@typescript-eslint/unbound-method': 'warn',
   },
 });
diff --git a/users/Profpatsch/lyric/extension/eslint.config.mjs b/users/Profpatsch/lyric/extension/eslint.config.mjs
index 996dd8ca58ee..1bb60bf639d6 100644
--- a/users/Profpatsch/lyric/extension/eslint.config.mjs
+++ b/users/Profpatsch/lyric/extension/eslint.config.mjs
@@ -1,6 +1,6 @@
-import tseslint from "typescript-eslint";
-import tsplugin from "@typescript-eslint/eslint-plugin";
-import parser from "@typescript-eslint/parser";
+import tseslint from 'typescript-eslint';
+import tsplugin from '@typescript-eslint/eslint-plugin';
+import parser from '@typescript-eslint/parser';
 
 export default tseslint.config(tseslint.configs.eslintRecommended, {
   languageOptions: {
@@ -9,34 +9,63 @@ export default tseslint.config(tseslint.configs.eslintRecommended, {
       projectService: true,
     },
   },
-  ignores: ["node_modules/", "eslint.config.mjs"],
-  plugins: { "@typescript-eslint": tsplugin },
+  ignores: ['node_modules/', 'eslint.config.mjs'],
+  plugins: { '@typescript-eslint': tsplugin },
   rules: {
-    "prettier/prettier": "off",
-    "prefer-const": "warn",
-    "@typescript-eslint/ban-ts-comment": "warn",
-    "no-array-constructor": "off",
-    "@typescript-eslint/no-array-constructor": "warn",
-    "@typescript-eslint/no-duplicate-enum-values": "warn",
-    "@typescript-eslint/no-empty-object-type": "warn",
-    "@typescript-eslint/no-explicit-any": "warn",
-    "@typescript-eslint/no-extra-non-null-assertion": "warn",
-    "@typescript-eslint/no-misused-new": "warn",
-    "@typescript-eslint/no-namespace": "warn",
-    "@typescript-eslint/no-non-null-asserted-optional-chain": "warn",
-    "@typescript-eslint/no-require-imports": "warn",
-    "@typescript-eslint/no-this-alias": "warn",
-    "@typescript-eslint/no-unnecessary-type-constraint": "warn",
-    "@typescript-eslint/no-unsafe-declaration-merging": "warn",
-    "@typescript-eslint/no-unsafe-function-type": "warn",
-    "@typescript-eslint/strict-boolean-expressions": ["warn"],
-    "no-unused-expressions": "off",
-    "@typescript-eslint/no-unused-expressions": "warn",
-    "no-unused-vars": "off",
-    "@typescript-eslint/no-unused-vars": ["warn", { argsIgnorePattern: "^_" }],
-    "@typescript-eslint/no-wrapper-object-types": "warn",
-    "@typescript-eslint/prefer-as-const": "warn",
-    "@typescript-eslint/prefer-namespace-keyword": "warn",
-    "@typescript-eslint/triple-slash-reference": "warn",
+    'prettier/prettier': 'off',
+    'prefer-const': 'warn',
+    '@typescript-eslint/ban-ts-comment': 'warn',
+    'no-array-constructor': 'off',
+    '@typescript-eslint/no-array-constructor': 'warn',
+    '@typescript-eslint/no-duplicate-enum-values': 'warn',
+    '@typescript-eslint/no-empty-object-type': 'warn',
+    '@typescript-eslint/no-explicit-any': 'warn',
+    '@typescript-eslint/no-extra-non-null-assertion': 'warn',
+    '@typescript-eslint/no-misused-new': 'warn',
+    '@typescript-eslint/no-namespace': 'warn',
+    '@typescript-eslint/no-non-null-asserted-optional-chain': 'warn',
+    '@typescript-eslint/no-require-imports': 'warn',
+    '@typescript-eslint/no-this-alias': 'warn',
+    '@typescript-eslint/no-unnecessary-type-constraint': 'warn',
+    '@typescript-eslint/no-unsafe-declaration-merging': 'warn',
+    '@typescript-eslint/no-unsafe-function-type': 'warn',
+    '@typescript-eslint/strict-boolean-expressions': ['warn'],
+    'no-unused-expressions': 'off',
+    '@typescript-eslint/no-unused-expressions': 'warn',
+    'no-unused-vars': 'off',
+    '@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
+    '@typescript-eslint/no-wrapper-object-types': 'warn',
+    '@typescript-eslint/prefer-as-const': 'warn',
+    '@typescript-eslint/prefer-namespace-keyword': 'warn',
+    '@typescript-eslint/triple-slash-reference': 'warn',
+
+    '@typescript-eslint/await-thenable': 'warn',
+    'no-array-constructor': 'off',
+    '@typescript-eslint/no-array-delete': 'warn',
+    '@typescript-eslint/no-base-to-string': 'warn',
+    '@typescript-eslint/no-duplicate-type-constituents': 'warn',
+    '@typescript-eslint/no-floating-promises': 'warn',
+    '@typescript-eslint/no-for-in-array': 'warn',
+    'no-implied-eval': 'off',
+    '@typescript-eslint/no-implied-eval': 'warn',
+    '@typescript-eslint/no-misused-promises': 'warn',
+    '@typescript-eslint/no-redundant-type-constituents': 'warn',
+    '@typescript-eslint/no-unnecessary-type-assertion': 'warn',
+    '@typescript-eslint/no-unsafe-argument': 'warn',
+    '@typescript-eslint/no-unsafe-assignment': 'warn',
+    '@typescript-eslint/no-unsafe-call': 'warn',
+    '@typescript-eslint/no-unsafe-enum-comparison': 'warn',
+    '@typescript-eslint/no-unsafe-member-access': 'warn',
+    '@typescript-eslint/no-unsafe-return': 'warn',
+    '@typescript-eslint/no-unsafe-unary-minus': 'warn',
+    'no-throw-literal': 'off',
+    '@typescript-eslint/only-throw-error': 'warn',
+    'prefer-promise-reject-errors': 'off',
+    '@typescript-eslint/prefer-promise-reject-errors': 'warn',
+    'require-await': 'off',
+    '@typescript-eslint/require-await': 'warn',
+    '@typescript-eslint/restrict-plus-operands': 'warn',
+    '@typescript-eslint/restrict-template-expressions': 'warn',
+    '@typescript-eslint/unbound-method': 'warn',
   },
 });
diff --git a/users/Profpatsch/lyric/extension/src/extension.ts b/users/Profpatsch/lyric/extension/src/extension.ts
index 1272b3c1b80d..a895bd57bf2a 100644
--- a/users/Profpatsch/lyric/extension/src/extension.ts
+++ b/users/Profpatsch/lyric/extension/src/extension.ts
@@ -416,7 +416,7 @@ class Ext {
     if (!match) {
       return;
     }
-    const [, timestamp, text] = match!;
+    const [, timestamp, text] = match;
     const milliseconds = parseTimestamp(timestamp);
     const seconds = milliseconds / 1000;
     return { milliseconds, seconds, text };
diff --git a/users/Profpatsch/lyric/src/index.ts b/users/Profpatsch/lyric/src/index.ts
index 6bab1c4590cd..9501fa57b347 100644
--- a/users/Profpatsch/lyric/src/index.ts
+++ b/users/Profpatsch/lyric/src/index.ts
@@ -1,16 +1,16 @@
-import { tapBpm } from "./tap-bpm.js";
+import { tapBpm } from './tap-bpm.js';
 
-async function main() {
+function main() {
   // subcommand for tap-bpm
-  if (process.argv[2] === "tap-bpm") {
-    await tapBpm();
+  if (process.argv[2] === 'tap-bpm') {
+    tapBpm();
   }
 }
 
-await main();
+main();
 
 // sleep in a loop to block nodejs
-console.log("Blocking event loop...");
+console.log('Blocking event loop...');
 while (true) {
-  await new Promise((resolve) => setTimeout(resolve, 1000));
+  await new Promise(resolve => setTimeout(resolve, 1000));
 }
diff --git a/users/Profpatsch/lyric/src/tap-bpm.ts b/users/Profpatsch/lyric/src/tap-bpm.ts
index 2062fb8bbca7..b3c727df5608 100644
--- a/users/Profpatsch/lyric/src/tap-bpm.ts
+++ b/users/Profpatsch/lyric/src/tap-bpm.ts
@@ -1,7 +1,7 @@
 // create a node command line listener that allows the user to press any key , and averages the distances between the key presses to determine the BPM (with a window of 4 key presses). If the user presses q, the program should exit and print the final BPM.
 
 // Import the necessary modules
-import * as readline from "readline";
+import * as readline from 'readline';
 
 export function tapBpm() {
   // Set up readline interface to listen for keypresses
@@ -19,35 +19,28 @@ export function tapBpm() {
       return 0;
     }
     const averageTimeDiff =
-      timeDifferences.reduce((acc, curr) => acc + curr, 0) /
-      timeDifferences.length;
+      timeDifferences.reduce((acc, curr) => acc + curr, 0) / timeDifferences.length;
     return (60 * 1000) / averageTimeDiff;
   }
 
   // Handle the SIGINT (Ctrl+C) event manually
-  process.on("SIGINT", () => {
-    console.log(
-      "\nExiting via SIGINT (Ctrl+C)... Final BPM:",
-      calculateBPM().toFixed(2)
-    );
+  process.on('SIGINT', () => {
+    console.log('\nExiting via SIGINT (Ctrl+C)... Final BPM:', calculateBPM().toFixed(2));
     process.exit();
   });
 
   // Listen for keypress events
-  process.stdin.on("keypress", (str, key) => {
+  process.stdin.on('keypress', (str, key: { name: string; sequence: string }) => {
     // Exit if 'q' is pressed
-    if (key.name === "q") {
-      console.log("Exiting... Final BPM:", calculateBPM().toFixed(2));
+    if (key.name === 'q') {
+      console.log('Exiting... Final BPM:', calculateBPM().toFixed(2));
       process.exit();
     }
 
     // Handle Ctrl+C (SIGINT)
-    if (key.sequence === "\u0003") {
+    if (key.sequence === '\u0003') {
       // '\u0003' is the raw code for Ctrl+C
-      console.log(
-        "\nExiting via Ctrl+C... Final BPM:",
-        calculateBPM().toFixed(2)
-      );
+      console.log('\nExiting via Ctrl+C... Final BPM:', calculateBPM().toFixed(2));
       process.exit();
     }
 
@@ -66,9 +59,9 @@ export function tapBpm() {
 
       // Calculate and display the BPM
       const bpm = calculateBPM();
-      console.log("Current BPM:", bpm.toFixed(2));
+      console.log('Current BPM:', bpm.toFixed(2));
     } else {
-      console.log("Waiting for more key presses to calculate BPM...");
+      console.log('Waiting for more key presses to calculate BPM...');
     }
 
     // Update the lastPressTime to the current time
diff --git a/users/Profpatsch/lyric/tsconfig.json b/users/Profpatsch/lyric/tsconfig.json
index f3c47a381e20..26a6a0a82db6 100644
--- a/users/Profpatsch/lyric/tsconfig.json
+++ b/users/Profpatsch/lyric/tsconfig.json
@@ -9,7 +9,7 @@
         "esModuleInterop": true
     },
     "include": [
-        "src/**/*.ts"
+        "src/**/*.ts",
     ],
     "exclude": [
         "node_modules"