Skip to content
This repository was archived by the owner on Aug 18, 2021. It is now read-only.

Commit b7eec91

Browse files
authored
Merge pull request #354 from babel/eslint-config-babel
Use eslint-config-babel
2 parents 2ce1f53 + 7cae53b commit b7eec91

File tree

12 files changed

+334
-345
lines changed

12 files changed

+334
-345
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test/fixtures

.eslintrc

Lines changed: 0 additions & 28 deletions
This file was deleted.

.eslintrc.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module.exports = {
2+
root: true,
3+
extends: "babel",
4+
parserOptions: {
5+
ecmaVersion: 7,
6+
sourceType: "module"
7+
},
8+
rules: {
9+
"no-var": 0,
10+
"max-len": 0
11+
},
12+
env: {
13+
node: true,
14+
mocha: true
15+
}
16+
};

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ matrix:
77
- node_js: "4"
88
- node_js: "5"
99
- node_js: "6"
10+
11+
script: npm run test-ci

babylon-to-espree/convertTemplateType.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,4 @@ module.exports = function (tokens, tt) {
9090
}
9191
startingToken++;
9292
}
93-
}
93+
};

babylon-to-espree/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ exports.convertComments = function (comments) {
1717
comment.range = [comment.start, comment.end];
1818
}
1919
}
20-
}
20+
};

babylon-to-espree/toAST.js

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,18 @@ function changeToLiteral(node) {
1717
}
1818
}
1919

20+
function changeComments(nodeComments) {
21+
for (var i = 0; i < nodeComments.length; i++) {
22+
var comment = nodeComments[i];
23+
if (comment.type === "CommentLine") {
24+
comment.type = "Line";
25+
} else if (comment.type === "CommentBlock") {
26+
comment.type = "Block";
27+
}
28+
comment.range = [comment.start, comment.end];
29+
}
30+
}
31+
2032
var astTransformVisitor = {
2133
noScope: true,
2234
enter: function (path) {
@@ -33,27 +45,11 @@ var astTransformVisitor = {
3345
}
3446

3547
if (node.trailingComments) {
36-
for (var i = 0; i < node.trailingComments.length; i++) {
37-
var comment = node.trailingComments[i];
38-
if (comment.type === "CommentLine") {
39-
comment.type = "Line";
40-
} else if (comment.type === "CommentBlock") {
41-
comment.type = "Block";
42-
}
43-
comment.range = [comment.start, comment.end];
44-
}
48+
changeComments(node.trailingComments);
4549
}
4650

4751
if (node.leadingComments) {
48-
for (var i = 0; i < node.leadingComments.length; i++) {
49-
var comment = node.leadingComments[i];
50-
if (comment.type === "CommentLine") {
51-
comment.type = "Line";
52-
} else if (comment.type === "CommentBlock") {
53-
comment.type = "Block";
54-
}
55-
comment.range = [comment.start, comment.end];
56-
}
52+
changeComments(node.leadingComments);
5753
}
5854

5955
// make '_paths' non-enumerable (babel-eslint #200)

index.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ exports.parse = function (code, options) {
388388
}
389389

390390
return exports.parseNoPatch(code, options);
391-
}
391+
};
392392

393393
exports.parseNoPatch = function (code, options) {
394394
var opts = {
@@ -397,20 +397,20 @@ exports.parseNoPatch = function (code, options) {
397397
allowReturnOutsideFunction: true,
398398
allowSuperOutsideMethod: true,
399399
plugins: [
400-
"flow",
401-
"jsx",
402-
"asyncFunctions",
403-
"asyncGenerators",
404-
"classConstructorCall",
405-
"classProperties",
406-
"decorators",
407-
"doExpressions",
408-
"exponentiationOperator",
409-
"exportExtensions",
410-
"functionBind",
411-
"functionSent",
412-
"objectRestSpread",
413-
"trailingFunctionCommas"
400+
"flow",
401+
"jsx",
402+
"asyncFunctions",
403+
"asyncGenerators",
404+
"classConstructorCall",
405+
"classProperties",
406+
"decorators",
407+
"doExpressions",
408+
"exponentiationOperator",
409+
"exportExtensions",
410+
"functionBind",
411+
"functionSent",
412+
"objectRestSpread",
413+
"trailingFunctionCommas"
414414
]
415415
};
416416

@@ -458,4 +458,4 @@ exports.parseNoPatch = function (code, options) {
458458
babylonToEspree.attachComments(ast, ast.comments, ast.tokens);
459459

460460
return ast;
461-
}
461+
};

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"bootstrap": "git submodule update --init && cd eslint && npm install",
2323
"eslint": "cd eslint && mocha -c tests/lib/rules/*.js -r ../eslint-tester.js",
2424
"test": "mocha",
25+
"test-ci" "npm test && npm run lint",
2526
"lint": "eslint index.js babylon-to-espree test",
2627
"fix": "eslint index.js babylon-to-espree test --fix",
2728
"preversion": "npm test",
@@ -38,6 +39,7 @@
3839
"homepage": "https://github.com/babel/babel-eslint",
3940
"devDependencies": {
4041
"eslint": "^3.0.0",
42+
"eslint-config-babel": "^1.0.1",
4143
"espree": "^3.0.0",
4244
"mocha": "^3.0.0"
4345
}

0 commit comments

Comments
 (0)