Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code: Disabling Error/Warning checks in for specific file type

At work, my team created our own little scripting language using Ruby and the Treetop parser. The syntax for the language itself is very similar to Ruby.

I'm using Ruby and the Ruby extension for syntax highlighting for our files for this language, but the Ruby extension throws errors because the language isn't actually Ruby.

Is there a way to disable error checking for specific file types? Should I fork the Ruby extension?

Thanks.

like image 267
OmriSama Avatar asked Jun 24 '20 19:06

OmriSama


People also ask

How do I disable VS Code Pylint warnings?

Go to the menu File -> Preferences -> Settings (Or open directly with Command + , or Ctrl + , ). Then in the search box at the top of the window, search for pylint Args . Click on the button Add item and add the line --disable=W .

How do I disable VS Code restricted mode?

To disable the Restricted mode status bar entry: Right click in the status bar. Uncheck the workspace trust entry.


1 Answers

You can disable it by configuring your own VSCode setting in your project root. I'm using Ruby extension with RuboCop linter. Here are the steps:

  1. Open your project root directory.
  2. Create our own setting by running touch .vscode/settings.json.
  3. Enable RuboCop by pasting this configurations into .vscode/settings.json:
{
  "ruby.lint": {
    "rubocop": true
  }
}
  1. Create .rubocop.yml file and paste the default settings from https://github.com/rubocop-hq/rubocop/blob/master/config/default.yml
  2. Set NewCops either enable or disable.
  3. Add new item in the Exclude. Let's say the excluded extension is .my. Something like this:
Exclude:
    - 'node_modules/**/*'
    - 'tmp/**/*'
    - 'vendor/**/*'
    - '.git/**/*'
    - '**/*.my'
  1. That's it.

As an evidence, here is how my .my looks like before I applied this configurations while using Ruby syntax highlighting with RuboCop linter enabled.

enter image description here

And, here is how it looks like after I configured it just like I explained above:

enter image description here

Hope it helps.

like image 159
wisn Avatar answered Oct 12 '22 23:10

wisn