lint/docs/disabling-linters.md

567 lines
15 KiB
Markdown
Raw Normal View History

2020-04-23 12:22:10 -04:00
# Disabling linters and Rules
2020-04-23 11:45:04 -04:00
If you find you need to ignore certain **errors** and **warnings**, you will need to know the *format* to disable the **Super-Linter** rules.
2020-04-22 11:22:51 -04:00
Below is examples and documentation for each language and the various methods to disable.
2020-04-23 12:22:10 -04:00
## Table of Linters
2020-04-23 10:57:18 -04:00
- [Ruby](#ruby)
- [Shell](#shell)
- [Ansible](#ansible)
- [YAML](#yaml)
- [Python](#python3)
- [JSON](#json)
- [Markdown](#markdown)
- [Perl](#perl)
- [XML](#xml)
- [Coffeescript](#coffeescript)
2020-04-23 12:18:58 -04:00
- [Javascript Eslint](#javascript-eslint)
- [Javascript Standard](#javascript-standard)
- [Typescript Eslint](#typescript-eslint)
- [Typescript Standard](#typescript-standard)
2020-04-23 10:57:18 -04:00
- [Golang](#golang)
- [Dockerfile](#dockerfile)
- [Terraform](#terraform)
- [CSS](#stylelint)
- [ENV](#dotenv-linter)
2020-04-23 10:57:18 -04:00
<!-- toc -->
2020-04-23 11:38:33 -04:00
2020-04-22 11:22:51 -04:00
--------------------------------------------------------------------------------
## Ruby
- [RuboCop](https://github.com/rubocop-hq/rubocop)
2020-04-22 12:58: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`
- **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
### RuboCop disable single line
2020-04-22 12:58:51 -04:00
```ruby
method(argument) # rubocop:disable SomeRule, SomeOtherRule
```
### 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
### 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: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
2020-04-23 10:39:20 -04:00
- [ansible-lint](https://github.com/ansible/ansible-lint)
2020-04-22 11:22:51 -04:00
### Ansible-lint Config file
2020-04-23 10:39:20 -04:00
- `.github/linters/.ansible-lint.yml`
- You can pass multiple rules and overwrite default rules
- File should be located at: `.github/linters/.ansible-lint.yml`
2020-04-22 11:22:51 -04:00
### Ansible-lint disable single line
2020-04-23 10:39:20 -04:00
```yml
- name: this would typically fire GitHasVersionRule 401 and BecomeUserWithoutBecomeRule 501
become_user: alice # noqa 401 501
git: src=/path/to/git/repo dest=checkout
```
2020-04-22 11:22:51 -04:00
### Ansible-lint disable code block
2020-04-23 10:39:20 -04:00
```yml
- name: this would typically fire GitHasVersionRule 401
git: src=/path/to/git/repo dest=checkout
tags:
- skip_ansible_lint
```
2020-04-22 11:22:51 -04:00
2020-04-23 10:39:20 -04:00
### Ansible-lint disable entire file
```yml
- name: this would typically fire GitHasVersionRule 401
git: src=/path/to/git/repo dest=checkout
tags:
- skip_ansible_lint
```
2020-04-22 11:22:51 -04:00
--------------------------------------------------------------------------------
## 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
- Key : value
dolor : sit,
foo : bar
2020-04-23 08:55:25 -04:00
# 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
2020-04-23 10:39:20 -04:00
- [pylint](https://www.pylint.org/)
2020-04-22 11:22:51 -04:00
### Pylint Config file
2020-04-23 10:39:20 -04:00
- `.github/linters/.python-lint`
- You can pass multiple rules and overwrite default rules
- File should be located at: `.github/linters/.python-lint`
2020-04-22 11:22:51 -04:00
### Pylint disable single line
2020-04-23 10:39:20 -04:00
```python
global VAR # pylint: disable=global-statement
```
2020-04-22 11:22:51 -04:00
### Pylint disable code block
2020-04-23 10:39:20 -04:00
```python
"""pylint option block-disable"""
__revision__ = None
class Foo(object):
"""block-disable test"""
def __init__(self):
pass
def meth1(self, arg):
"""this issues a message"""
print(self)
def meth2(self, arg):
"""and this one not"""
# pylint: disable=unused-argument
print(self\
+ "foo")
def meth3(self):
"""test one line disabling"""
# no error
print(self.baz) # pylint: disable=no-member
2020-04-23 10:39:20 -04:00
# error
print(self.baz)
2020-04-23 10:39:20 -04:00
```
2020-04-22 11:22:51 -04:00
### Pylint disable entire file
2020-04-23 10:39:20 -04:00
```python
#!/bin/python3
# pylint: skip-file
var = "terrible code down here..."
```
2020-04-22 11:22:51 -04:00
--------------------------------------------------------------------------------
## JSON
2020-04-23 10:19:21 -04:00
- [jsonlint](https://github.com/zaach/jsonlint)
2020-04-22 11:22:51 -04:00
### JsonLint Config file
2020-04-23 10:19:21 -04:00
- There is no top level *configuration file* available at this time
2020-04-22 11:22:51 -04:00
### JsonLint disable single line
2020-04-23 10:19:21 -04:00
- There is currently **No** way to disable rules inline of the file(s)
2020-04-22 11:22:51 -04:00
### JsonLint disable code block
2020-04-23 10:19:21 -04:00
- There is currently **No** way to disable rules inline of the file(s)
2020-04-22 11:22:51 -04:00
### JsonLint disable entire file
2020-04-23 10:19:21 -04:00
- There is currently **No** way to disable rules inline of the file(s)
2020-04-22 11:22:51 -04:00
--------------------------------------------------------------------------------
## Markdown
- [markdownlint-cli](https://github.com/igorshubovych/markdownlint-cli#readme)
- [markdownlint rule documentation](https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md)
- [markdownlint inline comment syntax](https://github.com/DavidAnson/markdownlint#configuration)
2020-04-22 11:22:51 -04:00
### 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
2020-04-22 11:22:51 -04:00
```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
2020-04-22 11:22:51 -04:00
```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
2020-04-22 11:22:51 -04:00
- You can encapsulate the entire file with the *code block format* to disable an entire file from being parsed
--------------------------------------------------------------------------------
## Perl
2020-04-23 10:41:00 -04:00
- [perl](https://pkgs.alpinelinux.org/package/edge/main/x86/perl)
2020-04-22 11:22:51 -04:00
### Perl Config file
2020-04-23 10:41:00 -04:00
- There is no top level *configuration file* available at this time
2020-04-22 11:22:51 -04:00
### Perl disable single line
2020-04-23 10:41:00 -04:00
- There is currently **No** way to disable rules inline of the file(s)
2020-04-22 11:22:51 -04:00
### Perl disable code block
2020-04-23 10:41:00 -04:00
- There is currently **No** way to disable rules inline of the file(s)
2020-04-22 11:22:51 -04:00
### Perl disable entire file
2020-04-23 10:41:00 -04:00
- There is currently **No** way to disable rules inline of the file(s)
2020-04-22 11:22:51 -04:00
--------------------------------------------------------------------------------
## 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-06-18 17:29:06 -04:00
- [coffeelint](https://coffeelint.github.io/)
2020-04-23 10:08:38 -04:00
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
--------------------------------------------------------------------------------
2020-04-23 12:18:58 -04:00
## Javascript eslint
2020-04-23 11:38:33 -04:00
- [eslint](https://eslint.org/)
2020-04-22 11:22:51 -04:00
### Javascript eslint Config file
2020-04-23 11:38:33 -04:00
- `.github/linters/.eslintrc.yml`
- You can pass multiple rules and overwrite default rules
- File should be located at: `.github/linters/.eslintrc.yml`
2020-04-22 11:22:51 -04:00
### Javascript eslint disable single line
2020-04-23 11:38:33 -04:00
```javascript
var thing = new Thing(); // eslint-disable-line no-use-before-define
thing.sayHello();
function Thing() {
this.sayHello = function() { console.log("hello"); };
}
```
2020-04-22 11:22:51 -04:00
### Javascript eslint disable code block
2020-04-23 11:38:33 -04:00
```javascript
/*eslint-disable */
//suppress all warnings between comments
alert('foo')
/*eslint-enable */
```
2020-04-22 11:22:51 -04:00
### Javascript eslint disable entire file
2020-04-23 11:38:33 -04:00
- Place at the top of the file:
```javascript
/* eslint-disable */
```
2020-04-22 11:22:51 -04:00
--------------------------------------------------------------------------------
2020-04-23 12:18:58 -04:00
## Javascript standard
2020-04-23 11:38:33 -04:00
- [standard js](https://standardjs.com/)
2020-04-22 11:22:51 -04:00
### Javascript standard Config file
2020-04-23 11:40:18 -04:00
- There is no top level *configuration file* available at this time
2020-04-23 11:38:33 -04:00
2020-04-22 11:22:51 -04:00
### Javascript standard disable single line
2020-04-23 11:40:18 -04:00
- There is currently **No** way to disable rules inline of the file(s)
2020-04-22 11:22:51 -04:00
### Javascript standard disable code block
2020-04-23 11:40:18 -04:00
- There is currently **No** way to disable rules inline of the file(s)
2020-04-22 11:22:51 -04:00
### Javascript standard disable entire file
2020-04-23 11:40:18 -04:00
- There is currently **No** way to disable rules inline of the file(s)
2020-04-22 11:22:51 -04:00
--------------------------------------------------------------------------------
2020-04-23 12:18:58 -04:00
## Typescript eslint
2020-04-23 11:38:33 -04:00
- [eslint](https://eslint.org/)
### Typescript eslint Config file
- `.github/linters/.eslintrc.yml`
- You can pass multiple rules and overwrite default rules
- File should be located at: `.github/linters/.eslintrc.yml`
2020-04-22 11:22:51 -04:00
### Typescript eslint disable single line
2020-04-23 11:38:33 -04:00
```typescript
var thing = new Thing(); // eslint-disable-line no-use-before-define
thing.sayHello();
function Thing() {
this.sayHello = function() { console.log("hello"); };
}
```
2020-04-22 11:22:51 -04:00
### Typescript eslint disable code block
2020-04-23 11:38:33 -04:00
```typescript
/*eslint-disable */
//suppress all warnings between comments
alert('foo')
/*eslint-enable */
```
2020-04-22 11:22:51 -04:00
### Typescript eslint disable entire file
2020-04-23 11:38:33 -04:00
```typescript
/* eslint-disable */
```
2020-04-22 11:22:51 -04:00
--------------------------------------------------------------------------------
2020-04-23 12:18:58 -04:00
## Typescript standard
2020-04-23 11:40:18 -04:00
- [standardjs](https://standardjs.com/)
2020-04-22 11:22:51 -04:00
### Typescript standard Config file
2020-04-23 11:40:18 -04:00
- There is no top level *configuration file* available at this time
2020-04-23 11:38:33 -04:00
2020-04-22 11:22:51 -04:00
### Typescript standard disable single line
2020-04-23 11:40:18 -04:00
- There is currently **No** way to disable rules inline of the file(s)
2020-04-22 11:22:51 -04:00
### Typescript standard disable code block
2020-04-23 11:40:18 -04:00
- There is currently **No** way to disable rules inline of the file(s)
2020-04-22 11:22:51 -04:00
### Typescript standard disable entire file
2020-04-23 11:40:18 -04:00
- There is currently **No** way to disable rules inline of the file(s)
2020-04-22 11:22:51 -04:00
--------------------------------------------------------------------------------
## Golang
2020-04-23 10:11:42 -04:00
- [golangci-lint](https://github.com/golangci/golangci-lint)
2020-04-22 11:22:51 -04:00
### golangci-lint standard Config file
2020-04-23 10:11:42 -04:00
- `.github/linters/.golangci.yml`
- You can pass multiple rules and overwrite default rules
- File should be located at: `.github/linters/.golangci.yml`
2020-04-22 11:22:51 -04:00
### golangci-lint disable single line
2020-04-23 10:11:42 -04:00
- There is currently **No** way to disable rules inline of the file(s)
2020-04-22 11:22:51 -04:00
### golangci-lint disable code block
2020-04-23 10:11:42 -04:00
- There is currently **No** way to disable rules inline of the file(s)
2020-04-22 11:22:51 -04:00
### golangci-lint disable entire file
2020-04-23 10:11:42 -04:00
- There is currently **No** way to disable rules inline of the file(s)
2020-04-22 11:22:51 -04:00
--------------------------------------------------------------------------------
2020-04-23 10:16:33 -04:00
2020-04-22 11:22:51 -04:00
## Dockerfile
2020-06-20 04:42:58 -04:00
- [dockerfilelint](https://github.com/replicatedhq/dockerfilelint.git)
2020-04-23 10:01:15 -04:00
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
2020-04-23 10:16:33 -04:00
- [tflint](https://github.com/terraform-linters/tflint)
2020-04-22 11:22:51 -04:00
### tflint standard Config file
2020-04-23 10:16:33 -04:00
- `.github/linters/.tflint.hcl`
- You can pass multiple rules and overwrite default rules
- File should be located at: `.github/linters/.tflint.hcl`
2020-04-22 11:22:51 -04:00
### tflint disable single line
2020-04-23 10:16:33 -04:00
- There is currently **No** way to disable rules inline of the file(s)
2020-04-22 11:22:51 -04:00
### tflint disable code block
2020-04-23 10:16:33 -04:00
- There is currently **No** way to disable rules inline of the file(s)
2020-04-22 11:22:51 -04:00
### tflint disable entire file
2020-04-23 10:16:33 -04:00
- There is currently **No** way to disable rules inline of the file(s)
2020-04-22 11:22:51 -04:00
--------------------------------------------------------------------------------
## CSS
- [stylelint](https://stylelint.io/)
### stylelint standard Config file
- `.github/linters/.stylelintrc.json`
### stylelint disable single line
```css
#id {
/* stylelint-disable-next-line declaration-no-important */
color: pink !important;
}
```
### stylelint disable code block
```css
/* stylelint-disable */
a {}
/* stylelint-enable */
```
### stylelint disable entire file
- You can disable entire files with the `ignoreFiles` property in `.stylelintrc.json`
```json
{
"ignoreFiles": [
"styles/ignored/wildcards/*.css",
"styles/ignored/specific-file.css"
]
}
```
--------------------------------------------------------------------------------
## ENV
- [dotenv-linter](https://github.com/dotenv-linter/dotenv-linter)
### dotenv-linter Config file
- There is no top level *configuration file* available at this time
### dotenv-linter disable single line
2020-06-19 13:59:06 -04:00
```env
# Comment line will be ignored
```
### dotenv-linter disable code block
- There is currently **No** way to disable rules inline of the file(s)
### dotenv-linter disable entire file
- There is currently **No** way to disable rules inline of the file(s)