Browse Source

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: https://github.com/nodejs/node/pull/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>
v7.x
Rich Trott 9 years ago
parent
commit
cbbddc4fb0
  1. 4
      .eslintignore
  2. 6
      Makefile
  3. 58
      tools/license2rtf.js
  4. 4
      vcbuild.bat

4
.eslintignore

@ -2,7 +2,7 @@ lib/internal/v8_prof_polyfill.js
lib/punycode.js lib/punycode.js
test/addons/??_*/ test/addons/??_*/
test/fixtures test/fixtures
test/**/node_modules
test/disabled test/disabled
test/tmp*/ test/tmp*/
tools/doc/node_modules tools/eslint
node_modules

6
Makefile

@ -678,13 +678,11 @@ bench-idle:
$(NODE) benchmark/idle_clients.js & $(NODE) benchmark/idle_clients.js &
jslint: jslint:
$(NODE) tools/jslint.js -J benchmark lib src test tools/doc \ $(NODE) tools/jslint.js -J benchmark lib src test tools
tools/eslint-rules tools/jslint.js
jslint-ci: jslint-ci:
$(NODE) tools/jslint.js $(PARALLEL_ARGS) -f tap -o test-eslint.tap \ $(NODE) tools/jslint.js $(PARALLEL_ARGS) -f tap -o test-eslint.tap \
benchmark lib src test tools/doc \ benchmark lib src test tools
tools/eslint-rules tools/jslint.js
CPPLINT_EXCLUDE ?= CPPLINT_EXCLUDE ?=
CPPLINT_EXCLUDE += src/node_root_certs.h CPPLINT_EXCLUDE += src/node_root_certs.h

58
tools/license2rtf.js

@ -1,15 +1,16 @@
'use strict';
var assert = require('assert'), const assert = require('assert');
Stream = require('stream'), const Stream = require('stream');
inherits = require('util').inherits; const inherits = require('util').inherits;
/* /*
* This filter consumes a stream of characters and emits one string per line. * This filter consumes a stream of characters and emits one string per line.
*/ */
function LineSplitter() { function LineSplitter() {
var self = this, const self = this;
buffer = ""; var buffer = '';
Stream.call(this); Stream.call(this);
this.writable = true; this.writable = true;
@ -38,12 +39,11 @@ inherits(LineSplitter, Stream);
* This filter consumes lines and emits paragraph objects. * This filter consumes lines and emits paragraph objects.
*/ */
function ParagraphParser() { function ParagraphParser() {
var self = this, const self = this;
block_is_license_block = false, var block_is_license_block = false;
block_has_c_style_comment, var block_has_c_style_comment;
is_first_line_in_paragraph, var paragraph_line_indent;
paragraph_line_indent, var paragraph;
paragraph;
Stream.call(this); Stream.call(this);
this.writable = true; this.writable = true;
@ -64,7 +64,6 @@ function ParagraphParser() {
}; };
function resetParagraph() { function resetParagraph() {
is_first_line_in_paragraph = true;
paragraph_line_indent = -1; paragraph_line_indent = -1;
paragraph = { paragraph = {
@ -165,8 +164,6 @@ function ParagraphParser() {
if (line) if (line)
paragraph.lines.push(line); paragraph.lines.push(line);
is_first_line_in_paragraph = false;
} }
} }
inherits(ParagraphParser, Stream); inherits(ParagraphParser, Stream);
@ -184,9 +181,9 @@ function Unwrapper() {
this.writable = true; this.writable = true;
this.write = function(paragraph) { this.write = function(paragraph) {
var lines = paragraph.lines, var lines = paragraph.lines;
break_after = [], var break_after = [];
i; var i;
for (i = 0; i < lines.length - 1; i++) { for (i = 0; i < lines.length - 1; i++) {
var line = lines[i]; var line = lines[i];
@ -203,7 +200,7 @@ function Unwrapper() {
} }
} }
for (i = 0; i < lines.length - 1; ) { for (i = 0; i < lines.length - 1;) {
if (!break_after[i]) { if (!break_after[i]) {
lines[i] += ' ' + lines.splice(i + 1, 1)[0]; lines[i] += ' ' + lines.splice(i + 1, 1)[0];
} else { } else {
@ -233,8 +230,8 @@ inherits(Unwrapper, Stream);
* This filter generates an rtf document from a stream of paragraph objects. * This filter generates an rtf document from a stream of paragraph objects.
*/ */
function RtfGenerator() { function RtfGenerator() {
var self = this, const self = this;
did_write_anything = false; var did_write_anything = false;
Stream.call(this); Stream.call(this);
this.writable = true; this.writable = true;
@ -245,11 +242,11 @@ function RtfGenerator() {
did_write_anything = true; did_write_anything = true;
} }
var li = paragraph.li, var li = paragraph.li;
level = paragraph.level + (li ? 1 : 0), var level = paragraph.level + (li ? 1 : 0);
lic = paragraph.in_license_block; var lic = paragraph.in_license_block;
var rtf = "\\pard"; var rtf = '\\pard';
rtf += '\\sa150\\sl300\\slmult1'; rtf += '\\sa150\\sl300\\slmult1';
if (level > 0) if (level > 0)
rtf += '\\li' + (level * 240); rtf += '\\li' + (level * 240);
@ -295,6 +292,7 @@ function RtfGenerator() {
.replace(/\t/g, function() { .replace(/\t/g, function() {
return '\\tab '; return '\\tab ';
}) })
// eslint-disable-next-line no-control-regex
.replace(/[\x00-\x1f\x7f-\xff]/g, function(m) { .replace(/[\x00-\x1f\x7f-\xff]/g, function(m) {
return '\\\'' + toHex(m.charCodeAt(0), 2); return '\\\'' + toHex(m.charCodeAt(0), 2);
}) })
@ -317,12 +315,12 @@ function RtfGenerator() {
inherits(RtfGenerator, Stream); inherits(RtfGenerator, Stream);
var stdin = process.stdin, const stdin = process.stdin;
stdout = process.stdout, const stdout = process.stdout;
line_splitter = new LineSplitter(), const line_splitter = new LineSplitter();
paragraph_parser = new ParagraphParser(), const paragraph_parser = new ParagraphParser();
unwrapper = new Unwrapper(), const unwrapper = new Unwrapper();
rtf_generator = new RtfGenerator(); const rtf_generator = new RtfGenerator();
stdin.setEncoding('utf-8'); stdin.setEncoding('utf-8');
stdin.resume(); stdin.resume();

4
vcbuild.bat

@ -348,12 +348,12 @@ if defined jslint_ci goto jslint-ci
if not defined jslint goto exit if not defined jslint goto exit
if not exist tools\eslint\bin\eslint.js goto no-lint if not exist tools\eslint\bin\eslint.js goto no-lint
echo running jslint echo running jslint
%config%\node tools\jslint.js -J benchmark lib src test tools\doc tools\eslint-rules tools\jslint.js %config%\node tools\jslint.js -J benchmark lib src test tools
goto exit goto exit
:jslint-ci :jslint-ci
echo running jslint-ci echo running jslint-ci
%config%\node tools\jslint.js -J -f tap -o test-eslint.tap benchmark lib src test tools\doc tools\eslint-rules tools\jslint.js %config%\node tools\jslint.js -J -f tap -o test-eslint.tap benchmark lib src test tools
goto exit goto exit
:no-lint :no-lint

Loading…
Cancel
Save