Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command line support for rules + addition of resources test + 404 detection #195

Closed
wants to merge 3 commits into from
Closed

Conversation

indieisaconcept
Copy link

Hi all,

Neat tool, the following enhancements for your consideration are based upon some custom tests I run at work as part of our FE code build/release process.

I'm going to be integrating CSSlint as part of our builds so it made sense to retire my tests and extend CSSlint to provide wider test coverage whilst including my refactored tests via a rule.

Enhancements

Command line support for rules

Allow rules to reference the cli.api object and access it's methods. I have added a new method isFile() to allow local resource references to be checked against the file system to see if they exist.

This is particularly useful when you are running CSSlint as part of a CI.

Resources rule

  • Check for external resource references.

Avoid reliance on external resources, localise where appropriate

  • Check for local resources not present in the file system.

Flag all files that do not exist to avoid 404s in a productions environment - keep server admins happy :-). This feature has meant we now only have around 30 problem files out of around 1800.

Cheers,

Jon

- Initial support added to allow 404 detection to be performed against
url properties
- CSSLint now warns if you use non-relative references to resources and
use external instead
- Fixed data uri detection
- Updated test cases
- Fixed node cli isFile
@nzakas
Copy link
Contributor

nzakas commented Oct 17, 2011

Thanks for the pull request. I really like the idea of the CLI checking for the existence of files, but this implementation doesn't follow our pattern of ensuring rules work across all JavaScript environments, including web pages. I'd really like to explore some other ways of accomplishing the same thing, though.

@indieisaconcept
Copy link
Author

Thanks for the feedback.

I had considered as part of the profiling requesting the resource and based on the returned status determine if there is an error but from an efficiency point of view I ruled it out.

It also gets a little tricky when the referenced files are not directly relative. There would have to be an option to specify the base path for a file. It gets even more complicated when the files you want to check are behind a firewall, so it rules out the option of offloading a batch of urls to check to an external web service.

I'll do some further exploration though, thanks again.

@nzakas
Copy link
Contributor

nzakas commented Oct 18, 2011

No problem, would love to figure out a way to get something like this in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants