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

refactor(vdb): use eslint over tslint #25

Merged
merged 1 commit into from
Jan 24, 2020
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
],
"rules": {
"@typescript-eslint/explicit-member-accessibility": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-parameter-properties": "off",
"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
"@typescript-eslint/no-use-before-define": "off",
"@nrwl/nx/enforce-module-boundaries": [
"error",
{
Expand Down
4 changes: 3 additions & 1 deletion angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,10 @@
"schematics": {},
"architect": {
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"builder": "@nrwl/linter:lint",
"options": {
"linter": "eslint",
"config": "libs/vdb/.eslintrc",
"tsConfig": ["libs/vdb/tsconfig.lib.json", "libs/vdb/tsconfig.spec.json"],
"exclude": ["**/node_modules/**", "!libs/vdb/**"]
}
Expand Down
1 change: 1 addition & 0 deletions libs/vdb/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "extends": "../../.eslintrc", "rules": {} }
1 change: 1 addition & 0 deletions libs/vdb/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ module.exports = {
transform: {
'^.+\\.[tj]sx?$': 'ts-jest',
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
};
5 changes: 3 additions & 2 deletions libs/vdb/src/lib/tree/internal-node.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,14 @@ describe('InternalNode', () => {
});

describe('setValueOn()', () => {
const generateRandomInRange = (min, max) => Math.floor(Math.random() * (max - min + 1) + min);
const generateRandomInRange = (min, max): number =>
Math.floor(Math.random() * (max - min + 1) + min);
const generateRandomCoord = (min, max): Coord => [
generateRandomInRange(min, max),
generateRandomInRange(min, max),
generateRandomInRange(min, max),
];
const generateRandomCoords = (length, min, max) => {
const generateRandomCoords = (length, min, max): Coord[][] => {
return Array.from({ length }, () => [generateRandomCoord(min, max)]);
};

Expand Down
15 changes: 9 additions & 6 deletions libs/vdb/src/lib/tree/leaf-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,43 +124,46 @@ export class LeafNode<T> implements HashableNode<T> {
* @brief Return the value of the voxel at the given coordinates.
* @note Used internally by ValueAccessor.
*/
getValueAndCache(xyz: Coord, _: ValueAccessor3<T>): T {
getValueAndCache(xyz: Coord, _accessor: ValueAccessor3<T>): T {
return this.getValue(xyz);
}

probeInternalNode1AndCache(xyz: Coord, _: ValueAccessor3<T>): InternalNode1<T> | undefined {
probeInternalNode1AndCache(
_xyz: Coord,
_accessor: ValueAccessor3<T>,
): InternalNode1<T> | undefined {
throw new Error(`Shouldn't be called on LeafNode`);
}

/**
* @brief Change the value of the voxel at the given coordinates and mark it as active.
* @note Used internally by ValueAccessor.
*/
setValueAndCache(xyz: Coord, value: T, _: ValueAccessor3<T>): void {
setValueAndCache(xyz: Coord, value: T, _accessor: ValueAccessor3<T>): void {
this.setValueOn(xyz, value);
}

/**
* @brief Change the value of the voxel at the given coordinates and mark it as inactive.
* @note Used internally by ValueAccessor.
*/
setValueOffAndCache(xyz: Coord, value: T, _: ValueAccessor3<T>): void {
setValueOffAndCache(xyz: Coord, value: T, _accessor: ValueAccessor3<T>): void {
this.setValueOff(xyz, value);
}

/**
* @brief Return `true` if the voxel at the given coordinates is active.
* @note Used internally by ValueAccessor.
*/
isValueOnAndCache(xyz: Coord, _: ValueAccessor3<T>): boolean {
isValueOnAndCache(xyz: Coord, _accessor: ValueAccessor3<T>): boolean {
return this.isValueOn(xyz);
}

/**
* @brief Set the active state of the voxel at the given coordinates without changing its value.
* @note Used internally by ValueAccessor.
*/
setActiveStateAndCache(xyz: Coord, on: boolean, _: ValueAccessor3<T>): void {
setActiveStateAndCache(xyz: Coord, on: boolean, _accessor: ValueAccessor3<T>): void {
return this.setActiveState(xyz, on);
}

Expand Down
2 changes: 2 additions & 0 deletions libs/vdb/src/lib/util/array.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
export function createDenseArray<T>(length: number, initialValueFactory?: () => T): T[] {
// Creating a dense/packed array, so it has no holes and avoiding it to be sparse.
// Dense: [undefined, 1, 2], sparse: [,,2] -> Chrome displays it as [empty × 2, 2]

// eslint-disable-next-line prefer-spread
const array: T[] = Array.apply(null, Array(length));

if (initialValueFactory) {
Expand Down
4 changes: 0 additions & 4 deletions libs/vdb/tslint.json

This file was deleted.