hilla icon indicating copy to clipboard operation
hilla copied to clipboard

Generated `tsconfig.json` is not `json` compliant

Open manolo opened this issue 4 years ago • 9 comments

When generating the tsconfig.json avoid any comment because IDE can complain about it.

Original report was in forum: https://vaadin.com/forum/thread/18187819/problem-vaadin-15-0-3-and-eclipse

manolo avatar Apr 03 '20 06:04 manolo

If we really want to keep the comment AND make the file JSON-compliant, we could consider a hack like in

{
  "__COMMENT__": [
    "This TypeScript configuration file is generated by vaadin-maven-plugin.",
    "This is needed for TypeScript compiler to compile your TypeScript code in the project.",
    "It is recommended to commit this file to the VCS.",
    "You might want to change the configurations to fit your preferences",
    "For more information about the configurations, please refer to ",
    "http://www.typescriptlang.org/docs/handbook/tsconfig-json.html",

    "NOTE: this is a comment",
    "But since JSON does not support //comments, it's added in this weird way."
  ],
  "compilerOptions": {
    "sourceMap": true,

vlukashov avatar Apr 07 '20 12:04 vlukashov

This also happens in 14.1.27

martinisraelsen avatar May 29 '20 18:05 martinisraelsen

This also happens in 14.1.27

A tsconfig.json file in a Vaadin 14.1.27 app? That sounds very confusing to me as I am pretty confident Vaadin 14.x does not have built-in support for TypeScript. Could you please attach a reduced example project where you see this issue happen in Vaadin 14.1.27?

vlukashov avatar May 29 '20 19:05 vlukashov

Hi @vlukashov,

I downloaded blank starter from Vaadin (14 LTS) and ran it with mvn jetty:run. A short while later the following shows up in eclipse.

Screen Shot 2020-05-30 at 2 41 00 PM

This is the file contents

Screen Shot 2020-05-30 at 2 43 05 PM

martinisraelsen avatar May 30 '20 19:05 martinisraelsen

Thanks! Now I understand the issue better. The screenshot shows that Eclipse complains about a file deep inside the node_modules folder. While this is not in direct control of Vaadin (it comes from a dependency and we do not generate this file nor can we modify it), I see how this becomes an annoying issue when you work with a Vaadin project in Eclipse.

I wonder, is there a way to configure Eclipse to not run any analysis on the contents of the node_modules folder.

vlukashov avatar Jun 01 '20 09:06 vlukashov

Yes you can configure eclipse not to run the json analysis for a project. Add exclude group and then add the rule. (Be sure the rule says 'folder' and not 'file')

exclude_node_modules

Still it would be nice if there is no json problem at all.

BrunoEberhard avatar Jun 17 '20 06:06 BrunoEberhard

Thanks @vlukashov and @BrunoEberhard. Best tip ever!

martinisraelsen avatar Jun 17 '20 12:06 martinisraelsen

Exactly the same happens for Vaadin 14.3.0 and with latest Eclipse even for the my-todo starter.

And thanks to @BrunoEberhard , JSON Validator Exclude rule for npm_modules folder clears the errors.

Obiwanbde avatar Jul 16 '20 10:07 Obiwanbde

I've made a PR for documentation on "using Eclipse" about disabling JSON syntax for node_modules. This issue can be still considered for the generated tsconfig.json file. But for 14 at least there is nothing else we can do.

pleku avatar Sep 10 '20 08:09 pleku