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 and re-enable comma-spacing rule #2072

Closed
wants to merge 2 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
  •  
  •  
  •  
3 changes: 1 addition & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ rules:
## 2 space indentation
indent: [2, 2]
## add space after comma
## set to 'warn' because of https://github.com/eslint/eslint/issues/2408
comma-spacing: 1
comma-spacing: 2
## put semi-colon
semi: 2
## require spaces operator like var sum = 1 + 1;
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-dgram-oob-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var assert = require('assert');
var dgram = require('dgram');

var socket = dgram.createSocket('udp4');
var buf = Buffer([1,2,3,4]);
var buf = Buffer([1, 2, 3, 4]);

function ok() {}
socket.send(buf, 0, 0, common.PORT, '127.0.0.1', ok); // useful? no
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-domain-http-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var http = require('http');
var assert = require('assert');
var common = require('../common');

var objects = { foo: 'bar', baz: {}, num: 42, arr: [1,2,3] };
var objects = { foo: 'bar', baz: {}, num: 42, arr: [1, 2, 3] };
objects.baz.asdf = objects;

var serverCaught = 0;
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-fs-mkdir.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ common.refreshTmpDir();

unlink(pathname);

fs.mkdir(pathname, 511 /*=0777*/, function(err) {
fs.mkdir(pathname, 0o777, function(err) {
assert.equal(err, null);
assert.equal(common.fileExists(pathname), true);
ncalls++;
Expand Down
6 changes: 3 additions & 3 deletions test/parallel/test-http-server-multiheaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ srv.listen(common.PORT, function() {
['www-authenticate', 'foo'],
['WWW-Authenticate', 'bar'],
['WWW-AUTHENTICATE', 'baz'],
['proxy-authenticate','foo'],
['Proxy-Authenticate','bar'],
['PROXY-AUTHENTICATE','baz'],
['proxy-authenticate', 'foo'],
['Proxy-Authenticate', 'bar'],
['PROXY-AUTHENTICATE', 'baz'],
['x-foo', 'bingo'],
['x-bar', 'banjo'],
['x-bar', 'bango'],
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-sys.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ assert.equal('{ readonly: [Getter] }',
common.inspect({get readonly() {}}));

assert.equal('{ readwrite: [Getter/Setter] }',
common.inspect({get readwrite() {},set readwrite(val) {}}));
common.inspect({get readwrite() {}, set readwrite(val) {}}));

assert.equal('{ writeonly: [Setter] }',
common.inspect({set writeonly(val) {}}));
Expand Down
6 changes: 3 additions & 3 deletions test/parallel/test-tls-npn-server-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,20 @@ var clientsOptions = [{
crl: serverOptions.crl,
NPNProtocols: ['a', 'b', 'c'],
rejectUnauthorized: false
},{
}, {
port: serverPort,
key: serverOptions.key,
cert: serverOptions.cert,
crl: serverOptions.crl,
NPNProtocols: ['c', 'b', 'e'],
rejectUnauthorized: false
},{
}, {
port: serverPort,
key: serverOptions.key,
cert: serverOptions.cert,
crl: serverOptions.crl,
rejectUnauthorized: false
},{
}, {
port: serverPort,
key: serverOptions.key,
cert: serverOptions.cert,
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-tls-session-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ if (!common.hasCrypto) {
process.exit();
}

doTest({ tickets: false } , function() {
doTest({ tickets: true } , function() {
doTest({ tickets: false }, function() {
doTest({ tickets: true }, function() {
console.error('all done');
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-util-log.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var tests = [
{input: function() {}, output: '[Function]'},
{input: parseInt('not a number', 10), output: 'NaN'},
{input: {answer: 42}, output: '{ answer: 42 }'},
{input: [1,2,3], output: '[ 1, 2, 3 ]'}
{input: [1, 2, 3], output: '[ 1, 2, 3 ]'}
];

// test util.log()
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-zlib-dictionary-fail.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var zlib = require('zlib');
}));

// String "test" encoded with dictionary "dict".
stream.write(Buffer([0x78,0xBB,0x04,0x09,0x01,0xA5]));
stream.write(Buffer([0x78, 0xBB, 0x04, 0x09, 0x01, 0xA5]));
})();

// Should raise an error, not trigger an assertion in src/node_zlib.cc
Expand All @@ -24,5 +24,5 @@ var zlib = require('zlib');
}));

// String "test" encoded with dictionary "dict".
stream.write(Buffer([0x78,0xBB,0x04,0x09,0x01,0xA5]));
stream.write(Buffer([0x78, 0xBB, 0x04, 0x09, 0x01, 0xA5]));
})();
2 changes: 1 addition & 1 deletion test/sequential/test-tls-honorcipherorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ test1();

function test1() {
// Client has the preference of cipher suites by default
test(false, 'AES256-SHA:DES-CBC-SHA:RC4-SHA','AES256-SHA', test2);
test(false, 'AES256-SHA:DES-CBC-SHA:RC4-SHA', 'AES256-SHA', test2);
}

function test2() {
Expand Down
38 changes: 35 additions & 3 deletions tools/eslint/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[![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

Expand All @@ -22,8 +23,26 @@ You can install ESLint using npm:

## Usage

If it's your first time using ESLint, you should set up a config file using `--init`:

eslint --init

After that, you can run ESLint on any JavaScript file:

eslint test.js test2.js

## Team

These folks keep the project moving and are resources for help:

* Nicholas C. Zakas ([@nzakas](https://github.com/nzakas)) - project lead
* Ilya Volodin ([@ilyavolodin](https://github.com/ilyavolodin)) - reviewer
* Brandon Mills ([@btmills](https://github.com/btmills)) - reviewer
* Mathias Schreck ([@lo1tuma](https://github.com/lo1tuma)) - committer
* Gyandeep Singh ([@gyandeeps](https://github.com/gyandeeps)) - committer
* Jamund Ferguson ([@xjamundx](https://github.com/xjamundx)) - committer


## Frequently Asked Questions

### Why don't you like JSHint???
Expand All @@ -34,12 +53,16 @@ I do like JSHint. And I like Anton and Rick. Neither of those were deciding fact

That's not really a question, but I got it. I'm not trying to convince you that ESLint is better than JSHint. The only thing I know is that ESLint is better than JSHint for what I'm doing. In the off chance you're doing something similar, it might be better for you. Otherwise, keep using JSHint, I'm certainly not going to tell you to stop using it.

### How does ESLint performance compare to JSHint?
### How does ESLint performance compare to JSHint and JSCS?

ESLint is slower than JSHint, usually 2-3x slower on a single file. This is because ESLint uses Espree to construct an AST before it can evaluate your code whereas JSHint evaluates your code as it's being parsed. The speed is also based on the number of rules you enable; the more rules you enable, the slower the process.

Despite being slower, we believe that ESLint is fast enough to replace JSHint without causing significant pain.

ESLint is faster than JSCS, as ESLint uses a single-pass traversal for analysis whereas JSCS using a querying model.

If you are using both JSHint and JSCS on your files, then using just ESLint will be faster.

### Is ESLint just linting or does it also check style?

ESLint does both traditional linting (looking for problematic patterns) and style checking (enforcement of conventions). You can use it for both.
Expand All @@ -50,6 +73,7 @@ The following projects are using ESLint to validate their JavaScript:

* [Drupal](https://www.drupal.org/node/2274223)
* [Esprima](https://github.com/ariya/esprima)
* [io.js](https://github.com/iojs/io.js/commit/f9dd34d301ab385ae316769b85ef916f9b70b6f6)
* [WebKit](https://bugs.webkit.org/show_bug.cgi?id=125048)

In addition, the following companies are using ESLint internally to validate their JavaScript:
Expand All @@ -62,11 +86,19 @@ In addition, the following companies are using ESLint internally to validate the

### What about ECMAScript 6 support?

We are implementing ECMAScript 6 support piece-by-piece starting with version 0.12.0. You'll be able to opt-in to any ECMAScript 6 feature you want to use.
ESLint has full support for ECMAScript 6. By default, this support is off. You can enable ECMAScript 6 support through [configuration](http://eslint.org/docs/user-guide/configuring).

### Does ESLint support JSX?

Yes, ESLint natively supports parsing JSX syntax (this must be enabled in [configuration](http://eslint.org/docs/user-guide/configuring).). Please note that supporting JSX syntax *is not* the same as supporting React. React applies specific semantics to JSX syntax that ESLint doesn't recognize. We recommend using [eslint-plugin-react](https://www.npmjs.com/package/eslint-plugin-react) if you are using React and want React semantics.

### What about ECMAScript 7/2016 and experimental features?

ESLint doesn't natively support experimental ECMAScript language features. You can use [babel-eslint](https://github.com/babel/babel-eslint) to use any option available in Babel.

### Where to ask for help?

Join our [Mailing List](https://groups.google.com/group/eslint)
Join our [Mailing List](https://groups.google.com/group/eslint) or [Chatroom](https://gitter.im/eslint/eslint)


[npm-image]: https://img.shields.io/npm/v/eslint.svg?style=flat-square
Expand Down
15 changes: 14 additions & 1 deletion tools/eslint/bin/eslint.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/usr/bin/env node
var concat = require("concat-stream"),
configInit = require("../lib/config-initializer"),
cli = require("../lib/cli");

var exitCode = 0,
useStdIn = (process.argv.indexOf("--stdin") > -1);
useStdIn = (process.argv.indexOf("--stdin") > -1),
init = (process.argv.indexOf("--init") > -1);

if (useStdIn) {
process.stdin.pipe(concat({ encoding: "string" }, function(text) {
Expand All @@ -15,6 +17,17 @@ if (useStdIn) {
exitCode = 1;
}
}));
} else if (init) {
configInit.initializeConfig(function(err) {
if (err) {
exitCode = 1;
console.error(err.message);
console.error(err.stack);
} else {
console.log("Successfully created .eslintrc file in " + process.cwd());
exitCode = 0;
}
});
} else {
exitCode = cli.execute(process.argv);
}
Expand Down
9 changes: 9 additions & 0 deletions tools/eslint/conf/environments.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ module.exports = {
"handle-callback-err": [2, "err"]
}
},
worker: {
globals: globals.worker
},
amd: {
globals: globals.amd
},
Expand All @@ -52,6 +55,12 @@ module.exports = {
meteor: {
globals: globals.meteor
},
mongo: {
globals: globals.mongo
},
applescript: {
globals: globals.applescript
},
es6: {
ecmaFeatures: {
arrowFunctions: true,
Expand Down
16 changes: 15 additions & 1 deletion tools/eslint/conf/eslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"no-duplicate-case": 2,
"no-else-return": 0,
"no-empty": 2,
"no-empty-class": 2,
"no-empty-class": 0,
"no-empty-character-class": 2,
"no-empty-label": 2,
"no-eq-null": 0,
"no-eval": 2,
Expand All @@ -56,6 +57,7 @@
"no-loop-func": 2,
"no-mixed-requires": [0, false],
"no-mixed-spaces-and-tabs": [2, false],
"linebreak-style": [0, "unix"],
"no-multi-spaces": 2,
"no-multi-str": 2,
"no-multiple-empty-lines": [0, {"max": 2}],
Expand Down Expand Up @@ -92,32 +94,41 @@
"no-sync": 0,
"no-ternary": 0,
"no-trailing-spaces": 2,
"no-this-before-super": 0,
"no-throw-literal": 0,
"no-undef": 2,
"no-undef-init": 2,
"no-undefined": 0,
"no-unexpected-multiline": 0,
"no-underscore-dangle": 2,
"no-unneeded-ternary": 0,
"no-unreachable": 2,
"no-unused-expressions": 2,
"no-unused-vars": [2, {"vars": "all", "args": "after-used"}],
"no-use-before-define": 2,
"no-void": 0,
"no-var": 0,
"prefer-const": 0,
"no-warning-comments": [0, { "terms": ["todo", "fixme", "xxx"], "location": "start" }],
"no-with": 2,
"no-wrap-func": 2,

"array-bracket-spacing": [0, "never"],
"accessor-pairs": 0,
"block-scoped-var": 0,
"brace-style": [0, "1tbs"],
"camelcase": 2,
"comma-dangle": [2, "never"],
"comma-spacing": 2,
"comma-style": 0,
"complexity": [0, 11],
"computed-property-spacing": [0, "never"],
"consistent-return": 2,
"consistent-this": [0, "that"],
"constructor-super": 0,
"curly": [2, "all"],
"default-case": 0,
"dot-location": 0,
"dot-notation": [2, { "allowKeywords": true }],
"eol-last": 2,
"eqeqeq": 2,
Expand All @@ -130,6 +141,7 @@
"handle-callback-err": 0,
"indent": 0,
"key-spacing": [2, { "beforeColon": false, "afterColon": true }],
"lines-around-comment": 0,
"max-depth": [0, 4],
"max-len": [0, 80, 4],
"max-nested-callbacks": [0, 2],
Expand All @@ -138,6 +150,7 @@
"new-cap": 2,
"new-parens": 2,
"newline-after-var": 0,
"object-curly-spacing": [0, "never"],
"object-shorthand": 0,
"one-var": 0,
"operator-assignment": [0, "always"],
Expand All @@ -159,6 +172,7 @@
"space-infix-ops": 2,
"space-return-throw-case": 2,
"space-unary-ops": [2, { "words": true, "nonwords": false }],
"spaced-comment": 0,
"spaced-line-comment": [0, "always"],
"strict": 2,
"use-isnan": 2,
Expand Down
3 changes: 2 additions & 1 deletion tools/eslint/lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
module.exports = {
linter: require("./eslint"),
cli: require("./cli"),
CLIEngine: require("./cli-engine")
CLIEngine: require("./cli-engine"),
validator: require("./config-validator")
};
Loading