{"id":20464939,"url":"https://github.com/stylus/stlint","last_synced_at":"2025-04-13T08:42:40.854Z","repository":{"id":34299730,"uuid":"175251456","full_name":"stylus/stlint","owner":"stylus","description":"Stylus Linter","archived":false,"fork":false,"pushed_at":"2023-01-07T03:45:33.000Z","size":2507,"stargazers_count":26,"open_issues_count":23,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-27T00:22:00.654Z","etag":null,"topics":["cli","linter","stylus"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/stylus.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":"2019-03-12T16:14:15.000Z","updated_at":"2025-01-14T16:49:55.000Z","dependencies_parsed_at":"2023-01-15T06:04:59.973Z","dependency_job_id":null,"html_url":"https://github.com/stylus/stlint","commit_stats":null,"previous_names":[],"tags_count":64,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stylus%2Fstlint","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stylus%2Fstlint/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stylus%2Fstlint/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stylus%2Fstlint/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stylus","download_url":"https://codeload.github.com/stylus/stlint/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248687528,"owners_count":21145727,"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":["cli","linter","stylus"],"created_at":"2024-11-15T13:16:51.800Z","updated_at":"2025-04-13T08:42:40.831Z","avatar_url":"https://github.com/stylus.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Stylus Linter\n[![Build Status](https://travis-ci.org/stylus/stlint.svg?branch=master)](https://travis-ci.org/stylus/stlint)\n[![NPM version](https://img.shields.io/npm/v/stlint.svg)](https://www.npmjs.org/package/stlint)\n[![NPM Downloads](https://img.shields.io/npm/dm/stlint.svg)](https://npmcharts.com/compare/stlint?minimal=true)\n\n[![NPM](https://nodei.co/npm/stlint.png?downloads=true\u0026downloadRank=true\u0026stars=true)](https://nodei.co/npm/stlint/)\n\n* [Issues](https://github.com/stylus/stlint/issues)\n* [Installation](#installation)\n* [Example cli Usage](#example-cli-usage)\n* [CLI](#cli)\n* [Non CLI Usage](#non-cli-usage)\n* [As Part of Your Workflow](#as-part-of-your-workflow)\n* [Ignore errors](#ignore-errors)\n* [Rules](#rules)\n* [License](#license)\n\n## Installation\n\nAs part of your project\n```bash\nnpm i stlint -D\n```\n\nAs a cli tool:\n```bash\nnpm install stlint -g\n```\n\n## Example cli Usage:\n`npx stlint` Run stlint on cwd\n\n`stlint` Run stlint on cwd as global\n\n`stlint path/to/filename.styl` Run stlint on a file\n\n`stlint path/to/dir --watch` Watch dir, run stlint on file change\n\n`stlint --help` Get list of commands\n\n`stlint --version` Get version number\n\n`stlint --config path/to/config/.configrc` Run stlint with custom config settings\n\n`stlint styl/ --watch -c path/to/config/.configrc` Watch dir, use custom config\n\n`stlint --command autocomplete --content #e --offset 0 --lineoffset 0` Get autocomplete suggestions for `#` string\n\n## CLI\n`-h` or `--help`    Display list of commands\n\n`-w` or `--watch`   Watch file or directory and run lint on change\n\n`-c` or `--config`  Pass in location of custom config file\n\n`-v` or `--version` Display current version\n\n`-g` or `--grep` Only run rules matching this string or regexp\n\n`-f` or `--fix` Try fix some issues\n\n`-i` or `--info` Show info about version and config (can be used with --grep for filter rules)\n\n`-r` or `--reporter` Reporter \"raw\", \"json\" or \"silent\"\n\nAll another options from [config](#Config file)\n\n## Non CLI Usage\n```javascript\nconst StylusLinter = require('stlint').StylusLinter;\nStylusLinter('path/to/stylus/', {\n  watch: true\n});\n```\nor check only one file or text\n```javascript\nconst Linter = require('stlint').Linter;\nconst linter = new Linter({\n  ...options\n});\n\n// if you want check content\nlinter.lint('./test.styl', 'content');\n\n// if you want check file\nlinter.lint('./test.styl');\n\n// and display errors.\nlinter.display();\n```\n\n## Config file\nCreate `.stlintrc` file in project root\n```json\n{\n  \"reporter\": \"raw\",\n  \"watch\": false,\n  \"extends\": [\"stlint-v4fire\", \"./test/.myfileconfig.json\"],\n  \"extraRules\": \"./my-rules/\",\n  \"rules\": {\n    \"color\": false,\n    \"colons\": [\"always\"],\n    \"depthControl\": {\n      \"indentPref\": 4\n    }\n  },\n  \"path\": \"./src\",\n  \"excludes\": [\"node_modules/\"],\n  \"stylusParserOptions\": {},\n  \"reportOptions\": {\n    \"columnSplitter\": \" | \",\n    \"maxWidth\": 70,\n    \"minWidth\": 70,\n    \"truncate\": false\n  }\n}\n```\n## As Part of Your Workflow\nStlint integrations with IDEs are available.\n\n* [WebStorm / PhpStorm / IntelliJ IDEA](https://github.com/stylus/stlint-idea-plugin)\n* [VSCode](https://marketplace.visualstudio.com/items?itemName=xdan.stlint-vscode-plugin)\n\n## Ignore errors\nsometimes you want to ignore the error for this there are two directives:\n* `@stlint-ignore` - ignores only one line after it\n* `@stlint-disable` `@stlint-enable` - ignore block (@stlint-enable is optional)\n\nFor example, in the following code, some errors will be ignored.\n```stylus\n$p = {\n  a: #CCC\n  // @stlint-ignore\n  b: #ccc // need use uppercase notation will be ignored\n  c: 10px\n}\n.test\n  margin-top 20px\n  // @stlint-disable\n  padding-top 20px  // need use mixin will be ignored\n  color #ccc        // need use uppercase notation and use variable will be ignored\n  // @stlint-enable\n  background-color #ddd\n```\n\nRespectively, in order not to display errors of the entire file, it is enough to add an\n`@stlint-disable` directive to its beginning\n\n```stylus\n// @stlint-disable - all errors below will be ignored\n$p = {\n  a: #CCC\n  b: #ccc\n  c: 10px\n}\n.test\n  margin-top 20px\n  padding-top 20px\n  color #ccc\n  background-color #ddd\n```\n\n## Rules\n\u003c!-- RULES START --\u003e\n\n### brackets\nCheck for brackets\n\n**Default value**\n```json\n[\n  \"never\"\n]\n```\n----\n\n### colons\nUse/Do not use colons after property\n\n**Default value**\n```json\n[\n  \"never\"\n]\n```\n----\n\n### color\nProcess all color values. Allow or deny use it not in variable and use uppercase or lowercase statements\nFor example this code has error - because we use only color in `uppercase`\n```stylus\n.test\n  color #ccc\n```\nIf `allowOnlyInVar` === true code above also has error - no use color without variable\n\nFixed code\n```stylus\n$color = #CCC\n.test\n  color $color\n```\n\n**Default value**\n```json\n{\n  \"conf\": \"uppercase\",\n  \"enabled\": true,\n  \"allowOnlyInVar\": true,\n  \"allowShortcut\": true,\n  \"denyRGB\": true\n}\n```\n----\n\n### commaInObject\nAllow or deny commas in object hash\n\n**Default value**\n```json\n[\n  \"never\"\n]\n```\n----\n\n### depthControl\nControl depth spaces or tab\n\n**Default value**\n```json\n{\n  \"indentPref\": \"tab\"\n}\n```\n----\n\n### emptyLines\nCheck if document has several empty lines\n\n**Default value**\n```json\ntrue\n```\n----\n\n### leadingZero\nCheck for leading 0 on numbers ( 0.5 )\n\n**Default value**\n```json\n[\n  \"always\"\n]\n```\n----\n\n### mixedSpaces\ncheck for mixed spaces and tabs\n\n**Default value**\n```json\n{\n  \"indentPref\": \"tab\"\n}\n```\n----\n\n### prefixVarsWithDollar\nCheck that $ is used when declaring vars\n\n**Default value**\n```json\n{\n  \"conf\": \"always\",\n  \"prefix\": \"$\",\n  \"allowConst\": true\n}\n```\n----\n\n### quotePref\nCheck that quote style is consistent with config\n\n**Default value**\n```json\n[\n  \"double\"\n]\n```\n----\n\n### semicolons\nCheck that selector properties are sorted accordingly\n\n**Default value**\n```json\n[\n  \"never\"\n]\n```\n----\n\n### sortOrder\nRule for checking properties order. Can use alphabetical order or order from grouped array\n\n**Default value**\n```json\n{\n  \"conf\": \"grouped\",\n  \"startGroupChecking\": 6,\n  \"order\": [\n    [\n      \"absolute\",\n      \"position\",\n      \"z-index\",\n      \"top\",\n      \"right\",\n      \"bottom\",\n      \"left\"\n    ],\n    [\n      \"content\",\n      \"display\",\n      \"flexbox\",\n      \"flex\",\n      \"flex-grow\",\n      \"flex-shrink\",\n      \"flex-basis\",\n      \"flex-direction\",\n      \"order\",\n      \"flex-order\",\n      \"flex-wrap\",\n      \"flex-flow\",\n      \"justify-content\",\n      \"align-self\",\n      \"align-items\",\n      \"align-content\",\n      \"flex-pack\",\n      \"flex-align\",\n      \"box-sizing\",\n      \"vertical-align\",\n      \"size\",\n      \"width\",\n      \"height\",\n      \"max-width\",\n      \"min-width\",\n      \"max-height\",\n      \"min-height\",\n      \"overflow\",\n      \"overflow-x\",\n      \"overflow-y\",\n      \"float\",\n      \"clear\",\n      \"visibility\",\n      \"opacity\",\n      \"margin\",\n      \"margin-top\",\n      \"margin-right\",\n      \"margin-bottom\",\n      \"margin-left\",\n      \"padding\",\n      \"padding-top\",\n      \"padding-right\",\n      \"padding-bottom\",\n      \"padding-left\"\n    ],\n    [\n      \"font\",\n      \"font-family\",\n      \"font-size\",\n      \"font-weight\",\n      \"font-style\",\n      \"font-variant\",\n      \"font-size-adjust\",\n      \"font-stretch\",\n      \"line-height\",\n      \"letter-spacing\",\n      \"text-align\",\n      \"text-align-last\",\n      \"text-decoration\",\n      \"text-emphasis\",\n      \"text-emphasis-position\",\n      \"text-emphasis-style\",\n      \"text-emphasis-color\",\n      \"text-indent\",\n      \"text-justify\",\n      \"text-outline\",\n      \"text-transform\",\n      \"text-wrap\",\n      \"text-overflow\",\n      \"text-overflow-ellipsis\",\n      \"text-overflow-mode\",\n      \"word-spacing\",\n      \"word-wrap\",\n      \"word-break\",\n      \"tab-size\",\n      \"hyphens\"\n    ],\n    [\n      \"pointer-events\",\n      \"border\",\n      \"border-spacing\",\n      \"border-collapse\",\n      \"border-width\",\n      \"border-style\",\n      \"border-color\",\n      \"border-top\",\n      \"border-top-width\",\n      \"border-top-style\",\n      \"border-top-color\",\n      \"border-right\",\n      \"border-right-width\",\n      \"border-right-style\",\n      \"border-right-color\",\n      \"border-bottom\",\n      \"border-bottom-width\",\n      \"border-bottom-style\",\n      \"border-bottom-color\",\n      \"border-left\",\n      \"border-left-width\",\n      \"border-left-style\",\n      \"border-left-color\",\n      \"border-radius\",\n      \"border-top-left-radius\",\n      \"border-top-right-radius\",\n      \"border-bottom-right-radius\",\n      \"border-bottom-left-radius\",\n      \"border-image\",\n      \"border-image-source\",\n      \"border-image-slice\",\n      \"border-image-width\",\n      \"border-image-outset\",\n      \"border-image-repeat\",\n      \"border-top-image\",\n      \"border-right-image\",\n      \"border-bottom-image\",\n      \"border-left-image\",\n      \"border-corner-image\",\n      \"border-top-left-image\",\n      \"border-top-right-image\",\n      \"border-bottom-right-image\",\n      \"border-bottom-left-image\",\n      \"color\",\n      \"background\",\n      \"filter\",\n      \"background-color\",\n      \"background-image\",\n      \"background-attachment\",\n      \"background-position\",\n      \"background-position-x\",\n      \"background-position-y\",\n      \"background-clip\",\n      \"background-origin\",\n      \"background-size\",\n      \"background-repeat\",\n      \"clip\",\n      \"list-style\",\n      \"outline\",\n      \"outline-width\",\n      \"outline-style\",\n      \"outline-color\",\n      \"outline-offset\",\n      \"cursor\",\n      \"box-shadow\",\n      \"text-shadow\",\n      \"table-layout\",\n      \"backface-visibility\",\n      \"will-change\",\n      \"transition\",\n      \"transform\",\n      \"animation\"\n    ]\n  ]\n}\n```\n----\n\n### useMixinInsteadUnit\nAllo or deny some mixin instead of unit statement\n\n**Default value**\n```json\n{\n  \"conf\": \"always\",\n  \"mixin\": \"basis\",\n  \"unitType\": \"px\",\n  \"allowOneUnit\": false\n}\n```\n----\u003c!-- RULES END --\u003e\n\n## Self rules\nYou can create folder and use it for extra rules\n```json\n{\n  \"extraRules\": \"/Users/v-chupurnov/WebstormProjects/test/rules/\"\n}\n```\nIn this folder you can create native JavaScript files\n```javascript\nconst Rgb = require('stlint').ast.RGB;\n\nfunction TestRule() {\n\tnodesFilter = ['rgb']; // can be one of https://github.com/stylus/stlint/tree/master/src/core/ast\n\n\t/**\n\t * Check the AST nodes\n\t * @param node\n\t */\n\tthis.checkNode = (node) =\u003e {\n\t\tif (node instanceof Rgb) {\n\t\t\tconsole.log(this.state.conf); // test111\n\t\t\tconsole.log(this.state.someExtraVariable); // 112\n\t\t\t// this.msg('Test error on test node', node.lineno, node.column, node.line.length);\n\t\t}\n\t};\n\n\t/**\n\t * Check every line\n\t * @param line\n\t */\n\tthis.checkLine = (line) =\u003e {\n\t\tif (line.lineno === 1) {\n\t\t\t// this.msg('Test error on test line', line.lineno, 1, line.line.length);\n\t\t}\n\t};\n}\n\nmodule.exports.TestRule = TestRule;\n```\nAnd you need add this rule in your config\n```json\n{\n  \"extraRules\": \"/Users/v-chupurnov/WebstormProjects/test/rules/\",\n  \"rules\": {\n    \"testRule\": {\n      \"conf\": \"test111\",\n      \"someExtraVariable\": 112,\n      \"enabled\": true\n    }\n  }\n}\n```\n\n## License\n\n[The MIT License](https://raw.githubusercontent.com/stylus/stlint/master/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstylus%2Fstlint","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstylus%2Fstlint","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstylus%2Fstlint/lists"}