Skip to content

Commit

Permalink
add eslint and configure for CI
Browse files Browse the repository at this point in the history
  • Loading branch information
ForestOfLight committed Jan 25, 2025
1 parent 3c06af7 commit 53fceb2
Show file tree
Hide file tree
Showing 8 changed files with 1,145 additions and 41 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ jobs:
- name: Install dependencies
run: npm install

- name: Run ESLint
run: npm run lint

- name: Run tests with coverage
run: npm test

Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.DS_Store
node_modules/
node_modules/
coverage/
4 changes: 3 additions & 1 deletion Canopy [BP]/scripts/include/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ class Utils {
let data = item.typeId.replace('minecraft:','');
if (items[data]) items[data] += item.amount;
else items[data] = item.amount;
} catch {}
} catch {
continue;
}
}

return items;
Expand Down
2 changes: 1 addition & 1 deletion Canopy [BP]/scripts/src/commands/help.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Commands, Rule, InfoDisplayRule, Extensions } from 'lib/canopy/Canopy';
import { Commands, Command, Rule, InfoDisplayRule, Extensions } from 'lib/canopy/Canopy';
import { HelpBook, CommandHelpPage, RuleHelpPage, InfoDisplayRuleHelpPage } from 'lib/canopy/Canopy';

const COMMANDS_PER_PAGE = 8;
Expand Down
4 changes: 3 additions & 1 deletion Canopy [BP]/scripts/src/rules/instantTame.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ world.beforeEvents.playerInteractWithEntity.subscribe(async (event) => {
system.run(() => {
try {
tameable.tame(event.player);
} catch {} // was already tamed
} catch {
// was already tamed
}
});
}
});
Expand Down
31 changes: 31 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import js from '@eslint/js'
import globals from 'globals'

import { includeIgnoreFile } from "@eslint/compat";
import path from "node:path";
import { fileURLToPath } from "node:url";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const gitignorePath = path.resolve(__dirname, ".gitignore");

/** @type {import('eslint').Linter.Config[]} */
export default [
{
ignores: [
'**/scripts/lib/mt.js',
'**/scripts/lib/ipc/',
'**/scripts/lib/SRCItemDatabase.js',
]
},
js.configs.recommended,
{
languageOptions: {
sourceType: "module",
globals: {
...globals.node
}
}
},
includeIgnoreFile(gitignorePath),
];
Loading

0 comments on commit 53fceb2

Please sign in to comment.