Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

Commit

Permalink
(require|disallow)CapitalizedComments: remove regenerate dependency
Browse files Browse the repository at this point in the history
Closes gh-861
  • Loading branch information
efolio authored and mrjoelkemp committed Dec 29, 2014
1 parent 5344ad7 commit 5d7bf3e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 22 deletions.
21 changes: 12 additions & 9 deletions lib/rules/disallow-capitalized-comments.js
@@ -1,13 +1,16 @@
var assert = require('assert');
var regenerate = require('regenerate');
var Lu = require('unicode-6.3.0/categories/Lu/code-points');
var Ll = require('unicode-6.3.0/categories/Ll/code-points');
var Lt = require('unicode-6.3.0/categories/Lt/code-points');
var Lm = require('unicode-6.3.0/categories/Lm/code-points');
var Lo = require('unicode-6.3.0/categories/Lo/code-points');
var Lu = require('unicode-6.3.0/categories/Lu/regex');
var Ll = require('unicode-6.3.0/categories/Ll/regex');
var Lt = require('unicode-6.3.0/categories/Lt/regex');
var Lm = require('unicode-6.3.0/categories/Lm/regex');
var Lo = require('unicode-6.3.0/categories/Lo/regex');

var letterPattern = regenerate(Lu, Ll, Lt, Lm, Lo).toRegExp();
var lowerCasePattern = regenerate(Ll).toRegExp();
function letterPattern(char) {
return Lu.test(char) || Ll.test(char) || Lt.test(char) || Lm.test(char) || Lo.test(char);
}
function lowerCasePattern(char) {
return Ll.test(char);
}

module.exports = function() {};

Expand All @@ -28,7 +31,7 @@ module.exports.prototype = {
var stripped = comment.value.replace(/[\n\s\*]/g, '');
var firstChar = stripped[0];

if (letterPattern.test(firstChar) && !lowerCasePattern.test(firstChar)) {
if (letterPattern(firstChar) && !lowerCasePattern(firstChar)) {
errors.add(
'Comments must start with a lowercase letter',
comment.loc.start
Expand Down
25 changes: 14 additions & 11 deletions lib/rules/require-capitalized-comments.js
@@ -1,13 +1,16 @@
var assert = require('assert');
var regenerate = require('regenerate');
var Lu = require('unicode-6.3.0/categories/Lu/code-points');
var Ll = require('unicode-6.3.0/categories/Ll/code-points');
var Lt = require('unicode-6.3.0/categories/Lt/code-points');
var Lm = require('unicode-6.3.0/categories/Lm/code-points');
var Lo = require('unicode-6.3.0/categories/Lo/code-points');

var letterPattern = regenerate(Lu, Ll, Lt, Lm, Lo).toRegExp();
var upperCasePattern = regenerate(Lu).toRegExp();
var Lu = require('unicode-6.3.0/categories/Lu/regex');
var Ll = require('unicode-6.3.0/categories/Ll/regex');
var Lt = require('unicode-6.3.0/categories/Lt/regex');
var Lm = require('unicode-6.3.0/categories/Lm/regex');
var Lo = require('unicode-6.3.0/categories/Lo/regex');

function letterPattern(char) {
return Lu.test(char) || Ll.test(char) || Lt.test(char) || Lm.test(char) || Lo.test(char);
}
function upperCasePattern(char) {
return Lu.test(char);
}

module.exports = function() {};

Expand All @@ -29,14 +32,14 @@ module.exports.prototype = {
file.getComments().forEach(function(comment) {
var stripped = comment.value.replace(/[\n\s\*]/g, '');
var firstChar = stripped[0];
var isLetter = firstChar && letterPattern.test(firstChar);
var isLetter = firstChar && letterPattern(firstChar);

if (!isLetter) {
inTextBlock = false;
return;
}

var isUpperCase = upperCasePattern.test(firstChar);
var isUpperCase = upperCasePattern(firstChar);
var isValid = isUpperCase || (inTextBlock && !isUpperCase);

if (!isValid) {
Expand Down
3 changes: 1 addition & 2 deletions package.json
Expand Up @@ -47,8 +47,7 @@
"vow-fs": "~0.3.1",
"xmlbuilder": "~2.4.0",
"supports-color": "~1.2.0",
"unicode-6.3.0": "~0.1.5",
"regenerate": "~1.0.1"
"unicode-6.3.0": "~0.1.5"
},
"devDependencies": {
"browserify": "~7.0.3",
Expand Down

0 comments on commit 5d7bf3e

Please sign in to comment.