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

Use eslint-config-babel #354

Merged
merged 4 commits into from
Aug 3, 2016
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test/fixtures
28 changes: 0 additions & 28 deletions .eslintrc

This file was deleted.

16 changes: 16 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
root: true,
extends: "babel",
parserOptions: {
ecmaVersion: 7,
sourceType: "module"
},
rules: {
"no-var": 0,
"max-len": 0
},
env: {
node: true,
mocha: true
}
};
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ matrix:
- node_js: "4"
- node_js: "5"
- node_js: "6"

script: npm run test-ci
2 changes: 1 addition & 1 deletion babylon-to-espree/convertTemplateType.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,4 @@ module.exports = function (tokens, tt) {
}
startingToken++;
}
}
};
2 changes: 1 addition & 1 deletion babylon-to-espree/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ exports.convertComments = function (comments) {
comment.range = [comment.start, comment.end];
}
}
}
};
32 changes: 14 additions & 18 deletions babylon-to-espree/toAST.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ function changeToLiteral(node) {
}
}

function changeComments(nodeComments) {
for (var i = 0; i < nodeComments.length; i++) {
var comment = nodeComments[i];
if (comment.type === "CommentLine") {
comment.type = "Line";
} else if (comment.type === "CommentBlock") {
comment.type = "Block";
}
comment.range = [comment.start, comment.end];
}
}

var astTransformVisitor = {
noScope: true,
enter: function (path) {
Expand All @@ -33,27 +45,11 @@ var astTransformVisitor = {
}

if (node.trailingComments) {
for (var i = 0; i < node.trailingComments.length; i++) {
var comment = node.trailingComments[i];
if (comment.type === "CommentLine") {
comment.type = "Line";
} else if (comment.type === "CommentBlock") {
comment.type = "Block";
}
comment.range = [comment.start, comment.end];
}
changeComments(node.trailingComments);
}

if (node.leadingComments) {
for (var i = 0; i < node.leadingComments.length; i++) {
var comment = node.leadingComments[i];
if (comment.type === "CommentLine") {
comment.type = "Line";
} else if (comment.type === "CommentBlock") {
comment.type = "Block";
}
comment.range = [comment.start, comment.end];
}
changeComments(node.leadingComments);
}

// make '_paths' non-enumerable (babel-eslint #200)
Expand Down
32 changes: 16 additions & 16 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ exports.parse = function (code, options) {
}

return exports.parseNoPatch(code, options);
}
};

exports.parseNoPatch = function (code, options) {
var opts = {
Expand All @@ -397,20 +397,20 @@ exports.parseNoPatch = function (code, options) {
allowReturnOutsideFunction: true,
allowSuperOutsideMethod: true,
plugins: [
"flow",
"jsx",
"asyncFunctions",
"asyncGenerators",
"classConstructorCall",
"classProperties",
"decorators",
"doExpressions",
"exponentiationOperator",
"exportExtensions",
"functionBind",
"functionSent",
"objectRestSpread",
"trailingFunctionCommas"
"flow",
"jsx",
"asyncFunctions",
"asyncGenerators",
"classConstructorCall",
"classProperties",
"decorators",
"doExpressions",
"exponentiationOperator",
"exportExtensions",
"functionBind",
"functionSent",
"objectRestSpread",
"trailingFunctionCommas"
]
};

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

return ast;
}
};
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"bootstrap": "git submodule update --init && cd eslint && npm install",
"eslint": "cd eslint && mocha -c tests/lib/rules/*.js -r ../eslint-tester.js",
"test": "mocha",
"test-ci" "npm test && npm run lint",
"lint": "eslint index.js babylon-to-espree test",
"fix": "eslint index.js babylon-to-espree test --fix",
"preversion": "npm test",
Expand All @@ -38,6 +39,7 @@
"homepage": "https://github.com/babel/babel-eslint",
"devDependencies": {
"eslint": "^3.0.0",
"eslint-config-babel": "^1.0.1",
"espree": "^3.0.0",
"mocha": "^3.0.0"
}
Expand Down
Loading