├── .gitignore ├── .sublimelinterrc ├── .travis.yml ├── LICENSE ├── README.md ├── linter.py ├── messages.json └── messages └── install.txt /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /.sublimelinterrc: -------------------------------------------------------------------------------- 1 | { 2 | "@python": 3, 3 | "linters": { 4 | "flake8": { 5 | "max-line-length": 120 6 | }, 7 | "pep257": { 8 | "add-ignore": ["D202"] 9 | }, 10 | "pep8": { 11 | "max-line-length": 120 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | python: 3 | - "3.6" 4 | # command to install dependencies 5 | install: 6 | - pip install flake8 7 | - pip install pep257 8 | # command to run tests 9 | script: 10 | - flake8 . --max-line-length=120 11 | - pep257 . --add-ignore=D202 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Permission is hereby granted, free of charge, to any person obtaining a copy 2 | of this software and associated documentation files (the "Software"), to deal 3 | in the Software without restriction, including without limitation the rights 4 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 5 | copies of the Software, and to permit persons to whom the Software is 6 | furnished to do so, subject to the following conditions: 7 | 8 | The above copyright notice and this permission notice shall be included in 9 | all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | THE SOFTWARE. 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | SublimeLinter-contrib-hadolint 2 | ================================ 3 | 4 | [![Build Status](https://travis-ci.org/niksite/SublimeLinter-contrib-hadolint.svg?branch=master)](https://travis-ci.org/niksite/SublimeLinter-contrib-hadolint) 5 | 6 | This linter plugin for [SublimeLinter][docs] provides an interface to [hadolint](https://github.com/lukasmartinelli/hadolint/). It will be used with files that have the “Dockerfile” syntax. 7 | 8 | ## Installation 9 | SublimeLinter 3 must be installed in order to use this plugin. If SublimeLinter 3 is not installed, please follow the instructions [here][installation]. 10 | 11 | ### Linter installation 12 | Before using this plugin, you must ensure that `hadolint` is installed on your system. To install `hadolint`, just follow instructions from the following: 13 | 14 | https://github.com/lukasmartinelli/hadolint#install 15 | 16 | **Note:** This plugin requires `hadolint` 0.1 or later. 17 | 18 | ### Linter configuration 19 | In order for `hadolint` 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. 20 | 21 | Once you have installed and configured `hadolint`, you can proceed to install the SublimeLinter-contrib-hadolint plugin if it is not yet installed. 22 | 23 | ### Plugin installation 24 | 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. 25 | 26 | To install via Package Control, do the following: 27 | 28 | 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. 29 | 30 | 1. When the plugin list appears, type `hadolint`. Among the entries you should see `SublimeLinter-contrib-hadolint`. If that entry is not highlighted, use the keyboard or mouse to select it. 31 | 32 | ## Settings 33 | 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]. 34 | 35 | ## Contributing 36 | If you would like to contribute enhancements or fixes, please do the following: 37 | 38 | 1. Fork the plugin repository. 39 | 1. Hack on a separate topic branch created from the latest `master`. 40 | 1. Commit and push the topic branch. 41 | 1. Make a pull request. 42 | 1. Be patient. ;-) 43 | 44 | Please note that modifications should follow these coding guidelines: 45 | 46 | - Indent is 4 spaces. 47 | - Code should pass flake8 and pep257 linters. 48 | - Vertical whitespace helps readability, don’t be afraid to use it. 49 | - Please use descriptive variable names, no abbreviations unless they are very well known. 50 | 51 | Thank you for helping out! 52 | 53 | [docs]: http://sublimelinter.readthedocs.org 54 | [installation]: http://sublimelinter.readthedocs.org/en/latest/installation.html 55 | [locating-executables]: http://sublimelinter.readthedocs.org/en/latest/usage.html#how-linter-executables-are-located 56 | [pc]: https://sublime.wbond.net/installation 57 | [cmd]: http://docs.sublimetext.info/en/sublime-text-3/extensibility/command_palette.html 58 | [settings]: http://sublimelinter.readthedocs.org/en/latest/settings.html 59 | [linter-settings]: http://sublimelinter.readthedocs.org/en/latest/linter_settings.html 60 | [inline-settings]: http://sublimelinter.readthedocs.org/en/latest/settings.html#inline-settings 61 | -------------------------------------------------------------------------------- /linter.py: -------------------------------------------------------------------------------- 1 | # 2 | # linter.py 3 | # Linter for SublimeLinter3, a code checking framework for Sublime Text 3 4 | # 5 | # Written by Nikolay Panov 6 | # Copyright (c) 2016 Nikolay Panov 7 | # 8 | # License: MIT 9 | # 10 | 11 | """This module exports the Hadolint plugin class.""" 12 | 13 | from SublimeLinter.lint import Linter, util 14 | 15 | 16 | class Hadolint(Linter): 17 | """Provides an interface to hadolint.""" 18 | 19 | cmd = 'hadolint' 20 | regex = r'(.+)\:(?P[^\s]+) (?P.+)' 21 | multiline = False 22 | line_col_base = (1, 1) 23 | tempfile_suffix = '-' 24 | error_stream = util.STREAM_BOTH 25 | word_re = None 26 | defaults = { 27 | 'selector': 'source.dockerfile' 28 | } 29 | -------------------------------------------------------------------------------- /messages.json: -------------------------------------------------------------------------------- 1 | { 2 | "install": "messages/install.txt" 3 | } 4 | -------------------------------------------------------------------------------- /messages/install.txt: -------------------------------------------------------------------------------- 1 | SublimeLinter-contrib-hadolint 2 | ------------------------------- 3 | This linter plugin for SublimeLinter provides an interface to hadolint. 4 | 5 | ** IMPORTANT! ** 6 | 7 | Before this plugin will activate, you *must* 8 | follow the installation instructions here: 9 | 10 | https://github.com/niksite/SublimeLinter-contrib-hadolint 11 | --------------------------------------------------------------------------------