├── Baidu FE Code Style.sublime-settings ├── bin ├── README.md └── jscs ├── Context.sublime-menu ├── Default.sublime-commands ├── .gitignore ├── LICENSE ├── Main.sublime-menu ├── README.md ├── gsq.py ├── gs.py └── fecs.py /Baidu FE Code Style.sublime-settings: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "fecs_bin": "/usr/local/bin/fecs", 4 | "node_bin": "/usr/local/bin/node" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /bin/README.md: -------------------------------------------------------------------------------- 1 | Webstorm本身有支持jscs插件,这个目录下的`jscs`只是把`fecs`包装了一下,处理Webstorm的调用时候的输入,输出它所需要的格式而已。 2 | 3 | 这么做的目的是减少开发工作,只需要修改一下Webstorm中集成的jscs插件的配置就可以使用`fecs`了。 -------------------------------------------------------------------------------- /Context.sublime-menu: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "fecs_lint", 4 | "command": "fecs_lint", 5 | "caption": "Baidu FE Code Style Linter" 6 | }, 7 | { 8 | "id": "fecs_format", 9 | "command": "fecs_format", 10 | "caption": "Baidu FE Code Style Formatter" 11 | } 12 | ] 13 | -------------------------------------------------------------------------------- /Default.sublime-commands: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "fecs_lint", 4 | "caption": "Baidu FE Code Style Linter", 5 | "command": "fecs_lint" 6 | }, 7 | { 8 | "id": "fecs_format", 9 | "caption": "Baidu FE Code Style Formatter", 10 | "command": "fecs_format" 11 | } 12 | ] 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | 5 | # C extensions 6 | *.so 7 | 8 | # Distribution / packaging 9 | .Python 10 | env/ 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | lib/ 17 | lib64/ 18 | parts/ 19 | sdist/ 20 | var/ 21 | *.egg-info/ 22 | .installed.cfg 23 | *.egg 24 | 25 | # PyInstaller 26 | # Usually these files are written by a python script from a template 27 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 28 | *.manifest 29 | *.spec 30 | 31 | # Installer logs 32 | pip-log.txt 33 | pip-delete-this-directory.txt 34 | 35 | # Unit test / coverage reports 36 | htmlcov/ 37 | .tox/ 38 | .coverage 39 | .cache 40 | nosetests.xml 41 | coverage.xml 42 | 43 | # Translations 44 | *.mo 45 | *.pot 46 | 47 | # Django stuff: 48 | *.log 49 | 50 | # Sphinx documentation 51 | docs/_build/ 52 | 53 | # PyBuilder 54 | target/ 55 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 leeight 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /Main.sublime-menu: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "caption": "Preferences", 4 | "mnemonic": "n", 5 | "id": "preferences", 6 | "children": 7 | [ 8 | { 9 | "caption": "Package Settings", 10 | "mnemonic": "P", 11 | "id": "package-settings", 12 | "children": 13 | [ 14 | { 15 | "caption": "Baidu FE Code Style", 16 | "children": 17 | [ 18 | { 19 | "command": "open_file", 20 | "args": {"file": "${packages}/Baidu FE Code Style/Baidu FE Code Style.sublime-settings"}, 21 | "caption": "Settings – Default" 22 | }, 23 | { 24 | "command": "open_file", 25 | "args": {"file": "${packages}/User/Baidu FE Code Style.sublime-settings"}, 26 | "caption": "Settings – User" 27 | } 28 | ] 29 | } 30 | ] 31 | } 32 | ] 33 | } 34 | ] 35 | -------------------------------------------------------------------------------- /bin/jscs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | /** 3 | * @file jscs.js ~ 2014/11/10 17:13:52 4 | * @author leeight(liyubei@baidu.com) 5 | **/ 6 | // webstorm 调用 bin/jscs 的时候,传递的参数是 7 | // ./jscs -v -r checkstyle --preset google -c \ 8 | // /private/var/folders/py/v52h5mdn4bj5clh12mxmn2240000gn/T/jscs_empty0.jscsrc 9 | // 我们只需要取最后一个即可 10 | var fs = require('fs'); 11 | var args = process.argv; 12 | if (!args.length || !fs.existsSync(args[args.length - 1])) { 13 | process.exit(0); 14 | } 15 | 16 | // fecs --silent --reporter=baidu --format=checkstyle \ 17 | // /Users/leeight/hd/local/WebstormProjects/hello-world/js/plugins.js 18 | var file = args[args.length - 1]; 19 | 20 | var spawn = process.env.comspec ? function(command, args, options) { 21 | var spawn = require('child_process').spawn; 22 | return spawn( 23 | process.env.comspec, 24 | ['/c', command].concat(args), 25 | options 26 | ); 27 | } : function(command, args, options) { 28 | var spawn = require('child_process').spawn; 29 | return spawn(command, args, options); 30 | }; 31 | 32 | var fecs = spawn('fecs', 33 | ['--silent', '--reporter=baidu', '--format=checkstyle', file], 34 | {stdio: 'inherit'}); 35 | fecs.on('close', function() { 36 | // ignore 37 | }); 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | /* vim: set ts=4 sw=4 sts=4 tw=120: */ 47 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Baidu-FE-Code-Style 2 | 3 | Baidu FE Code Style 是一个基于[fecs](https://github.com/ecomfe/fecs)开发的 Sublime Text 2/3 和 WebStorm 插件,目的是方便的验证所写的代码是否符合 [百度前端编码规范](https://github.com/ecomfe/spec) 的要求 4 | 5 | ## Sublime Text 2/3 6 | 7 | ### 安装 8 | 9 | #### 手工安装 10 | 11 | 1. git clone https://github.com/leeight/Baidu-FE-Code-Style.git 12 | 2. 把 'Baidu FE Code Style' 目录放到 13 | 1. OS X: ~/Library/Application Support/Sublime Text 2/Packages 14 | 2. Windows: %APPDATA%\Sublime Text 2\Packages 15 | 3. Linux: ~/.config/sublime-text-2/Packages 16 | 17 | #### 通过Package Control安装 18 | 19 | 输入`Baidu FE Code Style`来进行查询,查询之后安装即可 20 | 21 | ### 配置 22 | 23 | 安装完毕之后,因为 Sublime 无法读取系统的`PATH`环境变量,所以初次使用需要配置一下相关的路径: 24 | 25 | ![fecs-config.png](http://ecma.bdimg.com/adtest/fecs-config-cf2d1959.png) 26 | 27 | 主要配置的内容如下(按照自己系统上的路径填写即可): 28 | 29 | ```javascript 30 | { 31 | "env": { 32 | "fecs_bin": "/usr/local/bin/fecs", 33 | "node_bin": "/usr/local/bin/node" 34 | } 35 | } 36 | ``` 37 | 38 | ### 使用 39 | 40 | 当打开一个`js`文件开始编辑,保存之后会自动调用`fecs`对当前的文件进行验证,如果有 warning 的话,会显示在左侧: 41 | 42 | ![fecs-show.png](http://ecma.bdimg.com/adtest/fecs-show-ba52dc3f.png) 43 | 44 | 点击圆点之后,具体的 warning 信息会显示在底部的状态栏,如果错误信息太多,状态栏显示不全的话,可以通过`Ctrl + ~`调用 Sublime Text 的 Console,里面有更详细的信息。 45 | 46 | ## WebStorm 47 | 48 | ### 安装 49 | 50 | WebStorm默认集成了`jscs`的插件,我们只需要修改一下配置即可使用,首先需要通过`npm i -g fecs`来确保系统中已经安装了`fecs`,然后修改`jscs`的配置: 51 | 52 | ![webstorm-config.png](http://ecma.bdimg.com/adtest/webstorm-config-1bb84ea7.png) 53 | 54 | 主要是修改`JSCS Package`的路径。另外`Configuration file`和`Code style preset`可以随便选择,我们是用不到的(直接忽略了) 55 | 56 | ### 使用 57 | 58 | 配置之后就可以直接使用了,保存之后就会自动验证,效果如下: 59 | 60 | ![webstorm-result.png](http://ecma.bdimg.com/adtest/webstorm-result-c7aab9a3.png) 61 | -------------------------------------------------------------------------------- /gsq.py: -------------------------------------------------------------------------------- 1 | import gs 2 | import sublime 3 | import threading 4 | 5 | DOMAIN = 'GsQ' 6 | 7 | class Launcher(threading.Thread): 8 | def __init__(self, domain, f): 9 | threading.Thread.__init__(self) 10 | self.daemon = True 11 | self.domain = domain 12 | self.f = f 13 | 14 | def run(self): 15 | try: 16 | self.f() 17 | except Exception: 18 | gs.notice(self.domain, gs.traceback()) 19 | 20 | class Runner(threading.Thread): 21 | def __init__(self, domain, f, msg='', set_status=False): 22 | threading.Thread.__init__(self) 23 | self.daemon = True 24 | self.domain = domain 25 | self.f = f 26 | self.msg = msg 27 | self.set_status = set_status 28 | 29 | def run(self): 30 | tid = gs.begin(self.domain, self.msg, self.set_status) 31 | try: 32 | self.f() 33 | except Exception: 34 | gs.notice(self.domain, gs.traceback()) 35 | finally: 36 | gs.end(tid) 37 | 38 | class GsQ(threading.Thread): 39 | def __init__(self, domain): 40 | threading.Thread.__init__(self) 41 | self.daemon = True 42 | self.q = gs.queue.Queue() 43 | self.domain = domain 44 | 45 | def run(self): 46 | while True: 47 | try: 48 | f, msg, set_status = self.q.get() 49 | tid = gs.begin(self.domain, msg, set_status) 50 | 51 | try: 52 | f() 53 | except Exception: 54 | gs.notice(self.domain, gs.traceback()) 55 | except: 56 | pass 57 | 58 | gs.end(tid) 59 | 60 | def dispatch(self, f, msg, set_status=False): 61 | try: 62 | self.q.put((f, msg, set_status)) 63 | except Exception: 64 | gs.notice(self.domain, traceback()) 65 | 66 | try: 67 | m 68 | except: 69 | m = {} 70 | 71 | def dispatch(domain, f, msg='', set_status=False): 72 | global m 73 | 74 | q = m.get(domain, None) 75 | if not (q and q.is_alive()): 76 | q = GsQ(domain) 77 | q.start() 78 | m[domain] = q 79 | 80 | q.dispatch(f, msg, set_status) 81 | 82 | def do(domain, f, msg='', set_status=False): 83 | Runner(domain, f, msg, set_status).start() 84 | 85 | def launch(domain, f): 86 | Launcher(domain, f).start() 87 | -------------------------------------------------------------------------------- /gs.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | import traceback as tbck 4 | import datetime 5 | import threading 6 | 7 | try: 8 | import Queue as queue 9 | except ImportError: 10 | import queue 11 | 12 | import sublime 13 | 14 | PY3K = (sys.version_info[0] == 3) 15 | 16 | def getwd(): 17 | if PY3K: 18 | return os.getcwd() 19 | return os.getcwdu() 20 | 21 | def basedir_or_cwd(fn): 22 | if fn and not fn.startswith('gs.view://'): 23 | return os.path.dirname(fn) 24 | return getwd() 25 | 26 | def sel(view, i=0): 27 | try: 28 | s = view.sel() 29 | if s is not None and i < len(s): 30 | return s[i] 31 | except Exception: 32 | pass 33 | 34 | return sublime.Region(0, 0) 35 | 36 | def apath(fn, cwd=None): 37 | if not os.path.isabs(fn): 38 | if not cwd: 39 | cwd = getwd() 40 | fn = os.path.join(cwd, fn) 41 | return os.path.normcase(os.path.normpath(fn)) 42 | 43 | def traceback(domain='GoSublime'): 44 | return '%s: %s' % (domain, tbck.format_exc()) 45 | 46 | def is_js_source_view(view=None, strict=True): 47 | if view is None: 48 | return False 49 | 50 | # selector_match = view.score_selector(sel(view).begin(), 'source.go') > 0 51 | # if selector_match: 52 | # return True 53 | 54 | # if strict: 55 | # return False 56 | 57 | fn = view.file_name() or '' 58 | return fn.lower().endswith('.js') 59 | 60 | def active_valid_view(win=None, strict=True): 61 | if not win: 62 | win = sublime.active_window() 63 | if win: 64 | view = win.active_view() 65 | if view and is_js_source_view(view, strict): 66 | return view 67 | return None 68 | 69 | def notice(domain, txt): 70 | error(domain, txt) 71 | 72 | def error(domain, txt): 73 | txt = "%s: %s" % (domain, txt) 74 | # log(txt) 75 | # status_message(txt) 76 | 77 | def end(task_id): 78 | with sm_lck: 79 | try: 80 | del(sm_tasks[task_id]) 81 | except: 82 | pass 83 | 84 | def begin(domain, message, set_status=True, cancel=None): 85 | global sm_task_counter 86 | 87 | if message and set_status: 88 | status_message('%s: %s' % (domain, message)) 89 | 90 | with sm_lck: 91 | sm_task_counter += 1 92 | tid = 't%d' % sm_task_counter 93 | sm_tasks[tid] = { 94 | 'start': datetime.datetime.now(), 95 | 'domain': domain, 96 | 'message': message, 97 | 'cancel': cancel, 98 | } 99 | 100 | return tid 101 | 102 | def status_message(s): 103 | global sm_text 104 | global sm_tm 105 | 106 | with sm_lck: 107 | sm_text = s 108 | sm_tm = datetime.datetime.now() 109 | 110 | try: 111 | st2_status_message 112 | except: 113 | sm_lck = threading.Lock() 114 | sm_task_counter = 0 115 | sm_tasks = {} 116 | sm_frame = 0 117 | sm_frames = ( 118 | u'\u25D2', 119 | u'\u25D1', 120 | u'\u25D3', 121 | u'\u25D0' 122 | ) 123 | sm_tm = datetime.datetime.now() 124 | sm_text = '' 125 | sm_set_text = '' 126 | 127 | st2_status_message = sublime.status_message 128 | sublime.status_message = status_message 129 | 130 | DEVNULL = open(os.devnull, 'w') 131 | LOGFILE = DEVNULL 132 | -------------------------------------------------------------------------------- /fecs.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import subprocess 3 | import json 4 | import os 5 | import threading 6 | import copy 7 | 8 | import sublime 9 | import sublime_plugin 10 | 11 | st2 = (sys.version_info[0] == 2) 12 | dist_dir = os.path.dirname(os.path.abspath(__file__)) 13 | sys.path.insert(0, dist_dir) 14 | 15 | import gs 16 | import gsq 17 | 18 | DOMAIN = 'BaiduFECodeStyleLint' 19 | CL_DOMAIN = 'BaiduFECodeStyleCompLint' 20 | CL_DOMAIN_FORMAT = 'BaiduFECodeStyleCompFormat' 21 | 22 | 23 | settings = None 24 | 25 | def plugin_loaded(): 26 | global settings 27 | settings = sublime.load_settings("Baidu FE Code Style.sublime-settings") 28 | 29 | if st2: 30 | plugin_loaded() 31 | 32 | class FileRef(object): 33 | def __init__(self, view, file): 34 | self.view = view 35 | self.state = 0 36 | self.file = file 37 | self.errors = [] 38 | 39 | def highlight_regions(fr): 40 | regions = [] 41 | regions0 = [] 42 | domain0 = DOMAIN+'-zero' 43 | 44 | if len(fr.errors) > 0: 45 | print('\n%s' % fr.file) 46 | else: 47 | print('\n%s\nCongratulations! Everything is OK!' % fr.file) 48 | 49 | for r in fr.errors: 50 | row = r.get('line') or 0 51 | col = r.get('column') or 0 52 | print('%s:%s %s' % (row, col, r.get('message').encode('utf-8'))) 53 | line = fr.view.line(fr.view.text_point(row-1, 0)) 54 | pos = line.begin() + col 55 | if pos >= line.end(): 56 | pos = line.end() 57 | if pos == line.begin(): 58 | regions0.append(sublime.Region(pos, pos)) 59 | else: 60 | regions.append(sublime.Region(pos, pos)) 61 | 62 | if regions: 63 | fr.view.add_regions(DOMAIN, regions, 'comment', 'dot', sublime.DRAW_EMPTY_AS_OVERWRITE) 64 | else: 65 | fr.view.erase_regions(DOMAIN) 66 | 67 | if regions0: 68 | fr.view.add_regions(domain0, regions0, 'comment', 'dot', sublime.HIDDEN) 69 | else: 70 | fr.view.erase_regions(domain0) 71 | 72 | def update_status_message(fr): 73 | sel = gs.sel(fr.view).begin() 74 | row, _ = fr.view.rowcol(sel) 75 | 76 | msg = '' 77 | if len(fr.errors) > 0: 78 | msg = '%s (%d)' % (DOMAIN, len(fr.errors)) 79 | for item in fr.errors: 80 | line = item.get('line') or 0 81 | if line == (row + 1) and item.get('message'): 82 | msg = '%s: %s' % (msg, item.get('message')) 83 | 84 | if fr.state != 0: 85 | msg = u'\u231B %s' % msg 86 | 87 | fr.view.set_status(DOMAIN, msg) 88 | 89 | def highlight(fr): 90 | cleanup(fr.view) 91 | 92 | if fr.state == 1: 93 | fr.state = 0 94 | highlight_regions(fr) 95 | 96 | update_status_message(fr) 97 | 98 | def cleanup(view): 99 | view.set_status(DOMAIN, '') 100 | view.erase_regions(DOMAIN) 101 | view.erase_regions(DOMAIN+'-zero') 102 | 103 | 104 | def ref(fn, validate=True): 105 | with sem: 106 | if validate: 107 | for fn in list(file_refs.keys()): 108 | fr = file_refs[fn] 109 | if not fr.view.window() or fn != fr.view.file_name(): 110 | delref(fn) 111 | return file_refs.get(fn) 112 | 113 | def delref(fn): 114 | with sem: 115 | if fn in file_refs: 116 | del file_refs[fn] 117 | 118 | def do_comp_lint(fn, node_bin, fecs_bin): 119 | global settings, st2 120 | fr = ref(fn, False) 121 | if not fr: 122 | return 123 | 124 | errors = [] 125 | try: 126 | args = [node_bin, fecs_bin, '--silent', '--reporter=baidu', '--format=json', fn] 127 | proc = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) 128 | out, err = proc.communicate() 129 | if len(err.strip()) > 0: 130 | sublime.error_message(err) 131 | return 132 | if st2: 133 | result = json.loads(out) 134 | else: 135 | result = json.loads(out.decode('utf-8')) 136 | if len(result) > 0: 137 | errors = result[0]['errors'] 138 | except Exception as e: 139 | sublime.error_message(str(e)) 140 | return 141 | 142 | def cb(): 143 | fr.errors = errors 144 | fr.state = 1 145 | highlight(fr) 146 | sublime.set_timeout(cb, 0) 147 | 148 | def do_comp_format(fn, stdin, node_bin, fecs_bin): 149 | global settings 150 | fr = ref(fn, False) 151 | if not fr: 152 | return 153 | 154 | formated = '' 155 | try: 156 | args = [node_bin, fecs_bin, 'format', '--stream', '--silent'] 157 | proc = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) 158 | formated, err = proc.communicate(stdin.encode('utf-8')) 159 | if len(err.strip()) > 0: 160 | sublime.error_message(err) 161 | return 162 | except Exception as e: 163 | sublime.error_message(str(e)) 164 | return 165 | 166 | def cb(): 167 | edit = fr.view.begin_edit() 168 | region = sublime.Region(0, fr.view.size()) 169 | fr.view.replace(edit, region, formated.decode('utf-8')) 170 | fr.view.end_edit(edit) 171 | sublime.set_timeout(cb, 0) 172 | 173 | def watch(): 174 | view = sublime.active_window().active_view() 175 | if view is not None: 176 | fn = view.file_name() 177 | if fn and fn.lower().endswith('.js'): 178 | fn = os.path.abspath(fn) 179 | fr = ref(fn, False) 180 | if fr is not None: 181 | update_status_message(fr) 182 | 183 | sublime.set_timeout(watch, 500) 184 | 185 | 186 | def is_valid_settings(): 187 | global settings 188 | env = settings.get('env') 189 | if env is None: 190 | return ('', '', False) 191 | 192 | node_bin = env.get('node_bin') 193 | fecs_bin = env.get('fecs_bin') 194 | is_valid = os.path.exists(node_bin) and os.path.exists(fecs_bin) 195 | 196 | return (node_bin, fecs_bin, is_valid) 197 | 198 | def run_lint(view): 199 | node_bin, fecs_bin, is_valid = is_valid_settings() 200 | if not is_valid: 201 | return 202 | 203 | fn = view.file_name() 204 | if not fn.lower().endswith('.js'): 205 | return 206 | fn = os.path.abspath(fn) 207 | if fn: 208 | file_refs[fn] = FileRef(view, fn) 209 | gsq.dispatch(CL_DOMAIN, lambda: do_comp_lint(fn, node_bin, fecs_bin), '') 210 | 211 | def run_format(view): 212 | node_bin, fecs_bin, is_valid = is_valid_settings() 213 | if not is_valid: 214 | return 215 | 216 | fn = view.file_name() 217 | if not fn.lower().endswith('.js'): 218 | return 219 | fn = os.path.abspath(fn) 220 | if fn: 221 | file_refs[fn] = FileRef(view, fn) 222 | content = view.substr(sublime.Region(0, view.size())) 223 | gsq.dispatch(CL_DOMAIN_FORMAT, lambda: do_comp_format(fn, content, node_bin, fecs_bin), '') 224 | 225 | def is_js_buffer(view): 226 | fName = view.file_name() 227 | vSettings = view.settings() 228 | syntaxPath = vSettings.get('syntax') 229 | syntax = "" 230 | ext = "" 231 | 232 | if (fName != None): # file exists, pull syntax type from extension 233 | ext = os.path.splitext(fName)[1][1:] 234 | if(syntaxPath != None): 235 | syntax = os.path.splitext(syntaxPath)[0].split('/')[-1].lower() 236 | 237 | return ext in ['js', 'json'] or "javascript" in syntax or "json" in syntax 238 | 239 | class FecsLintEvent(sublime_plugin.EventListener): 240 | def on_post_save(self, view): 241 | run_lint(view) 242 | 243 | class FecsLintCommand(sublime_plugin.TextCommand): 244 | def run(self, edit): 245 | run_lint(self.view) 246 | 247 | def is_visible(self): 248 | return is_js_buffer(self.view) 249 | 250 | class FecsFormatCommand(sublime_plugin.TextCommand): 251 | def run(self, edit): 252 | run_format(self.view) 253 | 254 | def is_visible(self): 255 | return is_js_buffer(self.view) 256 | 257 | try: 258 | th 259 | except: 260 | th = None 261 | sem = threading.Semaphore() 262 | file_refs = {} 263 | 264 | watch() 265 | --------------------------------------------------------------------------------