Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7410949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:18:41+00:00 2026-05-29T06:18:41+00:00

Our application allows users to upload javascript, CSS, and HTML files. We need a

  • 0

Our application allows users to upload javascript, CSS, and HTML files. We need a way to validate these files against CSS and JS lint, as well as record any errors associated with them (file name, line, etc). This needs to be done “realtime,” or at the least passed off to a delayed job process to work in the background. The requirements won’t allow us to hook into a third-party online service (like the online w3c validator).

I’ve found jshint_on_rails and jslint_on_rails, which seems like they could work. They are reliant on rake tasks, however, and I’m not sure how I would get their output into a database. I have thus far not found anything similar for css lint. Are there packages like this out there that I could hook into?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T06:18:42+00:00Added an answer on May 29, 2026 at 6:18 am

    What I ended up doing was installing the Node.js versions of JSHint and CSSLint, and then calling them through Rails and parsing the output, like so:

      def validate_js(filepath)
        capture_error = false
        filename = get_filename(filepath)
        file_regex = Regexp.new(filepath)
        lint_config = "--config #{Rails.root}/test/validators/jshint.json"
        lint_reporter = "--reporter #{Rails.root}/test/validators/jshint-reporter.js"
    
        IO.popen("jshint #{filepath} #{lint_config} #{lint_reporter}") do |pipe|
    
          pipe.each do |line|
            if line =~ file_regex
              # Error detected
              error_msg = line.split("#{filepath}: ").last.strip
              @js_error = @instance.parse_warnings.new(:filename => filename, :error_type => 'javascript', 
                                                            :error_message => error_msg)
              capture_error = true
            elsif capture_error 
              # The actual line the error is on
              @js_error.error_content = line
              @js_error.save!
    
              capture_error = false
              @js_error = nil # Empty the variable so it isn't hanging around after the last error
            end
          end
        end
      end
    
    
    
    def validate_css(filepath)
        filename = get_filename(filepath)
        dir = File.expand_path(File.dirname(filepath)) # Where we want to dump the results.xml file
    
        system("csslint --format=lint-xml > #{dir}/#{filename}-results.xml #{filepath}") # Call CSSLint
    
        output = LibXML::XML::Parser.file("#{dir}/#{filename}-results.xml")
        doc = output.parse # Iterate over the errors
        doc.find('//issue').each do |issue|
          error_msg = "line #{issue['line']}, col #{issue['char']}, #{issue['reason']}"
          error_content = issue['evidence']
          @instance.parse_warnings.create!(:filename => filename, :error_type => 'css', :error_message => error_msg,
                                                :error_content => error_content)
        end
        FileUtils.rm("#{dir}/#{filename}-results.xml") # No need to keep the xml file around
      end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an asp.net application where the users can upload files to our database.
Our application uses SQL Server Reporting Services and allows users to add custom filters
By default Rails allows users of our application to input non-utf8 data, such as:
I am making an application that allows users to upload a file in a
All, I'm working on an application that allows authorized users to upload Excel spreadsheets
We have created a web application, using ASP.NET, that allows users to upload documents
This problem is a challenging one. Our application allows users to post news on
The question says it all. Our application is currently authenticating users against a database.
I'm about to implement a feature in our application that allows the user to
Our application allows administrators to add User Properties in order for them to be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.