Conversation
domoritz
left a comment
There was a problem hiding this comment.
At the moment, we don't use prettier.
To add this we would need to
- make prettier a dev dependency
- add prettier support to eslint
- ignore schema files
We should make sure that there are no degredations after we add prettier.
.prettierrc.json
Outdated
| { | ||
| "singleQuote": true, | ||
| "tabWidth": 2, | ||
| "trailingComma": "none" |
There was a problem hiding this comment.
I think we want a print width of 120
Addressed these. Hope I added all the necessary schema files in Also added printWidth |
|
Do we need a prettierignore? Doesn't eslint do that? Or is that for editors with auto formatter? |
|
I think we might need |
|
Makes sense. Eslint will also support format on save. |
|
Ci is failing btw. We probably need to reformat as well. |
|
yep, lemme check it out |
|
Should we add a command to package.json to write the changes? |
|
Yes |
|
I added the script and formatted the files in two separate commits; I don't know if the change is too drastic to review, if it is we can undo this format command and leave it up to the developers to use later (?) |
package.json
Outdated
| "clean": "lerna run clean", | ||
| "lint": "lerna run lint", | ||
| "test": "tsc --build && lerna run schema && vitest run", | ||
| "write": "prettier --write '**/*.{js,ts,json,yaml}'", |
There was a problem hiding this comment.
No, please add format or lint:fix and let ESLint fix things.
|
I added both |
domoritz
left a comment
There was a problem hiding this comment.
Overall looks reasonable with a few comments below. Thanks for your help here!
| params: | ||
| bandwidth: 50 | ||
| thresholds: 10 | ||
| plot: |
There was a problem hiding this comment.
Isn't this generated? Then we should not reformat.
There was a problem hiding this comment.
what other files would this go for? just making sure I know what else is generated here
There was a problem hiding this comment.
I think the yaml and esm example are all generated. Try building the library and website without formatting and see whether anything gets reset.
package.json
Outdated
| "test": "tsc --build && lerna run schema && vitest run", | ||
| "format": "prettier --write '**/*.{js,ts,tsx,json,css,md}'", | ||
| "lint:fix": "eslint '**/*.{js,ts,tsx}' --fix", | ||
| "format:check": "prettier --check '**/*.{js,ts,tsx,json,css,md}'", |
There was a problem hiding this comment.
That should be in lint already.
There was a problem hiding this comment.
what should be in lint? Sorry I don't understand?
There was a problem hiding this comment.
Lint should be a superset of format check
| "clean": "lerna run clean", | ||
| "lint": "lerna run lint", | ||
| "test": "tsc --build && lerna run schema && vitest run", | ||
| "format": "prettier --write '**/*.{js,ts,tsx,json,css,md}'", |
There was a problem hiding this comment.
Lint fix and format should be the same
There was a problem hiding this comment.
would having prettier-format not address more of files that eslint cannot go over though?
There was a problem hiding this comment.
Maybe. But then we should still have them in one command. I am also less worried about files other than ts.
There was a problem hiding this comment.
That makes sense. would you like me to make a combined command for them or just get rid of the prettier --write entirely?
There was a problem hiding this comment.
How much do we benefit from combined vs remove?
There was a problem hiding this comment.
How about we do:
"lint:fix": "eslint '**/*.{js,ts,tsx}' --fix && prettier --write '**/*.{js,ts,tsx,json,css,md}'",and then have a format:write command separately for the --write? Best of both worlds imo
There was a problem hiding this comment.
I don't suppose it's any harm removing the format command though; if we dont care about the files other than ts
| document | ||
| .getElementById('plot') | ||
| .replaceChildren( | ||
| vg.plot(vg.lineY(vg.from('aapl'), { x: 'Date', y: 'Close', tip: true }), vg.width(680), vg.height(200)) |
There was a problem hiding this comment.
This is worse in terms of readability. Any ideas how we can improve?
There was a problem hiding this comment.
umm.. I would say
- printWidth should be shorter like 80 or so (I tested 80 and works okay for me)
- es5 for the trailing commas
Doing that now...
There was a problem hiding this comment.
Let's try different line widths and see what gives us good results and fewer changes.
Why would trailing commas help?
There was a problem hiding this comment.
Yeah 100 works well for me too :)
We dont wanna use "all" for it since trailing commas are not seen in the project, so to keep things close to the previous version and reduce changes, I thought "es5" would be a good idea
| .querySelector('#plots') | ||
| .replaceChildren( | ||
| vg.vconcat( | ||
| vg.hconcat(vg.hspace('2em'), vg.menu({ from: 'weather', column: 'weather', label: 'Weather', as: selection })), |
There was a problem hiding this comment.
This also looks worse. But maybe okay as a trade off.
| * @returns this | ||
| */ | ||
| queryError(error: Error): this { // eslint-disable-line @typescript-eslint/no-unused-vars | ||
| queryError(error: Error): this { |
There was a problem hiding this comment.
good catch! This is interesting because the printwidth will wrap it to the next line. We have the option to:
- Move all these comments above the functions manually with
eslint-disable-next-line(time-taking) - Rename all unused args to start with
_perhaps? and then ignore them in global eslint config with something like"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }]
There was a problem hiding this comment.
1 seems cleaner. Even better might be to disable the check and use typescript with @ts-expect-error. The advantage of that is that this will error when the variable is actually used.
There was a problem hiding this comment.
Pardon me, but why would you say that is an advantage?
There was a problem hiding this comment.
ts expect error will silence an error but also will error if there is no error
| const sql = `${query}`; | ||
| if (isSelectQuery(query) && !cache.get(sql)) { | ||
| if ( | ||
| query._where.length || query._qualify.length || query._having.length || |
There was a problem hiding this comment.
Was there a reason for the grouping? Maybe use comments.
| sub(y, avg(y as ColumnRefNode)) | ||
| ) | ||
| ); | ||
| const sxy = sum(mul(sub(x, avg(x as ColumnRefNode)), sub(y, avg(y as ColumnRefNode)))); |
.prettierrc.json
Outdated
| "singleQuote": true, | ||
| "tabWidth": 2, | ||
| "trailingComma": "none", | ||
| "printWidth": 120, |
…es + remove format:check
domoritz
left a comment
There was a problem hiding this comment.
Thank you. Just a few comments left and then we can merge. I don't see many code changes which is surprising but also good.
| try { | ||
| await unlink(linkFile); | ||
| } catch (err) { // eslint-disable-line @typescript-eslint/no-unused-vars | ||
| // eslint-disable-next-line |
There was a problem hiding this comment.
I don't think this is needed anymore.
There was a problem hiding this comment.
Update the rest as well. We should probably have something like
export default tseslint.config({
rules: {
// Note: you must disable the base rule as it can report incorrect errors
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "error"
}
});
| _type: string, // eslint-disable-line @typescript-eslint/no-unused-vars | ||
| _value: unknown // eslint-disable-line @typescript-eslint/no-unused-vars | ||
| // eslint-disable-next-line | ||
| _type: string, // @typescript-eslint/no-unused-vars |
There was a problem hiding this comment.
We can handle _ automatically. Please read https://typescript-eslint.io/rules/no-unused-vars/
| el = el.children[0]; | ||
| } | ||
| // @ts-ignore | ||
| // @ts-expect-error |
There was a problem hiding this comment.
Let's include a description of what error is expected here.
| if (isNode(field)) { | ||
| if (field.type === 'COLUMN_REF') { | ||
| // @ts-ignore | ||
| // @ts-expect-error |
|
|
||
| [filter].flat().forEach(p => walk(p, (node) => { | ||
| if (node instanceof BetweenOpNode && `${node.expr}` === column) { | ||
| // @ts-ignore |
| codegen(ctx) { // eslint-disable-line no-unused-vars | ||
| // @ts-ignore | ||
| // eslint-disable-next-line | ||
| codegen(ctx) { // no-unused-vars |
There was a problem hiding this comment.
Are we not removing no-unused-vars?
| instantiate(ctx) { // eslint-disable-line no-unused-vars | ||
| // @ts-ignore | ||
| // eslint-disable-next-line | ||
| instantiate(ctx) { // no-unused-vars |
There was a problem hiding this comment.
Are we not removing no-unused-vars?
I haven't run |
|
Oh okay. I want to see the changes before I approve. I couldn't run the code locally since the installation was broken. I can check locally when the installation works. |
No description provided.