예제 #1
0
  def RunEsLintChecks(self, affected_js_files, format="stylish"):
    """Runs lint checks using ESLint. The ESLint rules being applied are defined
       in the .eslintrc.js configuration file.
    """
    os_path = self.input_api.os_path

    # Extract paths to be passed to ESLint.
    affected_js_files_paths = []
    for f in affected_js_files:
      affected_js_files_paths.append(f.AbsoluteLocalPath())

    from os import isatty as os_isatty
    args = ["--color"] if os_isatty(self.input_api.sys.stdout.fileno()) else []
    args += ["--format", format, "--ignore-pattern '!.eslintrc.js'"]
    args += affected_js_files_paths

    import eslint
    output = eslint.Run(os_path=os_path, args=args)

    return [self.output_api.PresubmitError(output)] if output else []
예제 #2
0
    def RunEsLintChecks(self, affected_js_files, format='stylish'):
        """Runs lint checks using ESLint. The ESLint rules being applied are defined
       in the .eslintrc.js configuration file.
    """
        os_path = self.input_api.os_path

        # Extract paths to be passed to ESLint.
        affected_js_files_paths = []
        presubmit_path = self.input_api.PresubmitLocalPath()
        for f in affected_js_files:
            affected_js_files_paths.append(
                os_path.relpath(f.AbsoluteLocalPath(), presubmit_path))

        args = [
            '--color', '--format', format, '--ignore-pattern \'!.eslintrc.js\''
        ]
        args += affected_js_files_paths

        import eslint
        output = eslint.Run(os_path=os_path, args=args)

        return [self.output_api.PresubmitError(output)] if output else []