diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 00000000..a843dc44 --- /dev/null +++ b/.eslintignore @@ -0,0 +1 @@ +test/fixtures diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 57a95f9d..00000000 --- a/.eslintrc +++ /dev/null @@ -1,28 +0,0 @@ -{ - "root": true, - "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, - "quotes": [1, "double", "avoid-escape"] - }, - "env": { - "node": true, - "mocha": true - } -} diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 00000000..1f91933f --- /dev/null +++ b/.eslintrc.js @@ -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 + } +}; diff --git a/.travis.yml b/.travis.yml index 8aac7f25..9f2b522c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,3 +7,5 @@ matrix: - node_js: "4" - node_js: "5" - node_js: "6" + +script: npm run test-ci diff --git a/babylon-to-espree/convertTemplateType.js b/babylon-to-espree/convertTemplateType.js index 0c3293dc..c9537ddd 100644 --- a/babylon-to-espree/convertTemplateType.js +++ b/babylon-to-espree/convertTemplateType.js @@ -90,4 +90,4 @@ module.exports = function (tokens, tt) { } startingToken++; } -} +}; diff --git a/babylon-to-espree/index.js b/babylon-to-espree/index.js index 70accfdf..401570b6 100644 --- a/babylon-to-espree/index.js +++ b/babylon-to-espree/index.js @@ -17,4 +17,4 @@ exports.convertComments = function (comments) { comment.range = [comment.start, comment.end]; } } -} +}; diff --git a/babylon-to-espree/toAST.js b/babylon-to-espree/toAST.js index cc680e99..388253f1 100644 --- a/babylon-to-espree/toAST.js +++ b/babylon-to-espree/toAST.js @@ -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) { @@ -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) diff --git a/index.js b/index.js index 90c9259f..f41deb04 100644 --- a/index.js +++ b/index.js @@ -388,7 +388,7 @@ exports.parse = function (code, options) { } return exports.parseNoPatch(code, options); -} +}; exports.parseNoPatch = function (code, options) { var opts = { @@ -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" ] }; @@ -458,4 +458,4 @@ exports.parseNoPatch = function (code, options) { babylonToEspree.attachComments(ast, ast.comments, ast.tokens); return ast; -} +}; diff --git a/package.json b/package.json index 0234029b..12f568b3 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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" } diff --git a/test/babel-eslint.js b/test/babel-eslint.js index 76005da1..95635480 100644 --- a/test/babel-eslint.js +++ b/test/babel-eslint.js @@ -36,20 +36,20 @@ function lookup(obj, keypath, backwardsDepth) { if (!keypath) { return obj; } return keypath.split(".").slice(0, -1 * backwardsDepth) - .reduce(function (base, segment) { return base && base[segment], obj }); + .reduce(function (base, segment) { return base && base[segment], obj; }); } function parseAndAssertSame(code) { var esAST = espree.parse(code, { ecmaFeatures: { // enable JSX parsing - jsx: true, + jsx: true, // enable return in global scope - globalReturn: true, + globalReturn: true, // enable implied strict mode (if ecmaVersion >= 5) - impliedStrict: true, + impliedStrict: true, // allow experimental object rest/spread - experimentalObjectRestSpread: true + experimentalObjectRestSpread: true }, tokens: true, loc: true, @@ -62,7 +62,7 @@ function parseAndAssertSame(code) { var babylonAST = babelEslint.parse(code); try { assertImplementsAST(esAST, babylonAST); - } catch(err) { + } catch (err) { var traversal = err.message.slice(3, err.message.indexOf(":")); if (esAST.tokens) { delete esAST.tokens; @@ -145,10 +145,10 @@ describe("babylon-to-esprima", function () { it("template with destructuring #31", function () { parseAndAssertSame([ "module.exports = {", - "render() {", - "var {name} = this.props;", - "return Math.max(null, `Name: ${name}, Name: ${name}`);", - "}", + "render() {", + "var {name} = this.props;", + "return Math.max(null, `Name: ${name}, Name: ${name}`);", + "}", "};" ].join("\n")); }); @@ -199,19 +199,19 @@ describe("babylon-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 () { @@ -231,7 +231,7 @@ describe("babylon-to-esprima", function () { }); it("export all", function () { - parseAndAssertSame('export * from "foo";'); + parseAndAssertSame("export * from \"foo\";"); }); it("export named", function () { @@ -272,11 +272,11 @@ describe("babylon-to-esprima", function () { it("block comments #124", function () { parseAndAssertSame([ "React.createClass({", - "render() {", - "// return (", - "//
", - "// ); // <-- this is the line that is reported", - "}", + "render() {", + "// return (", + "//
", + "// ); // <-- this is the line that is reported", + "}", "});" ].join("\n")); }); @@ -308,24 +308,24 @@ describe("babylon-to-esprima", function () { it("jsdoc", function () { parseAndAssertSame([ "/**", - "* @param {object} options", - "* @return {number}", - "*/", + "* @param {object} options", + "* @return {number}", + "*/", "const test = function({ a, b, c }) {", - "return a + b + c;", + "return a + b + c;", "};", "module.exports = test;" ].join("\n")); - }) + }); it("empty block with comment", function () { parseAndAssertSame([ "function a () {", - "try {", - "b();", - "} catch (e) {", - "// asdf", - "}", + "try {", + "b();", + "} catch (e) {", + "// asdf", + "}", "}" ].join("\n")); }); @@ -334,7 +334,7 @@ describe("babylon-to-esprima", function () { it("MethodDefinition", function () { parseAndAssertSame([ "export default class A {", - "a() {}", + "a() {}", "}" ].join("\n")); }); @@ -348,8 +348,8 @@ describe("babylon-to-esprima", function () { it("ClassMethod", function () { parseAndAssertSame([ "class A {", - "constructor() {", - "}", + "constructor() {", + "}", "}" ].join("\n")); }); @@ -357,8 +357,8 @@ describe("babylon-to-esprima", function () { it("ClassMethod multiple params", function () { parseAndAssertSame([ "class A {", - "constructor(a, b, c) {", - "}", + "constructor(a, b, c) {", + "}", "}" ].join("\n")); }); @@ -385,8 +385,8 @@ describe("babylon-to-esprima", function () { it("ObjectMethod", function () { parseAndAssertSame([ "var a = {", - "b(c) {", - "}", + "b(c) {", + "}", "}" ].join("\n")); }); @@ -394,7 +394,7 @@ describe("babylon-to-esprima", function () { it("do not allow import export everywhere", function() { assert.throws(function () { parseAndAssertSame("function F() { import a from \"a\"; }"); - }, /SyntaxError: 'import' and 'export' may only appear at the top level/) + }, /SyntaxError: 'import' and 'export' may only appear at the top level/); }); it("return outside function", function () { @@ -415,31 +415,31 @@ describe("babylon-to-esprima", function () { parseAndAssertSame("class A { get x ( ) { ; } }"); parseAndAssertSame([ "class A {", - "get x(", - ")", - "{", - ";", - "}", + "get x(", + ")", + "{", + ";", + "}", "}" ].join("\n")); parseAndAssertSame("class A { set x (a) { ; } }"); parseAndAssertSame([ "class A {", - "set x(a", - ")", - "{", - ";", - "}", + "set x(a", + ")", + "{", + ";", + "}", "}" ].join("\n")); parseAndAssertSame([ "var B = {", - "get x () {", - "return this.ecks;", - "},", - "set x (ecks) {", - "this.ecks = ecks;", - "}", + "get x () {", + "return this.ecks;", + "},", + "set x (ecks) {", + "this.ecks = ecks;", + "}", "};" ].join("\n")); }); diff --git a/test/fixtures/rules/strict/global-with.js b/test/fixtures/rules/strict/global-with.js index b28e68be..e967aa49 100644 --- a/test/fixtures/rules/strict/global-with.js +++ b/test/fixtures/rules/strict/global-with.js @@ -1,4 +1,4 @@ -"use strict";; +"use strict"; /* The empty statement is intentional. As of now, ESLint won't enforce string: [2, "global"] on a program with an empty body. A test for that without diff --git a/test/non-regression.js b/test/non-regression.js index eeb993ad..e75a75a6 100644 --- a/test/non-regression.js +++ b/test/non-regression.js @@ -23,7 +23,7 @@ function verifyAndAssertMessages(code, rules, expectedMessages, sourceType, over if (overrideConfig) { for (var key in overrideConfig) { - config[key] = overrideConfig[key] + config[key] = overrideConfig[key]; } } @@ -161,11 +161,11 @@ describe("verify", function () { it("comment with padded-blocks (issue #33)", function () { verifyAndAssertMessages([ - "if (a){", - "// i'm a comment!", - "let b = c", - "}" - ].join("\n"), + "if (a){", + "// i'm a comment!", + "let b = c", + "}" + ].join("\n"), { "padded-blocks": [1, "never"] }, [] ); @@ -174,8 +174,8 @@ describe("verify", function () { describe("flow", function () { it("check regular function", function () { verifyAndAssertMessages([ - "function a(b, c) { b += 1; c += 1; return b + c; } a;", - ].join("\n"), + "function a(b, c) { b += 1; c += 1; return b + c; } a;", + ].join("\n"), { "no-unused-vars": 1, "no-undef": 1 }, [] ); @@ -199,14 +199,14 @@ describe("verify", function () { it("multiple nullable type annotations and return #108", function () { verifyAndAssertMessages([ - "import type Foo from 'foo';", - "import type Foo2 from 'foo';", - "import type Foo3 from 'foo';", - "function log(foo: ?Foo, foo2: ?Foo2): ?Foo3 {", - "console.log(foo, foo2);", - "}", - "log(1, 2);" - ].join("\n"), + "import type Foo from 'foo';", + "import type Foo2 from 'foo';", + "import type Foo3 from 'foo';", + "function log(foo: ?Foo, foo2: ?Foo2): ?Foo3 {", + "console.log(foo, foo2);", + "}", + "log(1, 2);" + ].join("\n"), { "no-unused-vars": 1, "no-undef": 1 }, [] ); @@ -214,11 +214,11 @@ describe("verify", function () { it("type parameters", function () { verifyAndAssertMessages([ - "import type Foo from 'foo';", - "import type Foo2 from 'foo';", - "function log(a: T1, b: T2) { return a + b; }", - "log(1, 2);" - ].join("\n"), + "import type Foo from 'foo';", + "import type Foo2 from 'foo';", + "function log(a: T1, b: T2) { return a + b; }", + "log(1, 2);" + ].join("\n"), { "no-unused-vars": 1, "no-undef": 1 }, [] ); @@ -226,12 +226,12 @@ describe("verify", function () { it("nested type annotations", function () { verifyAndAssertMessages([ - "import type Foo from 'foo';", - "function foo(callback: () => Foo) {", - "return callback();", - "}", - "foo();" - ].join("\n"), + "import type Foo from 'foo';", + "function foo(callback: () => Foo) {", + "return callback();", + "}", + "foo();" + ].join("\n"), { "no-unused-vars": 1, "no-undef": 1 }, [] ); @@ -239,10 +239,10 @@ describe("verify", function () { it("type in var declaration", function () { verifyAndAssertMessages([ - "import type Foo from 'foo';", - "var x: Foo = 1;", - "x;" - ].join("\n"), + "import type Foo from 'foo';", + "var x: Foo = 1;", + "x;" + ].join("\n"), { "no-unused-vars": 1, "no-undef": 1 }, [] ); @@ -250,10 +250,10 @@ describe("verify", function () { it("object type annotation", function () { verifyAndAssertMessages([ - "import type Foo from 'foo';", - "var a: {numVal: Foo};", - "a;" - ].join("\n"), + "import type Foo from 'foo';", + "var a: {numVal: Foo};", + "a;" + ].join("\n"), { "no-unused-vars": 1, "no-undef": 1 }, [] ); @@ -261,13 +261,13 @@ describe("verify", function () { it("object property types", function () { verifyAndAssertMessages([ - "import type Foo from 'foo';", - "import type Foo2 from 'foo';", - "var a = {", - "circle: (null : ?{ setNativeProps(props: Foo): Foo2 })", - "};", - "a;" - ].join("\n"), + "import type Foo from 'foo';", + "import type Foo2 from 'foo';", + "var a = {", + "circle: (null : ?{ setNativeProps(props: Foo): Foo2 })", + "};", + "a;" + ].join("\n"), { "no-unused-vars": 1, "no-undef": 1 }, [] ); @@ -275,16 +275,16 @@ describe("verify", function () { it("namespaced types", function () { verifyAndAssertMessages([ - "var React = require('react-native');", - "var b = {", - "openExternalExample: (null: ?React.Component)", - "};", - "var c = {", - "render(): React.Component {}", - "};", - "b;", - "c;" - ].join("\n"), + "var React = require('react-native');", + "var b = {", + "openExternalExample: (null: ?React.Component)", + "};", + "var c = {", + "render(): React.Component {}", + "};", + "b;", + "c;" + ].join("\n"), { "no-unused-vars": 1, "no-undef": 1 }, [] ); @@ -292,9 +292,9 @@ describe("verify", function () { it("ArrayTypeAnnotation", function () { verifyAndAssertMessages([ - "import type Foo from 'foo';", - "var x: Foo[]; x;" - ].join("\n"), + "import type Foo from 'foo';", + "var x: Foo[]; x;" + ].join("\n"), { "no-unused-vars": 1, "no-undef": 1 }, [] ); @@ -302,9 +302,9 @@ describe("verify", function () { it("ClassImplements", function () { verifyAndAssertMessages([ - "import type Bar from 'foo';", - "export default class Foo implements Bar {}" - ].join("\n"), + "import type Bar from 'foo';", + "export default class Foo implements Bar {}" + ].join("\n"), { "no-unused-vars": 1, "no-undef": 1 }, [] ); @@ -312,9 +312,9 @@ describe("verify", function () { it("type alias creates declaration + usage", function () { verifyAndAssertMessages([ - "type Foo = any;", - "var x : Foo = 1; x;" - ].join("\n"), + "type Foo = any;", + "var x : Foo = 1; x;" + ].join("\n"), { "no-unused-vars": 1, "no-undef": 1 }, [] ); @@ -322,11 +322,11 @@ describe("verify", function () { it("type alias with type parameters", function () { verifyAndAssertMessages([ - "import type Bar from 'foo';", - "import type Foo3 from 'foo';", - "type Foo = Bar", - "var x : Foo = 1; x;" - ].join("\n"), + "import type Bar from 'foo';", + "import type Foo3 from 'foo';", + "type Foo = Bar", + "var x : Foo = 1; x;" + ].join("\n"), { "no-unused-vars": 1, "no-undef": 1 }, [] ); @@ -334,9 +334,9 @@ describe("verify", function () { it("export type alias", function () { verifyAndAssertMessages([ - "import type Foo2 from 'foo';", - "export type Foo = Foo2;" - ].join("\n"), + "import type Foo2 from 'foo';", + "export type Foo = Foo2;" + ].join("\n"), { "no-unused-vars": 1, "no-undef": 1 }, [] ); @@ -344,8 +344,8 @@ describe("verify", function () { it("polymorphpic types #109", function () { verifyAndAssertMessages([ - "export default function groupByEveryN(array: Array, n: number): Array> { n; }" - ].join("\n"), + "export default function groupByEveryN(array: Array, n: number): Array> { n; }" + ].join("\n"), { "no-unused-vars": 1, "no-undef": 1 }, [] ); @@ -353,10 +353,10 @@ describe("verify", function () { it("types definition from import", function () { verifyAndAssertMessages([ - "import type Promise from 'bluebird';", - "type Operation = () => Promise;", - "x: Operation;" - ].join("\n"), + "import type Promise from 'bluebird';", + "type Operation = () => Promise;", + "x: Operation;" + ].join("\n"), { "no-unused-vars": 1, "no-undef": 1 }, [] ); @@ -364,12 +364,12 @@ describe("verify", function () { it("polymorphpic/generic types for class #123", function () { verifyAndAssertMessages([ - "class Box {", - "value: T;", - "}", - "var box = new Box();", - "console.log(box.value);" - ].join("\n"), + "class Box {", + "value: T;", + "}", + "var box = new Box();", + "console.log(box.value);" + ].join("\n"), { "no-unused-vars": 1, "no-undef": 1 }, [] ); @@ -377,10 +377,10 @@ describe("verify", function () { it("polymorphpic/generic types for function #123", function () { verifyAndAssertMessages([ - "export function identity(value) {", - "var a: T = value; a;", - "}" - ].join("\n"), + "export function identity(value) {", + "var a: T = value; a;", + "}" + ].join("\n"), { "no-unused-vars": 1, "no-undef": 1 }, [] ); @@ -388,9 +388,9 @@ describe("verify", function () { it("polymorphpic/generic types for type alias #123", function () { verifyAndAssertMessages([ - "import Bar from './Bar';", - "type Foo = Bar; var x: Foo = 1; console.log(x);" - ].join("\n"), + "import Bar from './Bar';", + "type Foo = Bar; var x: Foo = 1; console.log(x);" + ].join("\n"), { "no-unused-vars": 1, "no-undef": 1 }, [] ); @@ -398,9 +398,9 @@ describe("verify", function () { it("polymorphpic/generic types - outside of fn scope #123", function () { verifyAndAssertMessages([ - "export function foo(value) { value; };", - "var b: T = 1; b;" - ].join("\n"), + "export function foo(value) { value; };", + "var b: T = 1; b;" + ].join("\n"), { "no-unused-vars": 1, "no-undef": 1 }, [ "1:21 'T' is defined but never used. no-unused-vars", "2:8 'T' is not defined. no-undef" ] @@ -409,9 +409,9 @@ describe("verify", function () { it("polymorphpic/generic types - extending unknown #123", function () { verifyAndAssertMessages([ - "import Bar from 'bar';", - "export class Foo extends Bar {}", - ].join("\n"), + "import Bar from 'bar';", + "export class Foo extends Bar {}", + ].join("\n"), { "no-unused-vars": 1, "no-undef": 1 }, [ "2:30 'T' is not defined. no-undef" ] ); @@ -419,12 +419,12 @@ describe("verify", function () { it("support declarations #132", function () { verifyAndAssertMessages([ - "declare class A { static () : number }", - "declare module B { declare var x: number; }", - "declare function foo(): void;", - "declare var bar", - "A; B; foo(); bar;" - ].join("\n"), + "declare class A { static () : number }", + "declare module B { declare var x: number; }", + "declare function foo(): void;", + "declare var bar", + "A; B; foo(); bar;" + ].join("\n"), { "no-undef": 1, "no-unused-vars": 1 }, [] ); @@ -1002,12 +1002,12 @@ describe("verify", function () { it("class definition: gaearon/redux#24", function () { verifyAndAssertMessages([ - "export default function root(stores) {", - "return DecoratedComponent => class ReduxRootDecorator {", - "a() { DecoratedComponent; stores; }", - "};", - "}", - ].join("\n"), + "export default function root(stores) {", + "return DecoratedComponent => class ReduxRootDecorator {", + "a() { DecoratedComponent; stores; }", + "};", + "}", + ].join("\n"), { "no-undef": 1, "no-unused-vars": 1 }, [] ); @@ -1032,10 +1032,10 @@ describe("verify", function () { it("template with destructuring #31", function () { verifyAndAssertMessages([ "module.exports = {", - "render() {", - "var {name} = this.props;", - "return Math.max(null, `Name: ${name}, Name: ${name}`);", - "}", + "render() {", + "var {name} = this.props;", + "return Math.max(null, `Name: ${name}, Name: ${name}`);", + "}", "};"].join("\n"), { "comma-spacing": 1 }, [] @@ -1064,12 +1064,12 @@ describe("verify", function () { "import classMethodDeclarationA from 'decorator';", "import decoratorParameter from 'decorator';", "export class TextareaAutosize {", - "@classMethodDeclarationA((parameter) => parameter)", - "@classMethodDeclarationA(decoratorParameter)", - "@classMethodDeclarationA", - "methodDeclaration(e) {", - "e();", - "}", + "@classMethodDeclarationA((parameter) => parameter)", + "@classMethodDeclarationA(decoratorParameter)", + "@classMethodDeclarationA", + "methodDeclaration(e) {", + "e();", + "}", "}" ].join("\n"), { "no-unused-vars": 1 }, @@ -1083,14 +1083,14 @@ describe("verify", function () { "import classMethodDeclarationA from 'decorator';", "import decoratorParameter from 'decorator';", "export class TextareaAutosize {", - "@classMethodDeclarationA((parameter) => parameter)", - "@classMethodDeclarationA(decoratorParameter)", - "@classMethodDeclarationA", - "get bar() { }", - "@classMethodDeclarationA((parameter) => parameter)", - "@classMethodDeclarationA(decoratorParameter)", - "@classMethodDeclarationA", - "set bar(val) { val; }", + "@classMethodDeclarationA((parameter) => parameter)", + "@classMethodDeclarationA(decoratorParameter)", + "@classMethodDeclarationA", + "get bar() { }", + "@classMethodDeclarationA((parameter) => parameter)", + "@classMethodDeclarationA(decoratorParameter)", + "@classMethodDeclarationA", + "set bar(val) { val; }", "}" ].join("\n"), { "no-unused-vars": 1 }, @@ -1104,12 +1104,12 @@ describe("verify", function () { "import classMethodDeclarationA from 'decorator';", "import decoratorParameter from 'decorator';", "var obj = {", - "@classMethodDeclarationA((parameter) => parameter)", - "@classMethodDeclarationA(decoratorParameter)", - "@classMethodDeclarationA", - "methodDeclaration(e) {", - "e();", - "}", + "@classMethodDeclarationA((parameter) => parameter)", + "@classMethodDeclarationA(decoratorParameter)", + "@classMethodDeclarationA", + "methodDeclaration(e) {", + "e();", + "}", "};", "obj;" ].join("\n"), @@ -1124,14 +1124,14 @@ describe("verify", function () { "import classMethodDeclarationA from 'decorator';", "import decoratorParameter from 'decorator';", "var obj = {", - "@classMethodDeclarationA((parameter) => parameter)", - "@classMethodDeclarationA(decoratorParameter)", - "@classMethodDeclarationA", - "get bar() { },", - "@classMethodDeclarationA((parameter) => parameter)", - "@classMethodDeclarationA(decoratorParameter)", - "@classMethodDeclarationA", - "set bar(val) { val; }", + "@classMethodDeclarationA((parameter) => parameter)", + "@classMethodDeclarationA(decoratorParameter)", + "@classMethodDeclarationA", + "get bar() { },", + "@classMethodDeclarationA((parameter) => parameter)", + "@classMethodDeclarationA(decoratorParameter)", + "@classMethodDeclarationA", + "set bar(val) { val; }", "};", "obj;" ].join("\n"), @@ -1202,13 +1202,13 @@ describe("verify", function () { it("don't warn no-unused-vars with spread #142", function () { verifyAndAssertMessages([ - "export default function test(data) {", - "return {", - "foo: 'bar',", - "...data", - "};", - "}", - ].join("\n"), + "export default function test(data) {", + "return {", + "foo: 'bar',", + "...data", + "};", + "}", + ].join("\n"), { "no-undef": 1, "no-unused-vars": 1 }, [] ); @@ -1218,8 +1218,8 @@ describe("verify", function () { verifyAndAssertMessages( [ "var a = [", - "1,", - "2, // a trailing comment makes this line fail comma-dangle (always-multiline)", + "1,", + "2, // a trailing comment makes this line fail comma-dangle (always-multiline)", "];", ].join("\n"), { "comma-dangle": [2, "always-multiline"] }, @@ -1229,9 +1229,9 @@ describe("verify", function () { verifyAndAssertMessages( [ "switch (a) {", - "// A comment here makes the above line fail brace-style", - "case 1:", - "console.log(a);", + "// A comment here makes the above line fail brace-style", + "case 1:", + "console.log(a);", "}" ].join("\n"), { "brace-style": 2 }, @@ -1241,8 +1241,8 @@ describe("verify", function () { it("ternary and parens #149", function () { verifyAndAssertMessages([ - "true ? (true) : false;" - ].join("\n"), + "true ? (true) : false;" + ].join("\n"), { "space-infix-ops": 1 }, [] ); @@ -1252,67 +1252,67 @@ describe("verify", function () { verifyAndAssertMessages( [ "React.createClass({", - "render() {", - "// return (", - "//
", - "// ); // <-- this is the line that is reported", - "}", + "render() {", + "// return (", + "//
", + "// ); // <-- this is the line that is reported", + "}", "});" ].join("\n"), { "space-in-parens": 1 }, [ ] - ) + ); }); it("block comment space-in-parens #124", function () { verifyAndAssertMessages( [ "React.createClass({", - "render() {", - "/*", - "return (", - "
", - "); // <-- this is the line that is reported", - "*/", - "}", + "render() {", + "/*", + "return (", + "
", + "); // <-- this is the line that is reported", + "*/", + "}", "});" ].join("\n"), { "space-in-parens": 1 }, [ ] - ) + ); }); it("no no-undef error with rest #11", function () { verifyAndAssertMessages("const [a, ...rest] = ['1', '2', '3']; a; rest;", { "no-undef": 1, "no-unused-vars": 1 }, [ ] - ) + ); }); it("async function with space-before-function-paren #168", function () { verifyAndAssertMessages("it('handles updates', async function() {});", { "space-before-function-paren": [1, "never"] }, [ ] - ) + ); }); it("default param flow type no-unused-vars #184", function () { verifyAndAssertMessages( [ "type ResolveOptionType = {", - "depth?: number,", - "identifier?: string", + "depth?: number,", + "identifier?: string", "};", "", "export default function resolve(", - "options: ResolveOptionType = {}", + "options: ResolveOptionType = {}", "): Object {", - "options;", + "options;", "}", ].join("\n"), { "no-unused-vars": 1, "no-undef": 1 }, [ ] - ) + ); }); it("no-use-before-define #192", function () { @@ -1322,8 +1322,8 @@ describe("verify", function () { "var x = 1;" ].join("\n"), { "no-use-before-define": 1 }, - [ "1:13 'x' was used before it was defined no-use-before-define" ] - ) + [ "1:13 'x' was used before it was defined. no-use-before-define" ] + ); }); it("jsx and stringliteral #216", function () { @@ -1331,31 +1331,31 @@ describe("verify", function () { "
", {}, [] - ) + ); }); it("getter/setter #218", function () { verifyAndAssertMessages([ - "class Person {", - " set a (v) { }", - "}" - ].join("\n"), + "class Person {", + " set a (v) { }", + "}" + ].join("\n"), { "space-before-function-paren": 1, "keyword-spacing": [1, {"before": true}], "indent": 1 }, [] - ) + ); }); it("getter/setter #220", function () { verifyAndAssertMessages([ - "var B = {", - "get x () {", - "return this.ecks;", - "},", - "set x (ecks) {", - "this.ecks = ecks;", - "}", - "};" - ].join("\n"), + "var B = {", + "get x () {", + "return this.ecks;", + "},", + "set x (ecks) {", + "this.ecks = ecks;", + "}", + "};" + ].join("\n"), { "no-dupe-keys": 1 }, [] ); @@ -1363,12 +1363,12 @@ describe("verify", function () { it("fixes issues with flow types and ObjectPattern", function () { verifyAndAssertMessages([ - "import type Foo from 'bar';", - "export default class Foobar {", - " foo({ bar }: Foo) { bar; }", - " bar({ foo }: Foo) { foo; }", - "}" - ].join("\n"), + "import type Foo from 'bar';", + "export default class Foobar {", + " foo({ bar }: Foo) { bar; }", + " bar({ foo }: Foo) { foo; }", + "}" + ].join("\n"), { "no-unused-vars": 1, "no-shadow": 1 }, [] ); @@ -1376,22 +1376,22 @@ describe("verify", function () { it("correctly detects redeclares if in script mode #217", function () { verifyAndAssertMessages([ - "var a = 321;", - "var a = 123;", - ].join("\n"), + "var a = 321;", + "var a = 123;", + ].join("\n"), { "no-redeclare": 1 }, - [ "2:5 'a' is already defined no-redeclare" ], + [ "2:5 'a' is already defined. no-redeclare" ], "script" ); }); it("correctly detects redeclares if in module mode #217", function () { verifyAndAssertMessages([ - "var a = 321;", - "var a = 123;", - ].join("\n"), + "var a = 321;", + "var a = 123;", + ].join("\n"), { "no-redeclare": 1 }, - [ "2:5 'a' is already defined no-redeclare" ], + [ "2:5 'a' is already defined. no-redeclare" ], "module" ); }); @@ -1437,10 +1437,10 @@ describe("verify", function () { it("allowImportExportEverywhere option (#327)", function () { verifyAndAssertMessages([ - "if (true) { import Foo from 'foo'; }", - "function foo() { import Bar from 'bar'; }", - "switch (a) { case 1: import FooBar from 'foobar'; }" - ].join("\n"), + "if (true) { import Foo from 'foo'; }", + "function foo() { import Bar from 'bar'; }", + "switch (a) { case 1: import FooBar from 'foobar'; }" + ].join("\n"), {}, [], "module", @@ -1478,11 +1478,11 @@ describe("verify", function () { it("decorator does not create TypeError #229", function () { verifyAndAssertMessages([ - "class A {", - " @test", - " f() {}", - "}" - ].join("\n"), + "class A {", + " @test", + " f() {}", + "}" + ].join("\n"), { "no-undef": 1 }, [ "2:4 'test' is not defined. no-undef" ] ); @@ -1490,9 +1490,9 @@ describe("verify", function () { it("Flow definition does not trigger warnings #223", function () { verifyAndAssertMessages([ - "import { Map as $Map } from 'immutable';", - "function myFunction($state: $Map, { a, b, c } : { a: ?Object, b: ?Object, c: $Map }) {}" - ].join("\n"), + "import { Map as $Map } from 'immutable';", + "function myFunction($state: $Map, { a, b, c } : { a: ?Object, b: ?Object, c: $Map }) {}" + ].join("\n"), { "no-dupe-args": 1, "no-redeclare": 1, "no-shadow": 1 }, [] ); @@ -1500,16 +1500,16 @@ describe("verify", function () { it("newline-before-return with comments #289", function () { verifyAndAssertMessages([ - "function a() {", - "if (b) {", - "/* eslint-disable no-console */", - "console.log('test');", - "/* eslint-enable no-console */", - "}", - "", - "return hasGlobal;", - "}" - ].join("\n"), + "function a() {", + "if (b) {", + "/* eslint-disable no-console */", + "console.log('test');", + "/* eslint-enable no-console */", + "}", + "", + "return hasGlobal;", + "}" + ].join("\n"), { "newline-before-return": 1 }, [] );