{"id":24869994,"url":"https://github.com/deepal/stdlint","last_synced_at":"2025-07-25T08:10:13.131Z","repository":{"id":57370470,"uuid":"368241283","full_name":"deepal/stdlint","owner":"deepal","description":"A non-opinionated development standard linter that helps you keep your repositories clean and consistent!","archived":false,"fork":false,"pushed_at":"2021-05-18T23:50:06.000Z","size":203,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-15T16:00:32.043Z","etag":null,"topics":["code-quality","development-standards","linting","stdlint"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/deepal.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null}},"created_at":"2021-05-17T15:49:07.000Z","updated_at":"2023-02-13T16:07:17.000Z","dependencies_parsed_at":"2022-08-29T18:30:21.406Z","dependency_job_id":null,"html_url":"https://github.com/deepal/stdlint","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/deepal/stdlint","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepal%2Fstdlint","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepal%2Fstdlint/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepal%2Fstdlint/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepal%2Fstdlint/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deepal","download_url":"https://codeload.github.com/deepal/stdlint/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepal%2Fstdlint/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266218358,"owners_count":23894460,"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":["code-quality","development-standards","linting","stdlint"],"created_at":"2025-02-01T03:36:23.412Z","updated_at":"2025-07-25T08:10:13.106Z","avatar_url":"https://github.com/deepal.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# stdlint\n#### A non-opinionated development standard linter that helps you keep your repositories clean and consistent!\n\n![logo](./docs/logo.png)\n\n### Table of Contents\n\u003c!-- toc --\u003e\n\n- [Rationale](#Rationale)\n- [What is stdlint](#What-is-stdlint)\n- [Installation](#Installation)\n  * [Installing per project](#Installing-per-project)\n  * [Installing globally](#Installing-globally)\n- [Usage](#Usage)\n  * [Available options](#Available-options)\n  * [Running against a local directory](#Running-against-a-local-directory)\n- [Configuring stdlint](#Configuring-stdlint)\n- [Using Rule Sets](#Using-Rule-Sets)\n- [Writing a rule](#Writing-a-rule)\n- [Future work](#Future-work)\n- [Contribution](#Contribution)\n\n\u003c!-- tocstop --\u003e\n### Rationale\n\nWhen we work with multiple projects, in a team of developers, we often have to follow some agreed conventions to make sure all our repositories are consistent. Consistency matters a lot especially because if makes it easier to maintain the repositories and enables faster new developer onboarding. However, the conventions we follow as a team of developers can be different depending on the team and developer community. \n\nA few examples for such conventions are,\n- `package.json` should contain the `engines` field with a valid value\n- `some_npm_package` package should not be used in the repositories, because we want to use `another_npm_package` package instead.\n- Github repository should have branch protection enabled on the default branch. \n- `PULL_REQUEST_TEMPLATE` and `CODEOWNERS` files should exist in all repositories\n\nConventions like these can be specific and ad-hoc. It is often very difficult to force each project to follow those rules because checking each project for these conventions can be a time-consuming and a manual task.\n\n### What is stdlint\n\n`stdlint` is a CLI tool which can run a set of rules against a repository and report if the repository configuration and the repository content follows the rules. You can think of it as an \"A linter for  development conventions\".\n\n![DEMO](./docs/stdlint.gif)\n\n### Installation\n\n#### Installing per project\nTo install `stdlint` in one of your projects, go to the project you need to install stdlint and run the following command:\n\n```\nnpm i stdlint --save-dev\n```\n\nAfter installing stdlint in your project, you can add an npm script to run stdlint in your package.json.\n\n```\n\"scripts\": {\n    \"stdlint\": \"stdlint --path .\"\n}\n```\n\nYou can then run stdlint using your npm script.\n\n```\nnpm run stdlint\n```\n\n#### Installing globally\n\nAlthough we don't recommend installing stdlint globally, you can do so as follows:\n\n```\nnpm i -g stdlint\n```\n\nOnce you install stdlint globally, you can use `stdlint` CLI command from any directory.\n\n### Usage\n\n`stdlint` needs to access github repositories on behalf of you in order to lint its configurations. Therefore, you need to provide stdlint a [Github personal access token](https://github.com/settings/tokens) which grants `stdlint` API read access to the repositories.\n\nYou can pass the personal access token to stdlint by setting it as `GITHUB_AUTH_TOKEN` environment variable in the same shell `stdlint` is run.\n\n#### Available options\n```\n$ stdlint --help\n\nUsage: stdlint [options]\n\nOptions:\n  -p, --path \u003cpath\u003e      local path of the project git repository\n  -u, --url \u003curl\u003e        github repository URL\n  -o, --output \u003coutput\u003e  output format for the result. one of json, xml, pretty (default: \"pretty\")\n  -l, --level \u003clevel\u003e    maximum error tolerance level (default: 1)\n  -h, --help             display help for command\n```\n\n|  Option   | Description |   \n| --- | --- |\n| `-p` or `--path`    | Local path of the project git repository. Can be an absolute path or a relative path   |\n| `-u` or `--url`    | Github repository URL   |\n| `-l` or `--level`   | Maximum tolerance level of errors. Valid values are -1, 0, 1, 2 where the number increases the tolerance level. Set it to `-1` to exit with exitCode 1 on all types of issues. e.g: If set to 0, stdlint will exit with exitCode 1 if at least one issue with `WARN` severity is found.|\n| `-h` or `--help`    | Display help and usage of the command   |\n\n#### Running against a local directory\n\n\u003e To run stdlint against a local directory, it is recommended to install stdlint per project and use it with npm scripts. Please refer to the installation instructions.\n\nIf you plan to run stdlint with a git CLI hook or a CI stage, you can do so by running stdlint as follows.\n\n```\nstdlint --path \u003cabsolute_or_relative_path_to_repository\u003e\n```\n\ne.g, To run stdlint on the current working directory, run `stdlint --path .`\n\n### Configuring stdlint\n\nYou can customise the behaviour of the rules or enable/disable them by using a `.stdlintrc` file at the root of your project.\n\ne.g, You can disable a rule (for example `myAwesomeRule`), but adding it to the `.stdlintrc` file as follows:\n\n```js\n{\n    \"rules\": {\n        \"myAwesomeRule\": false\n    }\n}\n```\n\nSome rules can be re-configured too. This is often useful to tweak the rule to fit your needs. If the rule supports customisation, you can pass the rule configuration using `.stdlintrc` as follows:\n\n```js\n{\n    \"rules\": {\n        \"conventionalCommits\": {\n            \"noOfCommitsToCheck\": 5\n        }\n    }\n}\n```\n\nTo see if a particular rule supports any configurations, please refer to the documentation of the rule set.\n\n### Using Rule Sets\n\n`stdlint` does not ship with a built-in rule set. You can instruct `stdlint` to use a rule set by installing it as an npm module and reference the rule set in `.stdlintrc` as the follows. \n\nFollowing example shows how to use `stdlint-config-bibliocircle` rule set with `stdlint`. You can find the repository for `stdlint-config-bibliocircle` [here](https://github.com/deepal/stdlint-config-bibliocircle).\n\ne.g,\n - Install `stdlint-config-bibliocircle` module in your project\n - Update the `.stdlintrc` as follows.\n\n ```\n{\n  \"extends\": [\n    \"stdlint-config-bibliocircle\"\n  ],\n}\n ```\n\nYou can extend with more than one rule set by providing them in the `\"extends\"` array.\n\n### Writing a rule\n\nAn example rule is as follows.\n\n```js\nmodule.exports = {\n  myAwesomeRule: ({ consts }) =\u003e ({\n    severity: consts.RULE_SEVERITY.ERROR,\n    category: 'Some Rule Category', // stdlint output will be grouped by the 'category' value. This is optional\n    checkFunction: async ({ \n        gitClient, // git client\n        repoConfig, // github project configuration object\n        defaultBranchProtectionConfig, // github branch protection configuration for the default branch\n        ruleConfig // custom configuration for the rule passed via `.stdlintrc`\n    }) =\u003e {\n      // Do your checks here, and return an object in the following format:\n      return {\n        score: 80, // a number between 0-100\n        passed: true, // boolean\n        message: \"Project passed myAwesomeRule with flying colours\" // information to show in the stdlint output\n      };\n    },\n  }),\n};\n```\n\n### Future work\n\n- [ ] `stdlint` only supports Github repositories at the moment. And we'll definitely work towards supporting GitLab and Bitbucket. If you would like `stdlint` to work with any other git service, please let us know by raising an issue.\n- [ ] You will need to have `git` command in the shell where `stdlint` is run, because `stdlint` relies on the `git` command. We are working on making `stdlint` free of `git` CLI dependency.\n\n### Contribution\n\nI would love to hear your feedback and suggestions. Please do not hesitate to raise an issue to request a feature or report a bug. And if you are interested in contributing, PRs are always welcome! 🎉. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeepal%2Fstdlint","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeepal%2Fstdlint","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeepal%2Fstdlint/lists"}