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

[WIP] Type fixes #457

Merged
merged 24 commits into from
Nov 4, 2024
Merged

[WIP] Type fixes #457

merged 24 commits into from
Nov 4, 2024

Conversation

funwithtriangles
Copy link
Member

@funwithtriangles funwithtriangles commented Oct 13, 2024

Went through and fixed a bunch of TS issues and linting. The biggest change is forcing imports to always be using aliases. You can never use relative imports. So basically an import always has to start with @renderer, @main, @engine, @components, etc. We can add more aliases as we go.

@cale-bradbury what do you think? Too strict? I'm not even allowing neighbouring imports like ./foo, only exception is ./MyComponent.module.css.

I'm not too precious over this, just wanted to get some consistency across the codebase, let me know if you hate it! It's worth noting that VSCode's auto import when typing out a variable should automatically use this format so no issues there (let me know if that's the case for you!)

⚠️ Note to self: Don't merge this until the other PRs are merged

@funwithtriangles funwithtriangles changed the base branch from save-list to alpha October 13, 2024 14:08
Copy link
Contributor

@cale-bradbury cale-bradbury left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just a few q's

.eslintrc.cjs Outdated
Comment on lines 20 to 23
'../*', // Disallow relative imports that go up a directory
'./*', // Optionally disallow relative imports within the same directory
'!./*.module.css', // allow relative import of CSS module files
'src/*', // Disallow absolute imports starting with `src/` and enforce alias usage
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering if we specify ts/js as there may be other files that make sense to import directly other than just module.css

Also, is part of the goal with this change (@engine, etc) to help with plugins or the web export/sub packages, etc?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I'm going to remove the rule ./* because I think it's fine to import sibling files. It's just when we start going up and down the file structure with lots of /../ that it gets a bit unwieldy.

The @engine stuff is just for tidiness when importing. For instance rather than having to do src/renderer/components/whatever put the whole import path, we can just do @components/whatever. It also means we could potentially change the location of that folder and all we'd need to update is the alias path. In the case of @engine though this will probably change quite soon when we move it to a monorepo...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I see your point now, I'm not going to allow neighbouring directories to be imported but neighbouring files (as you suggested) makes sense.

@@ -95,7 +95,7 @@ export class HedronEngine {
const sketchInstances = this.sketchManager!.getSketchInstances()
debugScene.clearPasses()
Object.values(sketches).forEach((sketch) => {
// eslint-disable-next-line
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const paramValues: { [key: string]: any } = {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it would be good to get this typed, but I can forsee wanting to have objects like a vec2, vec3, gradient, in the future. Maybe even want to support anything via plugins, and once it's external peoples desires may be endless

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I'm still not sure how to handle this 🙈. Hopefully we can work out something eventually

@funwithtriangles
Copy link
Member Author

Merging for now, not sure if it all makes complete sense but we can still change rules if we start getting annoyed by them

@funwithtriangles funwithtriangles merged commit 9adf36b into alpha Nov 4, 2024
1 check passed
@funwithtriangles funwithtriangles deleted the type-fixes branch November 4, 2024 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants