Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pick one of the valid config files #13

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@
from SublimeLinter.lint import NodeLinter


def get_config_file():
"""
Get the valid configuration file, as per the list of configuration files supported by ESLint.

This function iterates through a list of valid file names and check if the file actually exists. If it
does then return its name. If none of the file names exist then return the default value .eslintrc.
Refer: http://eslint.org/docs/user-guide/configuring#configuration-file-formats.
"""

file_names = ['.eslintrc.js', '.eslintrc.yaml', '.eslintrc.yml', '.eslintrc.json', '.eslintrc', 'package.json']
return next((name for name in file_names if os.path.isfile(name)), '.eslintrc')


class Eslint_d(NodeLinter):

"""Provides an interface to eslint_d."""
Expand All @@ -41,7 +54,7 @@ class Eslint_d(NodeLinter):
selectors = {
'html': 'source.js.embedded.html'
}
config_file = ('--config', '.eslintrc', '~')
config_file = ('--config', get_config_file(), '~')

def find_errors(self, output):
"""
Expand Down