Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gh-lint

Package Overview
Dependencies
Maintainers
2
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gh-lint - npm Package Compare versions

Comparing version 0.10.1 to 0.11.0

lib/rules/commit-pr.js

33

lib/rules/commit-name.js
'use strict';
const {allUsers, author, plural, users} = require('./util');
module.exports = {

@@ -64,39 +66,18 @@ meta: {

for (const commit of repoCommits) {
const msg = commit.commit.message;
for (const cmt of repoCommits) {
const msg = cmt.commit.message;
const valid = /^v?\d/.test(msg)
|| /^Merge|^Initial|^Revert/.test(msg)
|| (exclPatterns && exclPatterns.some((p) => p.test(msg)))
|| (exclAuthors && exclAuthors.indexOf(user(commit, 'author')) >= 0)
|| (exclAuthors && exclAuthors.indexOf(author(cmt)) >= 0)
|| regexp.test(msg);
if (!valid) commits.push(commit);
if (!valid) commits.push(cmt);
}
if (commits.length == 0) return {valid: true};
const allUsers = uniques(commits.map(users)).join(', ');
return {
valid: false,
message: `${commits.length} bad commit name${plural(commits)} by ${allUsers}`,
message: `${commits.length} bad commit name${plural(commits)} by ${allUsers(commits)}`,
messages: commits.map((c) => `Bad commit name by ${users(c)}:\n${c.html_url}\n${c.commit.message}`)
};
function users(cmt) {
const author = user(cmt, 'author');
const committer = user(cmt, 'committer');
if (author == committer) return author;
if (author && committer) return `${author} and ${committer}`;
return author || committer;
}
function user(cmt, userType) {
return cmt[userType] && cmt[userType].login && ('@' + cmt[userType].login) || cmt.commit[userType].name;
}
function uniques(arr) {
return arr.sort().filter((item, i) => !(i && item == arr[i-1]));
}
function plural(arr) {
return arr.length > 1 ? 's' : '';
}
},

@@ -103,0 +84,0 @@

'use strict';
const {plural, uniques} = require('./util');
module.exports = {

@@ -21,3 +23,3 @@ meta: {

const prMeta = await github.get(prUrl);
if (!prMeta.merged_at) continue;
if (!prMeta.merged) continue;
const reviews = await github.allPages(`${prUrl}/reviews`);

@@ -42,10 +44,2 @@ if (!reviews.some(approved)) prs.push(prMeta);

}
function uniques(arr) {
return arr.sort().filter((item, i) => !(i && item == arr[i-1]));
}
function plural(arr) {
return arr.length > 1 ? 's' : '';
}
},

@@ -52,0 +46,0 @@

{
"name": "gh-lint",
"version": "0.10.1",
"version": "0.11.0",
"description": "Rule-based command-line tool for auditing GitHub repositories",

@@ -23,3 +23,3 @@ "main": "lib/execute/index.js",

"ghlint-plugin-example": "^0.1.0",
"json-schema-test": "^1.3.0",
"json-schema-test": "^2.0.0",
"mocha": "^4.0.1",

@@ -26,0 +26,0 @@ "nock": "^9.0.2",

@@ -76,2 +76,4 @@ # gh-lint

- commit-name: check that commit names satisfy semantic commit conventions
- commit-pr: check that commit was added to master via PR
- commit-user: check that commit is associated with some GitHub user(s)

@@ -78,0 +80,0 @@

@@ -72,2 +72,6 @@ 'use strict';

`../fixtures/milojs_milo_pull${pullNumber}_reviews.json`);
},
commits(pullNumber) {
mock(`/repos/milojs/milo/pulls/${pullNumber}/commits?per_page=30&page=1`,
`../fixtures/milojs_milo_pull${pullNumber}_commits.json`);
}

@@ -74,0 +78,0 @@ }

[
{
"sha": "f1a6bc21ea7bec1538393b2907ca45c5678cf32a",
"commit": {
"author": {
"name": "Jason Ian Green",
"email": "jasoniangreen@users.noreply.github.com",
"date": "2017-07-06T16:09:36Z"
},
"committer": {
"name": "GitHub",
"email": "noreply@github.com",
"date": "2017-07-06T16:09:36Z"
},
"message": "feat: support a root el param in getOffset position util (#86)",
"tree": {
"sha": "2c395039d257a57ce9d5ba6e20004862b5fb03ac",
"url": "https://api.github.com/repos/milojs/milo/git/trees/2c395039d257a57ce9d5ba6e20004862b5fb03ac"
},
"url": "https://api.github.com/repos/milojs/milo/git/commits/f1a6bc21ea7bec1538393b2907ca45c5678cf32a",
"comment_count": 0,
"verification": {
"verified": false,
"reason": "unsigned",
"signature": null,
"payload": null
}
},
"url": "https://api.github.com/repos/milojs/milo/commits/f1a6bc21ea7bec1538393b2907ca45c5678cf32a",
"html_url": "https://github.com/milojs/milo/commit/f1a6bc21ea7bec1538393b2907ca45c5678cf32a",
"comments_url": "https://api.github.com/repos/milojs/milo/commits/f1a6bc21ea7bec1538393b2907ca45c5678cf32a/comments",
"author": {
"login": "jasoniangreen",
"id": 3481367,
"avatar_url": "https://avatars2.githubusercontent.com/u/3481367?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/jasoniangreen",
"html_url": "https://github.com/jasoniangreen",
"followers_url": "https://api.github.com/users/jasoniangreen/followers",
"following_url": "https://api.github.com/users/jasoniangreen/following{/other_user}",
"gists_url": "https://api.github.com/users/jasoniangreen/gists{/gist_id}",
"starred_url": "https://api.github.com/users/jasoniangreen/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/jasoniangreen/subscriptions",
"organizations_url": "https://api.github.com/users/jasoniangreen/orgs",
"repos_url": "https://api.github.com/users/jasoniangreen/repos",
"events_url": "https://api.github.com/users/jasoniangreen/events{/privacy}",
"received_events_url": "https://api.github.com/users/jasoniangreen/received_events",
"type": "User",
"site_admin": false
},
"committer": {
"login": "web-flow",
"id": 19864447,
"avatar_url": "https://avatars3.githubusercontent.com/u/19864447?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/web-flow",
"html_url": "https://github.com/web-flow",
"followers_url": "https://api.github.com/users/web-flow/followers",
"following_url": "https://api.github.com/users/web-flow/following{/other_user}",
"gists_url": "https://api.github.com/users/web-flow/gists{/gist_id}",
"starred_url": "https://api.github.com/users/web-flow/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/web-flow/subscriptions",
"organizations_url": "https://api.github.com/users/web-flow/orgs",
"repos_url": "https://api.github.com/users/web-flow/repos",
"events_url": "https://api.github.com/users/web-flow/events{/privacy}",
"received_events_url": "https://api.github.com/users/web-flow/received_events",
"type": "User",
"site_admin": false
},
"parents": [
{
"sha": "5febc21ec165bfe77f5c2c873c79b947d812c0fd",
"url": "https://api.github.com/repos/milojs/milo/commits/5febc21ec165bfe77f5c2c873c79b947d812c0fd",
"html_url": "https://github.com/milojs/milo/commit/5febc21ec165bfe77f5c2c873c79b947d812c0fd"
}
]
},
{
"sha": "5febc21ec165bfe77f5c2c873c79b947d812c0fd",

@@ -4,0 +80,0 @@ "commit": {

@@ -39,4 +39,7 @@ 'use strict';

mode: 2,
message: '1 bad commit name by @WebReflection and @jasoniangreen',
messages: ["Bad commit name by @WebReflection and @jasoniangreen:\nhttps://github.com/milojs/milo/commit/5febc21ec165bfe77f5c2c873c79b947d812c0fd\nchore: component.isReaady = false on destroy (#80)\n\n* chore: component.isReaady = false on destroy\r\n\r\n* Update c_class.js\r\n\r\nkeeping `isReady` as such:\r\n\r\n * `false` when not ready\r\n * `true` only once dispatching `'stateready'`\r\n * `undefined` when destroyed (the property is not shadowed 'cause I'm not sure if `false` is set as default in the prototype)\r\n\r\n* Update c_class.js\r\n\r\nBe sure `init()` sets `isReady` as `false`."],
message: '2 bad commit names by @WebReflection and @jasoniangreen, @jasoniangreen and @web-flow',
messages: [
'Bad commit name by @jasoniangreen and @web-flow:\nhttps://github.com/milojs/milo/commit/f1a6bc21ea7bec1538393b2907ca45c5678cf32a\nfeat: support a root el param in getOffset position util (#86)',
"Bad commit name by @WebReflection and @jasoniangreen:\nhttps://github.com/milojs/milo/commit/5febc21ec165bfe77f5c2c873c79b947d812c0fd\nchore: component.isReaady = false on destroy (#80)\n\n* chore: component.isReaady = false on destroy\r\n\r\n* Update c_class.js\r\n\r\nkeeping `isReady` as such:\r\n\r\n * `false` when not ready\r\n * `true` only once dispatching `'stateready'`\r\n * `undefined` when destroyed (the property is not shadowed 'cause I'm not sure if `false` is set as default in the prototype)\r\n\r\n* Update c_class.js\r\n\r\nBe sure `init()` sets `isReady` as `false`."
],
valid: false

@@ -70,4 +73,7 @@ }

mode: 2,
message: '1 bad commit name by @WebReflection and @jasoniangreen',
messages: ["Bad commit name by @WebReflection and @jasoniangreen:\nhttps://github.com/milojs/milo/commit/5febc21ec165bfe77f5c2c873c79b947d812c0fd\nchore: component.isReaady = false on destroy (#80)\n\n* chore: component.isReaady = false on destroy\r\n\r\n* Update c_class.js\r\n\r\nkeeping `isReady` as such:\r\n\r\n * `false` when not ready\r\n * `true` only once dispatching `'stateready'`\r\n * `undefined` when destroyed (the property is not shadowed 'cause I'm not sure if `false` is set as default in the prototype)\r\n\r\n* Update c_class.js\r\n\r\nBe sure `init()` sets `isReady` as `false`."],
message: '2 bad commit names by @WebReflection and @jasoniangreen, @jasoniangreen and @web-flow',
messages: [
'Bad commit name by @jasoniangreen and @web-flow:\nhttps://github.com/milojs/milo/commit/f1a6bc21ea7bec1538393b2907ca45c5678cf32a\nfeat: support a root el param in getOffset position util (#86)',
"Bad commit name by @WebReflection and @jasoniangreen:\nhttps://github.com/milojs/milo/commit/5febc21ec165bfe77f5c2c873c79b947d812c0fd\nchore: component.isReaady = false on destroy (#80)\n\n* chore: component.isReaady = false on destroy\r\n\r\n* Update c_class.js\r\n\r\nkeeping `isReady` as such:\r\n\r\n * `false` when not ready\r\n * `true` only once dispatching `'stateready'`\r\n * `undefined` when destroyed (the property is not shadowed 'cause I'm not sure if `false` is set as default in the prototype)\r\n\r\n* Update c_class.js\r\n\r\nBe sure `init()` sets `isReady` as `false`."
],
valid: false

@@ -119,2 +125,3 @@ }

'commit-name': [2, {
maxSubjectLength: 64,
maxLineLength: 128

@@ -121,0 +128,0 @@ }]

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc