2020-04-22 11:22:51 -04:00
|
|
|
# Disabling linters and rules
|
|
|
|
If you find you need to ignore certain errors and warnings, you will need to know the format to disable the linter rules.
|
|
|
|
Below is examples and documentation for each language and the various methods to disable.
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
## Ruby
|
2020-04-22 12:58:51 -04:00
|
|
|
- [Rubocop](https://github.com/rubocop-hq/rubocop)
|
|
|
|
|
2020-04-22 11:22:51 -04:00
|
|
|
### Rubocop Config file
|
2020-04-23 08:55:25 -04:00
|
|
|
- `.github/linters/.ruby-lint.yml`
|
2020-04-22 12:58:51 -04:00
|
|
|
- You can pass multiple rules and overwrite default rules
|
|
|
|
- File should be located at: `.github/linters/.ruby-lint.yml`
|
2020-04-23 08:50:07 -04:00
|
|
|
- **Note:** We use the Default **GitHub** Rule set from [Rubocop-GitHub](https://github.com/github/rubocop-github)
|
2020-04-22 12:58:51 -04:00
|
|
|
|
2020-04-22 11:22:51 -04:00
|
|
|
### Rubocop disable single line
|
2020-04-22 12:58:51 -04:00
|
|
|
```ruby
|
|
|
|
method(argument) # rubocop:disable SomeRule, SomeOtherRule
|
|
|
|
```
|
|
|
|
|
2020-04-22 11:22:51 -04:00
|
|
|
### Rubocop disable code block
|
2020-04-22 12:58:51 -04:00
|
|
|
```ruby
|
|
|
|
# rubocop:disable
|
|
|
|
This is a long line
|
|
|
|
var="this is some other stuff"
|
|
|
|
# rubocop:enable
|
|
|
|
```
|
2020-04-22 11:22:51 -04:00
|
|
|
|
2020-04-22 12:58:51 -04:00
|
|
|
### Rubocop disable entire file
|
2020-04-23 10:01:15 -04:00
|
|
|
If you need to ignore an entire file, you can update the `.github/linters/.ruby-lint.yml` to ignore certain files and locations
|
2020-04-23 08:50:07 -04:00
|
|
|
|
|
|
|
```yml
|
|
|
|
inherit_from:
|
|
|
|
- .rubocop_todo.yml
|
|
|
|
- .rubocop_app_overrides.yml
|
|
|
|
|
|
|
|
inherit_mode:
|
|
|
|
merge:
|
|
|
|
- Exclude
|
|
|
|
|
|
|
|
Rails:
|
|
|
|
Enabled: true
|
|
|
|
|
|
|
|
AllCops:
|
|
|
|
TargetRubyVersion: 2.5.1
|
|
|
|
EnabledByDefault: true
|
|
|
|
Exclude:
|
|
|
|
- 'db/**/*'
|
|
|
|
- 'config/**/*'
|
|
|
|
- 'script/**/*'
|
|
|
|
- 'bin/{rails,rake}'
|
|
|
|
- !ruby/regexp /old_and_unused\.rb$/
|
|
|
|
```
|
|
|
|
|
2020-04-22 11:22:51 -04:00
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
## Shell
|
2020-04-23 08:55:25 -04:00
|
|
|
**Shellcheck** is an opensource tool we use for linting and validation of the shell scripting language.
|
2020-04-23 08:50:07 -04:00
|
|
|
- [Shellcheck](https://github.com/koalaman/shellcheck)
|
|
|
|
|
2020-04-22 11:22:51 -04:00
|
|
|
### Shellcheck Config file
|
2020-04-23 08:50:07 -04:00
|
|
|
- There is no top level *configuration file* available at this time
|
|
|
|
|
2020-04-22 11:22:51 -04:00
|
|
|
### Shellcheck disable single line
|
2020-04-23 08:50:07 -04:00
|
|
|
```bash
|
|
|
|
echo "Terrible stuff" # shellcheck disable=SC2059,SC2086
|
|
|
|
```
|
|
|
|
|
2020-04-22 11:22:51 -04:00
|
|
|
### Shellcheck disable code block
|
2020-04-23 08:50:07 -04:00
|
|
|
```bash
|
|
|
|
# shellcheck disable=SC2059,SC2086
|
|
|
|
echo "some hot garbage"
|
|
|
|
echo "More garbage code"
|
|
|
|
```
|
|
|
|
|
2020-04-22 11:22:51 -04:00
|
|
|
### Shellcheck disable entire file
|
2020-04-23 08:50:07 -04:00
|
|
|
- **Note:** The disable must be on the second line of the code right after the shebang
|
|
|
|
```bash
|
|
|
|
#!/bin/sh
|
|
|
|
# shellcheck disable=SC2059,SC1084
|
|
|
|
|
|
|
|
echo "stuff"
|
|
|
|
moreThings()
|
|
|
|
```
|
2020-04-22 11:22:51 -04:00
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
## Ansible
|
|
|
|
### Ansible-lint Config file
|
|
|
|
### Ansible-lint disable single line
|
|
|
|
### Ansible-lint disable code block
|
|
|
|
### Ansible-lint disable entire file
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
## YAML
|
2020-04-23 08:55:25 -04:00
|
|
|
- [YamlLint](https://github.com/adrienverge/yamllint)
|
|
|
|
|
2020-04-22 11:22:51 -04:00
|
|
|
### Yamllint Config file
|
2020-04-23 08:55:25 -04:00
|
|
|
- `.github/linters/.yaml-lint.yml`
|
|
|
|
- You can pass multiple rules and overwrite default rules
|
|
|
|
- File should be located at: `.github/linters/.yaml-lint.yml`
|
|
|
|
|
2020-04-22 11:22:51 -04:00
|
|
|
### Yamllint disable single line
|
2020-04-23 08:55:25 -04:00
|
|
|
```yml
|
|
|
|
This line is waaaaaaaaaay too long # yamllint disable-line
|
|
|
|
```
|
|
|
|
|
2020-04-22 11:22:51 -04:00
|
|
|
### Yamllint disable code block
|
2020-04-23 08:55:25 -04:00
|
|
|
```yml
|
|
|
|
# yamllint disable rule:colons
|
|
|
|
- Lorem : ipsum
|
|
|
|
dolor : sit amet,
|
|
|
|
consectetur : adipiscing elit
|
|
|
|
# yamllint enable
|
|
|
|
```
|
|
|
|
|
2020-04-22 11:22:51 -04:00
|
|
|
### Yamllint disable entire file
|
2020-04-23 10:01:15 -04:00
|
|
|
If you need to ignore an entire file, you can update the `.github/linters/.yaml-lint.yml` to ignore certain files and locations
|
2020-04-23 08:55:25 -04:00
|
|
|
```yml
|
|
|
|
# For all rules
|
|
|
|
ignore: |
|
|
|
|
*.dont-lint-me.yaml
|
|
|
|
/bin/
|
|
|
|
!/bin/*.lint-me-anyway.yaml
|
|
|
|
|
|
|
|
rules:
|
|
|
|
key-duplicates:
|
|
|
|
ignore: |
|
|
|
|
generated
|
|
|
|
*.template.yaml
|
|
|
|
trailing-spaces:
|
|
|
|
ignore: |
|
|
|
|
*.ignore-trailing-spaces.yaml
|
|
|
|
/ascii-art/*
|
|
|
|
```
|
2020-04-22 11:22:51 -04:00
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
## Python3
|
|
|
|
### Pylint Config file
|
|
|
|
### Pylint disable single line
|
|
|
|
### Pylint disable code block
|
|
|
|
### Pylint disable entire file
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
## JSON
|
|
|
|
### JsonLint Config file
|
|
|
|
### JsonLint disable single line
|
|
|
|
### JsonLint disable code block
|
|
|
|
### JsonLint disable entire file
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
## Markdown
|
|
|
|
- [Markdownlint-cli](https://github.com/igorshubovych/markdownlint-cli#readme)
|
|
|
|
- [Markdownlint rules](https://awesomeopensource.com/project/DavidAnson/markdownlint)
|
|
|
|
|
|
|
|
### Markdownlint Config file
|
2020-04-23 10:08:38 -04:00
|
|
|
- `.github/linters/.markdown-lint.yml`
|
2020-04-22 11:22:51 -04:00
|
|
|
- You can pass multiple rules and overwrite default rules
|
|
|
|
- File should be located at: `.github/linters/.markdownlint.yml`
|
|
|
|
|
|
|
|
### Markdownlint disable single line
|
|
|
|
```markdown
|
|
|
|
## Here is some document
|
|
|
|
Here is some random data
|
|
|
|
<!-- markdownlint-disable -->
|
|
|
|
any violation you want
|
|
|
|
<!-- markdownlint-restore -->
|
|
|
|
Here is more data
|
|
|
|
```
|
|
|
|
### Markdownlint disable code block
|
|
|
|
```markdown
|
|
|
|
## Here is some document
|
|
|
|
Here is some random data
|
|
|
|
<!-- markdownlint-disable -->
|
|
|
|
any violations you want
|
|
|
|
<!-- markdownlint-restore -->
|
|
|
|
Here is more data
|
|
|
|
```
|
|
|
|
|
|
|
|
### Markdownlint disable entire file
|
|
|
|
- You can encapsulate the entire file with the *code block format* to disable an entire file from being parsed
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
## Perl
|
|
|
|
### Perl Config file
|
|
|
|
### Perl disable single line
|
|
|
|
### Perl disable code block
|
|
|
|
### Perl disable entire file
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
## XML
|
2020-04-23 10:03:56 -04:00
|
|
|
- [XML](http://xmlsoft.org/)
|
|
|
|
|
2020-04-22 11:22:51 -04:00
|
|
|
### LibXML Config file
|
2020-04-23 10:03:56 -04:00
|
|
|
- There is no top level *configuration file* available at this time
|
|
|
|
|
2020-04-22 11:22:51 -04:00
|
|
|
### LibXML disable single line
|
2020-04-23 10:03:56 -04:00
|
|
|
- There is currently **No** way to disable rules inline of the file(s)
|
|
|
|
|
2020-04-22 11:22:51 -04:00
|
|
|
### LibXML disable code block
|
2020-04-23 10:03:56 -04:00
|
|
|
- There is currently **No** way to disable rules inline of the file(s)
|
|
|
|
|
2020-04-22 11:22:51 -04:00
|
|
|
### LibXML disable entire file
|
2020-04-23 10:03:56 -04:00
|
|
|
- There is currently **No** way to disable rules inline of the file(s)
|
2020-04-22 11:22:51 -04:00
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
## Coffeescript
|
2020-04-23 10:08:38 -04:00
|
|
|
- [coffeelint](http://www.coffeelint.org/)
|
|
|
|
|
2020-04-22 11:22:51 -04:00
|
|
|
### coffeelint Config file
|
2020-04-23 10:08:38 -04:00
|
|
|
- `.github/linters/.coffee-lint.yml`
|
|
|
|
- You can pass multiple rules and overwrite default rules
|
|
|
|
- File should be located at: `.github/linters/.coffee.yml`
|
|
|
|
|
2020-04-22 11:22:51 -04:00
|
|
|
### coffeelint disable single line
|
2020-04-23 10:08:38 -04:00
|
|
|
```Coffeescript
|
|
|
|
# coffeelint: disable=max_line_length
|
|
|
|
foo = "some/huge/line/string/with/embed/#{values}.that/surpasses/the/max/column/width"
|
|
|
|
# coffeelint: enable=max_line_length
|
|
|
|
```
|
|
|
|
|
2020-04-22 11:22:51 -04:00
|
|
|
### coffeelint disable code block
|
2020-04-23 10:08:38 -04:00
|
|
|
```Coffeescript
|
|
|
|
# coffeelint: disable
|
|
|
|
foo = "some/huge/line/string/with/embed/#{values}.that/surpasses/the/max/column/width"
|
|
|
|
bar = "some/huge/line/string/with/embed/#{values}.that/surpasses/the/max/column/width"
|
|
|
|
baz = "some/huge/line/string/with/embed/#{values}.that/surpasses/the/max/column/width"
|
|
|
|
taz = "some/huge/line/string/with/embed/#{values}.that/surpasses/the/max/column/width"
|
|
|
|
# coffeelint: enable
|
|
|
|
```
|
|
|
|
|
2020-04-22 11:22:51 -04:00
|
|
|
### coffeelint disable entire file
|
2020-04-23 10:08:38 -04:00
|
|
|
- You can encapsulate the entire file with the *code block format* to disable an entire file from being parsed
|
2020-04-22 11:22:51 -04:00
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
## Javascript (eslint)
|
|
|
|
### Javascript eslint Config file
|
|
|
|
### Javascript eslint disable single line
|
|
|
|
### Javascript eslint disable code block
|
|
|
|
### Javascript eslint disable entire file
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
## Javascript (standard)
|
|
|
|
### Javascript standard Config file
|
|
|
|
### Javascript standard disable single line
|
|
|
|
### Javascript standard disable code block
|
|
|
|
### Javascript standard disable entire file
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
## Typescript (eslint)
|
|
|
|
|
|
|
|
### Typescript eslint disable single line
|
|
|
|
### Typescript eslint disable code block
|
|
|
|
### Typescript eslint disable entire file
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
## Typescript (standard)
|
|
|
|
### Typescript standard Config file
|
|
|
|
### Typescript standard disable single line
|
|
|
|
### Typescript standard disable code block
|
|
|
|
### Typescript standard disable entire file
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
## Golang
|
|
|
|
### golangci-lint standard Config file
|
|
|
|
### golangci-lint disable single line
|
|
|
|
### golangci-lint disable code block
|
|
|
|
### golangci-lint disable entire file
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
## Dockerfile
|
2020-04-23 10:01:15 -04:00
|
|
|
-[dockerfilelint](https://github.com/replicatedhq/dockerfilelint.git)
|
|
|
|
|
2020-04-22 11:22:51 -04:00
|
|
|
### Dockerfilelint standard Config file
|
2020-04-23 10:01:15 -04:00
|
|
|
- `.github/linters/.dockerfilelintrc`
|
|
|
|
- You can pass multiple rules and overwrite default rules
|
|
|
|
- File should be located at: `.github/linters/.dockerfilelintrc`
|
|
|
|
|
2020-04-22 11:22:51 -04:00
|
|
|
### Dockerfilelint disable single line
|
2020-04-23 10:01:15 -04:00
|
|
|
- There is currently **No** way to disable rules inline of the file(s)
|
|
|
|
|
2020-04-22 11:22:51 -04:00
|
|
|
### Dockerfilelint disable code block
|
2020-04-23 10:01:15 -04:00
|
|
|
- There is currently **No** way to disable rules inline of the file(s)
|
|
|
|
|
2020-04-22 11:22:51 -04:00
|
|
|
### Dockerfilelint disable entire file
|
2020-04-23 10:01:15 -04:00
|
|
|
- There is currently **No** way to disable rules inline of the file(s)
|
2020-04-22 11:22:51 -04:00
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
## Terraform
|
|
|
|
### tflint standard Config file
|
|
|
|
### tflint disable single line
|
|
|
|
### tflint disable code block
|
|
|
|
### tflint disable entire file
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|