├── .travis.yml ├── .gitignore ├── messages.json ├── .sublimelinterrc ├── messages └── install.txt ├── LICENSE ├── linter.py └── README.md /.travis.yml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /messages.json: -------------------------------------------------------------------------------- 1 | { 2 | "install": "messages/install.txt" 3 | } 4 | -------------------------------------------------------------------------------- /.sublimelinterrc: -------------------------------------------------------------------------------- 1 | { 2 | "@python": 3, 3 | "linters": { 4 | "flake8": { 5 | "max-line-length": 120 6 | }, 7 | "pep257": { 8 | "ignore": ["D202"] 9 | }, 10 | "pep8": { 11 | "max-line-length": 120 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /messages/install.txt: -------------------------------------------------------------------------------- 1 | SublimeLinter-contrib-dockerfilelint 2 | ------------------------------- 3 | This linter plugin for SublimeLinter provides an interface to dockerfilelint. 4 | 5 | ** IMPORTANT! ** 6 | 7 | Before this plugin will activate, you *must* 8 | follow the installation instructions here: 9 | 10 | https://github.com/prog1dev/SublimeLinter-contrib-dockerfilelint 11 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /linter.py: -------------------------------------------------------------------------------- 1 | # 2 | # linter.py 3 | # Linter for SublimeLinter3, a code checking framework for Sublime Text 3 4 | # 5 | # Written by Ivan Filenko 6 | # Copyright (c) 2017 Ivan Filenko 7 | # 8 | # License: MIT 9 | # 10 | 11 | """This module exports the Dockerfilelint plugin class.""" 12 | 13 | import json 14 | from SublimeLinter.lint import Linter, util 15 | 16 | 17 | class Dockerfilelint(Linter): 18 | """Provides an interface to dockerfilelint.""" 19 | 20 | syntax = 'dockerfile' 21 | cmd = 'dockerfilelint --json' 22 | executable = 'dockerfilelint' 23 | version_args = '--version' 24 | version_re = r'(?P\d+\.\d+\.\d+)' 25 | version_requirement = '>= 1.4.0' 26 | config_file = ('.dockerfilelintrc', '~') 27 | 28 | # The following regex parses text in format :::\n 29 | # 30 | # Possible Bug & Deprecation marked as errors 31 | # 32 | # Optimization & Clarity marked as warnings 33 | 34 | regex = ( 35 | r'^.+?:(?P\d+):' 36 | r'(?:(?PPossible Bug|Deprecation|)|(?POptimization|Clarity|)):' 37 | r'(?P.+)$\r?\n' 38 | ) 39 | multiline = True 40 | error_stream = util.STREAM_STDOUT 41 | selectors = {} 42 | defaults = {} 43 | 44 | def run(self, cmd, code): 45 | output = super().run(cmd, code) 46 | return self.format(output) 47 | 48 | def format(self, output): 49 | """Formats json output to text :::\n""" 50 | 51 | json_output = json.loads(output) 52 | formatted_lines = [] 53 | 54 | for issue in json_output['files'][0]['issues']: 55 | file = json_output['files'][0]['file'] 56 | line = issue['line'] 57 | error = issue['category'] 58 | message = issue['description'] 59 | 60 | formatted_lines.append(''.join([file, ':', line, ':', error, ':', message, "\n"])) 61 | 62 | return ''.join(formatted_lines) 63 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | SublimeLinter-contrib-dockerfilelint 2 | ========================= 3 | 4 | This linter plugin for [SublimeLinter](http://sublimelinter.readthedocs.org) provides an interface to [dockerfilelint](https://www.npmjs.com/package/dockerfilelint). It will be used with files that have the “Dockerfile” syntax. 5 | 6 | ## Installation 7 | SublimeLinter 3 must be installed in order to use this plugin. If SublimeLinter 3 is not installed, please follow the instructions [here](http://sublimelinter.readthedocs.org/en/latest/installation.html). 8 | 9 | ### Linter installation 10 | Before installing this plugin, you must ensure that `dockerfilelint` is installed on your system. To install `dockerfilelint`, do the following: 11 | 12 | 1. Install [Node.js](http://nodejs.org) (and [npm](https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager) on Linux). 13 | 14 | 2. Install `dockerfilelint` by typing the following in a terminal: 15 | ``` 16 | npm install -g dockerfilelint@">=1.4.0" 17 | ``` 18 | 19 | 3. If you are using `nvm` and `zsh`, ensure that the line to load `nvm` is in `.zshenv` or `.zprofile` and not `.zshrc`.(reason: [here](http://www.sublimelinter.com/en/latest/installation.html) and [here](https://github.com/SublimeLinter/SublimeLinter3/issues/128)) 20 | 21 | **Note:** This plugin requires `dockerfilelint` 1.4.0 or later. 22 | 23 | ### Linter configuration 24 | In order for `dockerfilelint` 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”](http://www.sublimelinter.com/en/latest/troubleshooting.html#validating-your-path) in the documentation. 25 | 26 | Once `dockerfilelint` is installed and configured, you can proceed to install the SublimeLinter-contrib-dockerfilelint plugin if it is not yet installed. 27 | 28 | ### Plugin installation 29 | Please use [Package Control](https://sublime.wbond.net/installation) 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. 30 | 31 | To install via Package Control, do the following: 32 | 33 | 1. Within Sublime Text, bring up the [Command Palette](http://docs.sublimetext.info/en/sublime-text-3/extensibility/command_palette.html) 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. 34 | 35 | 1. When the plugin list appears, type `dockerfilelint`. Among the entries you should see `SublimeLinter-contrib-dockerfilelint`. If that entry is not highlighted, use the keyboard or mouse to select it. 36 | 37 | ## Settings 38 | For general information on how SublimeLinter works with settings, please see [Settings](http://sublimelinter.readthedocs.org/en/latest/settings.html). For information on generic linter settings, please see [Linter Settings](http://sublimelinter.readthedocs.org/en/latest/linter_settings.html). 39 | 40 | You can configure `dockerfilelint` options in the way you would from the command line, with `.dockerfilelintrc` file. For more information, see the [dockerfilelint configuring section](https://www.npmjs.com/package/dockerfilelint#configuring). The linter plugin does this by searching for a `.dockerfilelintrc` file itself, just as `dockerfilelint` does from the command line. 41 | 42 | The path to the `.dockerfilelintrc` file is cached, meaning if you create a new `.dockerfilelintrc` that should have precedence over the previous one. You need to clear the cache for the linter to use the new `.dockerfilelintrc`. You can clear the cache by going to: Tools > SublimeLinter > Clear Caches. 43 | 44 | ## Contributing 45 | If you would like to contribute enhancements or fixes, please do the following: 46 | 47 | 1. Fork the plugin repository. 48 | 2. Hack on a separate topic branch created from the latest `master`. 49 | 3. Commit and push the topic branch. 50 | 4. Make a pull request. 51 | 5. Be patient. ;-) 52 | 53 | Please note that modications should follow these coding guidelines: 54 | 55 | - Indent is 4 spaces. 56 | - Code should pass flake8 and pep257 linters. 57 | - Vertical whitespace helps readability, don’t be afraid to use it. 58 | 59 | Thank you for helping out! 60 | --------------------------------------------------------------------------------