I'm creating a custom linting rule in lesshint.
I want to access the filename of the file being walked.
Current code:
module.exports = {
name: 'customrule',
nodeTypes: ['decl'],
lint: function(config, node) {
console.log(node.root().source.input.from);
}
};
node.root().source.input.from
config
Lead maintainer of lesshint
here.
I've just pushed an update where the full file path will be included on all nodes. You can access it via the source
property, like this:
module.exports = {
name: 'customrule',
nodeTypes: ['decl'],
lint: function(config, node) {
console.log(node.source.input.file)
}
};
The value of config
will be the value you specified for it in your .lesshintrc
file. For example:
{
"customrule": {
"enabled": true,
"option": false
}
}
Will pass that object in config
.
Link to the newly released version: https://github.com/lesshint/lesshint/releases/tag/v4.6.2