This assumes you have installed ansible-lint.
Lint a playbook (yaml file)
Let's say you have a playbook named foo.yml that contains the following markup.
- hosts: all
msg: "Hello World"
Here is how to use the ansible-lint command to lint the foo.yml playbook.
Let's say the following output is displayed.
 Trailing whitespace
This means there is one or more whitespaces after the line hosts:all.
If the ansible-line command does not produce any output, then this means there were no issues detected with the playbook by the ansible-line command.
Lint a role
Let's say you have the following role directory.
Here is how to lint the YAML files below the "bar" roles directory.