Skip to content

Commit 75c0d9f

Browse files
authored
Adding linting check for core-build-task (#28)
* - Adding basic linting to core-build-tasks * Change files * - Dummy change * - Fixing prettier config * - Reverting readme file changes * - Using gitattributes file instead. * - Using endOfLine auto again * - Fixing nit for the task
1 parent 8cf3f6a commit 75c0d9f

15 files changed

+230
-78
lines changed

.vscode/settings.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"eslint.experimental.useFlatConfig": true,
3+
"eslint.workingDirectories": [
4+
{
5+
"pattern": "./libraries/*/"
6+
},
7+
{
8+
"pattern": "./tools/*/"
9+
}
10+
]
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "none",
3+
"comment": "- Adding basic linting to core-build-tasks",
4+
"packageName": "@minecraft/core-build-tasks",
5+
"email": "[email protected]",
6+
"dependentChangeType": "none"
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "none",
3+
"comment": "Enabling prettier check",
4+
"packageName": "@minecraft/math",
5+
"email": "[email protected]",
6+
"dependentChangeType": "none"
7+
}

libraries/math/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"@minecraft/core-build-tasks": "*",
3737
"@minecraft/tsconfig": "*",
3838
"just-scripts": "^2.2.1",
39+
"prettier": "^2.8.2",
3940
"vitest": "^0.34.6"
4041
}
41-
}
42+
}

libraries/math/src/vector3/coreHelpers.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,9 @@ describe('Vector3 operations', () => {
178178

179179
it('calculates the lerp halfway between two vectors', () => {
180180
const result: Vector3 = Vector3Utils.lerp(v1, v2, 0.5);
181-
expect(result).toEqual({ x: 2.5, y: 3.5, z: 4.5});
181+
expect(result).toEqual({ x: 2.5, y: 3.5, z: 4.5 });
182182
});
183-
183+
184184
it('calculates the slerp halfway between two vectors', () => {
185185
const vecA: Vector3 = { x: 1, y: 0, z: 0 };
186186
const vecB: Vector3 = { x: 0, y: -1, z: 0 };

libraries/math/src/vector3/coreHelpers.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export class Vector3Utils {
125125
limits?: {
126126
min?: Partial<Vector3>;
127127
max?: Partial<Vector3>;
128-
},
128+
}
129129
): Vector3 {
130130
return {
131131
x: clampNumber(v.x, limits?.min?.x ?? Number.MIN_SAFE_INTEGER, limits?.max?.x ?? Number.MAX_SAFE_INTEGER),
@@ -154,10 +154,10 @@ export class Vector3Utils {
154154
*/
155155
static slerp(a: Vector3, b: Vector3, t: number): Vector3 {
156156
const theta = Math.acos(Vector3Utils.dot(a, b));
157-
const sinTheta = Math.sin(theta);
158-
const ta = Math.sin((1.0 - t) * theta) / sinTheta;
159-
const tb = Math.sin(t * theta) / sinTheta;
160-
return Vector3Utils.add(Vector3Utils.scale(a, ta), Vector3Utils.scale(b, tb));
157+
const sinTheta = Math.sin(theta);
158+
const ta = Math.sin((1.0 - t) * theta) / sinTheta;
159+
const tb = Math.sin(t * theta) / sinTheta;
160+
return Vector3Utils.add(Vector3Utils.scale(a, ta), Vector3Utils.scale(b, tb));
161161
}
162162
}
163163

@@ -279,4 +279,3 @@ export const VECTOR3_NORTH: Vector3 = { x: 0, y: 0, z: 1 };
279279
* @public
280280
*/
281281
export const VECTOR3_SOUTH: Vector3 = { x: 0, y: 0, z: -1 };
282-

libraries/math/src/vector3/vectorWrapper.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ describe('Vector3Builder', () => {
170170
const resultB = vectorA.lerp(vectorB, ratio);
171171
expect(resultA).toEqual(resultB);
172172
});
173-
173+
174174
it('should be able compute the slerp halfway between two vectors with the same result as the coreHelpers function', () => {
175175
const vectorA = new Vector3Builder(5, 6, 3);
176176
const vectorB = new Vector3Builder(4, 2, 6);

libraries/math/src/vector3/vectorWrapper.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ export class Vector3Builder implements Vector3 {
150150
return this.assign(Vector3Utils.clamp(this, limits));
151151
}
152152

153-
154153
/**
155154
* lerp
156155
*
@@ -165,7 +164,7 @@ export class Vector3Builder implements Vector3 {
165164
*
166165
* Constructs a new vector using spherical linear interpolation on each component from two vectors.
167166
*/
168-
slerp(vec: Vector3, t: number): this {
167+
slerp(vec: Vector3, t: number): this {
169168
return this.assign(Vector3Utils.slerp(this, vec, t));
170169
}
171170
}

package-lock.json

+153-58
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

prettier.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = {
22
arrowParens: 'avoid',
33
bracketSpacing: true,
4-
endOfLine: 'crlf',
4+
endOfLine: 'auto',
55
printWidth: 120,
66
singleQuote: true,
77
tabWidth: 4,
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import globals from 'globals';
2+
import tsParser from '@typescript-eslint/parser';
3+
4+
export default [
5+
{
6+
files: ['**/*.{ts,tsx,js,jsx}', '*.ts'],
7+
languageOptions: {
8+
parser: tsParser,
9+
parserOptions: {
10+
ecmaVersion: 'latest',
11+
project: './tsconfig.json',
12+
},
13+
globals: {
14+
...globals.node,
15+
},
16+
},
17+
rules: {
18+
eqeqeq: ['error', 'always'],
19+
},
20+
},
21+
];

0 commit comments

Comments
 (0)