Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: update ESLint to version 2.1.0 #5214

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
19 changes: 3 additions & 16 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
env:
node: true

# enable ECMAScript features
ecmaFeatures:
arrowFunctions: true
binaryLiterals: true
blockBindings: true
classes: true
forOf: true
generators: true
objectLiteralShorthandMethods: true
objectLiteralShorthandProperties: true
octalLiterals: true
templateStrings: true
es6: true

rules:
# Possible Errors
Expand Down Expand Up @@ -48,28 +36,27 @@ rules:
comma-spacing: 2
eol-last: 2
indent: [2, 2, {SwitchCase: 1}]
keyword-spacing: 2
max-len: [2, 80, 2]
new-parens: 2
no-mixed-spaces-and-tabs: 2
no-multiple-empty-lines: [2, {max: 2}]
no-trailing-spaces: 2
quotes: [2, "single", "avoid-escape"]
semi: 2
space-after-keywords: 2
space-before-blocks: [2, "always"]
space-before-function-paren: [2, "never"]
space-in-parens: [2, "never"]
space-infix-ops: 2
space-return-throw-case: 2
space-unary-ops: 2

# ECMAScript 6
# http://eslint.org/docs/rules/#ecmascript-6
arrow-parens: [2, "always"]
arrow-spacing: [2, {"before": true, "after": true}]
constructor-super: 2
no-arrow-condition: 2
no-class-assign: 2
no-confusing-arrow: 2
no-const-assign: 2
no-dupe-class-members: 2
no-this-before-super: 2
Expand Down
2 changes: 1 addition & 1 deletion src/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
get() {
const internalUtil = NativeModule.require('internal/util');
eeWarned = internalUtil.printDeprecationMessage(
`process.EventEmitter is deprecated. Use require('events') instead.`,
"process.EventEmitter is deprecated. Use require('events') instead.",
eeWarned
);
return EventEmitter;
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-debug-brk.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ const common = require('../common');
const assert = require('assert');
const spawnSync = require('child_process').spawnSync;

const args = [`--debug-brk=${common.PORT}`, `-e`, `0`];
const args = [`--debug-brk=${common.PORT}`, '-e', '0'];
const proc = spawnSync(process.execPath, args, {encoding: 'utf8'});
assert(/Debugger listening on/.test(proc.stderr));
2 changes: 1 addition & 1 deletion test/parallel/test-debug-no-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const common = require('../common');
const assert = require('assert');
const spawn = require('child_process').spawn;

const args = [`--debug`, `--debug-port=${common.PORT}`, `--interactive`];
const args = ['--debug', `--debug-port=${common.PORT}`, '--interactive'];
const proc = spawn(process.execPath, args, { stdio: 'pipe' });
proc.stdin.write(`
util.inspect(Promise.resolve(42));
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-dgram-udp4.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ const assert = require('assert');
const dgram = require('dgram');
const server_port = common.PORT;
const message_to_send = 'A message to send';
let server, client;
let client;
let timer;

server = dgram.createSocket('udp4');
const server = dgram.createSocket('udp4');
server.on('message', function(msg, rinfo) {
console.log('server got: ' + msg +
' from ' + rinfo.address + ':' + rinfo.port);
Expand Down
3 changes: 1 addition & 2 deletions test/parallel/test-file-write-stream3.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ function run_test_3() {
var file, options;

const data = '\u2026\u2026'; // 3 bytes * 2 = 6 bytes in UTF-8
let fileData;

options = { start: 10,
flags: 'r+' };
Expand All @@ -144,7 +143,7 @@ function run_test_3() {
console.log(' (debug: start ', file.start);
console.log(' (debug: pos ', file.pos);
assert.strictEqual(file.bytesWritten, data.length * 3);
fileData = fs.readFileSync(filepath, 'utf8');
const fileData = fs.readFileSync(filepath, 'utf8');
console.log(' (debug: file data ', fileData);
console.log(' (debug: expected ', fileDataExpected_3);
assert.equal(fileData, fileDataExpected_3);
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-fs-realpath.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function test_simple_relative_symlink(callback) {
[
[entry, '../' + common.tmpDirName + '/cycles/root.js']
].forEach(function(t) {
try {fs.unlinkSync(t[0]);}catch (e) {}
try {fs.unlinkSync(t[0]);} catch (e) {}
console.log('fs.symlinkSync(%j, %j, %j)', t[1], t[0], 'file');
fs.symlinkSync(t[1], t[0], 'file');
unlink.push(t[0]);
Expand Down
5 changes: 2 additions & 3 deletions test/parallel/test-path.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,12 +316,11 @@ joinTests.forEach(function(test) {
test[1].forEach(function(test) {
const actual = join.apply(null, test[0]);
const expected = test[1];
let actualAlt;
// For non-Windows specific tests with the Windows join(), we need to try
// replacing the slashes since the non-Windows specific tests' `expected`
// use forward slashes
if (join === path.win32.join)
actualAlt = actual.replace(/\\/g, '/');
const actualAlt = (join === path.win32.join) ?
actual.replace(/\\/g, '/') : undefined;
const fn = 'path.' +
(join === path.win32.join ? 'win32' : 'posix') +
'.join(';
Expand Down
8 changes: 4 additions & 4 deletions test/parallel/test-tls-two-cas-one-string.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ const tls = require('tls');
const fs = require('fs');

const ca1 =
fs.readFileSync(`${common.fixturesDir}/keys/ca1-cert.pem`, `utf8`);
fs.readFileSync(`${common.fixturesDir}/keys/ca1-cert.pem`, 'utf8');
const ca2 =
fs.readFileSync(`${common.fixturesDir}/keys/ca2-cert.pem`, `utf8`);
fs.readFileSync(`${common.fixturesDir}/keys/ca2-cert.pem`, 'utf8');
const cert =
fs.readFileSync(`${common.fixturesDir}/keys/agent3-cert.pem`, `utf8`);
fs.readFileSync(`${common.fixturesDir}/keys/agent3-cert.pem`, 'utf8');
const key =
fs.readFileSync(`${common.fixturesDir}/keys/agent3-key.pem`, `utf8`);
fs.readFileSync(`${common.fixturesDir}/keys/agent3-key.pem`, 'utf8');

function test(ca, next) {
const server = tls.createServer({ ca, cert, key }, function(conn) {
Expand Down
27 changes: 13 additions & 14 deletions test/parallel/test-url.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,20 +259,19 @@ var parseTests = {
path: '/vt/lyrs=m@114???&hl=en&src=api&x=2&y=2&z=3&s='
},

'http://user:pass@mt0.google.com/vt/lyrs=m@114???&hl=en&src=api&x=2&y=2&z=3&s=':
{
href: 'http://user:pass@mt0.google.com/vt/lyrs=m@114???' +
'&hl=en&src=api&x=2&y=2&z=3&s=',
protocol: 'http:',
slashes: true,
host: 'mt0.google.com',
auth: 'user:pass',
hostname: 'mt0.google.com',
search: '???&hl=en&src=api&x=2&y=2&z=3&s=',
query: '??&hl=en&src=api&x=2&y=2&z=3&s=',
pathname: '/vt/lyrs=m@114',
path: '/vt/lyrs=m@114???&hl=en&src=api&x=2&y=2&z=3&s='
},
'http://user:pass@mt0.google.com/vt/lyrs=m@114???&hl=en&src=api&x=2&y=2&z=3&s=': {
href: 'http://user:pass@mt0.google.com/vt/lyrs=m@114???' +
'&hl=en&src=api&x=2&y=2&z=3&s=',
protocol: 'http:',
slashes: true,
host: 'mt0.google.com',
auth: 'user:pass',
hostname: 'mt0.google.com',
search: '???&hl=en&src=api&x=2&y=2&z=3&s=',
query: '??&hl=en&src=api&x=2&y=2&z=3&s=',
pathname: '/vt/lyrs=m@114',
path: '/vt/lyrs=m@114???&hl=en&src=api&x=2&y=2&z=3&s='
},

'file:///etc/passwd': {
href: 'file:///etc/passwd',
Expand Down
4 changes: 2 additions & 2 deletions test/sequential/test-child-process-fork-getconnections.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ if (process.argv[2] === 'child') {

let disconnected = 0;
server.on('listening', function() {
let j = count, client;
let j = count;
while (j--) {
client = net.connect(common.PORT, '127.0.0.1');
const client = net.connect(common.PORT, '127.0.0.1');
client.on('close', function() {
disconnected += 1;
});
Expand Down
3 changes: 1 addition & 2 deletions tools/doc/addon-verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const contents = fs.readFileSync(doc).toString();

const tokens = marked.lexer(contents, {});
let files = null;
let blockName;
let id = 0;

// Just to make sure that all examples will be processed
Expand All @@ -28,7 +27,7 @@ oldDirs = oldDirs.filter(function(dir) {
for (var i = 0; i < tokens.length; i++) {
var token = tokens[i];
if (token.type === 'heading' && token.text) {
blockName = token.text;
const blockName = token.text;
if (files && Object.keys(files).length !== 0) {
verifyFiles(files,
blockName,
Expand Down
5 changes: 0 additions & 5 deletions tools/eslint-rules/new-with-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ module.exports = function(context) {

module.exports.schema = {
'type': 'array',
'items': [
{
'enum': [0, 1, 2]
}
],
'additionalItems': {
'type': 'string'
},
Expand Down
19 changes: 11 additions & 8 deletions tools/eslint-rules/require-buffer.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
'use strict';

const msg = 'Use const Buffer = require(\'buffer\').Buffer; ' +
'at the beginning of this file';

module.exports = function(context) {
function flagIt(reference) {
const msg = 'Use const Buffer = require(\'buffer\').Buffer; ' +
'at the beginning of this file';
context.report(reference.identifier, msg);
}

return {
'Program:exit': function() {
context.getScope().through.forEach(function(ref) {
if (ref.identifier.name === 'Buffer') {
context.report(ref.identifier, msg);
}
});
const globalScope = context.getScope();
const variable = globalScope.set.get('Buffer');
if (variable) {
variable.references.forEach(flagIt);
}
}
};
};
5 changes: 0 additions & 5 deletions tools/eslint-rules/required-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,6 @@ module.exports = function(context) {

module.exports.schema = {
'type': 'array',
'items': [
{
'enum': [0, 1, 2]
}
],
'additionalItems': {
'type': 'string'
},
Expand Down
14 changes: 13 additions & 1 deletion tools/eslint/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
[![NPM version][npm-image]][npm-url]
[![build status][travis-image]][travis-url]
[![Build status][appveyor-image]][appveyor-url]
[![Test coverage][coveralls-image]][coveralls-url]
[![Downloads][downloads-image]][downloads-url]
[![Bountysource](https://www.bountysource.com/badge/tracker?tracker_id=282608)](https://www.bountysource.com/trackers/282608-eslint?utm_source=282608&utm_medium=shield&utm_campaign=TRACKER_BADGE)
[![Join the chat at https://gitter.im/eslint/eslint](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/eslint/eslint?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

# ESLint

[Website](http://eslint.org) | [Configuring](http://eslint.org/docs/user-guide/configuring) | [Rules](http://eslint.org/docs/rules/) | [Contributing](http://eslint.org/docs/developer-guide/contributing) | [Twitter](https://twitter.com/geteslint) | [Mailing List](https://groups.google.com/group/eslint)
[Website](http://eslint.org) | [Configuring](http://eslint.org/docs/user-guide/configuring) | [Rules](http://eslint.org/docs/rules/) | [Contributing](http://eslint.org/docs/developer-guide/contributing) | [Reporting Bugs](http://eslint.org/docs/developer-guide/contributing/reporting-bugs) | [Twitter](https://twitter.com/geteslint) | [Mailing List](https://groups.google.com/group/eslint)

ESLint is a tool for identifying and reporting on patterns found in ECMAScript/JavaScript code. In many ways, it is similar to JSLint and JSHint with a few exceptions:

Expand Down Expand Up @@ -55,6 +56,7 @@ The three error levels allow you fine-grained control over how ESLint applies ru
## Sponsors

* Development is sponsored by [Box](https://box.com)
* Site search ([eslint.org](http://eslint.org)) is sponsored by [Algolia](https://www.algolia.com)

## Team

Expand All @@ -75,6 +77,14 @@ These folks keep the project moving and are resources for help:

We have scheduled releases every two weeks on Friday or Saturday.

## Filing Issues

Before filing an issue, please be sure to read the guidelines for what you're reporting:

* [Bug Report](http://eslint.org/docs/developer-guide/contributing/reporting-bugs)
* [Propose a New Rule](http://eslint.org/docs/developer-guide/contributing/new-rules)
* [Request a Change](http://eslint.org/docs/developer-guide/contributing/changes)

## Frequently Asked Questions

### Why don't you like JSHint???
Expand Down Expand Up @@ -120,6 +130,8 @@ Join our [Mailing List](https://groups.google.com/group/eslint) or [Chatroom](ht
[npm-url]: https://www.npmjs.com/package/eslint
[travis-image]: https://img.shields.io/travis/eslint/eslint/master.svg?style=flat-square
[travis-url]: https://travis-ci.org/eslint/eslint
[appveyor-image]: https://ci.appveyor.com/api/projects/status/iwxmiobcvbw3b0av/branch/master?svg=true
[appveyor-url]: https://ci.appveyor.com/project/nzakas/eslint/branch/master
[coveralls-image]: https://img.shields.io/coveralls/eslint/eslint/master.svg?style=flat-square
[coveralls-url]: https://coveralls.io/r/eslint/eslint?branch=master
[downloads-image]: https://img.shields.io/npm/dm/eslint.svg?style=flat-square
Expand Down
22 changes: 14 additions & 8 deletions tools/eslint/bin/eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var exitCode = 0,

// must do this initialization *before* other requires in order to work
if (debug) {
require("debug").enable("eslint:*");
require("debug").enable("eslint:*,-eslint:code-path");
}

//------------------------------------------------------------------------------
Expand Down Expand Up @@ -60,10 +60,16 @@ if (useStdIn) {
exitCode = cli.execute(process.argv);
}

/*
* Wait for the stdout buffer to drain.
* See https://github.com/eslint/eslint/issues/317
*/
process.on("exit", function() {
process.exit(exitCode);
});
// https://github.com/eslint/eslint/issues/4691
// In Node.js >= 0.12, you can use a cleaner way
if ("exitCode" in process) {
process.exitCode = exitCode;
} else {
/*
* Wait for the stdout buffer to drain.
* See https://github.com/eslint/eslint/issues/317
*/
process.on("exit", function() {
process.exit(exitCode);
});
}
33 changes: 33 additions & 0 deletions tools/eslint/conf/cli-options.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* @fileoverview Default CLIEngineOptions.
* @author Ian VanSchooten
* @copyright 2016 Ian VanSchooten. All rights reserved.
* See LICENSE in root directory for full license.
*/

"use strict";

var DEFAULT_PARSER = require("../conf/eslint.json").parser;

module.exports = {
configFile: null,
baseConfig: false,
rulePaths: [],
useEslintrc: true,
envs: [],
globals: [],
rules: {},
extensions: [".js"],
ignore: true,
ignorePath: null,
parser: DEFAULT_PARSER,
cache: false,
// in order to honor the cacheFile option if specified
// this option should not have a default value otherwise
// it will always be used
cacheLocation: "",
cacheFile: ".eslintcache",
fix: false,
allowInlineConfig: true,
cwd: process.cwd()
};
Loading