From 1c33bc0e8cca1249466cd2205805ca63f7a9613b Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 1 Nov 2017 21:46:46 -0700 Subject: [PATCH] remove 50 char limit on title line per new project guidelines --- README.md | 1 - lib/format-pretty.js | 1 - lib/format-tap.js | 6 +----- lib/rules/title-length.js | 39 --------------------------------------- test/validator.js | 14 +++++--------- 5 files changed, 6 insertions(+), 55 deletions(-) delete mode 100644 lib/rules/title-length.js diff --git a/README.md b/README.md index 75d802d..8ef9aae 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,6 @@ $ core-validate-commit --list pr-url enforce PR-URL reviewers enforce having reviewers subsystem enforce subsystem validity - title-length enforce max length of commit title ``` ## Test diff --git a/lib/format-pretty.js b/lib/format-pretty.js index 99b1885..0c51465 100644 --- a/lib/format-pretty.js +++ b/lib/format-pretty.js @@ -46,7 +46,6 @@ module.exports = function formatPretty(context, msgs, validator, opts) { } switch (ruleId) { - case 'title-length': case 'line-length': console.log(formatLength(msg, opts)) break diff --git a/lib/format-tap.js b/lib/format-tap.js index f6ab300..879f14c 100644 --- a/lib/format-tap.js +++ b/lib/format-tap.js @@ -22,7 +22,6 @@ module.exports = function formatTap(t, context, msgs, validator) { function onFail(context, m, validator, t) { switch (m.id) { case 'line-length': - case 'title-length': lengthFail(context, m, validator, t) break case 'subsystem': @@ -35,9 +34,6 @@ function onFail(context, m, validator, t) { } function lengthFail(context, m, validator, t) { - const body = m.id === 'title-length' - ? context.title - : context.body t.fail(`${m.id}: ${m.message}`, { found: m.string.length , compare: '<=' @@ -45,7 +41,7 @@ function lengthFail(context, m, validator, t) { , at: { line: m.line || 0 , column: m.column || 0 - , body: body + , body: context.body } }) } diff --git a/lib/rules/title-length.js b/lib/rules/title-length.js deleted file mode 100644 index 97b7bb8..0000000 --- a/lib/rules/title-length.js +++ /dev/null @@ -1,39 +0,0 @@ -'use strict' - -const id = 'title-length' - -module.exports = { - id: id -, meta: { - description: 'enforce max length of commit title' - , recommended: true - } -, defaults: { - length: 50 - } -, options: { - length: 50 - } -, validate: (context, rule) => { - const len = rule.options.length - if (context.title.length > len) { - context.report({ - id: id - , message: `Title must be <= ${len} columns.` - , string: context.title - , maxLength: len - , line: 0 - , column: len - , level: 'fail' - }) - return - } - - context.report({ - id: id - , message: `Title is <= ${len} columns.` - , string: '' - , level: 'pass' - }) - } -} diff --git a/test/validator.js b/test/validator.js index e655abc..2b4c9de 100644 --- a/test/validator.js +++ b/test/validator.js @@ -122,7 +122,7 @@ test('Validator - misc', (t) => { test('Validator - real commits', (t) => { t.test('basic', (tt) => { - tt.plan(18) + tt.plan(12) const v = new Validator() // run against the output of git show --quiet // run against the output of github's get commit api request @@ -139,9 +139,7 @@ test('Validator - real commits', (t) => { const filtered = msgs.filter((item) => { return item.level === 'fail' }) - tt.equal(filtered.length, 3, 'messages.length') - tt.equal(filtered[0].level, 'fail') - tt.equal(filtered[0].id, 'title-length') + tt.equal(filtered.length, 0, 'messages.length') }) }) @@ -159,9 +157,7 @@ test('Validator - real commits', (t) => { const filtered = msgs.filter((item) => { return item.level === 'fail' }) - tt.equal(filtered.length, 1, 'messages.length') - tt.equal(filtered[0].level, 'fail') - tt.equal(filtered[0].id, 'title-length') + tt.equal(filtered.length, 0, 'messages.length') tt.end() }) }) @@ -180,11 +176,11 @@ test('Validator - real commits', (t) => { const filtered = msgs.filter((item) => { return item.level === 'fail' }) - tt.equal(filtered.length, 3, 'messages.length') + tt.equal(filtered.length, 2, 'messages.length') const ids = filtered.map((item) => { return item.id }) - const exp = ['line-length', 'line-length', 'title-length'] + const exp = ['line-length', 'line-length'] tt.deepEqual(ids.sort(), exp.sort(), 'message ids') tt.end() })