{"id":13826719,"url":"https://github.com/hostnet/css-sniffer","last_synced_at":"2025-07-09T01:31:13.777Z","repository":{"id":56985925,"uuid":"99217167","full_name":"hostnet/css-sniffer","owner":"hostnet","description":"Static code analyses for CSS and LESS.","archived":true,"fork":false,"pushed_at":"2019-11-11T13:53:54.000Z","size":843,"stargazers_count":10,"open_issues_count":0,"forks_count":2,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-08-04T09:05:44.801Z","etag":null,"topics":["codestyle","css","less","linter","sniffer"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hostnet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-03T09:46:10.000Z","updated_at":"2024-08-04T09:05:44.802Z","dependencies_parsed_at":"2022-08-21T13:20:12.716Z","dependency_job_id":null,"html_url":"https://github.com/hostnet/css-sniffer","commit_stats":null,"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hostnet%2Fcss-sniffer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hostnet%2Fcss-sniffer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hostnet%2Fcss-sniffer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hostnet%2Fcss-sniffer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hostnet","download_url":"https://codeload.github.com/hostnet/css-sniffer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225476383,"owners_count":17480215,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["codestyle","css","less","linter","sniffer"],"created_at":"2024-08-04T09:01:43.133Z","updated_at":"2024-11-20T05:31:01.364Z","avatar_url":"https://github.com/hostnet.png","language":"PHP","readme":"**IMPORTANT:** Due to internal changes this repository will no longer be maintained. If you are using this, or have plans to use this, please consider an alternative like https://stylelint.io/.\n\n----------\n\n\u003cp align=\"center\"\u003e\u003ca href=\"http://www.hostnet.nl\" target=\"_blank\"\u003e\n    \u003cimg width=\"400\" src=\"https://www.hostnet.nl/images/hostnet.svg\"\u003e\n\u003c/a\u003e\u003c/p\u003e\n\nThe CSS sniffer is build to help improve (and maintain) a consistent code style in CSS and LESS files. It will reduce time figure out another style by enforcing rules. So no longer worrying about tabs vs. spaces, single vs. double quotes or 3 of 6 hex values for colors.\n\nThe tool is pretty straight forward, simply run it with the file you would like to inspect. So if you have a css file like so:\n```css\n.good { background-image: url(\"/foo.com\"); }\n.bad { background-image: url('/foo.com'); }\n```\nSimply run the tool and you will get the following output.\n```\n$ vendor/bin/css-sniff sniff quotes.less\n\nFILE: test/Sniff/fixtures/quotes.less\n--------------------------------------------------------------------------------\nFOUND 1 ERROR(S) AFFECTING 1 LINE(S)\n--------------------------------------------------------------------------------\n 2 | Text should use \" as quotes.\n--------------------------------------------------------------------------------\n```\n\u003e Some builtin sniffs are pretty opinionated. If you disagree you have two options: open an issue to change the current behavior or write your own sniff.\n\nInstallation\n------------\n**Using phar (recommended)**\n\nDownload the phar that is attached to the [latest release of the sniffer](https://github.com/hostnet/css-sniffer/releases).\n\n**Using composer**\n\n* `$ composer require --dev hostnet/css-sniffer`\n* This library follows [semantic versioning](http://semver.org/) strictly.\n\nDocumentation\n-------------\nBasic usuage is as follows:\n```\n$ vendor/bin/css-sniff --help\nUsage:\n  sniff [options] [--] [\u003cfiles\u003e]...\n\nArguments:\n  files                      Input file\n\nOptions:\n      --format[=FORMAT]      Type of output format, default: console [default: \"console\"]\n  -s, --standard[=STANDARD]  Code Standard to use, by default the Hostnet standard is used. This is the path to the xml file.\n      --stdin                If given, this option will tell the sniffer to check the STDIN for input.\n  -p, --pretty               Pretty format output\n      --no-exit-code         Always return 0 as exit code, regardless of the result\n  -h, --help                 Display this help message\n  -q, --quiet                Do not output any message\n  -V, --version              Display this application version\n      --ansi                 Force ANSI output\n      --no-ansi              Disable ANSI output\n  -n, --no-interaction       Do not ask any interactive question\n  -v|vv|vvv, --verbose       Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug\n\nHelp:\n  Sniffs the given input file and returns the result.\n```\n\n*Examples*:\n- `vendor/bin/css-sniff`\n- `vendor/bin/css-sniff sniff some/file.css`\n- `vendor/bin/css-sniff sniff --format=json -p some/file.css`\n- `cat some/file.css | vendor/bin/css-sniff sniff --stdin`\n\n### Sniffing for CI\nThe primary focus of the sniffer is to integrate with any CI tooling. For this, it is recommended to add a `csssniff.xml.dist` to your project root. This will allow you to configure which files and directories to process when running the sniffer. A common example would be:\n```xml\n\u003c?xml version=\"1.0\"?\u003e\n\u003ccsssniffer\u003e\n    \u003cdirectory\u003e./app/styles\u003c/directory\u003e\n\n    \u003csniff rel=\"Hostnet\" /\u003e\n\u003c/csssniffer\u003e\n\n```\nThis would process the `app/styles` folder relative from the project root using the `Hostnet` standard. For more information about the xml structure, see [the ruleset configuration documentation](RULESETS.md).\n\n### Output formatting\nMultiple output formats are supported. For now there is `console` (the default), `checkstyle` and `json`. The `json` output looks as follows:\n```\n$ vendor/bin/css-sniff sniff --format=json -p test/Sniff/fixtures/quotes.less\n{\n    \"totals\": {\n        \"errors\": 0\n    },\n    \"files\": {\n        \"test\\/Sniff\\/fixtures\\/quotes.less\": {\n            \"errors\": 3,\n            \"messages\": [\n                {\n                    \"message\": \"One statements found and should be on one line.\",\n                    \"source\": \"Hostnet\\\\Component\\\\CssSniff\\\\Sniff\\\\CurlySniff\",\n                    \"line\": 1,\n                    \"column\": 7\n                },\n                {\n                    \"message\": \"One statements found and should be on one line.\",\n                    \"source\": \"Hostnet\\\\Component\\\\CssSniff\\\\Sniff\\\\CurlySniff\",\n                    \"line\": 4,\n                    \"column\": 6\n                },\n                {\n                    \"message\": \"Text should use \\\" as quotes.\",\n                    \"source\": \"Hostnet\\\\Component\\\\CssSniff\\\\Sniff\\\\QuoteTypeSniff\",\n                    \"line\": 5,\n                    \"column\": 27\n                }\n            ]\n        }\n    }\n}\n\n```\n\u003e The `-p` is only a pretty format, this is optional but more readable.\n\n### `STDIN` input\nThe sniffer can also read from the `STDIN`. This can be usefull when intergrating the tool in an IDE where you might not have a file but want to pass the contents of an editor. Make sure to add the `--stdin` to tell the sniffer to read the `STDIN`. You can also pass a file to allows for you matching rules to work.\n```\n$ cat test/Sniff/fixtures/quotes.less | vendor/bin/css-sniff sniff --format=json -p --stdin test/Sniff/fixtures/quotes.less\n{\n    \"totals\": {\n        \"errors\": 0\n    },\n    \"files\": {\n        \"test\\/Sniff\\/fixtures\\/quotes.less\": {\n            \"errors\": 3,\n            \"messages\": [\n                {\n                    \"message\": \"One statements found and should be on one line.\",\n                    \"source\": \"Hostnet\\\\Component\\\\CssSniff\\\\Sniff\\\\CurlySniff\",\n                    \"line\": 1,\n                    \"column\": 7\n                },\n                {\n                    \"message\": \"One statements found and should be on one line.\",\n                    \"source\": \"Hostnet\\\\Component\\\\CssSniff\\\\Sniff\\\\CurlySniff\",\n                    \"line\": 4,\n                    \"column\": 6\n                },\n                {\n                    \"message\": \"Text should use \\\" as quotes.\",\n                    \"source\": \"Hostnet\\\\Component\\\\CssSniff\\\\Sniff\\\\QuoteTypeSniff\",\n                    \"line\": 5,\n                    \"column\": 27\n                }\n            ]\n        }\n    }\n}\n```\n\nLicense\n-------------\nThe `hostnet/css-sniffer` is licensed under the [MIT License](https://github.com/hostnet/css-sniffer/blob/master/LICENSE), meaning you can reuse the code within proprietary software provided that all copies of the licensed software include a copy of the MIT License terms and the copyright notice.\n\nGet in touch\n------------\n * Our primary contact channel is via IRC: [freenode.net#hostnet](http://webchat.freenode.net/?channels=%23hostnet).\n * Or via our email: opensource@hostnet.nl.\n","funding_links":[],"categories":["\u003ca id=\"7bf0f5839fb2827fdc1b93ae6ac7f53d\"\u003e\u003c/a\u003e工具"],"sub_categories":["\u003ca id=\"32739127f0c38d61b14448c66a797098\"\u003e\u003c/a\u003e嗅探\u0026\u0026Sniff"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhostnet%2Fcss-sniffer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhostnet%2Fcss-sniffer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhostnet%2Fcss-sniffer/lists"}