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

5.5k views Asked by At

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.

2

There are 2 answers

0
Lince Potiguara On

Workspaces can solve that

You need to save one folder for each project, let them be Ruby and DSL. Then you can, for example, disable the Ruby Syntax Highlighting extension in the DSL workspace and enable them in the Ruby workspace.

You may want to go to FileAdd Folder to Workspace..., if so both workspaces will appear in the Explorer panel.

0
wisn On

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.