Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vscode package.json String does not match the pattern

Tags:

I am trying out VSCode on an existing project that uses npm and has a package.json file with a corresponding "name:" key that reads "SpecPro-File-Management-UI". VSCode is objecting to this line with "String does not match the pattern ...", apparently because of the upper-case characters in the name.

This problem is described in a VSCode issue which is closed. Which leaves me with advice to setup a custom schema for my package.json file. This is pretty unfriendly, and a barrier to adopting VSCode. I don't want to spend my time on custom schemas. I don't want to rename my project. I just want to edit my code and take advantage of the many VSCode goodies without distracting messages that are wrong.

Considering that using uppercase characters for npm packages is a VERY common practice, it seems most reasonable that VSCode should adopt either a more friendly schema or an easy way to override the standard schema. As far as I can tell, I have to make my own personal schema to resolve this problem. That's a lot of work and future maintenance for such a simple issue.

Is there an easy way to banish this erroneous error message?

like image 821
Mark L. Avatar asked Feb 08 '18 21:02

Mark L.


Video Answer


1 Answers

This behavior is by design to enforce NPM conventions for the package.json file (to paraphrase, "lower-case only"). I agree it is a nuisance, especially since the project name is often pre-filled, e.g. by "create-react-app". As you point out, it is possible to create a custom schema to ignore this, but it's really not recommended. There isn't any alternative at this time. Myself, I just change the value to lower-case.

like image 151
Jay Avatar answered Sep 22 '22 02:09

Jay