Skip to content
This repository has been archived by the owner on Jul 27, 2023. It is now read-only.

Support for multiple files at once #41

Open
Mtihc opened this issue Dec 18, 2018 · 0 comments
Open

Support for multiple files at once #41

Mtihc opened this issue Dec 18, 2018 · 0 comments

Comments

@Mtihc
Copy link

Mtihc commented Dec 18, 2018

Is it true that rake eslint:run[filename] can only check one single file at a time?

It would be nice if there was support for checking multiple files at once.
Right now I have solved this by adding a file to my config/initializers/ folder.
The file contains the following code:

require 'eslint-rails'

ESLintRails::Runner.class_eval do
  def initialize(files)
    @files = files.split(' ').map do |file|
      normalize_infile(file)
    end if files.present?
  end

  def assets
    all_js_assets = Rails.application.assets.each_file.to_a.map { |path| Pathname.new(path) }.select do |asset|
      ESLintRails::Runner::JAVASCRIPT_EXTENSIONS.include?(asset.extname)
    end

    assets =
      if @files.present?
        all_js_assets.select { |a| a.in?(@files) }
      else
        all_js_assets
      end

    assets.reject { |a| a.to_s =~ /eslint.js|vendor|gems|min.js|editorial/ }
  end
end

It overrides overwrites the initialize and assets methods.
Now I can do: rake eslint:run["filename1 filename2 filename3"] 👍

But it would be nice if I can do that out-of-the-box.

Thanks for reading.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant