Giter Site home page Giter Site logo

Comments (11)

jgable avatar jgable commented on July 30, 2024

I think that's a neat idea. I believe we could add custom rules to CSSLint from within the task. The tricky part is making it configurable in a nice way. As a start, we could just allow you to specify a function that get's passed the plugins reference of CSSLint.

lesslint: {
  all: {
    options: {
      customRules: function (CSSLint) {  CSSLint.addRule(...); }
      // Or, preferably you'd have this in another file
      customRules: require('./grunt/customLessRules.js')
    }
  }
}

Thoughts?

from grunt-lesslint.

cvn avatar cvn commented on July 30, 2024

That would be ideal. This might be obvious, but being able to add multiple functions is desirable.

from grunt-lesslint.

jgable avatar jgable commented on July 30, 2024

Well, your required file could require all your other files that have multiple functions.

from grunt-lesslint.

jgable avatar jgable commented on July 30, 2024

Haven't forgot about this, but won't be able to get to it until next weekend probably.

from grunt-lesslint.

cvn avatar cvn commented on July 30, 2024

Someone has submitted a PR to grunt-contrib-csslint for adding custom rules. It might be helpful as a reference. gruntjs/grunt-contrib-csslint#46

from grunt-lesslint.

davidparsson avatar davidparsson commented on July 30, 2024

Any news on this? If I were to submit a PR that implements this, would that be included and released any time soon?

from grunt-lesslint.

jgable avatar jgable commented on July 30, 2024

Sure, give it a shot and I'll make you an admin on the project if you want.

from grunt-lesslint.

davidparsson avatar davidparsson commented on July 30, 2024

Thanks! I'll see what I can do.

from grunt-lesslint.

davidparsson avatar davidparsson commented on July 30, 2024

I've managed to load rule files with Grunt style globbing patterns, like this:

lesslint:
  options:
    customRules: ['rules/**/*.coffee']
  src: ['less/**/*.less']

I'm however facing trouble when it comes to allowing different customRules configurations for different lesslint targets. This is because CSSLint is a singleton and as far as I can tell it provides no simple way to reset its state.

It would be possible to resolve this using a rather complex solution, but the easiest and least error-prone implementation would be to only allow users to configure the same set of custom rules for all targets. In other words, only allowing customRules under the task's global option block, not under targets' option blocks.

@jgable, what are your thoughts on this? If you have the time, please review my changes so far.

from grunt-lesslint.

jgable avatar jgable commented on July 30, 2024

I took a look today and the changes look good. It's unfortunate we can't remove the specific rules we add in for each configuration section.

I found this issue related to removeRule that points to us being able to pass the explicit rules to the .verify call. It looks like we'd have to refactor our call to verify to always pass the default rules and then custom rule ids of the files matched in the customRules option.

from grunt-lesslint.

davidparsson avatar davidparsson commented on July 30, 2024

Thanks @jgable! The discussion in that issue pointed me in a better direction, which is to disable the unwanted rules by configuration instead of removing them. This is implemented in my PR above.

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.