add lint config from babel, lint
This commit is contained in:
parent
c38ea387e5
commit
face6ff6af
26
eslint/babel-eslint-parser/.eslintrc
Normal file
26
eslint/babel-eslint-parser/.eslintrc
Normal file
@ -0,0 +1,26 @@
|
||||
{
|
||||
"rules": {
|
||||
"strict": 0,
|
||||
"no-underscore-dangle": 0,
|
||||
"curly": 0,
|
||||
"no-multi-spaces": 0,
|
||||
"key-spacing": 0,
|
||||
"no-return-assign": 0,
|
||||
"consistent-return": 0,
|
||||
"no-shadow": 0,
|
||||
"comma-dangle": 0,
|
||||
"no-use-before-define": 0,
|
||||
"no-empty": 0,
|
||||
"new-parens": 0,
|
||||
"no-cond-assign": 0,
|
||||
"no-fallthrough": 0,
|
||||
"new-cap": 0,
|
||||
"no-loop-func": 0,
|
||||
"no-unreachable": 0,
|
||||
"no-process-exit": 0
|
||||
},
|
||||
"env": {
|
||||
"node": true,
|
||||
"mocha": true
|
||||
}
|
||||
}
|
||||
@ -73,10 +73,6 @@ exports.toTokens = function (tokens) {
|
||||
return tokens.map(exports.toToken);
|
||||
};
|
||||
|
||||
function isCompatTag(tagName) {
|
||||
return tagName && /^[a-z]|\-/.test(tagName);
|
||||
}
|
||||
|
||||
function convertTemplateType(tokens) {
|
||||
var startingToken = 0;
|
||||
var currentToken = 0;
|
||||
@ -124,7 +120,7 @@ function convertTemplateType(tokens) {
|
||||
start: tokens[start].loc.start,
|
||||
end: tokens[end].loc.end
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// put new token in place of old tokens
|
||||
tokens.splice(start, end - start + 1, templateToken);
|
||||
@ -174,7 +170,7 @@ function convertTemplateType(tokens) {
|
||||
|
||||
var astTransformVisitor = {
|
||||
noScope: true,
|
||||
exit: function (node, parent) {
|
||||
exit: function (node) { /* parent */
|
||||
if (this.isSpreadProperty()) {
|
||||
node.type = "Property";
|
||||
node.kind = "init";
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
var acornToEsprima = require("./acorn-to-esprima");
|
||||
var traverse = require("babel-core").traverse;
|
||||
var assign = require("lodash.assign");
|
||||
var pick = require("lodash.pick");
|
||||
var Module = require("module");
|
||||
@ -54,7 +53,7 @@ function monkeypatch() {
|
||||
// monkeypatch escope/referencer
|
||||
var referencerLoc;
|
||||
try {
|
||||
var referencerLoc = Module._resolveFilename("./referencer", escopeMod);
|
||||
referencerLoc = Module._resolveFilename("./referencer", escopeMod);
|
||||
} catch (err) {
|
||||
throw new ReferenceError("couldn't resolve escope/referencer");
|
||||
}
|
||||
@ -64,7 +63,7 @@ function monkeypatch() {
|
||||
// reference Definition
|
||||
var definitionLoc;
|
||||
try {
|
||||
var definitionLoc = Module._resolveFilename("./definition", referencerMod);
|
||||
definitionLoc = Module._resolveFilename("./definition", referencerMod);
|
||||
} catch (err) {
|
||||
throw new ReferenceError("couldn't resolve escope/definition");
|
||||
}
|
||||
@ -146,8 +145,8 @@ function monkeypatch() {
|
||||
} else if (propertyType.type === "typeAnnotation") {
|
||||
visitTypeAnnotation.call(this, node.typeAnnotation);
|
||||
} else if (propertyType.type === "typeParameters") {
|
||||
for (var j = 0; j < node.typeParameters.params.length; j++) {
|
||||
checkIdentifierOrVisit.call(this, node.typeParameters.params[j]);
|
||||
for (var l = 0; l < node.typeParameters.params.length; l++) {
|
||||
checkIdentifierOrVisit.call(this, node.typeParameters.params[l]);
|
||||
}
|
||||
} else if (propertyType.type === "id") {
|
||||
if (node.id.type === "Identifier") {
|
||||
@ -184,13 +183,13 @@ function monkeypatch() {
|
||||
}
|
||||
}
|
||||
if (node.typeParameters) {
|
||||
for (var i = 0; i < node.typeParameters.params.length; i++) {
|
||||
checkIdentifierOrVisit.call(this, node.typeParameters.params[i]);
|
||||
for (var j = 0; j < node.typeParameters.params.length; j++) {
|
||||
checkIdentifierOrVisit.call(this, node.typeParameters.params[j]);
|
||||
}
|
||||
}
|
||||
if (node.superTypeParameters) {
|
||||
for (var i = 0; i < node.superTypeParameters.params.length; i++) {
|
||||
checkIdentifierOrVisit.call(this, node.superTypeParameters.params[i]);
|
||||
for (var k = 0; k < node.superTypeParameters.params.length; k++) {
|
||||
checkIdentifierOrVisit.call(this, node.superTypeParameters.params[k]);
|
||||
}
|
||||
}
|
||||
visitClass.call(this, node);
|
||||
@ -220,8 +219,8 @@ function monkeypatch() {
|
||||
}
|
||||
}
|
||||
if (node.typeParameters) {
|
||||
for (var i = 0; i < node.typeParameters.params.length; i++) {
|
||||
checkIdentifierOrVisit.call(this, node.typeParameters.params[i]);
|
||||
for (var j = 0; j < node.typeParameters.params.length; j++) {
|
||||
checkIdentifierOrVisit.call(this, node.typeParameters.params[j]);
|
||||
}
|
||||
}
|
||||
visitFunction.call(this, node);
|
||||
@ -264,7 +263,7 @@ function monkeypatch() {
|
||||
checkIdentifierOrVisit.call(this, node.typeParameters.params[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
referencer.prototype.ComprehensionBlock = function(node) {
|
||||
var left = node.left;
|
||||
@ -282,7 +281,7 @@ function monkeypatch() {
|
||||
if (node.right) {
|
||||
this.visit(node.right);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
exports.attachComments = function (ast, comments, tokens) {
|
||||
|
||||
@ -195,19 +195,19 @@ describe("acorn-to-esprima", function () {
|
||||
});
|
||||
|
||||
it("default import", function () {
|
||||
parseAndAssertSame('import foo from "foo";');
|
||||
parseAndAssertSame("import foo from 'foo';");
|
||||
});
|
||||
|
||||
it("import specifier", function () {
|
||||
parseAndAssertSame('import { foo } from "foo";');
|
||||
parseAndAssertSame("import { foo } from 'foo';");
|
||||
});
|
||||
|
||||
it("import specifier with name", function () {
|
||||
parseAndAssertSame('import { foo as bar } from "foo";');
|
||||
parseAndAssertSame("import { foo as bar } from 'foo';");
|
||||
});
|
||||
|
||||
it("import bare", function () {
|
||||
parseAndAssertSame('import "foo";');
|
||||
parseAndAssertSame("import 'foo';");
|
||||
});
|
||||
|
||||
it("export default class declaration", function () {
|
||||
@ -227,7 +227,7 @@ describe("acorn-to-esprima", function () {
|
||||
});
|
||||
|
||||
it("export all", function () {
|
||||
parseAndAssertSame('export * from "foo";');
|
||||
parseAndAssertSame("export * from 'foo';");
|
||||
});
|
||||
|
||||
it("export named", function () {
|
||||
|
||||
@ -420,7 +420,7 @@ describe("verify", function () {
|
||||
{ "no-unused-vars": 1, "no-undef": 1 },
|
||||
[]
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it("10", function () {
|
||||
verifyAndAssertMessages(
|
||||
@ -672,7 +672,7 @@ describe("verify", function () {
|
||||
verifyAndAssertMessages(
|
||||
[
|
||||
"import type Foo from 'foo';",
|
||||
'var {x}: {x: Foo; } = { x: "hello" }; x;'
|
||||
"var {x}: {x: Foo; } = { x: 'hello' }; x;"
|
||||
].join("\n"),
|
||||
{ "no-unused-vars": 1, "no-undef": 1 },
|
||||
[]
|
||||
@ -683,7 +683,7 @@ describe("verify", function () {
|
||||
verifyAndAssertMessages(
|
||||
[
|
||||
"import type Foo from 'foo';",
|
||||
'var [x]: Array<Foo> = [ "hello" ]; x;'
|
||||
"var [x]: Array<Foo> = [ 'hello' ]; x;"
|
||||
].join("\n"),
|
||||
{ "no-unused-vars": 1, "no-undef": 1 },
|
||||
[]
|
||||
@ -764,8 +764,8 @@ describe("verify", function () {
|
||||
it("38", function () {
|
||||
verifyAndAssertMessages(
|
||||
[
|
||||
'import type {foo, bar} from "baz";',
|
||||
'foo; bar;'
|
||||
"import type {foo, bar} from 'baz';",
|
||||
"foo; bar;"
|
||||
].join("\n"),
|
||||
{ "no-unused-vars": 1, "no-undef": 1 },
|
||||
[]
|
||||
@ -775,8 +775,8 @@ describe("verify", function () {
|
||||
it("39", function () {
|
||||
verifyAndAssertMessages(
|
||||
[
|
||||
'import type {foo as bar} from "baz";',
|
||||
'bar;'
|
||||
"import type {foo as bar} from 'baz';",
|
||||
"bar;"
|
||||
].join("\n"),
|
||||
{ "no-unused-vars": 1, "no-undef": 1 },
|
||||
[]
|
||||
@ -786,8 +786,8 @@ describe("verify", function () {
|
||||
it("40", function () {
|
||||
verifyAndAssertMessages(
|
||||
[
|
||||
'import type from "foo";',
|
||||
'type;'
|
||||
"import type from 'foo';",
|
||||
"type;"
|
||||
].join("\n"),
|
||||
{ "no-unused-vars": 1, "no-undef": 1 },
|
||||
[]
|
||||
@ -797,8 +797,8 @@ describe("verify", function () {
|
||||
it("41", function () {
|
||||
verifyAndAssertMessages(
|
||||
[
|
||||
'import type, {foo} from "bar";',
|
||||
'type; foo;'
|
||||
"import type, {foo} from 'bar';",
|
||||
"type; foo;"
|
||||
].join("\n"),
|
||||
{ "no-unused-vars": 1, "no-undef": 1 },
|
||||
[]
|
||||
@ -808,8 +808,8 @@ describe("verify", function () {
|
||||
it("42", function () {
|
||||
verifyAndAssertMessages(
|
||||
[
|
||||
'import type * as namespace from "bar";',
|
||||
'namespace;'
|
||||
"import type * as namespace from 'bar';",
|
||||
"namespace;"
|
||||
].join("\n"),
|
||||
{ "no-unused-vars": 1, "no-undef": 1 },
|
||||
[]
|
||||
@ -1088,6 +1088,6 @@ describe("verify", function () {
|
||||
"var unused;",
|
||||
{ "no-unused-vars": 1 },
|
||||
[ "1:4 unused is defined but never used no-unused-vars" ]
|
||||
)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user