diff --git a/.eslintrc b/.eslintrc index 87ab33e1cbd..521e525cf1a 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,12 +1,13 @@ { "parser": "babel-eslint", + "extends": "eslint:recommended", "rules": { - "comma-dangle": [1, "always-multiline"], + "comma-dangle": ["error", "always-multiline"], "no-underscore-dangle": 0, - "quotes": [2, "single", "avoid-escape"], + "quotes": ["error", "single", "avoid-escape"], "strict": 0, - "no-unused-vars": 2, - "no-undef": 2 + "no-unused-vars": "error", + "no-undef": "error" }, "env": { "node": true, diff --git a/.travis.yml b/.travis.yml index 25d84adb5ab..03cf2b6b8cf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,4 +4,12 @@ node_js: - "4" - "6" - "8" -script: npm run check +before_install: + - curl -o- -L https://yarnpkg.com/install.sh | bash + - export PATH="$HOME/.yarn/bin:$PATH" +cache: + yarn: true + directories: + - ".eslintcache" + - "node_modules" +script: yarn test:ci diff --git a/package.json b/package.json index 7f40519318f..2fe0ba66068 100644 --- a/package.json +++ b/package.json @@ -17,14 +17,13 @@ ], "main": "dist/main.js", "scripts": { - "check": "npm run lint && npm run flow && npm test", - "flow": "flow", - "lint": "eslint src/", - "watch": "babel src/ --out-dir dist/ --watch", "build": "rimraf dist/ && babel src/ --out-dir dist/ --ignore __tests__,__mocks__", - "prepublish": "npm run build", - "preversion": "npm run lint", - "test": "jest" + "lint": "eslint src/ bin/", + "prepublish": "yarn run build", + "preversion": "yarn run lint", + "test": "jest", + "test:ci": "yarn lint && yarn flow && yarn test --runInBand", + "watch": "yarn build --watch" }, "keywords": [ "react", @@ -42,12 +41,13 @@ "recast": "^0.12.6" }, "devDependencies": { - "babel-cli": "^6.9.0", + "babel-cli": "^6.26.0", + "babel-core": "^6.26.0", "babel-eslint": "^7.0.0", "babel-jest": "^21.2.0", - "babel-plugin-transform-object-rest-spread": "^6.23.0", - "babel-plugin-transform-runtime": "^6.9.0", - "babel-preset-env": "^1.1.8", + "babel-plugin-transform-object-rest-spread": "^6.26.0", + "babel-plugin-transform-runtime": "^6.23.0", + "babel-preset-env": "^1.6.1", "babel-preset-flow": "^6.23.0", "cross-spawn": "^5.0.0", "eslint": "^4.3.0", diff --git a/src/resolver/__tests__/findAllExportedComponentDefinitions-test.js b/src/resolver/__tests__/findAllExportedComponentDefinitions-test.js index 25cd7953289..1b932202771 100644 --- a/src/resolver/__tests__/findAllExportedComponentDefinitions-test.js +++ b/src/resolver/__tests__/findAllExportedComponentDefinitions-test.js @@ -202,13 +202,13 @@ describe('findAllExportedComponentDefinitions', () => { expect(actual.length).toBe(1); expect(actual[0].node).toBe(expected.node); - var parsed = parse(` + parsed = parse(` var R = require("React"); var ComponentA = R.createClass({}); var ComponentB = R.createClass({}); module.exports = ComponentB; `); - var actual = findComponents(parsed); + actual = findComponents(parsed); expect(actual.length).toBe(1); }); @@ -270,13 +270,13 @@ describe('findAllExportedComponentDefinitions', () => { expect(actual.length).toBe(1); - var parsed = parse(` + parsed = parse(` var R = require("React"); class ComponentA extends R.Component {} class ComponentB extends R.Component {} module.exports = ComponentB; `); - var actual = findComponents(parsed); + actual = findComponents(parsed); expect(actual.length).toBe(1); }); @@ -314,11 +314,11 @@ describe('findAllExportedComponentDefinitions', () => { expect(actual.length).toBe(1); expect(actual[0].node).toBe(expected.node); - var parsed = parse(` + parsed = parse(` var React = require("React"); export default React.createClass({}); `); - var actual = findComponents(parsed); + actual = findComponents(parsed); expect(actual.length).toBe(1); }); @@ -337,13 +337,13 @@ describe('findAllExportedComponentDefinitions', () => { expect(actual[0].node).toBe(expectedA.node); expect(actual[1].node).toBe(expectedB.node); - var parsed = parse(` + parsed = parse(` import React, { createElement } from "React" var Component = React.createClass({}) export {Component}; export default React.createClass({}); `); - var actual = findComponents(parsed); + actual = findComponents(parsed); expect(actual.length).toBe(2); }); @@ -374,11 +374,11 @@ describe('findAllExportedComponentDefinitions', () => { expect(actual.length).toBe(1); expect(actual[0].node).toBe(expected.node); - var parsed = parse(` + parsed = parse(` import React from 'React'; export default class Component extends React.Component {}; `); - var actual = findComponents(parsed); + actual = findComponents(parsed); expect(actual.length).toBe(1); }); @@ -397,13 +397,13 @@ describe('findAllExportedComponentDefinitions', () => { expect(actual[0].node).toBe(expectedA.node); expect(actual[1].node).toBe(expectedB.node); - var parsed = parse(` + parsed = parse(` import React from 'React'; var Component = class extends React.Component {}; export {Component}; export default class ComponentB extends React.Component{}; `); - var actual = findComponents(parsed); + actual = findComponents(parsed); expect(actual.length).toBe(2); }); @@ -436,30 +436,30 @@ describe('findAllExportedComponentDefinitions', () => { expect(actual.length).toBe(1); expect(actual[0].node).toBe(expected.node); - var parsed = parse(` + parsed = parse(` var React = require("React"); export let Component = React.createClass({}), somethingElse = 42; `); - var actual = findComponents(parsed); + actual = findComponents(parsed); expect(actual.length).toBe(1); - var parsed = parse(` + parsed = parse(` var React = require("React"); export const something = 21, Component = React.createClass({}), somethingElse = 42; `); - var actual = findComponents(parsed); + actual = findComponents(parsed); expect(actual.length).toBe(1); - var parsed = parse(` + parsed = parse(` var React = require("React"); export var somethingElse = function() {}; export let Component = React.createClass({}); `); - var actual = findComponents(parsed); + actual = findComponents(parsed); expect(actual.length).toBe(1); }); @@ -474,13 +474,13 @@ describe('findAllExportedComponentDefinitions', () => { expect(actual.length).toBe(2); - var parsed = parse(` + parsed = parse(` var R = require("React"); export var ComponentA = R.createClass({}); var ComponentB = R.createClass({}); export {ComponentB}; `); - var actual = findComponents(parsed); + actual = findComponents(parsed); expect(actual.length).toBe(2); }); @@ -511,33 +511,33 @@ describe('findAllExportedComponentDefinitions', () => { expect(actual.length).toBe(1); expect(actual[0].node).toBe(expected.node); - var parsed = parse(` + parsed = parse(` import React from 'React'; export let Component = class extends React.Component {}, somethingElse = 42; `); - var actual = findComponents(parsed); + actual = findComponents(parsed); expect(actual.length).toBe(1); expect(actual[0].node.type).toBe('ClassExpression'); - var parsed = parse(` + parsed = parse(` import React from 'React'; export const something = 21, Component = class extends React.Component {}, somethingElse = 42; `); - var actual = findComponents(parsed); + actual = findComponents(parsed); expect(actual.length).toBe(1); expect(actual[0].node.type).toBe('ClassExpression'); - var parsed = parse(` + parsed = parse(` import React from 'React'; export var somethingElse = function() {}; export let Component = class extends React.Component {}; `); - var actual = findComponents(parsed); + actual = findComponents(parsed); expect(actual.length).toBe(1); expect(actual[0].node.type).toBe('ClassExpression'); @@ -553,13 +553,13 @@ describe('findAllExportedComponentDefinitions', () => { expect(actual.length).toBe(2); - var parsed = parse(` + parsed = parse(` import React from 'React'; export var ComponentA = class extends React.Component {}; var ComponentB = class extends React.Component {}; export {ComponentB}; `); - var actual = findComponents(parsed); + actual = findComponents(parsed); expect(actual.length).toBe(2); }); @@ -590,33 +590,33 @@ describe('findAllExportedComponentDefinitions', () => { expect(actual.length).toBe(1); expect(actual[0].node.type).toBe('ArrowFunctionExpression'); - var parsed = parse(` + parsed = parse(` import React from 'React'; export let Component = () =>
, somethingElse = 42; `); - var actual = findComponents(parsed); + actual = findComponents(parsed); expect(actual.length).toBe(1); expect(actual[0].node.type).toBe('ArrowFunctionExpression'); - var parsed = parse(` + parsed = parse(` import React from 'React'; export const something = 21, Component = () =>
, somethingElse = 42; `); - var actual = findComponents(parsed); + actual = findComponents(parsed); expect(actual.length).toBe(1); expect(actual[0].node.type).toBe('ArrowFunctionExpression'); - var parsed = parse(` + parsed = parse(` import React from 'React'; export var somethingElse = function() {}; export let Component = () =>
`); - var actual = findComponents(parsed); + actual = findComponents(parsed); expect(actual.length).toBe(1); expect(actual[0].node.type).toBe('ArrowFunctionExpression'); @@ -632,13 +632,13 @@ describe('findAllExportedComponentDefinitions', () => { expect(actual.length).toBe(2); - var parsed = parse(` + parsed = parse(` import React from 'React'; export var ComponentA = () =>
var ComponentB = () =>
export {ComponentB}; `); - var actual = findComponents(parsed); + actual = findComponents(parsed); expect(actual.length).toBe(2); }); @@ -674,24 +674,24 @@ describe('findAllExportedComponentDefinitions', () => { expect(actual.length).toBe(1); expect(actual[0].node).toBe(expected.node); - var parsed = parse(` + parsed = parse(` import React from "React" var React = require("React"); var Component = React.createClass({}); export {Component, foo} `); - var actual = findComponents(parsed); + actual = findComponents(parsed); expect(actual.length).toBe(1); - var parsed = parse(` + parsed = parse(` import React, { createElement } from "React" var foo = 42; var baz = 21; var Component = React.createClass({}); export {foo, Component as bar, baz} `); - var actual = findComponents(parsed); + actual = findComponents(parsed); expect(actual.length).toBe(1); }); @@ -758,25 +758,25 @@ describe('findAllExportedComponentDefinitions', () => { expect(actual.length).toBe(1); expect(actual[0].node.type).toBe('ClassExpression'); - var parsed = parse(` + parsed = parse(` import React from 'React'; var foo = 42; var Component = class extends React.Component {}; export {Component, foo}; `); - var actual = findComponents(parsed); + actual = findComponents(parsed); expect(actual.length).toBe(1); expect(actual[0].node.type).toBe('ClassExpression'); - var parsed = parse(` + parsed = parse(` import React from 'React'; var foo = 42; var baz = 21; var Component = class extends React.Component {}; export {foo, Component as bar, baz}; `); - var actual = findComponents(parsed); + actual = findComponents(parsed); expect(actual.length).toBe(1); expect(actual[0].node.type).toBe('ClassExpression'); @@ -849,25 +849,25 @@ describe('findAllExportedComponentDefinitions', () => { expect(actual.length).toBe(1); expect(actual[0].node.type).toBe('FunctionDeclaration'); - var parsed = parse(` + parsed = parse(` import React from 'React'; var foo = 42; var Component = () =>
; export {Component, foo}; `); - var actual = findComponents(parsed); + actual = findComponents(parsed); expect(actual.length).toBe(1); expect(actual[0].node.type).toBe('ArrowFunctionExpression'); - var parsed = parse(` + parsed = parse(` import React from 'React'; var foo = 42; var baz = 21; var Component = function () { return
; } export {foo, Component as bar, baz}; `); - var actual = findComponents(parsed); + actual = findComponents(parsed); expect(actual.length).toBe(1); expect(actual[0].node.type).toBe('FunctionExpression'); diff --git a/src/utils/__tests__/getFlowType-test.js b/src/utils/__tests__/getFlowType-test.js index 4e6c9202a00..36222bf0a51 100644 --- a/src/utils/__tests__/getFlowType-test.js +++ b/src/utils/__tests__/getFlowType-test.js @@ -239,7 +239,7 @@ describe('getFlowType', () => { 'properties': [{ 'key': 'x', 'value': { 'name': 'string', 'required': true } }], }, 'type': 'object', - }] + }], }, 'React.StatelessFunctionalComponent': { 'elements': [{ 'name': 'Props2' } ] }, }; diff --git a/yarn.lock b/yarn.lock index 39d47c6f648..4cd7b69c24b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -200,7 +200,7 @@ aws4@^1.2.1, aws4@^1.6.0: version "1.6.0" resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.6.0.tgz#83ef5ca860b2b32e4a0deedee8c771b9db57471e" -babel-cli@^6.9.0: +babel-cli@^6.26.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-cli/-/babel-cli-6.26.0.tgz#502ab54874d7db88ad00b887a06383ce03d002f1" dependencies: @@ -618,7 +618,7 @@ babel-plugin-transform-flow-strip-types@^6.22.0: babel-plugin-syntax-flow "^6.18.0" babel-runtime "^6.22.0" -babel-plugin-transform-object-rest-spread@^6.23.0: +babel-plugin-transform-object-rest-spread@^6.26.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-plugin-transform-object-rest-spread/-/babel-plugin-transform-object-rest-spread-6.26.0.tgz#0f36692d50fef6b7e2d4b3ac1478137a963b7b06" dependencies: @@ -631,7 +631,7 @@ babel-plugin-transform-regenerator@^6.22.0: dependencies: regenerator-transform "^0.10.0" -babel-plugin-transform-runtime@^6.9.0: +babel-plugin-transform-runtime@^6.23.0: version "6.23.0" resolved "https://registry.yarnpkg.com/babel-plugin-transform-runtime/-/babel-plugin-transform-runtime-6.23.0.tgz#88490d446502ea9b8e7efb0fe09ec4d99479b1ee" dependencies: @@ -652,7 +652,7 @@ babel-polyfill@^6.26.0: core-js "^2.5.0" regenerator-runtime "^0.10.5" -babel-preset-env@^1.1.8: +babel-preset-env@^1.6.1: version "1.6.1" resolved "https://registry.yarnpkg.com/babel-preset-env/-/babel-preset-env-1.6.1.tgz#a18b564cc9b9afdf4aae57ae3c1b0d99188e6f48" dependencies: