Skip to content

Commit 574d36e

Browse files
committed
Change --stdin-filename to relative to check by .eslintignore
1 parent d0c526a commit 574d36e

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

Diff for: linter.py

+31-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
"""This module exports the ESLint plugin class."""
1212

13+
import sublime
14+
import os
1315
from SublimeLinter.lint import NodeLinter
1416

1517

@@ -19,7 +21,7 @@ class ESLint(NodeLinter):
1921

2022
syntax = ('javascript', 'html', 'javascriptnext', 'javascript (babel)', 'javascript (jsx)')
2123
npm_name = 'eslint'
22-
cmd = ('eslint', '--format', 'compact', '--stdin', '--stdin-filename', '@')
24+
cmd = ('eslint', '--format', 'compact', '--stdin', '--stdin-filename', '__RELATIVE_TO_FOLDER__')
2325
version_args = '--version'
2426
version_re = r'v(?P<version>\d+\.\d+\.\d+)'
2527
version_requirement = '>= 0.20.0'
@@ -32,3 +34,31 @@ class ESLint(NodeLinter):
3234
selectors = {
3335
'html': 'source.js.embedded.html'
3436
}
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

Comments
 (0)