Skip to content

Commit 2a84da5

Browse files
Trottevanlucas
authored andcommitted
tools: increase lint coverage
Extend linting to tools/license2rtf.js and any other JS that gets added to the `tools` directory by default. This incidentally simplifies lint invocation. PR-URL: #7647 Reviewed-By: Michaël Zasso <mic.besace@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
1 parent f15d2d6 commit 2a84da5

4 files changed

Lines changed: 55 additions & 59 deletions

File tree

‎.eslintignore‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ lib/internal/v8_prof_polyfill.js
22
lib/punycode.js
33
test/addons/??_*/
44
test/fixtures
5-
test/**/node_modules
65
test/disabled
76
test/tmp*/
8-
tools/doc/node_modules
7+
tools/eslint
8+
node_modules

‎Makefile‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -678,13 +678,11 @@ bench-idle:
678678
$(NODE) benchmark/idle_clients.js &
679679

680680
jslint:
681-
$(NODE) tools/jslint.js -J benchmark lib src test tools/doc \
682-
tools/eslint-rules tools/jslint.js
681+
$(NODE) tools/jslint.js -J benchmark lib src test tools
683682

684683
jslint-ci:
685684
$(NODE) tools/jslint.js $(PARALLEL_ARGS) -f tap -o test-eslint.tap \
686-
benchmark lib src test tools/doc \
687-
tools/eslint-rules tools/jslint.js
685+
benchmark lib src test tools
688686

689687
CPPLINT_EXCLUDE ?=
690688
CPPLINT_EXCLUDE += src/node_root_certs.h

‎tools/license2rtf.js‎

Lines changed: 49 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1+
'use strict';
12

2-
varassert=require('assert'),
3-
Stream=require('stream'),
4-
inherits=require('util').inherits;
3+
constassert=require('assert');
4+
constStream=require('stream');
5+
constinherits=require('util').inherits;
56

67

78
/*
89
* This filter consumes a stream of characters and emits one string per line.
910
*/
1011
functionLineSplitter(){
11-
varself=this,
12-
buffer="";
12+
constself=this;
13+
varbuffer='';
1314

1415
Stream.call(this);
1516
this.writable=true;
@@ -38,33 +39,31 @@ inherits(LineSplitter, Stream);
3839
* This filter consumes lines and emits paragraph objects.
3940
*/
4041
functionParagraphParser(){
41-
varself=this,
42-
block_is_license_block=false,
43-
block_has_c_style_comment,
44-
is_first_line_in_paragraph,
45-
paragraph_line_indent,
46-
paragraph;
47-
48-
Stream.call(this);
49-
this.writable=true;
50-
51-
resetBlock(false);
52-
53-
this.write=function(data){
54-
parseLine(data+'');
55-
returntrue;
56-
};
57-
58-
this.end=function(data){
59-
if(data){
60-
parseLine(data+'');
61-
}
62-
flushParagraph();
63-
self.emit('end');
64-
};
42+
constself=this;
43+
varblock_is_license_block=false;
44+
varblock_has_c_style_comment;
45+
varparagraph_line_indent;
46+
varparagraph;
47+
48+
Stream.call(this);
49+
this.writable=true;
50+
51+
resetBlock(false);
52+
53+
this.write=function(data){
54+
parseLine(data+'');
55+
returntrue;
56+
};
57+
58+
this.end=function(data){
59+
if(data){
60+
parseLine(data+'');
61+
}
62+
flushParagraph();
63+
self.emit('end');
64+
};
6565

6666
functionresetParagraph(){
67-
is_first_line_in_paragraph=true;
6867
paragraph_line_indent=-1;
6968

7069
paragraph={
@@ -165,8 +164,6 @@ function ParagraphParser() {
165164

166165
if(line)
167166
paragraph.lines.push(line);
168-
169-
is_first_line_in_paragraph=false;
170167
}
171168
}
172169
inherits(ParagraphParser,Stream);
@@ -184,16 +181,16 @@ function Unwrapper() {
184181
this.writable=true;
185182

186183
this.write=function(paragraph){
187-
varlines=paragraph.lines,
188-
break_after=[],
189-
i;
184+
varlines=paragraph.lines;
185+
varbreak_after=[];
186+
vari;
190187

191188
for(i=0;i<lines.length-1;i++){
192189
varline=lines[i];
193190

194191
// When a line is really short, the line was probably kept separate for a
195192
// reason.
196-
if(line.length<50){
193+
if(line.length<50){
197194
// If the first word on the next line really didn't fit after the line,
198195
// it probably was just ordinary wrapping after all.
199196
varnext_first_word_length=lines[i+1].replace(/\s.*$/,'').length;
@@ -203,7 +200,7 @@ function Unwrapper() {
203200
}
204201
}
205202

206-
for(i=0;i<lines.length-1;){
203+
for(i=0;i<lines.length-1;){
207204
if(!break_after[i]){
208205
lines[i]+=' '+lines.splice(i+1,1)[0];
209206
}else{
@@ -233,8 +230,8 @@ inherits(Unwrapper, Stream);
233230
* This filter generates an rtf document from a stream of paragraph objects.
234231
*/
235232
functionRtfGenerator(){
236-
varself=this,
237-
did_write_anything=false;
233+
constself=this;
234+
vardid_write_anything=false;
238235

239236
Stream.call(this);
240237
this.writable=true;
@@ -245,11 +242,11 @@ function RtfGenerator() {
245242
did_write_anything=true;
246243
}
247244

248-
varli=paragraph.li,
249-
level=paragraph.level+(li ? 1 : 0),
250-
lic=paragraph.in_license_block;
245+
varli=paragraph.li;
246+
varlevel=paragraph.level+(li ? 1 : 0);
247+
varlic=paragraph.in_license_block;
251248

252-
varrtf="\\pard";
249+
varrtf='\\pard';
253250
rtf+='\\sa150\\sl300\\slmult1';
254251
if(level>0)
255252
rtf+='\\li'+(level*240);
@@ -290,18 +287,19 @@ function RtfGenerator() {
290287
functionrtfEscape(string){
291288
returnstring
292289
.replace(/[\\\{\}]/g,function(m){
293-
return'\\'+m;
290+
return'\\'+m;
294291
})
295292
.replace(/\t/g,function(){
296293
return'\\tab ';
297294
})
295+
// eslint-disable-next-line no-control-regex
298296
.replace(/[\x00-\x1f\x7f-\xff]/g,function(m){
299297
return'\\\''+toHex(m.charCodeAt(0),2);
300298
})
301299
.replace(/\ufeff/g,'')
302300
.replace(/[\u0100-\uffff]/g,function(m){
303301
return'\\u'+toHex(m.charCodeAt(0),4)+'?';
304-
});
302+
});
305303
}
306304

307305
functionemitHeader(){
@@ -317,12 +315,12 @@ function RtfGenerator() {
317315
inherits(RtfGenerator,Stream);
318316

319317

320-
varstdin=process.stdin,
321-
stdout=process.stdout,
322-
line_splitter=newLineSplitter(),
323-
paragraph_parser=newParagraphParser(),
324-
unwrapper=newUnwrapper(),
325-
rtf_generator=newRtfGenerator();
318+
conststdin=process.stdin;
319+
conststdout=process.stdout;
320+
constline_splitter=newLineSplitter();
321+
constparagraph_parser=newParagraphParser();
322+
constunwrapper=newUnwrapper();
323+
constrtf_generator=newRtfGenerator();
326324

327325
stdin.setEncoding('utf-8');
328326
stdin.resume();

‎vcbuild.bat‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,12 +348,12 @@ if defined jslint_ci goto jslint-ci
348348
ifnotdefined jslint gotoexit
349349
ifnotexist tools\eslint\bin\eslint.js goto no-lint
350350
echo running jslint
351-
%config%\node tools\jslint.js -J benchmark lib src test tools\doc tools\eslint-rules tools\jslint.js
351+
%config%\node tools\jslint.js -J benchmark lib src test tools
352352
gotoexit
353353

354354
:jslint-ci
355355
echo running jslint-ci
356-
%config%\node tools\jslint.js -J -f tap -o test-eslint.tap benchmark lib src test tools\doc tools\eslint-rules tools\jslint.js
356+
%config%\node tools\jslint.js -J -f tap -o test-eslint.tap benchmark lib src test tools
357357
gotoexit
358358

359359
:no-lint

0 commit comments

Comments
 (0)