Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace ESLint with Biome #449

Merged
merged 4 commits into from
Feb 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
10 changes: 8 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Lint & Build Project
name: Check & Build Project

on:
pull_request:
Expand All @@ -23,7 +23,13 @@ jobs:
run: npm i

- name: Run Linter
run: npm run lint
run: npm run lint:fin

- name: Run Formatter
run: npm run format:fin

- name: Run Tests
run: npm run test:fin

- name: Run Typecheck
run: npm run typecheck
Expand Down
2 changes: 1 addition & 1 deletion .swcrc
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
"dynamicImport": false
}
}
}
}
8 changes: 4 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"editor.tabSize": 4,
"files.trimTrailingWhitespace": true,
"files.trimFinalNewlines": true,
"files.insertFinalNewline": true
"editor.tabSize": 4,
"files.trimTrailingWhitespace": true,
"files.trimFinalNewlines": true,
"files.insertFinalNewline": true
}
36 changes: 9 additions & 27 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,15 @@ RuneJS was created with the intention of utilizing JavaScript/TypeScript and Nod
- This defeats the purpose of RuneJS by implementing basic flows that any regular Java-based server would use. Think outside the box and really utilize ES6, TypeScript, Node, and RxJS! :)
2. Additional/outside dependencies
- Sometimes additional dependencies cannot be avoided, but we'd like to avoid them as much as possible. RuneJS intends to be simple and easy for anyone to pick up, without requiring the user to set up any databases or additional third party systems.
- In some cases this is of course unavoidable, as such we'll handle them on a case-by-case basis.
- In some cases this is of course unavoidable, as such we'll handle them on a case-by-case basis.

Ultimately if you're looking to contribute, it's best to check in with us on Discord to see if we're already working on a specific feature or have plans for it already. Add us at **Tyn#0001**

## Code Style

We do have a few coding styles and lint rules we'd like all contributors to adhere to. **Please run the linter via `npm run lint` before submitting any Pull Requests**:

- 4 space indentation
- Spaces between TS/ES6 import/export braces
- `import { this } from 'that';` instead of `import {this} from 'that';`
- Semicolon line endings
- `let myVariable = true;` instead of only `let myVariable = true`
- Single quotes instead of double quotes
- `let myString = 'hello world!';` instead of `let myString = "hello world";`
- `import { this } from 'that';` instead of `import { this } from "that";`
- Avoid the `var` keyword
- `let myVariable;` instead of `var myVariable;`
- Prefer `const` to `let`
- If a variable is never going to be modified, please declare it using `const` instead of `let`
- `const neverChanged = true;` instead of `let neverChanged = true;`
- Add types to all method parameters and return types to all methods
- `public myMethod(firstParam: string, secondParam: number): void {` instead of `public myMethod(firstParam, secondParam) {`
- Add `public`, `private`, or `protected` to every class variable or method
- `public myMethod(): void {` instead of `myMethod(): void {`
- `private myVar: number;` instead of `myVar: number;`
- Use TypeScript getters/setters instead of specific getter/setter methods
- `public get myVar(): number` instead of `public getMyVar(): number`
- `public set myVar(myVar: number)` instead of `public setMyVar(myVar: number)`
Code style (linting and formatting) are handled by [Biome](https://biomejs.dev/). It is recommended that you install [the Biome extension for your IDE](https://biomejs.dev/guides/editors/first-party-extensions/).

Running `npm run fin` will perform all necessary checks (linting, formatting, typechecking and tests).

## Testing

Expand Down Expand Up @@ -75,4 +55,6 @@ describe('when there is a player', () => {
There are two main benefits to this kind of design:

- It serves as living documentation: from reading the `beforeEach` block you can clearly see how the prerequisite of "player is wearing a hat" is achieved
- It allows for easy expansion of test cases: future developers can add further statements inside "when player is wearing a hat" if they want to make use of that setup
- It allows for easy expansion of test cases: future developers can add further
statements inside "when player is wearing a hat" if they want to make use of
that setup
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,8 @@ Before running these commands, you must:
* `npm run standalone` Launches all three servers concurrently without building
* `npm run build:watch` Builds the application and watches for changes
* `npm run build` Builds the application
* `npm run lint` Runs the linter against the codebase to look for code style issues
* `npm run lint` Runs Biome in linting mode, use `lint:fix` to autofix
* `npm run format` Runs Biome in formatting mode, use `format:fix` to autofix
* `npm run test` Runs all tests with Jest
* `npm run typecheck` Typechecks the project
* `npm run fin` Combines lint:fix, format:fix, test and typecheck into a single command
78 changes: 78 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"ignoreUnknown": false,
"ignore": []
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 4,
"lineWidth": 140
},
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"complexity": {
"recommended": true,
"noBannedTypes": "off",
"noForEach": "off",
"noStaticOnlyClass": "off",
"noUselessConstructor": "off",
"noUselessSwitchCase": "off",
"useLiteralKeys": "off",
"useOptionalChain": "off"
},
"correctness": {
"recommended": true,
"noSwitchDeclarations": "off"
},
"performance": {
"recommended": true,
"noAccumulatingSpread": "off",
"noDelete": "off"
},
"suspicious": {
"recommended": true,
"noAssignInExpressions": "off",
"noConfusingVoidType": "off",
"noDoubleEquals": "off",
"noDuplicateObjectKeys": "off",
"noExplicitAny": "off",
"noGlobalIsNan": "off",
"noImplicitAnyLet": "off",
"noSelfCompare": "off",
"noUnsafeDeclarationMerging": "off"
},
"style": {
"recommended": true,
"noInferrableTypes": "off",
"noNonNullAssertion": "off",
"noParameterAssign": "off",
"noUnusedTemplateLiteral": "off",
"noUselessElse": "off",
"useEnumInitializers": "off",
"useImportType": "off",
"useNodejsImportProtocol": "off",
"useNumberNamespace": "off",
"useSingleVarDeclarator": "off",
"useTemplate": "off"
}
}
},
"javascript": {
"formatter": {
"quoteStyle": "single",
"arrowParentheses": "asNeeded"
}
}
}
2 changes: 1 addition & 1 deletion data/config/items/barrows/dharoks.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"rs:dharoks_axe" : {
"rs:dharoks_axe": {
"tradable": true,
"equippable": true,
"equipment_data": {
Expand Down
2 changes: 1 addition & 1 deletion data/config/items/currency.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"game_id": 995,
"tradable": true
}
}
}
104 changes: 52 additions & 52 deletions data/config/items/equipment/amulets.json
Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@
{
"rs:amulet_of_glory": {
"game_id": 1704,
"examine": "A very powerful dragonstone amulet.",
"tradable": true,
"weight": 0.01,
"equippable": true,
"equipment_data": {
"equipment_slot": "neck",
"offensive_bonuses": {
"stab": 10,
"slash": 10,
"crush": 10,
"magic": 10,
"ranged": 10
},
"defensive_bonuses": {
"stab": 3,
"slash": 3,
"crush": 3,
"magic": 3,
"ranged": 3
},
"skill_bonuses": {
"prayer": 3,
"strength": 6,
"ranged": 0,
"magic": 0
}
},
"variations": [
{
"game_id": 1706,
"examine": "A dragonstone amulet with 1 magic charge.",
"suffix": "charged_1"
},
{
"game_id": 1708,
"examine": "A dragonstone amulet with 2 magic charges.",
"suffix": "charged_2"
},
{
"game_id": 1710,
"examine": "A dragonstone amulet with 3 magic charges.",
"suffix": "charged_3"
},
{
"game_id": 1712,
"examine": "A dragonstone amulet with 4 magic charges.",
"suffix": "charged_4"
}
]
}
"rs:amulet_of_glory": {
"game_id": 1704,
"examine": "A very powerful dragonstone amulet.",
"tradable": true,
"weight": 0.01,
"equippable": true,
"equipment_data": {
"equipment_slot": "neck",
"offensive_bonuses": {
"stab": 10,
"slash": 10,
"crush": 10,
"magic": 10,
"ranged": 10
},
"defensive_bonuses": {
"stab": 3,
"slash": 3,
"crush": 3,
"magic": 3,
"ranged": 3
},
"skill_bonuses": {
"prayer": 3,
"strength": 6,
"ranged": 0,
"magic": 0
}
},
"variations": [
{
"game_id": 1706,
"examine": "A dragonstone amulet with 1 magic charge.",
"suffix": "charged_1"
},
{
"game_id": 1708,
"examine": "A dragonstone amulet with 2 magic charges.",
"suffix": "charged_2"
},
{
"game_id": 1710,
"examine": "A dragonstone amulet with 3 magic charges.",
"suffix": "charged_3"
},
{
"game_id": 1712,
"examine": "A dragonstone amulet with 4 magic charges.",
"suffix": "charged_4"
}
]
}
}
6 changes: 2 additions & 4 deletions data/config/items/equipment/halberd.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"style": "halberd"
}
}

},
"rs:steel_halberd": {
"game_id": 3194,
Expand Down Expand Up @@ -261,8 +260,7 @@
},
"weapon_info": {
"style": "halberd"
}

}
}
}
}
}
Loading