This repository has been archived by the owner on Mar 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 105
/
joblint.js
634 lines (563 loc) · 18.4 KB
/
joblint.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
/*! Joblint 2.3.2 | https://github.com/rowanmanning/joblint */
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.joblint = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
'use strict';
var extend = require('extend');
module.exports = joblint;
module.exports.defaults = {
rules: require('./rules')
};
function joblint (text, options) {
options = defaultOptions(options);
var result = {
counts: {},
issues: []
};
options.rules.forEach(function (rule) {
rule.triggers.forEach(function (trigger) {
var match;
while ((match = trigger.exec(text)) !== null) {
incrementKeys(rule.increment, result.counts);
result.issues.push(buildIssueFromMatch(match, rule));
}
});
});
Object.keys(result.counts).forEach(function (key) {
result.counts[key] = Math.max(result.counts[key], 0);
});
result.issues = result.issues.sort(sortByPosition);
return result;
}
function defaultOptions (options) {
options = extend({}, module.exports.defaults, options);
options.rules = buildRules(options.rules);
return options;
}
function buildRules (rules) {
return rules.map(buildRule);
}
function buildRule (rule) {
rule = extend(true, {}, rule);
rule.increment = rule.increment || {};
rule.triggers = rule.triggers.map(function (trigger) {
return new RegExp('\\b(' + trigger + ')\\b', 'gim');
});
return rule;
}
function incrementKeys (amounts, store) {
Object.keys(amounts).forEach(function (key) {
if (!store[key]) {
store[key] = 0;
}
store[key] += amounts[key];
});
}
function buildIssueFromMatch (match, rule) {
var issue = {
name: rule.name,
reason: rule.reason,
solution: rule.solution,
level: rule.level,
increment: rule.increment,
occurance: match[1],
position: match.index
};
issue.context = buildIssueContext(match.input, issue.occurance, issue.position);
return issue;
}
function buildIssueContext (input, occurance, position) {
var context = '{{occurance}}';
input
.substr(0, position)
.split(/[\r\n]+/)
.pop()
.replace(/\s+/g, ' ')
.split(/(\s+)/)
.reverse()
.forEach(function (word) {
if (context.length < 32) {
context = word + context;
}
else if (!/^…/.test(context)) {
context = '…' + context.trim();
}
});
input
.substr(position + occurance.length)
.split(/[\r\n]+/)
.shift()
.replace(/\s+/g, ' ')
.split(/(\s+)/)
.forEach(function (word) {
if (context.length < 52) {
context += word;
}
else if (!/…$/.test(context)) {
context = context.trim() + '…';
}
});
return context.trim();
}
function sortByPosition (a, b) {
if (a.position > b.position) {
return 1;
}
if (a.position < b.position) {
return -1;
}
return 0;
}
},{"./rules":2,"extend":3}],2:[function(require,module,exports){
// jscs:disable maximumLineLength
'use strict';
module.exports = [
// Use of gendered word
{
name: 'Use of gendered word',
reason: 'Use of gendered words could indicate that you\'re discriminating in favour of a certain gender.',
solution: 'Replace gendered words with gender-neutral alternatives.',
level: 'error',
increment: {
sexism: 1
},
triggers: [
'boys?',
'bros?',
'broth(a|er)s?',
'chicks?',
'dads?',
'dudes?',
'fathers?',
'females?',
'gentlem[ae]n',
'girls?',
'grandfathers?',
'grandmas?',
'grandmothers?',
'grandpas?',
'gran',
'grann(y|ies)',
'guys?',
'husbands?',
'lad(y|ies)?',
'm[ae]n',
'm[ou]ms?',
'males?',
'momm(y|ies)',
'mommas?',
'mothers?',
'papas?',
'sist(a|er)s?',
'wi(fe|ves)',
'wom[ae]n'
]
},
// Use of gendered pronoun
{
name: 'Use of gendered pronoun',
reason: 'Use of gendered pronouns indicate that you\'re discriminating in favour of a certain gender, or fail to recognise that gender is not binary.',
solution: 'Replace gendered pronouns with "them" or "they".',
level: 'error',
increment: {
sexism: 1
},
triggers: [
'he|her|him|his|she'
]
},
// Use of derogatory gendered term
{
name: 'Use of derogatory gendered term',
reason: 'When you use derogatory gendered terms, you\'re being discriminatory. These are offensive in a job post.',
solution: 'Remove these words.',
level: 'error',
increment: {
sexism: 2,
culture: 1
},
triggers: [
'bia?tch(es)?',
'bimbos?',
'hoes?',
'hunks?',
'milfs?',
'slags?',
'sluts?',
'stallions?',
'studs?'
]
},
// Mention of facial hair
{
name: 'Mention of facial hair',
reason: 'The use of "grizzled" or "bearded" indicates that you\'re only looking for male developers.',
solution: 'Remove these words.',
level: 'error',
increment: {
sexism: 1
},
triggers: [
'beard(ed|s|y)?',
'grizzl(ed|y)'
]
},
// Use of sexualised terms
{
name: 'Use of sexualised terms',
reason: 'Terms like "sexy code" are often used if the person writing a post doesn\'t know what they are talking about or can\'t articulate what good code is. It can also be an indicator of bro culture or sexism.',
solution: 'Remove these words.',
level: 'warning',
increment: {
culture: 1
},
triggers: [
'gay for',
'sexy',
'hawt',
'phat'
]
},
// Use of bro terminology
{
name: 'Use of bro terminology',
reason: 'Bro culture terminology can really reduce the number of people likely to show interest. It discriminates against anyone who doesn\'t fit into a single gender-specific archetype.',
solution: 'Remove these words.',
level: 'error',
increment: {
culture: 1
},
triggers: [
'bros?',
'brogramm(er|ers|ing)',
'crank',
'crush',
'dude(bro)?s?',
'hard[ -]*core',
'hella',
'mak(e|ing) it rain',
'skillz'
]
},
// Use of dumb job titles
{
name: 'Use of dumb job titles',
reason: 'Referring to tech people as Ninjas or similar devalues the work that they do and shows a lack of respect and professionalism. It\'s also rather cliched and can be an immediate turn-off to many people.',
solution: 'Consider what you\'re really asking for in an applicant and articulate this in the job post.',
level: 'warning',
increment: {
culture: 1,
realism: 1
},
triggers: [
'gurus?',
'hero(es|ic)?',
'ninjas?',
'rock[ -]*stars?',
'super[ -]*stars?',
'badass(es)?',
'BAMF'
]
},
// Mention of hollow benefits
{
name: 'Mention of hollow benefits',
reason: 'Benefits such as "beer fridge" and "pool table" are not bad in themselves, but their appearance in a job post often disguises the fact that there are few real benefits to working for a company. Be wary of these.',
solution: 'Ensure you\'re outlining real employee benefits if you have them. Don\'t use these as a carrot.',
level: 'warning',
increment: {
culture: 1,
recruiter: 1
},
triggers: [
'ales?',
'beers?',
'brewskis?',
'coffee',
'(foos|fuss)[ -]*ball',
'happy[ -]*hours?',
'keg(erator)?s?',
'lagers?',
'nerf[ -]*guns?',
'ping[ -]*pong?',
'pints?',
'pizzas?',
'play\\s*stations?',
'pool[ -]*table|pool',
'rock[ -]*walls?',
'table[ -]*football',
'table[ -]*tennis',
'wiis?',
'xbox(es|s)?',
'massages?'
]
},
// Competitive environment
{
name: 'Competitive environment',
reason: 'Competition can be healthy, but for a lot of people a heavily competitive environment can be a strain. You could also potentially be excluding people who have more important outside-of-work commitments, such as a family.',
solution: 'Be wary if you come across as competitive, aim for welcoming and friendly.',
level: 'notice',
increment: {
realism: 1,
recruiter: 1
},
triggers: [
'compete(?!nt|nce|ncy|ncies)',
'competition',
'competitive(?! salary| pay)',
'cutting[ -]edge',
'fail',
'fore[ -]*front',
'super[ -]*stars?',
'the best',
'reach the top',
'top of .{2,8} (game|class)',
'win'
]
},
// New starter expectations
{
name: 'New starter expectations',
reason: 'Terms like "hit the ground running" and others can indicate that the person writing a job post is unaware of the time and effort involved in preparing a new starter for work.',
solution: 'Reevaluate the use of these terms.',
level: 'notice',
increment: {
realism: 1
},
triggers: [
'hit[ -]the[ -]ground[ -]running',
'juggle',
'tight deadlines?'
]
},
// Use of Meritocracy
{
name: 'Use of Meritocracy',
reason: 'The term "meritocracy" is originally a satirical term relating to how we justify our own successes. Unfortunately, it\'s probably impossible to objectively measure merit, so this usually indicates that the company in question rewards people similar to themselves or using specious metrics.',
solution: 'Reevaluate the use of this term.',
level: 'notice',
increment: {
realism: 1
},
triggers: [
'meritocra(cy|cies|tic)'
]
},
// Use of profanity
{
name: 'Use of profanity',
reason: 'While swearing in the workplace can be OK, you shouldn\'t be using profanity in a job post – it\'s unprofessional.',
solution: 'Remove these words.',
level: 'warning',
increment: {
recruiter: 1
},
triggers: [
'bloody',
'bugger',
'cunt',
'damn',
'fuck(er|ing)?',
'piss(ing)?',
'shit',
'motherfuck(ers?|ing)'
]
},
// Use of "visionary" terminology
{
name: 'Use of "visionary" terminology',
reason: 'Terms like "blue sky" and "enlightened" often indicate that a non technical person (perhaps a CEO or stakeholder) has been involved in writing the post. Be down-to-earth, and explain things in plain English.',
solution: 'Reword these phrases, say what you actually mean.',
level: 'warning',
increment: {
culture: 1,
realism: 1
},
triggers: [
'blue[ -]*sk(y|ies)',
'enlighten(ed|ing)?',
'green[ -]*fields?',
'incentivi[sz]e',
'paradigm',
'producti[sz]e',
'reach(ed|ing)? out',
'synerg(y|ize|ise)',
'visionar(y|ies)'
]
},
// Need to reassure
{
name: 'Need to reassure',
reason: 'Something feels off when you need to reassure someone of something that should definitely not be an issue in any workplace.',
solution: 'Reassess the need for these phrases.',
level: 'notice',
increment: {
culture: 1
},
triggers: [
'drama[ -]*free',
'stress[ -]*free'
]
},
// Mention of legacy technology
{
name: 'Mention of legacy technology',
reason: 'Legacy technologies can reduce the number of people interested in a job. Sometimes we can\'t avoid this, but extreme legacy tech can often indicate that a company isn\'t willing to move forwards or invest in career development.',
solution: 'If possible (and you\'re being honest), play down the use of this technology.',
level: 'notice',
increment: {
realism: 1,
tech: 1
},
triggers: [
'cobol',
'cvs',
'front[ -]*page',
'rcs',
'sccs',
'source[ -]*safe',
'vb\\s*6',
'visual[ -]*basic\\s*6',
'vbscript'
]
},
// Mention of a development environment
{
name: 'Mention of a development environment',
reason: 'Unless you\'re building in a something which requires a certain development environment (e.g. iOS development and XCode), it shouldn\'t matter which tools a developer decides to use to write code – their output will be better if they are working in a familiar environment.',
solution: 'Don\'t specify a development environment unless absolutely necessary.',
level: 'notice',
increment: {
culture: 1,
tech: 1
},
triggers: [
'atom',
'bb[ -]*edit',
'dream[ -]*weaver',
'eclipse',
'emacs',
'net[ -]*beans',
'note[ -]*pad',
'sublime[ -]*text',
'text[ -]*wrangler',
'text[ -]*mate',
'vim?',
'visual[ -]*studio'
]
},
// Use of expanded acronyms
{
name: 'Use of expanded acronyms',
reason: 'Tech people know their acronyms; you come across as not very tech-savvy if you expand them.',
solution: 'Use acronyms in place of these words.',
level: 'warning',
increment: {
recruiter: 1,
tech: 1
},
triggers: [
'cascading[ -]?style[ -]?sheets',
'hyper[ -]?text([ -]?mark[ -]?up([ -]?language)?)?'
]
},
// Java script?
{
name: 'Java script?',
reason: 'JavaScript is one word. You write JavaScript, not javascripts or java script.',
solution: 'Replace this word with "JavaScript".',
level: 'error',
increment: {
recruiter: 1
},
triggers: [
'java[ -]script|java[ -]*scripts'
]
},
// Ruby on Rail?
{
name: 'Ruby on Rail?',
reason: 'Ruby On Rails is plural – there is more than one rail.',
solution: 'Replace this with "Ruby on Rails".',
level: 'error',
increment: {
recruiter: 1
},
triggers: [
'ruby on rail'
]
}
];
},{}],3:[function(require,module,exports){
'use strict';
var hasOwn = Object.prototype.hasOwnProperty;
var toStr = Object.prototype.toString;
var isArray = function isArray(arr) {
if (typeof Array.isArray === 'function') {
return Array.isArray(arr);
}
return toStr.call(arr) === '[object Array]';
};
var isPlainObject = function isPlainObject(obj) {
if (!obj || toStr.call(obj) !== '[object Object]') {
return false;
}
var hasOwnConstructor = hasOwn.call(obj, 'constructor');
var hasIsPrototypeOf = obj.constructor && obj.constructor.prototype && hasOwn.call(obj.constructor.prototype, 'isPrototypeOf');
// Not own constructor property must be Object
if (obj.constructor && !hasOwnConstructor && !hasIsPrototypeOf) {
return false;
}
// Own properties are enumerated firstly, so to speed up,
// if last one is own, then all properties are own.
var key;
for (key in obj) {/**/}
return typeof key === 'undefined' || hasOwn.call(obj, key);
};
module.exports = function extend() {
var options, name, src, copy, copyIsArray, clone,
target = arguments[0],
i = 1,
length = arguments.length,
deep = false;
// Handle a deep copy situation
if (typeof target === 'boolean') {
deep = target;
target = arguments[1] || {};
// skip the boolean and the target
i = 2;
} else if ((typeof target !== 'object' && typeof target !== 'function') || target == null) {
target = {};
}
for (; i < length; ++i) {
options = arguments[i];
// Only deal with non-null/undefined values
if (options != null) {
// Extend the base object
for (name in options) {
src = target[name];
copy = options[name];
// Prevent never-ending loop
if (target !== copy) {
// Recurse if we're merging plain objects or arrays
if (deep && copy && (isPlainObject(copy) || (copyIsArray = isArray(copy)))) {
if (copyIsArray) {
copyIsArray = false;
clone = src && isArray(src) ? src : [];
} else {
clone = src && isPlainObject(src) ? src : {};
}
// Never move original objects, clone them
target[name] = extend(deep, clone, copy);
// Don't bring in undefined values
} else if (typeof copy !== 'undefined') {
target[name] = copy;
}
}
}
}
}
// Return the modified object
return target;
};
},{}]},{},[1])(1)
});