csstree / validator

CSS validator based on CSSTree
MIT License
65 stars 14 forks source link

Browser support #11

Closed streamich closed 3 years ago

streamich commented 6 years ago

Can this lib be used in a browser?

lahmatiy commented 6 years ago

Nope, at the monent, since it uses fs module. What a use case do you have?

streamich commented 6 years ago

I want to create an addon for nano-css that in dev mode would automatically validate CSS and inform developer. Is there a lib you could recommend for that?

lahmatiy commented 6 years ago

This module is a wrapper for CSSTree. You can use it for your purposes like that module does.

revelt commented 4 years ago

What if we separated CLI from the core (function which takes string and outputs array of zero or more error plain objects), then tapped that core in CLI, plus published the core using Rollup in CJS, ES Modules and UMD formats? Theoretically, people would be able to access that UMD build via browsers, maybe even straight from npm CDN's (for example, <script src="https://cdn.jsdelivr.net/npm/email-comb/dist/email-comb.umd.js"></script> of mine).

Another problem with this CLI being bundled is that when I consume this package, my Rollup complains about path and fs dependencies — but I don't even use them via validateString()! It's the bundled CLI that uses them, basically, all I need is validateString().

errors

The benefit of this program is that it sugar-coats the AST traversal from people — which can cause brain haemorrhages for junior developers. Conceptually, it's genius: a function with string-in, array of zero or more error objects out.

It's just Rollup is needed and CLI must be separated.