feat(init): add check task to run all static analysis#1454
Conversation
|
On the other hand this will make startup slow, deno disabled typechecking by default everywhere for this reason Also is there a reason to not just use Maybe at least we should have |
|
Also I remember the argument for disabling type-checking by default was that the editor should have the checks via the lsp already and the uesr shouldn't need to pay the costly startup time for the same redundant diagnostics. I guess the mentality is the user should fix errors before running the file |
|
Agree that the error message thrown by V8 is confusing and not as user friendly as it should be. I'm a little worried about introducing a type-check step when launching the server as it slows down the startup sequence very noticeably. For smaller projects that is likely not much of a concern, but with bigger ones you tend to end up in situations where type checking takes more than 30s. I feel like another alternative is custom linting rules. I've added one that catches when an |
|
I've reworked this to introduce a Fun fact: if you do this in a newly created project, it doesn't pass. When we build the |
|
I like |
|
i like |
|
I realized we also need to check .tsx files as well 🤦 . And it seems useful enough to have in the fresh source itself, no? |
I don't think so. I find myself doing all of these things, and I wanted a shortcut. I could imagine other people do the same as well, and also want a shortcut. So "check:types" isn't descriptive of linting and formatting and type checking. And if you're suggesting removing linting/formatting, then I'm also not in favor of that 😅 , since I want all at once. |
Another strange CI failure, which didn't happen on any of the other variants in this run... |
iuioiua
left a comment
There was a problem hiding this comment.
To clarify, what I had in mind was to have a check:types task and an all-encompassing check task that uses check:types within it. However, I retract this suggestion as I doubt the average dev wants this. It's more of a personal preference for me. Either way, LGTM!
| lock: false, | ||
| tasks: { | ||
| check: | ||
| "deno fmt --check && deno lint && deno check **/*.ts && deno check **/*.tsx", |
There was a problem hiding this comment.
Ah just realized, we might want to wrap the globs in single quotes ' to be compatible with all shells. I wonder if something like '**/*.{[tj]sx?}' would work to check all files in one go.
There was a problem hiding this comment.
Cool idea. Sadly:
deno task check
Task check deno fmt --check && deno lint && deno check '**/*.{[tj]sx?}'
Checked 16 files
Checked 12 files
error: Module not found "file:///Users/reed/code/temp/1454/**/*.%7B[tj]sx%3F%7D".
And with a simpler version:
deno task check
Task check deno fmt --check && deno lint && deno check '**/*.{ts,tsx}'
Checked 16 files
Checked 12 files
error: Module not found "file:///Users/reed/code/temp/1454/**/*.%7Bts,tsx%7D".
Even simpler:
deno task check
Task check deno fmt --check && deno lint && deno check '**/*.ts' && deno check '**/*.tsx'
Checked 16 files
Checked 12 files
error: Module not found "file:///Users/reed/code/temp/1454/**/*.ts".
I would just keep it as is for now, and if we want to get fancier, then we could build on #1422 which introduces a small cli script we can add to. Then we could do the fanciest of checks and just invoke it via deno task cli myUltraFancyCheck and not have to worry about different shells and globs and all of this. Just nice controllable typescript.
There was a problem hiding this comment.
I would just keep it as is for now, and if we want to get fancier, then we could build on #1422 which introduces a small cli script we can add to. Then we could do the fanciest of checks and just invoke it via
deno task cli myUltraFancyCheckand not have to worry about different shells and globs and all of this. Just nice controllable typescript.
I'd suggest keeping the checks simple. The checks in this PR do the job great! 🙂
This is, I think, the natural followup to #1539 and #1454. Now that we have an easy way to type check the initialized project, we should assert that there are no type errors in that project. This adds three seconds on my slow computer, but I think it's worth it; releasing code with red squiggles or linting or formatting errors is a bit silly.

closes #784
The author of 784 has very kindly provided a repo to reproduce the issue. I agree, the error message when starting the project is horrible:
It does highlight the problematic file
Counter.tsx, but the error shown isn't super clear. I don't understand why we're not type checking projects before. After I add thecheckcommand to thestarttask I get the following:This makes it abundantly clear what's wrong with the project. If someone doesn't want to type check their project, it should be decently clear about how to remove the
deno check main.ts &&part from the task. But the other way -- figuring out how to add this isn't so obvious. (I only got it working after a few attempts, e.g.deno check dev.tsdoesn't catch the error. How checkingmain.tschecks the other files in the project is still a mystery to me. As another hurdle to figuring out how to do this on your own: https://deno.land/manual@v1.35.0/tools doesn't mentioncheck, so this is difficult to find.)