Using custom linters via the CLI
See original GitHub issueThe README indicates custom linters can be defined via the CLI via the --linters
option, however, from my experience adding custom linters to the lesshintrc
file they must also be enabled. Can you provide an example of custom linter usage via the CLI as it is unclear how to both define and enable the customer linter via the CLI.
Thanks.
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Command Line Interface
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >Custom Linters
Custom Linters ; lsp_json, Produces diagnostics as Language Server Protocol JSON. ; pass_fail, Writes a single file-level diagnostic to stdout . ; regex,...
Read more >New linters | golangci-lint
Some people and organizations may choose to have custom-made linters run as a part of golangci-lint . Typically, these linters can't be open-sourced...
Read more >Using go/analysis to write a custom linter
We're going to write a custom linter using the new go/analysis framework which dramatically speeds up creating new linters.
Read more >Using openapi-cli : custom rules
If you're planning to lint OpenAPI description documents (you should!), always check whether a linter supports adding custom rules.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi, yes! It “should”* be a relatively simple process. Something like following should probably end up in the docs in some form…
First, create a JavaScript file somewhere that looks like one of the linters from lesshint’s
lib/linters
directory.important_rule.js
is a pretty simple starting point.As a custom example, here’s a rule that logs on every declaration:
Given the following file named
test.less
……and a
.lesshintrc
file that enables the rule……if you run the following command* (assuming you’ve run
npm i -g lesshint
)……you should get the following output:
You can then extend the linter to return an array of failures.
*After testing v2.4.0 today, it looks like the
require
logic requires relative to thelesshint
install, not the script calling it. I’ll fix that ASAP. You can get around it by using the absolute paths (C:/Code/my-lesshint-stuff/linter.js
instead of./linter.js
). As per this SO answer you can debug where Node is looking for objects viarequire
.export NODE_DEBUG=module
on *nix;set NODE_DEBUG=module
on Windows.Closing this since it’s better documented now.
@kloots Please give us a shout if you disagree!