Giter Site home page Giter Site logo

Comments (8)

jgable avatar jgable commented on July 30, 2024

Hmm... are your imported files not run through less lint as well? Wouldn't they fail upstream or downstream?

from grunt-lesslint.

cvn avatar cvn commented on July 30, 2024

Our architecture is that we have one main less files with a bunch of partials that get imported. It's not practical to lint the partials themselves because they use variables from a separate partial, and cause false positives about missing variables.

So we only lint the main file, and add the partials directory to the imports: [] config. Without caching, this works very well, including giving us accurate line numbers for linting errors in the partials. With caching on, it will ignore changes in the partials if there is no change in the main less file, and will miss any linting errors that are introduced after the cache is primed.

from grunt-lesslint.

jgable avatar jgable commented on July 30, 2024

So, essentially we'd have to change the cache key of the file from just that files contents to its contents and any imports contents. I'll investigate and see what the impact is on speed.

from grunt-lesslint.

jgable avatar jgable commented on July 30, 2024

This is proving to be tricky, I can build a naive solution that just parses the less into css every time and then uses the css as a cache key but that doesn't really improve performance as much as now because the less parsing is what we're trying to avoid.

Ideally, I think we'd do a regex match for import statements, grab their file contents (keep the file contents around for later lookups from other less that import it), add all the contents together as hash key.

The problems I foresee with this are relative path resolution vs passing in less options with import lookup paths.

I'm going to punt for now and probably push up something that parses every time since there is a risk of false positive cache hits right now.

from grunt-lesslint.

cvn avatar cvn commented on July 30, 2024

Your idea sounds good, but I can imagine how it would be tricky. To start with, you'd have to recursively regex match all @import'ed less files for more @imports to build a complete set for hashing, right?

What about this: Read the less imports: [] option and hash the complete result set. Then compare that hash every time. It wouldn't have awareness of what files were used by the primary less files, and as a result would invalidate the cache when unrelated files changed, but it would eliminate false positive cache hits and still make things quicker for people doing most of their work in their primary less files instead of in their partials. This would only be necessary when the imports: [] array is non-empty, of course.

from grunt-lesslint.

jgable avatar jgable commented on July 30, 2024

@cvn just to update on this, plan to go with your strategy of hashing the imports: [] (and possibly caching the hash based on all the names of the import globbed files). Don't really have an ETA but if I can find time today I'll do it.

from grunt-lesslint.

jgable avatar jgable commented on July 30, 2024

The intermediate fix has landed in 0.19.0.

from grunt-lesslint.

cvn avatar cvn commented on July 30, 2024

Very cool. Thanks, @jgable

from grunt-lesslint.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.