-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Parser reports "Parsing error" for new files added to project (VSCode) #864
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
Parser reports "Parsing error" for new files added to project (VSCode) #864
Comments
cc @uniqueiniquity - it looks like maybe we haven't handled watch mode well enough? |
Yeah... this makes sense to me. Currently, once we determine the source files of a tsconfig, we won't add to it - that is, we're not watching for new files in case we need to update. |
how does vscode's typescript integration do it? |
In VS Code, we use TSServer, which handles of the file watching, project creation, and everything else. What we do in typescript-estree is at a lower level in the TS architecture, where we interact directly with the Node API for the TS compiler itself. By stepping up to a higher level of the TS architecture, we'd get more pieces handled for us (including this file watching piece), but may incur more performance overhead. |
interesting. We should probably look into the mechanisms that the eslint vscode plugin uses to setup its watch mode - maybe there's something we can listen to to help inform how we watch. |
I should note that this is actually also happening during the Webpack build, i.e. |
If it's happening during webpack watch mode, then it's the same issue. If it's happening on a single build - then your tsconfig isn't including the files. |
I'm seeing this behaviour in IntelliJ as well, so I suspect they share a root cause. I'd image WebStorms handling of TS is similar enough to vscodes that the same fix should work for both, but someone like @prigara would be able to tell you for sure (+ I figure they'd interested in knowing about this issue). Since there isn't way to restart the eslint service (WEB-38066 wink wink nudge nudge), I have to open & close the project everytime I add a new file in some places. No pressure or nothing, but this is actually super annoying 😂 Let me know if there's anything I can do to help - happy to do testing & what-have-you w/ IntelliJ/WebStorm on my end, and can report an issue on YouTrack if needed 🙂 On a side note: would it be possible/worth having an option to revert back to the pre-2.0.0 behaviour in the meantime? |
@G-Rath see the information in #890 If that's working for you, then feel free to add We're going to look into a proper fix. |
@bradzacher thanks for the link - I didn't see that issue, but I did see the I've confirmed that in this project, running
As expected since
Let me know if you'd like me to make a new webstorm-specific issue 🙂 |
I only raised #890 this morning, to try and consolidate the discussion going forward because people were commenting on closed issues. Yup, it doesn't matter if it's via Because eslint never "dies", our parser maintains its state - you launch the IDE, it starts eslint, which triggers our parser, which triggers typescript and detects all of the valid files matched by your tsconfig. This is great for existing files, as we only need to do a small bit of work when you update the file. However with new files, it means that our project state doesn't contain the brand new file. Unfortunately, we don't currently have a mechanism for telling typescript to "rescan" the workspace to detect new files. Which means ofc your file just throws an error.
We will figure out how to build the "rescan" functionality above, so that you can turn off |
That's interesting, b/c it's fine if I do
Looking forward to it - as always, let me know if I can do anything to help (but I suspect in this case I'll be less able to help than w/ rewriting indent & co) 🙂 btw thanks for the quick & detailed responses! |
In a nutshell, you'll probably find that the IDEs use eslint's internal APIs to trigger a parse of the file based on the file contents the IDE loaded. This is how they do parses whilst you're still typing without saving! In the interest of saving time and memory however, the IDE will essentially maintain its NodeJS instance, so as far as our parser is concerned - it's one big, long, continuous, never ending lint session. https://eslint.org/docs/developer-guide/nodejs-api#cliengineexecuteontext const cli = new CLIEngine(require('.eslintrc.js'));
ide.onFileContentChange((contents, filename) => {
const report = cli.executeOnText(contents, filename);
}); |
This comment has been minimized.
This comment has been minimized.
- If we include `test` or `typings` files, we get a compiler error related to microsoft/TypeScript#9858. - If we exclude (not added to `include`) `test` or `typings` files, we get a lint "Parsing error". Related to typescript-eslint/typescript-eslint#864 We will go with the linter error. Better to have a non-zero return code for the `lint` script compared with the `build` script.
This comment has been minimized.
This comment has been minimized.
Hey all – just checking in if there's an ETA or a workaround patch... finding that this error is leading developers to disable linting in their IDEs completely. Should we step down to 1.13 in the meantime or is a fix close? Thanks for all the work on this! |
not sure if it's a workaround, exactly, but I use |
The workaround is |
Parser reports "Parsing error" for new files added to project (VSCode) #864 typescript-eslint/typescript-eslint#864
Now that the file watching has been added, it should no longer be necessary to use
|
When do you plan to release it? :) |
https://github.com/typescript-eslint/typescript-eslint/blob/master/README.md#package-versions Automated release schedule is listed in the readme. |
Thanks! |
@bradzacher this is still occurring in Intellij on the latest 2.4.0 (https://github.com/typescript-eslint/typescript-eslint/releases/tag/v2.4.0) which includes your PR #973 Versions
|
please raise a new issue with some repro steps. |
What code were you trying to parse?
A new React component module. This happens on all new TypeScript source files, however. This is being triggered from the instance of ESLint that VSCode runs in the background, meaning that in order to get this error to go away, I have to reload the entire VSCode window.
tsconfig.json
include
:What did you expect to happen?
The file should be parsed normally, as its path is matched by the
include
property in mytsconfig.json
file.What actually happened?
A "Parsing error" is reported on the first line of any file that is created while the VSCode linter instance is running, saying that the file is not included in the project. The error does not go away unless I restart VSCode (or reload the window).
Versions
@typescript-eslint/parser
2.0.0
TypeScript
3.4.5
ESLint
6.1.0
node
12.7.0
npm
yarn
1.17.3
The text was updated successfully, but these errors were encountered: