├── .python-version ├── .sublimelinterrc ├── .travis.yml ├── LICENSE ├── README.md ├── linter.py ├── messages.json └── messages ├── 1.0.11.txt ├── 1.0.12.txt ├── 1.0.13.txt ├── 1.1.0.txt ├── 1.1.1.txt └── install.txt /.python-version: -------------------------------------------------------------------------------- 1 | 3.8 2 | -------------------------------------------------------------------------------- /.sublimelinterrc: -------------------------------------------------------------------------------- 1 | { 2 | "linters": { 3 | "flake8": { 4 | "max-line-length": 120 5 | }, 6 | "pep8": { 7 | "max-line-length": 120 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | python: 3 | - "3.3" 4 | # command to install dependencies 5 | install: 6 | - pip install flake8 7 | - pip install pydocstyle 8 | # command to run tests 9 | script: 10 | - flake8 . --max-line-length=120 11 | - pydocstyle . --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-jsxhint 2 | ========================= 3 | 4 | JSXHint has been deprecated. 5 | -------------------------------------------------------------------------------- /linter.py: -------------------------------------------------------------------------------- 1 | # 2 | # linter.py 3 | # Linter for SublimeLinter3, a code checking framework for Sublime Text 3 4 | # 5 | # SublimeLinter-jshint written by Aparajita Fishman 6 | # Copyright (c) 2015-2016 The SublimeLinter Community 7 | # Copyright (c) 2013-2014 Aparajita Fishman 8 | # 9 | # Forked for JSXHint by Samuel Reed (STRML) 10 | # 11 | # License: MIT 12 | # 13 | 14 | """This module exports the JSXHint plugin linter class.""" 15 | 16 | import re 17 | from SublimeLinter.lint import Linter 18 | 19 | 20 | class JSXHint(Linter): 21 | """Provides an interface to the jsxhint executable.""" 22 | 23 | # "javascript 6to5" is now "javascript (babel)", but lets leave 6to5 24 | # for a bit while users migrate 25 | syntax = ('jsx', 'javascript_jsx', 'javascript (jsx)', 'javascript (babel)', 'javascript 6to5') 26 | executable = 'jsxhint' 27 | config_file = ('--config', '.jshintrc', '~') 28 | version_re = r'\bv(?P\d+\.\d+\.\d+)' 29 | version_requirement = '>= 0.4.0' 30 | regex = ( 31 | r'^(?:(?PERROR: .+)|' 32 | r'.+?: line (?P\d+), col (?P\d+), ' 33 | r'(?P' 34 | # undefined warnings 35 | r'\'(?P.+)\'.+(?=.+W098)' 36 | # duplicate key 37 | r'|.+\'(?P.+)\'.+(?=.+W075)' 38 | # camel case 39 | r'|.+\'(?P.+)\'.+(?=.+W106)' 40 | # using later defined 41 | r'|(.+)?\'(?P.+)\'.+(?=.+W003)' 42 | # double declaration 43 | r'|(.+)?\'(?P.+)\'.+(?=.+W004)' 44 | # unexpected use, typically use of non strict operators 45 | r'|.+\'(?P.+)\'\.(?=.+W116)' 46 | # unexpected use of ++ etc 47 | r'|.+\'(?P.+)\'\.(?=.+W016)' 48 | # match all messages 49 | r'|.+)' 50 | # capture error, warning and code 51 | r' \((?:(?PE)|(?PW))(?P\d+)\))' 52 | ) 53 | 54 | def cmd(self): 55 | """Return the command line to execute.""" 56 | command = [self.executable_path, '--verbose', '--filename', '@'] 57 | 58 | return command + ['*', '-'] 59 | 60 | def build_args(self, settings=None): 61 | """Override build_args to allow setting a custom config filename.""" 62 | backup = self.config_file 63 | if 'config_filename' in settings and self.filename: 64 | self.config_file = (self.config_file[0], settings['config_filename'], self.config_file[2]) 65 | 66 | out = super().build_args(settings) 67 | 68 | # Reset the value of config_file so that this can apply per-project. 69 | self.config_file = backup 70 | 71 | return out 72 | 73 | def split_match(self, match): 74 | """ 75 | Return the components of the match. 76 | 77 | We override this to catch linter error messages and return more presise 78 | info used for highlighting. 79 | 80 | """ 81 | # restore word regex to default each iteration 82 | self.word_re = None 83 | 84 | if match: 85 | fail = match.group('fail') 86 | 87 | if fail: 88 | # match, line, col, error, warning, message, near 89 | return match, 0, 0, True, False, fail, None 90 | 91 | # now safe to proceed, no error occured with jshint 92 | error = match.group('error') 93 | warning = match.group('warning') 94 | message = match.group('message') 95 | code = match.group('code') 96 | # force line numbers to be at least 0 97 | # if not they appear at end of file 98 | line = max(int(match.group('line')) - 1, 0) 99 | col = int(match.group('col')) - 1 100 | near = None 101 | 102 | if warning: 103 | # highlight variables used before defined 104 | if code == '003': 105 | near = match.group('late_def') 106 | col -= len(match.group('late_def')) 107 | 108 | # highlight double declared variables 109 | elif code == '004': 110 | near = match.group('double_declare') 111 | col -= len(match.group('double_declare')) 112 | 113 | # now jshint place the column in front, 114 | # and as such we need to change our word matching regex, 115 | # and keep the column info 116 | elif code == '016': 117 | self.word_re = re.compile(r'\+\+|--') 118 | 119 | # mark the duplicate key 120 | elif code == '075' and match.group('duplicate'): 121 | near = match.group('duplicate') 122 | col = None 123 | 124 | # mark the undefined word 125 | elif code == '098' and match.group('undef'): 126 | near = match.group('undef') 127 | col = None 128 | 129 | # mark the no camel case key, cannot use safer method of 130 | # subtracting the length of the match, as the original col info 131 | # from jshint is always column 0, using near instead 132 | elif code == '106': 133 | near = match.group('no_camel') 134 | col = None 135 | 136 | # if we have a operator == or != manually change the column, 137 | # this also handles the warning when curly brackets are required 138 | # near won't work here as we might have multiple ==/!= on a line 139 | elif code == '116': 140 | actual = match.group('actual') 141 | # match the actual result 142 | near = match.group('actual') 143 | 144 | # if a comparison then also change the column 145 | if actual == '!=' or actual == '==': 146 | col -= len(actual) 147 | 148 | return match, line, col, error, warning, message, near 149 | 150 | return match, None, None, None, None, '', None 151 | -------------------------------------------------------------------------------- /messages.json: -------------------------------------------------------------------------------- 1 | { 2 | "install": "messages/install.txt", 3 | "1.0.11": "messages/1.0.11.txt", 4 | "1.0.12": "messages/1.0.12.txt", 5 | "1.0.13": "messages/1.0.13.txt", 6 | "1.1.0": "messages/1.1.0.txt", 7 | "1.1.1": "messages/1.1.1.txt" 8 | } 9 | -------------------------------------------------------------------------------- /messages/1.0.11.txt: -------------------------------------------------------------------------------- 1 | SublimeLinter-jsxhint 1.0.11 2 | ---------------------------- 3 | 4 | The dependency on `STRML/JSXHint` has been removed, as ownership of the name `jsxhint` on npm has been 5 | transferred to the new project. 6 | 7 | You may now get the newest version of `jsxhint` via `npm install -g jsxhint`. 8 | -------------------------------------------------------------------------------- /messages/1.0.12.txt: -------------------------------------------------------------------------------- 1 | SublimeLinter-jsxhint 1.0.12 2 | ---------------------------- 3 | 4 | Fixed off-by-one line numbering error in jsxhint. 5 | 6 | Pulled in the latest changes from SublimeLinter-jshint, allowing more precise error highlighting. 7 | -------------------------------------------------------------------------------- /messages/1.0.13.txt: -------------------------------------------------------------------------------- 1 | SublimeLinter-jsxhint 1.0.13 2 | ---------------------------- 3 | 4 | More precise error location highlighting. 5 | -------------------------------------------------------------------------------- /messages/1.1.0.txt: -------------------------------------------------------------------------------- 1 | SublimeLinter-jsxhint 1.1.0 2 | ---------------------------- 3 | 4 | Added "Javascript 6to5" to syntax target list. 5 | 6 | Removed bundled JSX syntax. Users should install sublime-react or 6to5-sublime packages instead, which are 7 | properly maintained. 8 | 9 | Added `config_filename` option. Set to e.g. `.jsxhintrc` to use a separate config file for jsxhint. 10 | -------------------------------------------------------------------------------- /messages/1.1.1.txt: -------------------------------------------------------------------------------- 1 | SublimeLinter-jsxhint 1.1.1 2 | ---------------------------- 3 | 4 | 6to5 has now been renamed to Babel. 5 | 6 | - Added "javascript (babel)" to syntax target list. 7 | - Updated documentation to reflect 6to5 name change. 8 | -------------------------------------------------------------------------------- /messages/install.txt: -------------------------------------------------------------------------------- 1 | SublimeLinter-jsxhint 2 | ------------------------------- 3 | 4 | This plugin has been deprecated 5 | --------------------------------------------------------------------------------