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

Adding linting check for core-build-task #28

Merged
merged 8 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"eslint.experimental.useFlatConfig": true,
"eslint.workingDirectories": [
{
"pattern": "./libraries/*/"
},
{
"pattern": "./tools/*/"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "- Adding basic linting to core-build-tasks",
"packageName": "@minecraft/core-build-tasks",
"email": "[email protected]",
"dependentChangeType": "none"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "Enabling prettier check",
"packageName": "@minecraft/math",
"email": "[email protected]",
"dependentChangeType": "none"
}
3 changes: 2 additions & 1 deletion libraries/math/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"@minecraft/core-build-tasks": "*",
"@minecraft/tsconfig": "*",
"just-scripts": "^2.2.1",
"prettier": "^2.8.2",
SBLMikeDemone marked this conversation as resolved.
Show resolved Hide resolved
"vitest": "^0.34.6"
}
}
}
4 changes: 2 additions & 2 deletions libraries/math/src/vector3/coreHelpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,9 @@ describe('Vector3 operations', () => {

it('calculates the lerp halfway between two vectors', () => {
const result: Vector3 = Vector3Utils.lerp(v1, v2, 0.5);
expect(result).toEqual({ x: 2.5, y: 3.5, z: 4.5});
expect(result).toEqual({ x: 2.5, y: 3.5, z: 4.5 });
});

it('calculates the slerp halfway between two vectors', () => {
const vecA: Vector3 = { x: 1, y: 0, z: 0 };
const vecB: Vector3 = { x: 0, y: -1, z: 0 };
Expand Down
11 changes: 5 additions & 6 deletions libraries/math/src/vector3/coreHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export class Vector3Utils {
limits?: {
min?: Partial<Vector3>;
max?: Partial<Vector3>;
},
}
): Vector3 {
return {
x: clampNumber(v.x, limits?.min?.x ?? Number.MIN_SAFE_INTEGER, limits?.max?.x ?? Number.MAX_SAFE_INTEGER),
Expand Down Expand Up @@ -154,10 +154,10 @@ export class Vector3Utils {
*/
static slerp(a: Vector3, b: Vector3, t: number): Vector3 {
const theta = Math.acos(Vector3Utils.dot(a, b));
const sinTheta = Math.sin(theta);
const ta = Math.sin((1.0 - t) * theta) / sinTheta;
const tb = Math.sin(t * theta) / sinTheta;
return Vector3Utils.add(Vector3Utils.scale(a, ta), Vector3Utils.scale(b, tb));
const sinTheta = Math.sin(theta);
const ta = Math.sin((1.0 - t) * theta) / sinTheta;
const tb = Math.sin(t * theta) / sinTheta;
return Vector3Utils.add(Vector3Utils.scale(a, ta), Vector3Utils.scale(b, tb));
}
}

Expand Down Expand Up @@ -279,4 +279,3 @@ export const VECTOR3_NORTH: Vector3 = { x: 0, y: 0, z: 1 };
* @public
*/
export const VECTOR3_SOUTH: Vector3 = { x: 0, y: 0, z: -1 };

2 changes: 1 addition & 1 deletion libraries/math/src/vector3/vectorWrapper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ describe('Vector3Builder', () => {
const resultB = vectorA.lerp(vectorB, ratio);
expect(resultA).toEqual(resultB);
});

it('should be able compute the slerp halfway between two vectors with the same result as the coreHelpers function', () => {
const vectorA = new Vector3Builder(5, 6, 3);
const vectorB = new Vector3Builder(4, 2, 6);
Expand Down
3 changes: 1 addition & 2 deletions libraries/math/src/vector3/vectorWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ export class Vector3Builder implements Vector3 {
return this.assign(Vector3Utils.clamp(this, limits));
}


/**
* lerp
*
Expand All @@ -165,7 +164,7 @@ export class Vector3Builder implements Vector3 {
*
* Constructs a new vector using spherical linear interpolation on each component from two vectors.
*/
slerp(vec: Vector3, t: number): this {
slerp(vec: Vector3, t: number): this {
return this.assign(Vector3Utils.slerp(this, vec, t));
}
}
Expand Down
211 changes: 153 additions & 58 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion prettier.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
arrowParens: 'avoid',
bracketSpacing: true,
endOfLine: 'crlf',
SBLMikeDemone marked this conversation as resolved.
Show resolved Hide resolved
endOfLine: 'auto',
printWidth: 120,
singleQuote: true,
tabWidth: 4,
Expand Down
21 changes: 21 additions & 0 deletions tools/core-build-tasks/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import globals from 'globals';
import tsParser from '@typescript-eslint/parser';

export default [
{
files: ['**/*.{ts,tsx,js,jsx}', '*.ts'],
languageOptions: {
parser: tsParser,
parserOptions: {
ecmaVersion: 'latest',
project: './tsconfig.json',
},
globals: {
...globals.node,
},
},
rules: {
eqeqeq: ['error', 'always'],
},
},
];
Loading