From 147d4801f7ab8a96870ad6c968322e22f590fee1 Mon Sep 17 00:00:00 2001 From: stirante Date: Tue, 27 Feb 2024 14:57:56 +0100 Subject: [PATCH] Add eslint --- .eslintrc.json | 29 +++++++++++++++++++++++++++++ package.json | 6 +++++- src/Vec3.test.ts | 2 +- src/scheduling/PulseScheduler.ts | 2 +- 4 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 .eslintrc.json diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..33a0ac4 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,29 @@ +{ + "root": true, + "extends": [ + "eslint:recommended", + "plugin:@typescript-eslint/recommended" + ], + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": "latest", + "sourceType": "module", + "project": "./tsconfig.json" + }, + "plugins": [ + "@typescript-eslint", + "minecraft-linting" + ], + "overrides": [ + { + "files": [ + "*.ts" + ] + } + ], + "rules": { + "minecraft-linting/avoid-unnecessary-command": "error" + // "prefer-const": "warn", + // "@typescript-eslint/no-explicit-any": "off" + } +} \ No newline at end of file diff --git a/package.json b/package.json index add7120..1b8ff5b 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,11 @@ "@types/jest": "^29.5.6", "jest": "^29.7.0", "ts-jest": "^29.1.1", - "tsup": "^7.2.0" + "tsup": "^7.2.0", + "@typescript-eslint/eslint-plugin": "^7.1.0", + "@typescript-eslint/parser": "^7.1.0", + "eslint": "^8.57.0", + "eslint-plugin-minecraft-linting": "^1.1.0" }, "dependencies": { "@minecraft/server": "beta", diff --git a/src/Vec3.test.ts b/src/Vec3.test.ts index 168f711..3b1d158 100644 --- a/src/Vec3.test.ts +++ b/src/Vec3.test.ts @@ -1,4 +1,4 @@ -import { LogLevel, Logger } from './Logging'; +/* eslint-disable @typescript-eslint/no-explicit-any */ import Vec3 from './Vec3'; import { Direction } from '@minecraft/server'; diff --git a/src/scheduling/PulseScheduler.ts b/src/scheduling/PulseScheduler.ts index 9e71f34..d105287 100644 --- a/src/scheduling/PulseScheduler.ts +++ b/src/scheduling/PulseScheduler.ts @@ -125,7 +125,7 @@ export default class PulseScheduler { return; } // Number of items to process this tick - let scheduledExecutions = this.executionSchedule[this.currentTick]; + const scheduledExecutions = this.executionSchedule[this.currentTick]; if (scheduledExecutions === 0) { log.debug("No items to process this tick."); // Increment the tick counter