
"""This module exports the SlimLint plugin class."""

from SublimeLinter.lint import RubyLinter


class SlimLint(RubyLinter):

    """Provides an interface to slim-lint."""

    syntax = 'ruby slim'
    cmd = 'slim-lint'
    tempfile_suffix = '-'
    config_file = ('--config', '.slim-lint.yml', '~')

    version_args = '--version'
    version_re = r'(?P<version>\d+\.\d+\.\d+)'
    version_requirement = ' >= 0.4.0'

    regex = (
        r'^.+?:(?P<line>\d+) '
        r'(?:(?P<error>\[E\])|(?P<warning>\[W\])) '
        r'(?P<message>[^`]*(?:`(?P<near>.+?)`)?.*)'
    )


"""This module exports the SlimLint plugin class."""

import os
from SublimeLinter.lint import RubyLinter, util


class SlimLint(RubyLinter):

    """Provides an interface to slim-lint."""

    syntax = 'ruby slim'
    cmd = 'slim-lint'
    tempfile_suffix = '-'
    config_file = ('--config', '.slim-lint.yml', '~')

    version_args = '--version'
    version_re = r'(?P<version>\d+\.\d+\.\d+)'
    version_requirement = ' >= 0.4.0'

    regex = (
        r'^.+?:(?P<line>\d+) '
        r'(?:(?P<error>\[E\])|(?P<warning>\[W\])) '
        r'(?P<message>[^`]*(?:`(?P<near>.+?)`)?.*)'
    )

    def build_args(self, settings):
        """
        Return a list of args to add to cls.cmd.

        We hook into this method to find the rubocop config and set it as an
        environment variable for the rubocop linter to pick up.
        """

        if self.filename:
            config = util.find_file(
                os.path.dirname(self.filename),
                '.rubocop.yml',
                aux_dirs='~'
            )
            if config:
                os.environ["RUBOCOP_CONFIG"] = config

        return super().build_args(settings)

Add functionality to find rubocop config
Add functionality to find rubocop config

Once it's found, we set it as an environment variable for the rubocop
linter to pick up.

  
  """This module exports the SlimLint plugin class."""
  
+ import os
- from SublimeLinter.lint import RubyLinter
+ from SublimeLinter.lint import RubyLinter, util
  
  
  class SlimLint(RubyLinter):
  
      """Provides an interface to slim-lint."""
  
      syntax = 'ruby slim'
      cmd = 'slim-lint'
      tempfile_suffix = '-'
      config_file = ('--config', '.slim-lint.yml', '~')
  
      version_args = '--version'
      version_re = r'(?P<version>\d+\.\d+\.\d+)'
      version_requirement = ' >= 0.4.0'
  
      regex = (
          r'^.+?:(?P<line>\d+) '
          r'(?:(?P<error>\[E\])|(?P<warning>\[W\])) '
          r'(?P<message>[^`]*(?:`(?P<near>.+?)`)?.*)'
      )
  
+     def build_args(self, settings):
+         """
+         Return a list of args to add to cls.cmd.
+ 
+         We hook into this method to find the rubocop config and set it as an
+         environment variable for the rubocop linter to pick up.
+         """
+ 
+         if self.filename:
+             config = util.find_file(
+                 os.path.dirname(self.filename),
+                 '.rubocop.yml',
+                 aux_dirs='~'
+             )
+             if config:
+                 os.environ["RUBOCOP_CONFIG"] = config
+ 
+         return super().build_args(settings)
+ 
Add functionality to find rubocop config
## Code Before:

"""This module exports the SlimLint plugin class."""

from SublimeLinter.lint import RubyLinter


class SlimLint(RubyLinter):

    """Provides an interface to slim-lint."""

    syntax = 'ruby slim'
    cmd = 'slim-lint'
    tempfile_suffix = '-'
    config_file = ('--config', '.slim-lint.yml', '~')

    version_args = '--version'
    version_re = r'(?P<version>\d+\.\d+\.\d+)'
    version_requirement = ' >= 0.4.0'

    regex = (
        r'^.+?:(?P<line>\d+) '
        r'(?:(?P<error>\[E\])|(?P<warning>\[W\])) '
        r'(?P<message>[^`]*(?:`(?P<near>.+?)`)?.*)'
    )

## Instruction:
Add functionality to find rubocop config
## Code After:

"""This module exports the SlimLint plugin class."""

import os
from SublimeLinter.lint import RubyLinter, util


class SlimLint(RubyLinter):

    """Provides an interface to slim-lint."""

    syntax = 'ruby slim'
    cmd = 'slim-lint'
    tempfile_suffix = '-'
    config_file = ('--config', '.slim-lint.yml', '~')

    version_args = '--version'
    version_re = r'(?P<version>\d+\.\d+\.\d+)'
    version_requirement = ' >= 0.4.0'

    regex = (
        r'^.+?:(?P<line>\d+) '
        r'(?:(?P<error>\[E\])|(?P<warning>\[W\])) '
        r'(?P<message>[^`]*(?:`(?P<near>.+?)`)?.*)'
    )

    def build_args(self, settings):
        """
        Return a list of args to add to cls.cmd.

        We hook into this method to find the rubocop config and set it as an
        environment variable for the rubocop linter to pick up.
        """

        if self.filename:
            config = util.find_file(
                os.path.dirname(self.filename),
                '.rubocop.yml',
                aux_dirs='~'
            )
            if config:
                os.environ["RUBOCOP_CONFIG"] = config

        return super().build_args(settings)
