10
10
11
11
"""This module exports the ESLint plugin class."""
12
12
13
+ import sublime
14
+ import os
13
15
from SublimeLinter .lint import NodeLinter
14
16
15
17
@@ -19,7 +21,7 @@ class ESLint(NodeLinter):
19
21
20
22
syntax = ('javascript' , 'html' , 'javascriptnext' , 'javascript (babel)' , 'javascript (jsx)' )
21
23
npm_name = 'eslint'
22
- cmd = ('eslint' , '--format' , 'compact' , '--stdin' , '--stdin-filename' , '@ ' )
24
+ cmd = ('eslint' , '--format' , 'compact' , '--stdin' , '--stdin-filename' , '__RELATIVE_TO_FOLDER__ ' )
23
25
version_args = '--version'
24
26
version_re = r'v(?P<version>\d+\.\d+\.\d+)'
25
27
version_requirement = '>= 0.20.0'
@@ -32,3 +34,31 @@ class ESLint(NodeLinter):
32
34
selectors = {
33
35
'html' : 'source.js.embedded.html'
34
36
}
37
+
38
+ def split_match (self , match ):
39
+ """
40
+ Extract and return values from match.
41
+
42
+ We override this method to silent warning by .eslintignore settings.
43
+
44
+ """
45
+
46
+ match , line , col , error , warning , message , near = super ().split_match (match )
47
+ if message and message == 'File ignored because of your .eslintignore file. Use --no-ignore to override.' :
48
+ return match , None , None , None , None , '' , None
49
+
50
+ return match , line , col , error , warning , message , near
51
+
52
+ def communicate (self , cmd , code = None ):
53
+ """Run an external executable using stdin to pass code and return its output."""
54
+
55
+ window = self .view .window ()
56
+ vars = window .extract_variables ()
57
+ relfilename = os .path .relpath (self .filename , vars ['folder' ])
58
+
59
+ if '__RELATIVE_TO_FOLDER__' in cmd :
60
+ cmd [cmd .index ('__RELATIVE_TO_FOLDER__' )] = relfilename
61
+ elif not code :
62
+ cmd .append (self .filename )
63
+
64
+ return super ().communicate (cmd , code )
0 commit comments