{"id":13431912,"url":"https://github.com/SamVerschueren/clinton","last_synced_at":"2025-03-16T22:32:36.932Z","repository":{"id":57200401,"uuid":"47210443","full_name":"SamVerschueren/clinton","owner":"SamVerschueren","description":"Project style linter","archived":false,"fork":false,"pushed_at":"2019-11-06T17:49:17.000Z","size":334,"stargazers_count":122,"open_issues_count":10,"forks_count":9,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-15T02:51:08.503Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/SamVerschueren.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":"2015-12-01T18:52:51.000Z","updated_at":"2024-02-25T21:04:38.000Z","dependencies_parsed_at":"2022-09-16T15:11:28.668Z","dependency_job_id":null,"html_url":"https://github.com/SamVerschueren/clinton","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SamVerschueren%2Fclinton","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SamVerschueren%2Fclinton/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SamVerschueren%2Fclinton/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SamVerschueren%2Fclinton/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SamVerschueren","download_url":"https://codeload.github.com/SamVerschueren/clinton/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243676749,"owners_count":20329433,"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":[],"created_at":"2024-07-31T02:01:06.978Z","updated_at":"2025-03-16T22:32:36.596Z","avatar_url":"https://github.com/SamVerschueren.png","language":"JavaScript","readme":"# clinton\n\n[![Build Status: Linux](https://travis-ci.org/SamVerschueren/clinton.svg?branch=master)](https://travis-ci.org/SamVerschueren/clinton) [![Build status: Windows](https://ci.appveyor.com/api/projects/status/1lcv1c0eqjtcg83s/branch/master?svg=true)](https://ci.appveyor.com/project/SamVerschueren/clinton/branch/master) [![Coverage Status](https://coveralls.io/repos/github/SamVerschueren/clinton/badge.svg?branch=master)](https://coveralls.io/github/SamVerschueren/clinton?branch=master)\n\n\n\u003e JavaScript project style linter\n\n\n## Install\n\n```\n$ npm install --save clinton\n```\n\n\n## Usage\n\n```js\nconst clinton = require('clinton');\n\nclinton.lint('/Users/sam/projects/clinton', {rules: {'license': ['error', 'MIT']}}).then(validations =\u003e {\n\tconsole.log(validations);\n\t/*\n\t\t[\n\t\t\t{\n\t\t\t\truleId: 'license',\n\t\t\t\tseverity: 'error',\n\t\t\t\tmessage: 'License is not of type MIT (http://www.opensource.org/licenses/MIT).'\n\t\t\t}\n\t\t]\n\t*/\n});\n```\n\nInstead of passing the rules as an option, you can also add them to your `package.json` file.\n\n```json\n{\n\t\"name\": \"foo\",\n\t\"license\": \"ISC\",\n\t\"clinton\": {\n\t\t\"rules\": {\n\t\t\t\"license\": [\"error\", \"MIT\"]\n\t\t}\n\t}\n}\n```\n\n\n## API\n\n### .lint(path, [options])\n\n#### path\n\nType: `string`\n\nProject path.\n\n#### options\n\n##### rules\n\nType: `object`\n\nOverride any of the [default rules](https://github.com/SamVerschueren/clinton/blob/master/config.js).\n\n##### inherit\n\nType: `boolean`\u003cbr\u003e\nDefault: `true`\n\nInherit from the [default rules](https://github.com/SamVerschueren/clinton/blob/master/config.js). Set to `false` if you want to start with a clean sheet.\n\n##### plugins\n\nType: `string[]`\n\nList of plugin names.\n\n##### ignores\n\nType: `string[]`\n\nPaths in `.gitignore` are ignored by default. Additional ignores can be added here.\n\n##### cwd\n\nType: `string`\n\nCurrent working directory when linting local projects.\n\n\n## CLI\n\n```\n    Usage\n      $ clinton [\u003cpath\u003e]\n\n    Options\n      --no-inherit  Prevent inheriting from the default rules.\n      --ignores     Ignore files. Can be added multiple times.\n      --fix         Automatically fix problems.\n\n    Examples\n      $ clinton\n        .editorconfig\n        ⚠  Use .editorconfig to define and maintain consistent coding styles between editors.     editorconfig\n\n        1  warning\n\n      $ clinton ~/projects/project\n        license\n        ✖  No MIT license found.  license-mit\n\n        1  error\n```\n\n\u003e Tip: Use the config in `package.json` whenever possible for maintainability and to make it easier for eventual other tools to read the config.\n\n\n## Rules\n\n- [ava](docs/rules/ava.md) - Enforces the use of [AVA](https://github.com/avajs/ava). *(fixable)*\n- [cli](docs/rules/cli.md) - Enforces the existance and executability of the cli file.\n- [editorconfig](docs/rules/editorconfig.md) - Enforces the use and rules of  [EditorConfig](http://editorconfig.org).\n- [filename-case](docs/rules/filename-case.md) - Enforce a case style for filenames.\n- [gitignore](docs/rules/gitignore.md) - Enforce the use of `.gitignore`. *(fixable)*\n- [gulp](docs/rules/gulp.md) - Enforces the correct `devDependencies` when Gulp is detected.\n- [keywords](docs/rules/keywords.md) - Enforces the use of `keywords` in `package.json`.\n- [license](docs/rules/license.md) - Enforce the use of a specific license.\n- [max-depth](docs/rules/max-depth.md) - Enforce the maximum depth of the directory structure.\n- [no-callback](docs/rules/no-callback.md) - Enforces the use of promises instead of callbacks.\n- [no-dup-keywords](docs/rules/no-dup-keywords.md) - Enforce not having duplicate keywords in `package.json`. *(fixable)*\n- [no-empty-keywords](docs/rules/no-empty-keywords.md) - Enforce not having empty keywords in `package.json`. *(fixable)*\n- [no-git-merge-conflict](docs/rules/no-git-merge-conflict.md) - Prevents having Git merge conflict markers.\n- [pkg-dependency-order](docs/rules/pkg-dependency-order.md) - Enforces alphabetical order of `dependencies` and `devDependencies` in `package.json`. *(fixable)*\n- [pkg-description](docs/rules/pkg-description.md) - Enforces the description to start with a capital letter and not end with a dot. *(fixable)*\n- [pkg-engine](docs/rules/pkg-engine.md) - Enforces the use of a `engines.node` field in `package.json`.\n- [pkg-main](docs/rules/pkg-main.md) - Enforces the existance of the main file.\n- [pkg-name](docs/rules/pkg-name.md) - Enforces a valid package name.\n- [pkg-normalize](docs/rules/pkg-normalize.md) - Enforces package normalization. *(fixable)*\n- [pkg-property-order](docs/rules/pkg-property-order.md) - Enforces order of properties in in `package.json`. *(fixable)*\n- [pkg-schema](docs/rules/pkg-schema.md) - Enforces a valid `package.json`.\n- [pkg-shorthand-repository](docs/rules/pkg-shorthand-repository.md) - Enforces the use of the shorthand repository URL. *(fixable)*\n- [pkg-user-order](docs/rules/pkg-user-order.md) - Enforces order of properties in user objects in `package.json`. *(fixable)*\n- [readme](docs/rules/readme.md) - Enforce having a readme.\n- [test-script](docs/rules/test-script.md) - Enforces the use of tests.\n- [travis](docs/rules/travis.md) - Enforces the correct versions in `.travis.yml`. *(fixable)*\n- [use-travis](docs/rules/use-travis.md) - Enforces the use of [Travis CI](https://travis-ci.org/).\n- [valid-properties](docs/rules/valid-properties.md) - Enforce recommended properties in `package.json`.\n- [valid-version](docs/rules/valid-version.md) - Enforces a valid version identifier in `package.json`.\n- [xo](docs/rules/xo.md) - Enforces the use of [XO](https://github.com/sindresorhus/xo). *(fixable)*\n\n\n## Plugins\n\nEveryone can create plugins or custom rules that can be validated with `Clinton`. The name of the plugin should be\n`clinton-plugin-*` where `*` is the name of the plugin.\n\n### Example\n\nLet's create a `clinton-plugin-file-exists` rule that checks if the file provided as argument really exists.\n\n```js\n'use strict';\nmodule.exports = ctx =\u003e {\n\tconst fileName = ctx.options[0];\n\n\tif (!ctx.files.includes(fileName)) {\n\t\tctx.report({\n\t\t\tmessage: `File ${fileName} does not exist.`\n\t\t});\n\t}\n};\n```\n\nYou can also return a promise if you are performing asynchronous operations.\n\nYou can wrap this up in a project, publish it to [npm](https://www.npmjs.com/) and install it in every project where you want to check if a file in your project really exists.\n\n```json\n{\n\t\"name\": \"Unicorn\",\n\t\"description\": \"My unicorn package\",\n\t\"version\": \"1.0.0\",\n\t\"scripts\": {\n\t\t\"test\": \"clinton\"\n\t},\n\t\"devDependencies\": {\n\t\t\"clinton\": \"*\",\n\t\t\"clinton-plugin-file-exists\": \"1.0.0\"\n\t},\n\t\"clinton\": {\n\t\t\"plugins\": [\n\t\t\t\"file-exists\"\n\t\t],\n\t\t\"rules\": {\n\t\t\t\"file-exists\": [\"error\", \"index.js\"]\n\t\t}\n\t}\n}\n```\n\nWhen running `npm test`, `clinton` will execute your plugin and will use `index.js` as the option argument. The first that is passed to the plugin, `error` in this example, indicates the severity of the error.\n\n\n## Related\n\n- [gh-lint-brainstorm](https://github.com/SamVerschueren/gh-lint-brainstorm) - Brainstorming repository for this module\n\n\n## License\n\nMIT © [Sam Verschueren](http://github.com/SamVerschueren)\n","funding_links":[],"categories":["JavaScript","Linters","Linters and Formatters"],"sub_categories":["JavaScript","Linters"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSamVerschueren%2Fclinton","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSamVerschueren%2Fclinton","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSamVerschueren%2Fclinton/lists"}