Tuesday, May 7, 2024
HomeJavaScriptReadonly information in VSCode | Stefan Judis Net Improvement

Readonly information in VSCode | Stefan Judis Net Improvement


Printed at

Up to date at

Studying time
2min

This put up is a part of my Right this moment I realized sequence during which I share all my internet growth learnings.

This is a fast tip from the superb vscode.e-mail e-newsletter: VS Code permits you to mark information as readonly.

When would you utilize it?

Many functions embrace generated information, which might be information fashions or schemas. These information are sometimes checked into model management and solely up to date periodically. Individuals know they should not contact these information as a result of they begin with a giant warning — don’t edit this file manually.

This is a file from my present mission.


Do individuals learn all of the feedback? No. Does this stop me from altering the file manually? Additionally, no.

I like the concept of fixing this downside on the editor stage.

The “Readonly embrace” choice accepts information or glob patterns.

VSCode setting "Readonly Include": Configure paths or glob patterns to mark as read-only. Glob patterns are always evaluated relative to the path of the workspace folder unless they are absolute paths. You can exclude matching paths via the Files: Readonly Exclude setting. Files from readonly file system providers will always be read-only independent of this setting.

And voila! I am unable to edit these generated information in VS Code anymore now.

VS Code editor showing a tooltip telling that this file is readonly.

The trick is to not outline this setting in your international config however somewhat in your workspace or mission config at your-project/.vscode/settings.json.

{
  "information.readonlyInclude": {
    "src/app/core/generated-models/**": true
  }
}

Now, no VS Code person will edit the generated information. Win win!

Was this TIL put up useful?
Sure? Cool! You may wish to try Net Weekly for extra fast learnings. The final version went out 3 days in the past.

Associated Matters

Associated Articles

Concerning the creator

Stefan standing in the park in front of a green background
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments