Skip to content

Commit

Permalink
First commit of yamllint sublime plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasmeeus committed Oct 20, 2017
0 parents commit c41cf2a
Show file tree
Hide file tree
Showing 8 changed files with 162 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
14 changes: 14 additions & 0 deletions .sublimelinterrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"@python": 3,
"linters": {
"flake8": {
"max-line-length": 120
},
"pep257": {
"add-ignore": ["D202"]
},
"pep8": {
"max-line-length": 120
}
}
}
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
language: python
python:
- "3.3"
# command to install dependencies
install:
- pip install flake8
- pip install pydocstyle
# command to run tests
script:
- flake8 . --max-line-length=120
- pydocstyle . --add-ignore=D202
17 changes: 17 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
73 changes: 73 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
SublimeLinter-contrib-yamllint
================================

[![Build Status](https://travis-ci.org/SublimeLinter/SublimeLinter-contrib-yamllint.svg?branch=master)](https://travis-ci.org/SublimeLinter/SublimeLinter-contrib-yamllint)

This linter plugin for [SublimeLinter][docs] provides an interface to [yamllint](__linter_homepage__). It will be used with files that have the “__syntax__” syntax.

## Installation
SublimeLinter 3 must be installed in order to use this plugin. If SublimeLinter 3 is not installed, please follow the instructions [here][installation].

### Linter installation
Before using this plugin, you must ensure that `yamllint` is installed on your system. To install `yamllint`, do the following:

1. Install [Python](http://python.org/download/) and [pip](http://www.pip-installer.org/en/latest/installing.html).

1. Install `yamllint` by typing the following in a terminal:
```
[sudo] pip install yamllint
```


**Note:** This plugin requires `yamllint` __version__ or later.

### Linter configuration
In order for `yamllint` to be executed by SublimeLinter, you must ensure that its path is available to SublimeLinter. Before going any further, please read and follow the steps in [“Finding a linter executable”](http://sublimelinter.readthedocs.org/en/latest/troubleshooting.html#finding-a-linter-executable) through “Validating your PATH” in the documentation.

Once you have installed and configured `yamllint`, you can proceed to install the SublimeLinter-contrib-yamllint plugin if it is not yet installed.

### Plugin installation
Please use [Package Control][pc] to install the linter plugin. This will ensure that the plugin will be updated when new versions are available. If you want to install from source so you can modify the source code, you probably know what you are doing so we won’t cover that here.

To install via Package Control, do the following:

1. Within Sublime Text, bring up the [Command Palette][cmd] and type `install`. Among the commands you should see `Package Control: Install Package`. If that command is not highlighted, use the keyboard or mouse to select it. There will be a pause of a few seconds while Package Control fetches the list of available plugins.

1. When the plugin list appears, type `yamllint`. Among the entries you should see `SublimeLinter-contrib-yamllint`. If that entry is not highlighted, use the keyboard or mouse to select it.

## Settings
For general information on how SublimeLinter works with settings, please see [Settings][settings]. For information on generic linter settings, please see [Linter Settings][linter-settings].

In addition to the standard SublimeLinter settings, SublimeLinter-contrib-yamllint provides its own settings. Those marked as “Inline Setting” or “Inline Override” may also be [used inline][inline-settings].

|Setting|Description|Inline Setting|Inline Override|
|:------|:----------|:------------:|:-------------:|
|foo|Something.|✓| |
|bar|Something else.| |✓|

## Contributing
If you would like to contribute enhancements or fixes, please do the following:

1. Fork the plugin repository.
1. Hack on a separate topic branch created from the latest `master`.
1. Commit and push the topic branch.
1. Make a pull request.
1. Be patient. ;-)

Please note that modifications should follow these coding guidelines:

- Indent is 4 spaces.
- Code should pass flake8 and pep257 linters.
- Vertical whitespace helps readability, don’t be afraid to use it.
- Please use descriptive variable names, no abbreviations unless they are very well known.

Thank you for helping out!

[docs]: http://sublimelinter.readthedocs.org
[installation]: http://sublimelinter.readthedocs.org/en/latest/installation.html
[locating-executables]: http://sublimelinter.readthedocs.org/en/latest/usage.html#how-linter-executables-are-located
[pc]: https://sublime.wbond.net/installation
[cmd]: http://docs.sublimetext.info/en/sublime-text-3/extensibility/command_palette.html
[settings]: http://sublimelinter.readthedocs.org/en/latest/settings.html
[linter-settings]: http://sublimelinter.readthedocs.org/en/latest/linter_settings.html
[inline-settings]: http://sublimelinter.readthedocs.org/en/latest/settings.html#inline-settings
33 changes: 33 additions & 0 deletions linter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#
# linter.py
# Linter for SublimeLinter3, a code checking framework for Sublime Text 3
#
# Written by thomas
# Copyright (c) 2017 Thomas Meeus <[email protected]>
#
# License: MIT
#

"""This module exports the Yamllint plugin class."""

from SublimeLinter.lint import PythonLinter, util


class Yamllint(PythonLinter):
"""Provides an interface to yamllint."""

syntax = ('yml', 'yaml')
cmd = ('yamllint@python', '-f', 'parsable')
executable = None
version_args = '--version'
version_re = r'(?P<version>\d+\.\d+\.\d+)'
version_requirement = '>= 1.9'
regex = (
r'^.+?:(?P<line>\d+):(?P<col>\d+): \[((?P<warning>warning)|(?P<error>error))\] (?P<message>.+)'
)
multiline = True
line_col_base = (1, 1)
tempfile_suffix = '-'
error_stream = util.STREAM_STDOUT
word_re = r'^(".*?"|[-\w]+)'
module = 'yamllint'
3 changes: 3 additions & 0 deletions messages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"install": "messages/install.txt"
}
10 changes: 10 additions & 0 deletions messages/install.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
SublimeLinter-contrib-yamllint
-------------------------------
This linter plugin for SublimeLinter provides an interface to yamllint.

** IMPORTANT! **

Before this plugin will activate, you *must*
follow the installation instructions here:

https://github.com/thomasmeeus/SublimeLinter-contrib-yamllint

0 comments on commit c41cf2a

Please sign in to comment.