Comments (11)
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.
That would be ideal. This might be obvious, but being able to add multiple functions is desirable.
from grunt-lesslint.
Well, your required file could require all your other files that have multiple functions.
from grunt-lesslint.
Haven't forgot about this, but won't be able to get to it until next weekend probably.
from grunt-lesslint.
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.
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.
Sure, give it a shot and I'll make you an admin on the project if you want.
from grunt-lesslint.
Thanks! I'll see what I can do.
from grunt-lesslint.
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.
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.
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)
- NPM package should be named 'grunt-contrib-lesslint' HOT 4
- DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead. HOT 1
- Imported files aren't linted HOT 21
- Please read the question from closed issue #53
- Possiblity to mute certain errors? HOT 3
- Getting errors from imports without specifying the imports HOT 7
- Way to rewrite import rules HOT 3
- Comments in .csslintrc HOT 3
- Load options through the .csslintrc file in the current working directory HOT 2
- Import Statement leads to Parse Error HOT 3
- Change to using grunt in js instead of coffee HOT 4
- Update less to 2.5.x? HOT 1
- I can't get lesslint to honor newer HOT 1
- Not Validating HOT 13
- Add support for showing lint warnings HOT 2
- Would like to add imports before parsing HOT 1
- [Question] Dislay multiple errors per file HOT 1
- Update dependencies HOT 1
- Is it possible to ignore lines? HOT 1
- parsing error: Cannot read property 'lineNumber' of undefined HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grunt-lesslint.