Add formatter option to add custom formatters using the CLI #593

Open
wants to merge 1 commit into
from

Projects

None yet

5 participants

@SimenB
SimenB commented Apr 28, 2015

I haven't written any tests in case you are not interested in this.

The use case is to provide formatters over npm, instead of maintaining them within CSSLint core.

Usage:
image

I'm currently trying to throw together a custom reporter (based on jshint-stylish), which is the one used in the SS. If I could publish it to npm, it's release-cycle is not dependent on this.

The format of the formatter-options is just a path (relative to where csslint is called) than can be required, and resolves into a formatter.

EDIT: I published the formatter on npm. https://www.npmjs.com/package/csslint-stylish

npm i csslint-stylish, and then the command in the Screenshot should work to use the formatter from npm. npm link would make the node call cleaner, but meh

@SimenB SimenB changed the title from Try to require unknown formatters if running Node to Add formatter option to CLI, to add formatter using the CLI Apr 29, 2015
@SimenB SimenB commented on the diff Apr 29, 2015
src/cli/common.js
@@ -222,6 +223,17 @@ function cli(api){
api.print("csslint: No files specified.");
exitCode = 1;
} else {
+ if (api.isNode && options.formatter) {
+ /*jshint node:true */
+ var path = require("path");
+ var fullPath = path.resolve(process.cwd(), options.formatter);
+
+ var customFormatter = require(fullPath);
@SimenB
SimenB Apr 29, 2015

This line could throw exception. Catch it and return exitcode = 1?

@SimenB SimenB changed the title from Add formatter option to CLI, to add formatter using the CLI to Add formatter option to add custom formatters using the CLI Apr 29, 2015
@ideadapt

I like this feature. Would be nice to have this merged :)

@SimenB
SimenB commented Mar 1, 2016

@frvge @XhmikosR Thoughts on this?

@XhmikosR
Member
XhmikosR commented Apr 8, 2016

I guess it's OK having such a feature, but we need more people to help with the development.

@SimenB
SimenB commented Jul 28, 2016

@XhmikosR what do you mean, "more people"? This thing is really just exposing part of the programmatic API through the CLI. It's missing tests, I know, could probably write them if you want (unsure how you test the CLI itself)

@mbejda
mbejda commented Sep 21, 2016

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment